Skip to content
Snippets Groups Projects
Commit 8cda7417 authored by Olivier Langella's avatar Olivier Langella
Browse files

load in separate thread

parent b792e149
No related branches found
No related tags found
No related merge requests found
......@@ -27,21 +27,24 @@ XpipFile::XpipFile(const QUrl & xpip_source) : _xpip_source(xpip_source)
}
XpipFile::XpipFile(const QFileInfo & xpip_source): _xpip_source(xpip_source.absoluteFilePath())
XpipFile::XpipFile(const QFileInfo & xpip_source): _xpip_source(xpip_source.absoluteFilePath())
{
}
XpipFile::XpipFile(const XpipFile & other) : _xpip_source(other._xpip_source)
{
}
XpipFile::~XpipFile()
{
}
ProjectSp XpipFile::getProjectSp() const {
ProjectSp project_sp = Project().makeProjectSp();
project_sp.get()->readXpipFile(QFileInfo(_xpip_source.toLocalFile()));
return (project_sp);
}
\ No newline at end of file
ProjectSp project_sp = Project().makeProjectSp();
project_sp.get()->readXpipFile(QFileInfo(_xpip_source.toLocalFile()));
return (project_sp);
}
......@@ -31,6 +31,7 @@ class XpipFile
public:
XpipFile(const QUrl & xpip_source);
XpipFile(const QFileInfo & xpip_source);
XpipFile(const XpipFile & other);
~XpipFile();
ProjectSp getProjectSp() const;
......
......@@ -28,7 +28,7 @@
GroupingPeptideMass::GroupingPeptideMass()
{
_p_monitor = new pappso::GrpGroupingMonitor();
//_p_monitor = new pappso::GrpGroupingMonitor();
_p_grp_experiment = new pappso::GrpExperiment(_p_monitor);
}
......
......@@ -40,7 +40,7 @@ protected :
GroupingPeptideMass();
private :
pappso::GrpGroupingMonitor * _p_monitor;
pappso::GrpGroupingMonitor * _p_monitor = nullptr;
pappso::GrpExperiment * _p_grp_experiment;
};
......
......@@ -25,38 +25,53 @@
#include <QSettings>
#include <QFileDialog>
#include <QMessageBox>
#include <QDebug>
#include "mainwindow.h"
#include "ui_main.h"
#include "files/xpipfile.h"
#include "gui/peptide_list_view/peptidelistwindow.h"
#include <pappsomspp/pappsoexception.h>
void PwizLoaderThread::doMsDataFileLoad(const QString & parameter) {
pwiz::msdata::MSDataFile* p_ms_data_file = getPwizMSDataFile(parameter);
/* ... here is the expensive or blocking operation ... */
emit msDataReady(p_ms_data_file);
void XtpLoaderThread::doXpipFileLoad(QString filename) {
qDebug() << "XtpLoaderThread::doXpipFileLoad begin "<< filename;
try {
QFileInfo new_xpip_file;
new_xpip_file.setFile(filename);
XpipFile xpip_file(new_xpip_file);
ProjectSp project_sp = xpip_file.getProjectSp();
emit projectReady(project_sp);
}
catch (pappso::PappsoException & error) {
emit projectNotReady(tr("Error while reading XPIP file :\n%1").arg(error.qwhat()));
}
qDebug() << "XtpLoaderThread::doXpipFileLoad end";
}
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent),
ui(new Ui::Main)
{
ui->setupUi(this);
PwizLoaderThread *worker = new PwizLoaderThread;
XtpLoaderThread *worker = new XtpLoaderThread;
worker->moveToThread(&workerThread);
/*
*/
workerThread.start();
//QDockWidget *dock = new QDockWidget(tr("Protein List"), this);
_protein_list_window = new ProteinListWindow(this);
_protein_list_window->show();
//QDockWidget *dock = new QDockWidget(tr("Protein List"), this);
//dock->setWidget(_protein_list_window);
//addDockWidget(Qt::RightDockWidgetArea, dock);
qRegisterMetaType<ProjectSp>("ProjectSp");
#if QT_VERSION >= 0x050000
// Qt5 code
/*
......@@ -67,6 +82,9 @@ MainWindow::MainWindow(QWidget *parent):
#else
// Qt4 code
connect (_protein_list_window, SIGNAL(proteinMatchClicked(ProteinMatch *)), this ,SLOT(doProteinMatchClicked(ProteinMatch *)));
connect(this, SIGNAL(operateXpipFile(QString)), worker,SLOT(doXpipFileLoad(QString)));
connect(worker, SIGNAL(projectReady(ProjectSp)), this,SLOT(doProjectReady(ProjectSp)));
/*
connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(this, SIGNAL(operateMsDataFile(QString)), worker,SLOT(doMsDataFileLoad(QString)));
......@@ -99,6 +117,21 @@ void MainWindow::viewError(QString error) {
}
void MainWindow::doProjectReady(ProjectSp project_sp) {
try {
project_sp.get()->startGrouping();
}
catch (pappso::PappsoException & error) {
viewError(tr("Error while grouping :\n%1").arg(error.qwhat()));
}
setProjectSp(project_sp);
}
void MainWindow::doProjectNotReady(QString error) {
viewError(tr("Error while grouping :\n%1").arg(error));
}
void MainWindow::doProteinMatchClicked(ProteinMatch * protein_match) {
PeptideListWindow * peptide_window = new PeptideListWindow(this);
......@@ -118,23 +151,17 @@ void MainWindow::selectXpipFile() {
if (filename.isEmpty()) {
return;
}
QFileInfo new_xpip_file;
new_xpip_file.setFile(filename);
XpipFile xpip_file(new_xpip_file);
_project_sp = xpip_file.getProjectSp();
_protein_list_window->setIdentificationGroup(_project_sp.get()->getCurrentIdentificationGroupP());
emit operateXpipFile(filename);
}
catch (pappso::PappsoException & error) {
viewError(tr("Error while reading XPIP file :\n%1").arg(error.qwhat()));
}
try {
_project_sp.get()->startGrouping();
}
catch (pappso::PappsoException & error) {
viewError(tr("Error while grouping :\n%1").arg(error.qwhat()));
}
}
void MainWindow::setProjectSp(ProjectSp project_sp) {
_project_sp = project_sp;
_protein_list_window->setIdentificationGroup(_project_sp.get()->getCurrentIdentificationGroupP());
_protein_list_window->show();
}
......@@ -36,6 +36,7 @@
#include "../utils/readspectrum.h"
#include "protein_list_view/proteinlistwindow.h"
#include "core/project.h"
#include "files/xpipfile.h"
......@@ -44,7 +45,7 @@ class Main;
}
class PwizLoaderThread : public QObject
class XtpLoaderThread : public QObject
{
Q_OBJECT
public:
......@@ -55,10 +56,11 @@ protected:
void closeEvent(QCloseEvent *event);
public slots:
void doMsDataFileLoad(const QString & parameter);
void doXpipFileLoad(QString filename);
signals:
void msDataReady(pwiz::msdata::MSDataFile * p_ms_data_file);
void projectReady(ProjectSp project_sp);
void projectNotReady(QString error);
};
class MainWindow: public QMainWindow {
......@@ -73,16 +75,19 @@ public:
public slots:
void selectXpipFile();
void doProteinMatchClicked(ProteinMatch * protein_match);
void doProjectReady(ProjectSp project_sp);
void doProjectNotReady(QString error);
//void peptideEdited(QString peptideStr);
// void setColor(const QColor &color);
// void setShape(Shape shape);
signals:
//void peptideChanged(pappso::PeptideSp peptide);
void operateXpipFile(QString xpip_file);
protected:
void closeEvent(QCloseEvent *event) override;
void setProjectSp(ProjectSp project_sp);
private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment