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

context menu deployed on PTM peptide

parent d3378789
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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();
}
......@@ -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:
......
......@@ -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);
......
......@@ -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);
......
......@@ -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();
}
......@@ -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;
......
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