Commit a242821b authored by Edlira Nano's avatar Edlira Nano
Browse files

Progress barre fonctionnelle

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2251 e4b6dbb4-9209-464b-83f7-6257456c460c
parent fa88f4b8
......@@ -5,11 +5,13 @@
#include <QStatusBar>
#include <QProgressDialog>
#include <QApplication>
#include <QTimer>
#include "mainwindow.h"
#include "xicSelectionWidget.h"
#include "xicProfile.h"
#include "xicPlot.h"
//#include "msrunLoaderThread.h"
......@@ -100,26 +102,30 @@ MainWindow::loadMsrun() {
if (!filename.isEmpty()) {
_current_msrun_file = filename;
QProgressDialog progressDialog(QObject::tr("Loading MS run %1...").arg(strippedFilename(filename)), QObject::tr("Cancel"), 0, 2, this);
progressDialog.show();
progressDialog.setValue(0);
_progressDialog = new QProgressDialog(QObject::tr("Loading MS run %1...").arg(strippedFilename(filename)), QObject::tr("Cancel"), 0, 2, this);
_progressDialog->setValue(0);
QApplication::processEvents();
connect(&_msrun_loader_thread, SIGNAL(loadedMsrun(Msrun *)),
this, SLOT(doneLoading(Msrun *)));
this, SLOT(doneLoading(Msrun *)));
_masschroq_gui->setMsRun(filename, &_msrun_loader_thread);//, &progressDialog);
// progressDialog.setCancelButtonText(QObject::tr("&Cancel"));
//connect(_progressDialog, SIGNAL(canceled()), this, SLOT(cancelLoadMsrun()));
// progressDialog.setRange(0, 2);
//_mainwindow->statusBar()->addWidget(&progressDialog);
//progressDialog.setValue(0);
//progressDialog.setValue(1);
// QApplication::processEvents();
_masschroq_gui->setMsRun(filename, &_msrun_loader_thread);
//QApplication::processEvents();
//progressDialog.setValue(2);
QTimer * timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateProgress()));
timer->start(1000);
}
}
void
MainWindow::updateProgress() {
if (! _msrun_loader_thread.isFinished()) {
unsigned int progress = _msrun_loader_thread.getProgressValue();
_progressDialog->setValue(progress);
}
}
void
MainWindow::doneLoading(Msrun * msrun) {
QString filename = (msrun->getXmlFileInfo()).filePath();
......
......@@ -27,6 +27,7 @@ private slots:
void filterXic();
void about();
void doneLoading(Msrun * msrun);
void updateProgress();
protected:
......@@ -64,7 +65,7 @@ private:
QAction * _aboutAct;
QAction * _quitAct;
QProgressDialog _progressDialog;
QProgressDialog * _progressDialog;
MsrunLoaderThread _msrun_loader_thread;
QString _current_msrun_file;
......
......@@ -34,7 +34,6 @@ MasschroqGui::~MasschroqGui() {
void
MasschroqGui::setMsRun(const QString & filename,
MsrunLoaderThread * thread) {
// QProgressDialog * progressDialog) {
QFileInfo filenameInfo(filename);
if (! filenameInfo.exists()) {
......@@ -85,7 +84,7 @@ MasschroqGui::setMsRun(const QString & filename,
try {
thread->loadMsrun(msrun, filename, format);
thread->loadMsrun(msrun, filename, format);
} catch (mcqError error) {
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
......
......@@ -54,7 +54,6 @@ class MasschroqGui {
/// creates and sets an msrun
void setMsRun(const QString & filename,
MsrunLoaderThread * thread);
//QProgressDialog * progressDialog);
void extractXicProfile(XicProfile * xic_profile,
const QString & msrun_filename,
......
/**
/**
* \file msrunLoaderThread.cpp
* \date December 09, 2011
* \author Edlira Nano
......@@ -6,6 +6,8 @@
#include "msrunLoaderThread.h"
MsrunLoaderThread::MsrunLoaderThread(QObject * parent)
:
QThread(parent)
......@@ -29,11 +31,9 @@ void
MsrunLoaderThread::loadMsrun(Msrun * msrun,
const QString & filename,
const mcq_xml_format & format) {
// QProgressDialog * progressDialog) {
_current_msrun = msrun;
_msrun_filename = filename;
_msrun_format = format;
//_progressDialog = progressDialog;
if (!isRunning()) {
start();
......@@ -43,6 +43,13 @@ MsrunLoaderThread::loadMsrun(Msrun * msrun,
}
}
const unsigned int
MsrunLoaderThread::getProgressValue() {
progressMutex.lock();
unsigned int return_value = _progressValue;
progressMutex.unlock();
return return_value;
}
void
MsrunLoaderThread::run() {
......@@ -52,24 +59,26 @@ MsrunLoaderThread::run() {
Msrun * msrun = this->_current_msrun;
QString filename = this->_msrun_filename;
mcq_xml_format format = this->_msrun_format;
// QProgressDialog * progressDialog = this->_progressDialog;
mutex.unlock();
cout << "Yo 1" << endl;
if (restart) {
cout << "Yo 2" << endl;
break;
}
if (abort) {
cout << "Yo 3" << endl;
return;
}
msrun->set_from_xml(filename, format);
cout << "Yo 4" << endl;
//progressDialog->setValue(1);
progressMutex.lock();
_progressValue = 1;
progressMutex.unlock();
msrun->prepareSpectraForQuantification(NULL);
//progressDialog->setValue(2);
progressMutex.lock();
_progressValue = 2;
progressMutex.unlock();
if (!restart)
emit loadedMsrun(msrun);
......
......@@ -50,7 +50,8 @@ class MsrunLoaderThread : public QThread {
void loadMsrun(Msrun * msrun,
const QString & filename,
const mcq_xml_format & format);
// QProgressDialog * progressDialog);
const unsigned int getProgressValue();
signals:
......@@ -63,6 +64,7 @@ class MsrunLoaderThread : public QThread {
private:
QMutex mutex;
QMutex progressMutex;
QWaitCondition condition;
bool restart;
bool abort;
......@@ -70,8 +72,7 @@ class MsrunLoaderThread : public QThread {
Msrun * _current_msrun;
QString _msrun_filename;
mcq_xml_format _msrun_format;
//QProgressDialog * _progressDialog;
unsigned int _progressValue;
};
#endif /* MSRUN_LOADER_THREAD_H_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment