From 2cd289899825f2f7954b537af00a256b8782d82d Mon Sep 17 00:00:00 2001 From: Olivier Langella <olivier.langella@u-psud.fr> Date: Thu, 21 Jun 2018 19:00:26 +0200 Subject: [PATCH] system to display only present columns --- .../peptide_list_view/peptidetablemodel.cpp | 43 ++++++++++++++++--- src/gui/peptide_list_view/peptidetablemodel.h | 3 ++ .../peptidetableproxymodel.cpp | 21 +++++---- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/src/gui/peptide_list_view/peptidetablemodel.cpp b/src/gui/peptide_list_view/peptidetablemodel.cpp index b028f6b3..1f0a2ad7 100644 --- a/src/gui/peptide_list_view/peptidetablemodel.cpp +++ b/src/gui/peptide_list_view/peptidetablemodel.cpp @@ -55,7 +55,7 @@ PeptideTableModel::setProteinMatch(ProteinMatch *p_protein_match) // QModelIndex topLeft = createIndex(0,0); // QModelIndex bottomRight = createIndex(rowCount(),columnCount()); - std::set<PeptideListColumn> engine_columns; + _engine_columns_to_display.clear(); bool first = true; for(auto &&peptide_match : _p_protein_match->getPeptideMatchList()) { @@ -65,11 +65,15 @@ PeptideTableModel::setProteinMatch(ProteinMatch *p_protein_match) PeptideEvidenceParam::peptide_prophet_probability); if(!var.isNull()) { + _engine_columns_to_display.insert( + PeptideListColumn::peptide_prophet_probability); } var = peptide_match.getPeptideEvidence()->getParam( PeptideEvidenceParam::peptide_inter_prophet_probability); if(!var.isNull()) { + _engine_columns_to_display.insert( + PeptideListColumn::peptide_inter_prophet_probability); } first = false; } @@ -77,17 +81,24 @@ PeptideTableModel::setProteinMatch(ProteinMatch *p_protein_match) peptide_match.getPeptideEvidence()->getIdentificationEngine(); if(engine == IdentificationEngine::XTandem) { - engine_columns.insert(PeptideListColumn::tandem_hyperscore); + _engine_columns_to_display.insert( + PeptideListColumn::tandem_hyperscore); } else if(engine == IdentificationEngine::mascot) { - engine_columns.insert(PeptideListColumn::mascot_score); + _engine_columns_to_display.insert(PeptideListColumn::mascot_score); + _engine_columns_to_display.insert( + PeptideListColumn::mascot_expectation_value); } } + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " + << _engine_columns_to_display.size(); _p_peptide_list_window->resizeColumnsToContents(); // emit dataChanged(topLeft, topLeft); - // emit headerDataChanged(Qt::Horizontal, 0,3); + // emit headerDataChanged(Qt::Horizontal, 0,33); + emit layoutAboutToBeChanged(); + emit layoutChanged(); qDebug() << "PeptideTableModel::setProteinMatch end "; } @@ -407,7 +418,7 @@ PeptideTableModel::getTitle(PeptideListColumn column) const QString PeptideTableModel::getDescription(PeptideListColumn column) { - qDebug() << "PeptideTableModel::columnCount begin "; + // qDebug() << "PeptideTableModel::columnCount begin "; return PeptideTableModel::getDescription((std::int8_t)column); // qDebug() << "ProteinTableModel::columnCount end "; } @@ -416,7 +427,7 @@ const QString PeptideTableModel::getTitle(std::int8_t column) { - qDebug() << "PeptideTableModel::getTitle begin " << column; + // qDebug() << "PeptideTableModel::getTitle begin " << column; switch(column) { @@ -586,7 +597,7 @@ PeptideTableModel::getDescription(std::int8_t column) int PeptideTableModel::getColumnWidth(int column) { - qDebug() << "PeptideTableModel::getColumnWidth " << column; + // qDebug() << "PeptideTableModel::getColumnWidth " << column; switch(column) { @@ -605,3 +616,21 @@ PeptideTableModel::getColumnWidth(int column) } return 100; } + + +bool +PeptideTableModel::hasColumn(PeptideListColumn column) +{ + if((std::int8_t)column < 21) + { + return true; + } + qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " " + << _engine_columns_to_display.size(); + if(_engine_columns_to_display.find(column) != + _engine_columns_to_display.end()) + { + return true; + } + return false; +} diff --git a/src/gui/peptide_list_view/peptidetablemodel.h b/src/gui/peptide_list_view/peptidetablemodel.h index 549aa337..ed865d62 100644 --- a/src/gui/peptide_list_view/peptidetablemodel.h +++ b/src/gui/peptide_list_view/peptidetablemodel.h @@ -87,6 +87,7 @@ class PeptideTableModel : public QAbstractTableModel static const QString getTitle(PeptideListColumn column); static const QString getDescription(PeptideListColumn column); static PeptideListColumn getPeptideListColumn(std::int8_t column); + bool hasColumn(PeptideListColumn column); void setProteinMatch(ProteinMatch *p_protein_match); ProteinMatch *getProteinMatch(); @@ -104,6 +105,8 @@ class PeptideTableModel : public QAbstractTableModel private: ProteinMatch *_p_protein_match = nullptr; PeptideListWindow *_p_peptide_list_window = nullptr; + //contains columns to display (present in this peptide match) + std::set<PeptideListColumn> _engine_columns_to_display; }; #endif // PEPTIDETABLEMODEL_H diff --git a/src/gui/peptide_list_view/peptidetableproxymodel.cpp b/src/gui/peptide_list_view/peptidetableproxymodel.cpp index 80267509..5e9fa827 100644 --- a/src/gui/peptide_list_view/peptidetableproxymodel.cpp +++ b/src/gui/peptide_list_view/peptidetableproxymodel.cpp @@ -65,18 +65,23 @@ bool PeptideTableProxyModel::filterAcceptsColumn( int source_column, const QModelIndex &source_parent) const { - if(_peptide_table_model_p->getPeptideListColumn(source_column) == - PeptideListColumn::label) + if(_column_display[source_column]) { - if(_p_peptide_list_window->getProjectWindow() - ->getProjectP() - ->getLabelingMethodSp() - .get() == nullptr) + PeptideListColumn peptide_column = + _peptide_table_model_p->getPeptideListColumn(source_column); + if(peptide_column == PeptideListColumn::label) { - return false; + if(_p_peptide_list_window->getProjectWindow() + ->getProjectP() + ->getLabelingMethodSp() + .get() == nullptr) + { + return false; + } } + return _peptide_table_model_p->hasColumn(peptide_column); } - return _column_display[source_column]; + return false; } bool -- GitLab