diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index c0e05693014720954426a7b52b4e5bb19e6e75f1..fb14cd1b40da1db3951cc5c1c4cb94e7c4594f39 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -44,6 +44,10 @@ const pappso::ProteinSp & ProteinMatch::getProteinSp() const { void ProteinMatch::setEvalue(pappso::pappso_double evalue) { _evalue = evalue; } + +pappso::pappso_double ProteinMatch::getEvalue() const { + return _evalue; +} void ProteinMatch::setProteinSp(pappso::ProteinSp protein_sp) { _protein_sp = protein_sp; } diff --git a/src/core/proteinmatch.h b/src/core/proteinmatch.h index ffe62a7efc81228d3b9c47973bb4f7464a952f62..a0a0f5999d34e6839c125ff26cba3c77656b580d 100644 --- a/src/core/proteinmatch.h +++ b/src/core/proteinmatch.h @@ -37,6 +37,7 @@ public: const pappso::ProteinSp & getProteinSp() const; void setEvalue(pappso::pappso_double evalue); + pappso::pappso_double getEvalue() const; void setProteinSp(pappso::ProteinSp protein_sp); void addPeptideMatch(PeptideMatch * peptide_match); std::vector<PeptideMatch *> & getPeptideMatchList(); diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index 71ae18a086e13c1a413e62f6ca531388ac3cf35f..c071a0c4eb547c9c08e980095b4fda8b478d5f9a 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -58,6 +58,8 @@ 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 &))); } ProteinListWindow::~ProteinListWindow() diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp index 697cb11e7e1bf20593695d1758e26be1fdb477f0..71a639df8528b48758746d4aafe8657252ef5ef1 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -34,8 +34,15 @@ ProteinTableProxyModel::ProteinTableProxyModel(QObject *parent,ProteinTableModel bool ProteinTableProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { - //return _protein_table_model_p->acceptRow(source_row); - return true; + return _protein_table_model_p->acceptRow(source_row); + //return true; +} + +void ProteinTableProxyModel::onTableClicked(const QModelIndex &index) +{ + qDebug() << "ProteinTableProxyModel::onTableClicked begin " << index.row(); + qDebug() << "ProteinTableProxyModel::onTableClicked begin " << this->mapToSource(index).row(); + _protein_table_model_p->onTableClicked(this->mapToSource(index)); } bool ProteinTableProxyModel::lessThan(const QModelIndex & left, const QModelIndex & right) const { @@ -44,8 +51,11 @@ bool ProteinTableProxyModel::lessThan(const QModelIndex & left, const QModelInde if (leftData.type() == QVariant::UInt) { return leftData.toUInt() < rightData.toUInt(); } - if (leftData.type() == QVariant::Int) { - return leftData.toInt() < rightData.toInt(); + 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(); //if (leftData.type() == QVariant::DateTime) { @@ -101,7 +111,7 @@ int ProteinTableModel::rowCount(const QModelIndex &parent ) const { return 0; } int ProteinTableModel::columnCount(const QModelIndex &parent ) const { - return 3; + return 4; } QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, int role) const { @@ -111,11 +121,13 @@ QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, switch (section) { case 0: - return QString("group"); + return QString("checked"); case 1: - return QString("subgroup"); + return QString("accession"); case 2: return QString("protein description"); + case 3: + return QString("Evalue"); } } } @@ -143,10 +155,7 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { break; case Qt::DisplayRole: if (col == 0) { - if (_p_identification_group != nullptr) { - - return QVariant ((quint16) _p_identification_group->getProteinMatchList().at(row)->getPeptideMatchList().size()); - } + return QVariant(); } if (col == 1) { if (_p_identification_group != nullptr) { @@ -158,6 +167,20 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { return _p_identification_group->getProteinMatchList().at(row)->getProteinSp().get()->getDescription(); } } + if (col == 3) { + if (_p_identification_group != nullptr) { + + return _p_identification_group->getProteinMatchList().at(row)->getEvalue(); + } + } + + if (col == 4) { + if (_p_identification_group != nullptr) { + + return QVariant ((quint16) _p_identification_group->getProteinMatchList().at(row)->getPeptideMatchList().size()); + } + } + return QString("Row%1, Column%2") .arg(index.row() + 1) .arg(index.column() +1); @@ -165,6 +188,21 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { return QVariant(); } +void ProteinTableModel::onTableClicked(const QModelIndex &index) +{ + 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); + } +} bool ProteinTableModel::acceptRow(int source_row) { if (_p_identification_group->isValid(_p_identification_group->getProteinMatchList().at(source_row))) { diff --git a/src/gui/protein_list_view/proteintablemodel.h b/src/gui/protein_list_view/proteintablemodel.h index 2d58c87932d2b7f16be2c378d78b73f282a0e28e..f548695e74e3b9da499bb6bb6be149931a66c0bc 100644 --- a/src/gui/protein_list_view/proteintablemodel.h +++ b/src/gui/protein_list_view/proteintablemodel.h @@ -41,8 +41,7 @@ public: bool lessThan(const QModelIndex & left, const QModelIndex & right) const override; public slots: - //void setMinGravity(double minGravity); - // void setMinDensity(double minDensity); + void onTableClicked(const QModelIndex &index); private: double m_minGravity; double m_minDensity; @@ -62,7 +61,8 @@ 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; };