diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index e991cb71ba071fdd70afdd754c3d7e0b40f90adb..708c7948b105a46459d04cbb18261c3095051f7e 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -75,7 +75,7 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent): // Qt4 code connect (_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); - connect (this, SIGNAL(proteinDataChanged()), _protein_table_model_p, SLOT(onProteinDataChanged())); + connect (this, SIGNAL(proteinDataChanged()), _protein_table_model_p, SLOT(onProteinDataChanged())); connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &))); //connect(ui->tableView, SIGNAL(doubleClicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableDoubleClicked(const QModelIndex &))); //connect(ui->protein_search_edit, SIGNAL(textChanged(QString)), this, SLOT(onProteinSearchEdit(QString))); @@ -131,6 +131,7 @@ void ProteinListWindow::doFocusReceived(bool has_focus) { void ProteinListWindow::showContextMenu(const QPoint & pos) { QMenu contextMenu(tr("Context menu"), this); + QAction accession_action("accession", this); accession_action.setCheckable(true); accession_action.setChecked(_display_evalue); @@ -143,6 +144,16 @@ void ProteinListWindow::showContextMenu(const QPoint & pos) { connect(&evalue_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool))); contextMenu.addAction(&evalue_action); + QAction * p_action; + for (unsigned int i=0; i < _protein_table_model_p->columnCount(); i++) { + p_action = new QAction(_protein_table_model_p->getTitle(i),this); + p_action->setData(QVariant(i)); + p_action->setCheckable(true); + //evalue_action.setChecked(_display_evalue); + //connect(p_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool))); + contextMenu.addAction(p_action); + } + contextMenu.exec(mapToGlobal(pos)); } @@ -214,14 +225,14 @@ void ProteinListWindow::doIdentificationGroupGrouped(IdentificationGroup * p_ide } void ProteinListWindow::setIdentificationGroup(IdentificationGroup * p_identification_group) { - qDebug() << "ProteinListWindow::setIdentificationGroup begin " ; + qDebug() << "ProteinListWindow::setIdentificationGroup begin " ; if (p_identification_group != nullptr) { qDebug() << "ProteinListWindow::setIdentificationGroup not null"; _p_identification_group = p_identification_group; _protein_table_model_p->setIdentificationGroup(p_identification_group); //_p_proxy_model->setSourceModel(_protein_table_model_p); - - + + } else { qDebug() << "ProteinListWindow::setIdentificationGroup null"; diff --git a/src/gui/protein_list_view/proteintablemodel.h b/src/gui/protein_list_view/proteintablemodel.h index f943abf1b43321daf6869fa29b29158388e7f11a..e635bf1d8a0f75f9cb12c110b6ed2b06ab1bbdb7 100644 --- a/src/gui/protein_list_view/proteintablemodel.h +++ b/src/gui/protein_list_view/proteintablemodel.h @@ -33,19 +33,19 @@ */ enum class ProteinListColumn { - checked, ///< manual checked - protein_grouping_id, ///< protein grouping id - accession, ///< accession - description, ///< protein description - log_evalue, ///< log(Evalue) - evalue, ///< Evalue - spectrum, ///< spectrum count - specific_spectrum, ///< specific spectrum count - sequence, ///< unique sequence count - specific_sequence, ///< specific unique sequence - coverage, ///< protein coverage - pai, ///< PAI - empai, ///< emPAI + checked, ///< manual checked + protein_grouping_id, ///< protein grouping id + accession, ///< accession + description, ///< protein description + log_evalue, ///< log(Evalue) + evalue, ///< Evalue + spectrum, ///< spectrum count + specific_spectrum, ///< specific spectrum count + sequence, ///< unique sequence count + specific_sequence, ///< specific unique sequence + coverage, ///< protein coverage + pai, ///< PAI + empai, ///< emPAI }; class ProteinListWindow; @@ -59,27 +59,27 @@ public: virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override; virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override; virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - + static const QString getTitle(ProteinListColumn column); static const QString getDescription(ProteinListColumn column); + static const QString getTitle(std::int8_t column); + static const QString getDescription(std::int8_t column); void setIdentificationGroup(IdentificationGroup * p_identification_group); IdentificationGroup * getIdentificationGroup(); using columnMap = std::int8_t[30]; - + public slots: void onProteinDataChanged(); private : - static const QString getTitle(std::int8_t column); - static const QString getDescription(std::int8_t column); void refresh(); private : IdentificationGroup * _p_identification_group = nullptr; ProteinListWindow * _p_protein_list_window; QStringList _columns; - + static columnMap _column_assignment; }; diff --git a/src/gui/protein_list_view/proteintableproxymodel.cpp b/src/gui/protein_list_view/proteintableproxymodel.cpp index 7c03ab3cd0914bdbb5177f76494d020c42743eed..74debfe4430f82173d9960cd86d0b65a13bf2326 100644 --- a/src/gui/protein_list_view/proteintableproxymodel.cpp +++ b/src/gui/protein_list_view/proteintableproxymodel.cpp @@ -173,8 +173,11 @@ bool ProteinTableProxyModel::lessThan(const QModelIndex & left, const QModelInde QVariant ProteinTableProxyModel::headerData(int section, Qt::Orientation orientation, int role) const { - return sourceModel()->headerData(section, orientation, + int col = mapToSource(index(0,section)).column(); + + return sourceModel()->headerData(col, orientation, role); + } void ProteinTableProxyModel::hideNotValid(bool hide) {