diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 462b946e2b353ed2d3e1d0df183a999ef29b36a7..ade8d7f8ff6358cefc73f955f75856bd65a4404a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -74,18 +74,23 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ) SET(XTPCPP_SRCS ./gui/mainwindow.cpp + ./gui/peptide_list_view/peptidelistwindow.cpp + ./gui/peptide_list_view/peptidetablemodel.cpp ./gui/protein_list_view/proteinlistwindow.cpp ./gui/protein_list_view/proteintablemodel.cpp ) SET (GUI_UIS ./gui/main.ui + ./gui/peptide_list_view/peptide_view.ui ./gui/protein_list_view/protein_view.ui ) SET(XTPCPP_MOC_HDRS ./gui/mainwindow.h + ./gui/peptide_list_view/peptidelistwindow.h + ./gui/peptide_list_view/peptidetablemodel.h ./gui/protein_list_view/proteinlistwindow.h ./gui/protein_list_view/proteintablemodel.h ) diff --git a/src/core/peptidematch.cpp b/src/core/peptidematch.cpp index ba399e77e546c7fcf5867b615229b5bc71e6c398..d150c5ab5bd411a09f8b01c8e47814d8dec975e4 100644 --- a/src/core/peptidematch.cpp +++ b/src/core/peptidematch.cpp @@ -52,6 +52,27 @@ void PeptideMatch::setPeptideSp (pappso::PeptideSp peptide) { void PeptideMatch::setChecked(bool arg1) { _checked = arg1; } + +bool PeptideMatch::isChecked() const { + return _checked; +} + void PeptideMatch::setIdentificationDataSource(IdentificationDataSource* identification_source) { _p_identification_source = identification_source; } +IdentificationDataSource* PeptideMatch::getIdentificationDataSource () const { + return _p_identification_source; +} +unsigned int PeptideMatch::getScan() const { + return _scan; +} +pappso::pappso_double PeptideMatch::getRetentionTime() const { + return _rt; +} +unsigned int PeptideMatch::getCharge() const { + return _charge; +} + +pappso::PeptideSp PeptideMatch::getPeptideSp() const { + return _peptide_sp; +} diff --git a/src/core/peptidematch.h b/src/core/peptidematch.h index 1bcfe877dc95b90068bb47206f2db7a02254e7cf..6f2672febb49af0a69e03ee91121f38244b0f647 100644 --- a/src/core/peptidematch.h +++ b/src/core/peptidematch.h @@ -41,7 +41,13 @@ public : void setPeptideSp (pappso::PeptideSp peptide); void setIdentificationDataSource(IdentificationDataSource* identification_source); void setChecked(bool arg1); + bool isChecked() const; + IdentificationDataSource* getIdentificationDataSource () const; + unsigned int getScan() const; + pappso::pappso_double getRetentionTime() const; + unsigned int getCharge() const; + pappso::PeptideSp getPeptideSp() const; private : pappso::MsRunIdSp _msrunid_sp; @@ -53,11 +59,11 @@ private : unsigned int _start; unsigned int _charge; IdentificationDataSource* _p_identification_source = nullptr; - + /** @brief manually checked by user (true by default) */ bool _checked = true; - + /** @brief automatic filter result (false by default) */ bool _proxy_valid = false; diff --git a/src/core/project.cpp b/src/core/project.cpp index bf7bf509456802e694340ab64d3c5406a48ff347..26c90667470ebe050adadd9ea7e1ba3c452f10ac 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -22,6 +22,7 @@ ******************************************************************************/ #include "project.h" #include "../input/xpipsaxhandler.h" +#include "peptidematch.h" Project::Project() { @@ -80,3 +81,7 @@ void Project::readXpipFile(QFileInfo xpip_fileinfo) { IdentificationGroup* Project::getCurrentIdentificationGroupP() const { return _p_current_identification_group; } + +bool Project::isValid(PeptideMatch* p_peptide_match) const { + return true; +} diff --git a/src/core/project.h b/src/core/project.h index 997d750309e3736d6449cb9a852740779d7a5703..2bc65e7e0108677242f198d1eb95cd6083f89f7a 100644 --- a/src/core/project.h +++ b/src/core/project.h @@ -29,6 +29,8 @@ class Project; typedef std::shared_ptr<Project> ProjectSp; +class PeptideMatch; + class Project { public: @@ -39,6 +41,10 @@ public: void readXpipFile(QFileInfo xpip_source); IdentificationGroup* newIdentificationGroup(); IdentificationGroup* getCurrentIdentificationGroupP() const; + /** @brief is it valid regarding threshold and project rules + */ + bool isValid(PeptideMatch* p_peptide_match) const; + private : std::vector<IdentificationGroup *> _identification_goup_list; IdentificationGroup* _p_current_identification_group = nullptr; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 487df39db2e6bb21d2a0066aed66cfaa8de621b3..491c0958a466d415a85fc71736abb0cb8f744616 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -28,8 +28,14 @@ #include "ui_main.h" #include "files/xpipfile.h" +#include "gui/peptide_list_view/peptidelistwindow.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); +} MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::Main) @@ -38,6 +44,17 @@ MainWindow::MainWindow(QWidget *parent): PwizLoaderThread *worker = new PwizLoaderThread; worker->moveToThread(&workerThread); + /* + */ + workerThread.start(); + + QDockWidget *dock = new QDockWidget(tr("Protein List"), this); + _protein_list_window = new ProteinListWindow(this); + //_protein_list_window->show(); + dock->setWidget(_protein_list_window); + addDockWidget(Qt::RightDockWidgetArea, dock); + + #if QT_VERSION >= 0x050000 // Qt5 code /* @@ -47,21 +64,13 @@ MainWindow::MainWindow(QWidget *parent): */ #else // Qt4 code + connect (_protein_list_window, SIGNAL(proteinMatchClicked(ProteinMatch *)), this ,SLOT(doProteinMatchClicked(ProteinMatch *))); /* connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater())); connect(this, SIGNAL(operateMsDataFile(QString)), worker,SLOT(doMsDataFileLoad(QString))); connect(worker, SIGNAL(msDataReady(pwiz::msdata::MSDataFile *)), this, SLOT(handleMsDataFile(pwiz::msdata::MSDataFile *))); */ #endif - /* - */ - workerThread.start(); - - QDockWidget *dock = new QDockWidget(tr("Protein List"), this); - _protein_list_window = new ProteinListWindow(this); - //_protein_list_window->show(); - dock->setWidget(_protein_list_window); - addDockWidget(Qt::RightDockWidgetArea, dock); } MainWindow::~MainWindow() @@ -74,6 +83,12 @@ MainWindow::~MainWindow() } +void MainWindow::doProteinMatchClicked(ProteinMatch * protein_match) { + PeptideListWindow * peptide_window = new PeptideListWindow(this); + peptide_window->setProteinMatch(_project_sp.get(), protein_match); + peptide_window->show(); +} + void MainWindow::selectXpipFile() { QSettings settings; @@ -88,10 +103,10 @@ void MainWindow::selectXpipFile() { } 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()); - + } diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 4603e576f3f8fa82b66e040d361e81df6a204e9b..536da3dc36eaf261bc59699f70405f45a4cc140b 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -49,11 +49,7 @@ class PwizLoaderThread : public QObject public: public slots: - void 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 doMsDataFileLoad(const QString & parameter); signals: void msDataReady(pwiz::msdata::MSDataFile * p_ms_data_file); @@ -70,6 +66,7 @@ public: public slots: void selectXpipFile(); + void doProteinMatchClicked(ProteinMatch * protein_match); //void peptideEdited(QString peptideStr); // void setColor(const QColor &color); // void setShape(Shape shape); diff --git a/src/gui/peptide_list_view/peptide_view.ui b/src/gui/peptide_list_view/peptide_view.ui new file mode 100644 index 0000000000000000000000000000000000000000..fda502b32f6ea791bd7d756a810099a22edfdf46 --- /dev/null +++ b/src/gui/peptide_list_view/peptide_view.ui @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PeptideView</class> + <widget class="QMainWindow" name="PeptideView"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>826</width> + <height>404</height> + </rect> + </property> + <property name="windowTitle"> + <string>Protein list</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTableView" name="tableView"/> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>826</width> + <height>19</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar"/> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/gui/peptide_list_view/peptidelistwindow.cpp b/src/gui/peptide_list_view/peptidelistwindow.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ff0fd533c624b66d9b3780e2419ef0f671f040d1 --- /dev/null +++ b/src/gui/peptide_list_view/peptidelistwindow.cpp @@ -0,0 +1,78 @@ + +/******************************************************************************* +* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. +* +* This file is part of XTPcpp. +* +* XTPcpp is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* XTPcpp is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. +* +* Contributors: +* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation +******************************************************************************/ + +#include "peptidelistwindow.h" + +#include "ui_peptide_view.h" + + +PeptideListWindow::PeptideListWindow(QWidget *parent): + QMainWindow(parent), + ui(new Ui::PeptideView) +{ + ui->setupUi(this); + +#if QT_VERSION >= 0x050000 + // Qt5 code + /* + connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater); + connect(this, &PtSpectrumViewer::operateMsDataFile, worker, &PwizLoaderThread::doMsDataFileLoad); + connect(worker, &PwizLoaderThread::msDataReady, this, &PtSpectrumViewer::handleMsDataFile); + */ +#else +// Qt4 code + /* + connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater())); + connect(this, SIGNAL(operateMsDataFile(QString)), worker,SLOT(doMsDataFileLoad(QString))); + connect(worker, SIGNAL(msDataReady(pwiz::msdata::MSDataFile *)), this, SLOT(handleMsDataFile(pwiz::msdata::MSDataFile *))); + */ +#endif + /* + */ + + _peptide_table_model_p = new PeptideTableModel(0); + + + _p_proxy_model = new PeptideTableProxyModel(this, _peptide_table_model_p); + _p_proxy_model->setSourceModel(_peptide_table_model_p); + _p_proxy_model->setDynamicSortFilter(true); + ui->tableView->setModel( _p_proxy_model ); + ui->tableView->setSortingEnabled(true); + + connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &))); +} + +PeptideListWindow::~PeptideListWindow() +{ + //if (_p_ms_data_file != nullptr) delete _p_ms_data_file; + delete ui; + +} + + +void PeptideListWindow::setProteinMatch(Project * p_project, ProteinMatch * p_protein_match) { + _peptide_table_model_p->setProteinMatch(p_project, p_protein_match); + _p_proxy_model->setSourceModel(_peptide_table_model_p); + +} + diff --git a/src/gui/peptide_list_view/peptidelistwindow.h b/src/gui/peptide_list_view/peptidelistwindow.h new file mode 100644 index 0000000000000000000000000000000000000000..9917d62c84f6cb98db08eb66e9ecfe142623f783 --- /dev/null +++ b/src/gui/peptide_list_view/peptidelistwindow.h @@ -0,0 +1,60 @@ + +/******************************************************************************* +* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. +* +* This file is part of XTPcpp. +* +* XTPcpp is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* XTPcpp is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. +* +* Contributors: +* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation +******************************************************************************/ + +#ifndef PEPTIDELISTWINDOW_H +#define PEPTIDELISTWINDOW_H + +#include <QMainWindow> +#include "peptidetablemodel.h" +#include "../../core/proteinmatch.h" +#include "../../core/project.h" + +//http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html +namespace Ui { +class PeptideView; +} + +class PeptideListWindow: public QMainWindow { + Q_OBJECT + +public: + + explicit PeptideListWindow(QWidget * parent = 0); + ~PeptideListWindow(); + void setProteinMatch(Project * p_project, ProteinMatch * p_protein_match); + +public slots: + //void peptideEdited(QString peptideStr); + // void setColor(const QColor &color); + // void setShape(Shape shape); +signals: + //void peptideChanged(pappso::PeptideSp peptide); + +private: + Ui::PeptideView *ui; + PeptideTableModel * _peptide_table_model_p = nullptr; + PeptideTableProxyModel * _p_proxy_model = nullptr; + +}; + +#endif // PEPTIDELISTWINDOW_H diff --git a/src/gui/peptide_list_view/peptidetablemodel.cpp b/src/gui/peptide_list_view/peptidetablemodel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3096830a85debce124ce42832fa23b923e511294 --- /dev/null +++ b/src/gui/peptide_list_view/peptidetablemodel.cpp @@ -0,0 +1,198 @@ + +/******************************************************************************* +* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. +* +* This file is part of XTPcpp. +* +* XTPcpp is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* XTPcpp is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. +* +* Contributors: +* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation +******************************************************************************/ + +#include "peptidetablemodel.h" + +#include <QDebug> + + +PeptideTableProxyModel::PeptideTableProxyModel(QObject *parent,PeptideTableModel* peptide_table_model_p): QSortFilterProxyModel(parent) +{ + _peptide_table_model_p = peptide_table_model_p; +} + +bool PeptideTableProxyModel::filterAcceptsRow(int source_row, + const QModelIndex &source_parent) const { + return _peptide_table_model_p->acceptRow(source_row); + //return true; +} + +void PeptideTableProxyModel::onTableClicked(const QModelIndex &index) +{ + qDebug() << "PeptideTableProxyModel::onTableClicked begin " << index.row(); + qDebug() << "PeptideTableProxyModel::onTableClicked begin " << this->mapToSource(index).row(); + _peptide_table_model_p->onTableClicked(this->mapToSource(index)); +} + +bool PeptideTableProxyModel::lessThan(const QModelIndex & left, const QModelIndex & right) const { + QVariant leftData = sourceModel()->data(left); + QVariant rightData = sourceModel()->data(right); + if (leftData.type() == QVariant::UInt) { + return leftData.toUInt() < rightData.toUInt(); + } + if (leftData.type() == QVariant::UInt) { + return leftData.toUInt() < rightData.toUInt(); + } + if (leftData.type() == QVariant::Double) { + return leftData.toDouble() < rightData.toDouble(); + } + return leftData.toString() < rightData.toString(); +} + +QVariant PeptideTableProxyModel::headerData(int section, Qt::Orientation orientation, + int role) const { + return sourceModel()->headerData(section, orientation, + role); +} + +PeptideTableModel::PeptideTableModel(QObject *parent) + :QAbstractTableModel(parent) +{ + + //ui->tableView->show(); + // QModelIndex topLeft = createIndex(0,0); + //emit a signal to make the view reread identified data + //emit dataChanged(topLeft, topLeft); +} + + +void PeptideTableModel::setProteinMatch(Project * p_project, ProteinMatch * p_protein_match) { + qDebug() << "PeptideTableModel::setProteinMatch begin " ; + _p_project = p_project; + _p_protein_match = p_protein_match; + + QModelIndex topLeft = createIndex(0,0); + QModelIndex bottomRight = createIndex(rowCount(),columnCount()); + emit dataChanged(topLeft, bottomRight); + emit headerDataChanged(Qt::Horizontal, 0,3); +} + +int PeptideTableModel::rowCount(const QModelIndex &parent ) const { + if (_p_protein_match != nullptr) { + qDebug() << "PeptideTableModel::rowCount(const QModelIndex &parent ) " << _p_protein_match->getPeptideMatchList().size(); + return _p_protein_match->getPeptideMatchList().size(); + } + return 0; +} +int PeptideTableModel::columnCount(const QModelIndex &parent ) const { + return 6; +} +QVariant PeptideTableModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role == Qt::DisplayRole) + { + if (orientation == Qt::Horizontal) { + switch (section) + { + case 0: + return QString("checked"); + case 1: + return QString("sample"); + case 2: + return QString("scan"); + case 3: + return QString("RT"); + case 4: + return QString("charge"); + case 5: + return QString("sequence"); + } + } + } + return QVariant(); +} +QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const { + // generate a log message when this method gets called + int row = index.row(); + int col = index.column(); + qDebug() << QString("row %1, col%2, role %3") + .arg(row).arg(col).arg(role); + + switch(role) { + case Qt::CheckStateRole: + + if (col == 0) //add a checkbox to cell(1,0) + { + if ( _p_protein_match->getPeptideMatchList().at(row)->isChecked()) { + return Qt::Checked; + } + else { + return Qt::Unchecked; + } + } + break; + case Qt::DisplayRole: + if (_p_protein_match == nullptr) { + } + else { + if (col == 0) { + return QVariant(); + } + if (col == 1) { + return _p_protein_match->getPeptideMatchList().at(row)->getIdentificationDataSource()->getResourceName(); + } + if (col == 2) { + return QVariant ((quint16) _p_protein_match->getPeptideMatchList().at(row)->getScan()); + } + if (col == 3) { + return QVariant ((qreal) _p_protein_match->getPeptideMatchList().at(row)->getRetentionTime()); + } + if (col == 4) { + return QVariant ((quint8) _p_protein_match->getPeptideMatchList().at(row)->getCharge()); + } + if (col == 5) { + return _p_protein_match->getPeptideMatchList().at(row)->getPeptideSp().get()->getSequence(); + } + } + return QString("Row%1, Column%2") + .arg(index.row() + 1) + .arg(index.column() +1); + } + return QVariant(); +} + +void PeptideTableModel::onTableClicked(const QModelIndex &index) +{ + int row = index.row(); + int col = index.column(); + if (col == 0) //add a checkbox to cell(1,0) + { + if ( _p_protein_match->getPeptideMatchList().at(row)->isChecked()) { + _p_protein_match->getPeptideMatchList().at(row)->setChecked(false); + } + else { + _p_protein_match->getPeptideMatchList().at(row)->setChecked(true); + } + //emit dataChanged(index, index); + } + else { + emit peptideMatchClicked(_p_protein_match->getPeptideMatchList().at(row)); + } +} + +bool PeptideTableModel::acceptRow(int source_row) { + if (_p_project->isValid(_p_protein_match->getPeptideMatchList().at(source_row))) { + return true; + } + return false; +} diff --git a/src/gui/peptide_list_view/peptidetablemodel.h b/src/gui/peptide_list_view/peptidetablemodel.h new file mode 100644 index 0000000000000000000000000000000000000000..b1f935532b374eb891fd755debcf21884bc0ae7f --- /dev/null +++ b/src/gui/peptide_list_view/peptidetablemodel.h @@ -0,0 +1,72 @@ + +/******************************************************************************* +* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. +* +* This file is part of XTPcpp. +* +* XTPcpp is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* XTPcpp is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. +* +* Contributors: +* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation +******************************************************************************/ +#ifndef PEPTIDETABLEMODEL_H +#define PEPTIDETABLEMODEL_H + +#include <QAbstractTableModel> +#include <QSortFilterProxyModel> +#include "../../core/project.h" + +class PeptideTableModel; +class PeptideTableProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT +public: + PeptideTableProxyModel(QObject* parent,PeptideTableModel* peptide_table_model_p); + bool filterAcceptsRow(int source_row, + const QModelIndex &source_parent) const override; + QVariant headerData(int section, Qt::Orientation orientation, + int role) const override; + bool lessThan(const QModelIndex & left, const QModelIndex & right) const override; + +public slots: + void onTableClicked(const QModelIndex &index); +private: + PeptideTableModel* _peptide_table_model_p; +}; + +class PeptideTableModel: public QAbstractTableModel +{ + Q_OBJECT +public: + PeptideTableModel(QObject *parent=0); + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + 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 setProteinMatch(Project * p_project, ProteinMatch * p_protein_match); + bool acceptRow(int source_row); +signals: + void peptideMatchClicked(PeptideMatch * p_peptide_match); + +public slots: + void onTableClicked(const QModelIndex &index); + +private : + Project * _p_project; + ProteinMatch * _p_protein_match= nullptr; +}; + +#endif // PEPTIDETABLEMODEL_H diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index c071a0c4eb547c9c08e980095b4fda8b478d5f9a..c56c6365c33d8a40c7af54a097f0da2fb570b04b 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -50,7 +50,7 @@ ProteinListWindow::ProteinListWindow(QWidget *parent): /* */ - _protein_table_model_p = new ProteinTableModel(0); + _protein_table_model_p = new ProteinTableModel(this, this); _p_proxy_model = new ProteinTableProxyModel(this, _protein_table_model_p); @@ -58,10 +58,14 @@ ProteinListWindow::ProteinListWindow(QWidget *parent): _p_proxy_model->setDynamicSortFilter(true); ui->tableView->setModel( _p_proxy_model ); ui->tableView->setSortingEnabled(true); - + connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &))); } +void ProteinListWindow::clickOnproteinMatch(ProteinMatch * p_protein_match) { + emit proteinMatchClicked(p_protein_match); +} + ProteinListWindow::~ProteinListWindow() { //if (_p_ms_data_file != nullptr) delete _p_ms_data_file; diff --git a/src/gui/protein_list_view/proteinlistwindow.h b/src/gui/protein_list_view/proteinlistwindow.h index e30f7aabefe2eef7e45207c01b46b28f602aed27..b982156d486fcfa7f658c873c35ffd6c9b0b0c02 100644 --- a/src/gui/protein_list_view/proteinlistwindow.h +++ b/src/gui/protein_list_view/proteinlistwindow.h @@ -41,14 +41,14 @@ public: explicit ProteinListWindow(QWidget * parent = 0); ~ProteinListWindow(); void setIdentificationGroup(IdentificationGroup * p_identification_group); + void clickOnproteinMatch(ProteinMatch * p_protein_match); public slots: //void peptideEdited(QString peptideStr); // void setColor(const QColor &color); // void setShape(Shape shape); signals: - //void peptideChanged(pappso::PeptideSp peptide); - + void proteinMatchClicked(ProteinMatch * p_protein_match); 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 71a639df8528b48758746d4aafe8657252ef5ef1..eef60b8ee8eeeb4f00b82ea5fd4bdbb847b5a0f5 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -22,6 +22,7 @@ ******************************************************************************/ #include "proteintablemodel.h" +#include "proteinlistwindow.h" #include <QDebug> @@ -40,8 +41,8 @@ bool ProteinTableProxyModel::filterAcceptsRow(int source_row, void ProteinTableProxyModel::onTableClicked(const QModelIndex &index) { - qDebug() << "ProteinTableProxyModel::onTableClicked begin " << index.row(); - qDebug() << "ProteinTableProxyModel::onTableClicked begin " << this->mapToSource(index).row(); + qDebug() << "ProteinTableProxyModel::onTableClicked begin " << index.row(); + qDebug() << "ProteinTableProxyModel::onTableClicked begin " << this->mapToSource(index).row(); _protein_table_model_p->onTableClicked(this->mapToSource(index)); } @@ -82,10 +83,10 @@ QVariant ProteinTableProxyModel::headerData(int section, Qt::Orientation orienta role); } -ProteinTableModel::ProteinTableModel(QObject *parent) +ProteinTableModel::ProteinTableModel(QObject *parent, ProteinListWindow * p_protein_list_window) :QAbstractTableModel(parent) { - + _p_protein_list_window = p_protein_list_window; //ui->tableView->show(); // QModelIndex topLeft = createIndex(0,0); //emit a signal to make the view reread identified data @@ -170,7 +171,7 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { if (col == 3) { if (_p_identification_group != nullptr) { - return _p_identification_group->getProteinMatchList().at(row)->getEvalue(); + return QVariant ((qreal)_p_identification_group->getProteinMatchList().at(row)->getEvalue()); } } @@ -190,18 +191,22 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { void ProteinTableModel::onTableClicked(const QModelIndex &index) { - int row = index.row(); + int row = index.row(); int col = index.column(); if (col == 0) //add a checkbox to cell(1,0) - { - if ( _p_identification_group->getProteinMatchList().at(row)->isChecked()) { - _p_identification_group->getProteinMatchList().at(row)->setChecked(false); - } - else { - _p_identification_group->getProteinMatchList().at(row)->setChecked(true); - } - //emit dataChanged(index, index); + { + if ( _p_identification_group->getProteinMatchList().at(row)->isChecked()) { + _p_identification_group->getProteinMatchList().at(row)->setChecked(false); + } + else { + _p_identification_group->getProteinMatchList().at(row)->setChecked(true); } + //emit dataChanged(index, index); + } + + else { + _p_protein_list_window->clickOnproteinMatch(_p_identification_group->getProteinMatchList().at(row)); + } } bool ProteinTableModel::acceptRow(int source_row) { diff --git a/src/gui/protein_list_view/proteintablemodel.h b/src/gui/protein_list_view/proteintablemodel.h index f548695e74e3b9da499bb6bb6be149931a66c0bc..307a55426436dc27bb2f82986a951ff795c7457e 100644 --- a/src/gui/protein_list_view/proteintablemodel.h +++ b/src/gui/protein_list_view/proteintablemodel.h @@ -28,6 +28,8 @@ #include <QSortFilterProxyModel> #include "../../core/project.h" +class ProteinListWindow; + class ProteinTableModel; class ProteinTableProxyModel : public QSortFilterProxyModel { @@ -52,7 +54,7 @@ class ProteinTableModel: public QAbstractTableModel { Q_OBJECT public: - ProteinTableModel(QObject *parent=0); + ProteinTableModel(QObject *parent, ProteinListWindow * p_protein_list_window); int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; @@ -61,10 +63,12 @@ public: void setIdentificationGroup(IdentificationGroup * p_identification_group); bool acceptRow(int source_row); + public slots: void onTableClicked(const QModelIndex &index); private : IdentificationGroup * _p_identification_group = nullptr; + ProteinListWindow * _p_protein_list_window; }; #endif // PROTEINTABLEMODEL_H