diff --git a/src/grouping/ptm/ptmgroupingexperiment.h b/src/grouping/ptm/ptmgroupingexperiment.h index a96a525873e6e5b153ca8002863a9e2f6cc1cf4f..61ab3c26e0946fed1f8e3dd8b0b786a36c1c4403 100644 --- a/src/grouping/ptm/ptmgroupingexperiment.h +++ b/src/grouping/ptm/ptmgroupingexperiment.h @@ -59,10 +59,10 @@ public: /** @brief count number of modifications in a PeptideMatch * */ unsigned int countPeptideMatchPtm(const PeptideMatch* p_peptide_match)const; + std::vector<unsigned int> getPtmPositions(const PeptideMatch * p_peptide_match) const; private: std::vector<unsigned int> getPtmPositions(const ProteinMatch * protein_match) const; - std::vector<unsigned int> getPtmPositions(const PeptideMatch * p_peptide_match) const; std::vector< PtmIslandSp > mergePeptideMatchPtmIslandList(vector< PtmIslandSp > ptm_island_list); void addPtmIsland(PtmIslandSp ptm_island); diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp index 32cd364671ffa6d19bba99e52e6cbdf775d2dbcc..b9b9962675ded135fcafbabfaf708081d3bfd9c4 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp +++ b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp @@ -71,7 +71,7 @@ PtmPeptideListWindow::PtmPeptideListWindow(PtmIslandListWindow * parent):QMainWi //connect (_project_window, SIGNAL(identificationPtmGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationPtmGroupGrouped(IdentificationGroup *))); //connect (_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); - connect(ui->ptm_peptide_tableview, SIGNAL(clicked(const QModelIndex &)), _ptm_table_model_p, SLOT(onTableClicked(const QModelIndex &))); + connect(ui->ptm_peptide_tableview, SIGNAL(clicked(const QModelIndex &)), _ptm_proxy_model_p, SLOT(onTableClicked(const QModelIndex &))); #endif } @@ -81,3 +81,10 @@ void PtmPeptideListWindow::setPtmIsland(PtmIsland * p_ptm_island) { _p_ptm_island = p_ptm_island; _ptm_table_model_p->setPtmIsland(_p_ptm_island_list_window->getIdentificationGroup()->getPtmGroupingExperiment(), _p_ptm_island); } + +void PtmPeptideListWindow::askPeptideDetailView(const PeptideMatch * p_peptide_match) { + qDebug() << "PtmPeptideListWindow::askPeptideDetailView begin"; + emit requestPeptideDetailView(p_peptide_match); + qDebug() << "PtmPeptideListWindow::askPeptideDetailView end"; + //updateStatusBar(); +} diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h index 26bbcc7474a0243237958eb06d9ccf2524c92231..b9fe1bfd34fce862bd132bb74ef881280ea66764 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h +++ b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h @@ -49,6 +49,10 @@ public: explicit PtmPeptideListWindow(PtmIslandListWindow * parent = 0); ~PtmPeptideListWindow(); void setPtmIsland(PtmIsland * p_ptm_island); + void askPeptideDetailView(const PeptideMatch * p_peptide_match); + +signals: + void requestPeptideDetailView(const PeptideMatch * p_peptide_match); private: diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp index 8a9bf2f030350d61c6f7355fdb953a027094ad30..8b455b208c07034ffde49326a1a2440535fd766c 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp +++ b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp @@ -37,6 +37,14 @@ PtmPeptideTableModel::PtmPeptideTableModel(PtmPeptideListWindow * p_ptm_peptide_ PtmPeptideTableModel::~PtmPeptideTableModel() { } + + const PtmGroupingExperiment * PtmPeptideTableModel::getPtmGroupingExperiment() const { + return _p_ptm_grouping_experiment; + } +const std::vector<PtmSampleScanSp> & PtmPeptideTableModel::getPtmSampleScanSpList() const { + return _ptm_sample_scan_list; +} + const QString PtmPeptideTableModel::getTitle(PtmPeptideListColumn column) { qDebug() << "PtmPeptideTableModel::getTitle begin "; return PtmPeptideTableModel::getTitle((std::int8_t) column); diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.h b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.h index 603d5346c6889ed24811e43dab07031e077af49d..cbd8344d0d42732629282b2c032e6b371a86ab93 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.h +++ b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.h @@ -75,6 +75,9 @@ public: ~PtmPeptideTableModel(); void setPtmIsland(const PtmGroupingExperiment * p_ptm_grouping_experiment, PtmIsland * ptm_island); + const std::vector<PtmSampleScanSp> & getPtmSampleScanSpList() const; + const PtmGroupingExperiment * getPtmGroupingExperiment() const; + private : static const QString getTitle(std::int8_t column); static const QString getDescription(std::int8_t column); diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp b/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp index c7f34df3a48a71596ec215795ae99899a41c445c..fdd8605b26cdc01659d03551f02a09fbeb3a761c 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp +++ b/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp @@ -29,6 +29,7 @@ #include "ptmpeptidetableproxymodel.h" #include "ptmpeptidetablemodel.h" #include "ptmpeptidelistwindow.h" +#include "../../grouping/ptm/ptmgroupingexperiment.h" #include <QTextDocument> PtmPeptideMenuQicon::PtmPeptideMenuQicon( const PtmSampleScan * p_ptm_sample, const PeptideMatch * p_peptide_match):QIcon() { @@ -40,25 +41,31 @@ PtmPeptideMenuQicon::~PtmPeptideMenuQicon( ) { void PtmPeptideMenuQicon::paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, Mode mode, State state) const { - // if (option.state & QStyle::State_Selected) - // painter->fillRect(option.rect, option.palette.highlight()); + // if (option.state & QStyle::State_Selected) + // painter->fillRect(option.rect, option.palette.highlight()); QTextDocument document; - document.setDocumentMargin(2); - //document.setHtml(_p_ptm_sample_scan->getHtmlSequence(_p_ptm_island_list_window->getIdentificationGroup()-//>getPtmGroupingExperiment())); - //painter->translate(option.rect.topLeft()); - document.drawContents(painter); - //painter->translate(-option.rect.topLeft()); - - //edit_seq.render(painter); - //edit..paint(painter, option.rect, option.palette, - // StarRating::ReadOnly); + document.setDocumentMargin(2); + //document.setHtml(_p_ptm_sample_scan->getHtmlSequence(_p_ptm_island_list_window->getIdentificationGroup()-//>getPtmGroupingExperiment())); + //painter->translate(option.rect.topLeft()); + document.drawContents(painter); + //painter->translate(-option.rect.topLeft()); + + //edit_seq.render(painter); + //edit..paint(painter, option.rect, option.palette, + // StarRating::ReadOnly); } -PtmPeptideMenuQaction::PtmPeptideMenuQaction(PtmPeptideTableProxyModel * parent, const PtmSampleScan * p_ptm_sample, const PeptideMatch * p_peptide_match):QAction(parent) { +PtmPeptideMenuQaction::PtmPeptideMenuQaction(PtmPeptideTableProxyModel * parent, const PtmGroupingExperiment * p_ptm_grouping_experiment, const PtmSampleScan * p_ptm_sample, const PeptideMatch * p_peptide_match):QAction(parent) { this->setIcon(PtmPeptideMenuQicon(p_ptm_sample, p_peptide_match)); - this->setText(p_peptide_match->getPeptideXtpSp().get()->getSequence()); + //this->setText(p_peptide_match->getPeptideXtpSp().get()->getSequence()); + + QStringList position_list; + for (unsigned int position : p_ptm_grouping_experiment->getPtmPositions(p_peptide_match)) { + position_list << QString("%1").arg(position+1); + } + this->setText(position_list.join(" ")); //evalue_action.setChecked(_display_evalue); //connect(p_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool))); @@ -110,18 +117,41 @@ bool PtmPeptideTableProxyModel::lessThan(const QModelIndex &left, void PtmPeptideTableProxyModel::showContextMenu(const QModelIndex &index) { if (_p_context_menu == nullptr) { _p_context_menu = new QMenu(tr("Context menu")); - - QVariant index_data = sourceModel()->data(index); - - if (index_data.canConvert<PtmSampleScan *>()) { - PtmSampleScan * p_ptm_sample = qvariant_cast<PtmSampleScan *>(index_data); - PtmPeptideMenuQaction * p_action; - for (auto p_peptide_match : p_ptm_sample->getPeptideMatchList()) { - p_action = new PtmPeptideMenuQaction(this, p_ptm_sample, p_peptide_match); - _p_context_menu->addAction(p_action); - } } - //_p_context_menu->exec(mapToGlobal(pos)); + _p_context_menu->clear(); + QModelIndex source_index(this->mapToSource(index)); + int row = source_index.row(); + PtmSampleScanSp sp_ptm_sample_scan = _p_ptm_table_model->getPtmSampleScanSpList().at(row); + + PtmPeptideMenuQaction * p_action; + for (auto p_peptide_match : sp_ptm_sample_scan.get()->getPeptideMatchList()) { + p_action = new PtmPeptideMenuQaction(this, _p_ptm_table_model->getPtmGroupingExperiment(), sp_ptm_sample_scan.get(), p_peptide_match); + _p_context_menu->addAction(p_action); } + + _p_context_menu->exec(QCursor::pos()); + + //_p_context_menu->exec(_p_ptm_peptide_list_window-> mapToGlobal(QCursor::pos())); + _p_context_menu->show(); } + +void PtmPeptideTableProxyModel::onTableClicked(const QModelIndex &index) +{ + qDebug() << "PtmPeptideTableProxyModel::onTableClicked begin " << index.row(); + qDebug() << "PtmPeptideTableProxyModel::onTableClicked begin " << this->mapToSource(index).row(); + + //_protein_table_model_p->onTableClicked(this->mapToSource(index)); + QModelIndex source_index(this->mapToSource(index)); + int row = source_index.row(); + int col = source_index.column(); + PtmSampleScanSp sp_ptm_sample_scan = _p_ptm_table_model->getPtmSampleScanSpList().at(row); + + if (sp_ptm_sample_scan.get()->getPeptideMatchList().size() == 1) { + _p_ptm_peptide_list_window->askPeptideDetailView(sp_ptm_sample_scan.get()->getPeptideMatchList().at(0)); + } + this->showContextMenu(index); + + qDebug() << "PtmPeptideTableProxyModel::onTableClicked end " << index.row(); + +} diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.h b/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.h index 993c0484d6e54c0d309b20c9eed1b870ad96e713..8336d9e1674b22692ff318f6adc2b70b3c26f8f2 100644 --- a/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.h +++ b/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.h @@ -57,7 +57,7 @@ class PtmPeptideMenuQaction: public QAction { Q_OBJECT public: - explicit PtmPeptideMenuQaction(PtmPeptideTableProxyModel * parent, const PtmSampleScan * p_ptm_sample, const PeptideMatch * p_peptide_match); + explicit PtmPeptideMenuQaction(PtmPeptideTableProxyModel * parent, const PtmGroupingExperiment * p_ptm_grouping_experiment, const PtmSampleScan * p_ptm_sample, const PeptideMatch * p_peptide_match); ~PtmPeptideMenuQaction(); private: @@ -71,9 +71,13 @@ public: PtmPeptideTableProxyModel(PtmPeptideListWindow * p_ptm_peptide_list_window, PtmPeptideTableModel* ptm_table_model_p); ~PtmPeptideTableProxyModel(); +public slots: + void onTableClicked(const QModelIndex &index); + protected: bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; void showContextMenu(const QModelIndex &index); + private: PtmPeptideListWindow * _p_ptm_peptide_list_window; PtmPeptideTableModel* _p_ptm_table_model;