diff --git a/src/core/project.cpp b/src/core/project.cpp index 2d848022c29711dcb8626007305b87f3e4dd846f..af17bcbd715ce4ea417182f02a654ae1bc3da918 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -78,5 +78,10 @@ void Project::readXpipFile(QFileInfo xpip_fileinfo) { } -void Project::addProteinSp(pappso::ProteinSp makeProteinSp) { +void Project::addProteinSp(pappso::ProteinSp protein_sp) { + _protein_list.push_back(protein_sp); } + + std::vector<pappso::ProteinSp> & Project::getProteinList() { + return _protein_list; + } \ No newline at end of file diff --git a/src/core/project.h b/src/core/project.h index 49338ace7d920457a8b111d533d81ca82085fc96..07ea7a3a2de517173a50b09ec6ccc3a0340dc148 100644 --- a/src/core/project.h +++ b/src/core/project.h @@ -39,9 +39,12 @@ public: ProjectSp makeProjectSp() const; void readXpipFile(QFileInfo xpip_source); - void addProteinSp(pappso::ProteinSp makeProteinSp); + void addProteinSp(pappso::ProteinSp protein_sp); + std::vector<pappso::ProteinSp> & getProteinList(); - pappso::GrpExperiment * _p_grp_experiment= nullptr; + pappso::GrpExperiment * _p_grp_experiment= nullptr; +private : + std::vector<pappso::ProteinSp> _protein_list; }; #endif // PROJECT_H diff --git a/src/files/xpipfile.cpp b/src/files/xpipfile.cpp index e5e55f04ada8ad7885c8d79f03bb9641b82bd25a..d3aa2cea93edaae9ac59bf9bca536c6ae48935d1 100644 --- a/src/files/xpipfile.cpp +++ b/src/files/xpipfile.cpp @@ -24,6 +24,12 @@ XpipFile::XpipFile(const QUrl & xpip_source) : _xpip_source(xpip_source) { +} + + + XpipFile::XpipFile(const QFileInfo & xpip_source): _xpip_source(xpip_source.absoluteFilePath()) +{ + } XpipFile::~XpipFile() diff --git a/src/files/xpipfile.h b/src/files/xpipfile.h index 86d162f2f96f2f0139877f4ca3130445149c1e0a..666be1512427b130a0ffddb176ae1badbe0e6027 100644 --- a/src/files/xpipfile.h +++ b/src/files/xpipfile.h @@ -23,12 +23,14 @@ #define XPIPFILE_H #include <QUrl> +#include <QFileInfo> #include "../core/project.h" class XpipFile { public: XpipFile(const QUrl & xpip_source); + XpipFile(const QFileInfo & xpip_source); ~XpipFile(); ProjectSp getProjectSp() const; diff --git a/src/gui/main.ui b/src/gui/main.ui index c9ed6bdcc0b02513fb2fb1b458eb5dff4f4138dd..960706c92cb2aff00165fb36d45466e80e816f4b 100644 --- a/src/gui/main.ui +++ b/src/gui/main.ui @@ -20,7 +20,7 @@ <x>0</x> <y>0</y> <width>286</width> - <height>22</height> + <height>19</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -39,5 +39,25 @@ </action> </widget> <resources/> - <connections/> + <connections> + <connection> + <sender>actionLoad</sender> + <signal>triggered()</signal> + <receiver>Main</receiver> + <slot>selectXpipFile()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>142</x> + <y>185</y> + </hint> + </hints> + </connection> + </connections> + <slots> + <slot>selectXpipFile()</slot> + </slots> </ui> diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index e368dee9aba0c84ca7e02be34c15cac574e9c207..1bf9b7dd8f6457bb59f800751aa6748ad4a7f30d 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -22,9 +22,12 @@ ******************************************************************************/ #include <QDockWidget> +#include <QSettings> +#include <QFileDialog> #include "mainwindow.h" #include "ui_main.h" +#include "files/xpipfile.h" MainWindow::MainWindow(QWidget *parent): @@ -69,3 +72,26 @@ MainWindow::~MainWindow() delete ui; } + + +void MainWindow::selectXpipFile() { + + QSettings settings; + QString default_location = settings.value("path/xpipfile", "").toString(); + + QString filename = QFileDialog::getOpenFileName(this, + tr("Open XPIP File"), default_location, + tr("xpip files (*.xpip);;all files (*)")); + + 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->setProject(_project_sp.get()); + +} diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index eeb5495ca31ed1aa59006b4658cd31c707857fb1..4603e576f3f8fa82b66e040d361e81df6a204e9b 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -34,6 +34,7 @@ #include <pwiz/data/msdata/MSDataFile.hpp> #include "../utils/readspectrum.h" #include "protein_list_view/proteinlistwindow.h" +#include "core/project.h" @@ -45,7 +46,7 @@ class Main; class PwizLoaderThread : public QObject { Q_OBJECT - public: +public: public slots: void doMsDataFileLoad(const QString & parameter) { @@ -58,7 +59,7 @@ signals: void msDataReady(pwiz::msdata::MSDataFile * p_ms_data_file); }; -class MainWindow: public QMainWindow { +class MainWindow: public QMainWindow { Q_OBJECT QThread workerThread; @@ -68,6 +69,7 @@ public: ~MainWindow(); public slots: + void selectXpipFile(); //void peptideEdited(QString peptideStr); // void setColor(const QColor &color); // void setShape(Shape shape); @@ -76,10 +78,13 @@ signals: private: Ui::Main *ui; - - + + ProteinListWindow * _protein_list_window=nullptr; +private : + ProjectSp _project_sp=nullptr; + }; #endif // MAINWINDOW_H diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index 7c646b25cade7bd4639e7d3887ebb9b10705de31..55f272bcbbd3da6cf0685becb1ecf5893d893a68 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -24,7 +24,6 @@ #include "proteinlistwindow.h" #include "ui_protein_view.h" -#include "proteintablemodel.h" ProteinListWindow::ProteinListWindow(QWidget *parent): @@ -51,8 +50,8 @@ ProteinListWindow::ProteinListWindow(QWidget *parent): /* */ - ProteinTableModel * p_myModel = new ProteinTableModel(0); - ui->tableView->setModel( p_myModel ); + _protein_table_model_p = new ProteinTableModel(0); + ui->tableView->setModel( _protein_table_model_p ); } ProteinListWindow::~ProteinListWindow() @@ -60,4 +59,9 @@ ProteinListWindow::~ProteinListWindow() //if (_p_ms_data_file != nullptr) delete _p_ms_data_file; delete ui; -} \ No newline at end of file +} + + + void ProteinListWindow::setProject(Project* project_p) { + _protein_table_model_p->setProject(project_p); + } \ No newline at end of file diff --git a/src/gui/protein_list_view/proteinlistwindow.h b/src/gui/protein_list_view/proteinlistwindow.h index 192134546352919421705eed5c19fe8d3049faf9..826d7a2b43417f7853f672cd34f7cbbe24488e8b 100644 --- a/src/gui/protein_list_view/proteinlistwindow.h +++ b/src/gui/protein_list_view/proteinlistwindow.h @@ -26,6 +26,7 @@ #include <QMainWindow> +#include "proteintablemodel.h" //http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html namespace Ui { @@ -39,6 +40,7 @@ public: explicit ProteinListWindow(QWidget * parent = 0); ~ProteinListWindow(); + void setProject(Project* project_p); public slots: //void peptideEdited(QString peptideStr); @@ -49,6 +51,7 @@ signals: private: Ui::ProteinView *ui; + ProteinTableModel * _protein_table_model_p = nullptr; }; diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp index 7ef7e8e9abf70ec96d69cdffd0ab13d6cedfcd23..5ec0ff14befd2b4033df4486fb0db62feb072395 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -35,8 +35,21 @@ ProteinTableModel::ProteinTableModel(QObject *parent) //emit dataChanged(topLeft, topLeft); } + +void ProteinTableModel::setProject(Project * p_project) { + qDebug() << "ProteinTableModel::setProject begin " << p_project->getProteinList().size(); + _p_project = p_project; + + QModelIndex topLeft = createIndex(0,0); + emit headerDataChanged(Qt::Horizontal, 0,3); + emit dataChanged(topLeft, topLeft); +} + int ProteinTableModel::rowCount(const QModelIndex &parent ) const { - return 2; + if (_p_project != nullptr) { + return _p_project->getProteinList().size(); + } + return 0; } int ProteinTableModel::columnCount(const QModelIndex &parent ) const { return 3; @@ -67,6 +80,11 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { .arg(row).arg(col).arg(role); if (role == Qt::DisplayRole) { + if (col == 2) { + if (_p_project != nullptr) { + return _p_project->getProteinList().at(row).get()->getDescription(); + } + } return QString("Row%1, Column%2") .arg(index.row() + 1) .arg(index.column() +1); diff --git a/src/gui/protein_list_view/proteintablemodel.h b/src/gui/protein_list_view/proteintablemodel.h index 473e630f880775fbc605e3bff893d916ab2852e8..3d80ff26805d059d03955d2a22b131110a1afc73 100644 --- a/src/gui/protein_list_view/proteintablemodel.h +++ b/src/gui/protein_list_view/proteintablemodel.h @@ -25,6 +25,7 @@ #define PROTEINTABLEMODEL_H #include <QAbstractTableModel> +#include "../../core/project.h" class ProteinTableModel: public QAbstractTableModel { @@ -35,6 +36,12 @@ public: int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + + + void setProject(Project * p_project); + +private : + Project * _p_project = nullptr; }; #endif // PROTEINTABLEMODEL_H diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp index 38d82c6d307c6a69161e1c7405423d745daadd20..f05a2dd4a46948fbdcb2596b486dbf490777cf50 100644 --- a/src/input/xpipsaxhandler.cpp +++ b/src/input/xpipsaxhandler.cpp @@ -41,9 +41,9 @@ bool XpipSaxHandler::startElement(const QString & namespaceURI, const QString & try { //startElement_group - if (qName == "group") + if (qName == "protein") { - //is_ok = startElement_group(attributes); + is_ok = startElement_protein(attributes); } _current_text.clear(); } @@ -64,10 +64,13 @@ bool XpipSaxHandler::endElement(const QString & namespaceURI, const QString & lo bool is_ok = true; // endElement_peptide_list try { - if (qName == "group") + if (qName == "protein") { - //is_ok = endElement_group(); + is_ok = endElement_protein(); } + else if (qName == "sequence") { + is_ok = endElement_sequence(); + } // end of detection_moulon // else if ((_tag_stack.size() > 1) &&