From 36b9f6e766f9cd41e548f3a2fe34e782a08cdb8d Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Fri, 31 Mar 2017 22:26:55 +0200 Subject: [PATCH] yes it works ! --- src/CMakeLists.txt | 4 +- src/core/project.cpp | 4 +- src/gui/project_view/projectwindow.cpp | 11 +- .../protein_list_view/proteinlistwindow.cpp | 52 +++--- src/gui/protein_list_view/proteinlistwindow.h | 4 +- .../protein_list_view/proteintablemodel.cpp | 170 +++++++++--------- src/gui/protein_list_view/proteintablemodel.h | 23 ++- src/gui/protein_view/proteinwindow.cpp | 3 +- 8 files changed, 136 insertions(+), 135 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 46172223..617e2004 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,8 +29,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS} ${Qt5 #sudo apt-get install libpappsomspp-dev #FIND_PACKAGE( Pappsomspp REQUIRED ) -# SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") - SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") + SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") +# SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src") SET (PAPPSOMSPP_QT4_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt4.so") diff --git a/src/core/project.cpp b/src/core/project.cpp index ecbb6f91..7c09d5e3 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -66,7 +66,7 @@ IdentificationGroup* Project::newIdentificationGroup() { return _p_current_identification_group; } void Project::readXpipFile(QFileInfo xpip_fileinfo) { - + qDebug() << "Project::readXpipFile begin"; XpipSaxHandler * parser = new XpipSaxHandler(this); @@ -96,6 +96,8 @@ void Project::readXpipFile(QFileInfo xpip_fileinfo) { } IdentificationGroup* Project::getCurrentIdentificationGroupP() const { + + qDebug() << "Project::getCurrentIdentificationGroupP begin " << _p_current_identification_group; return _p_current_identification_group; } diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 37cc24fd..8774ead8 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -196,10 +196,10 @@ void ProjectWindow::doViewProteinDetail(ProteinMatch * protein_match) { } void ProjectWindow::doViewProteinList(IdentificationGroup* p_identification_group) { - qDebug() << "ProjectWindow::doViewProteinList begin"; - if (p_identification_group == nullptr) { + qDebug() << "ProjectWindow::doViewProteinList begin " << p_identification_group; + //if (p_identification_group == nullptr) { p_identification_group = _project_sp.get()->getCurrentIdentificationGroupP(); - } + //} if (_protein_list_window_collection.size() == 0) { connectNewProteinListWindow(); } @@ -209,9 +209,12 @@ void ProjectWindow::doViewProteinList(IdentificationGroup* p_identification_grou } - _p_current_protein_list_window->setIdentificationGroup(p_identification_group); _p_current_protein_list_window->show(); + qDebug() << "ProjectWindow::doViewProteinList end " << p_identification_group; + _p_current_protein_list_window->setIdentificationGroup(p_identification_group); + + emit identificationGroupGrouped(p_identification_group); qDebug() << "ProjectWindow::doViewProteinList end"; } diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index f1f3533a..17b642ed 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -40,9 +40,9 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent): _p_proxy_model = new ProteinTableProxyModel(this, _protein_table_model_p); - //_p_proxy_model->setSourceModel(_protein_table_model_p); - //_p_proxy_model->setDynamicSortFilter(true); - ui->tableView->setModel( _protein_table_model_p ); + _p_proxy_model->setSourceModel(_protein_table_model_p); + _p_proxy_model->setDynamicSortFilter(true); + ui->tableView->setModel( _p_proxy_model ); ui->tableView->setSortingEnabled(true); QSettings settings; @@ -50,17 +50,17 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent): if (hide) { ui->hideNotValidCheckBox->setCheckState(Qt::Checked); } - _protein_table_model_p->hideNotValid(hide); + _p_proxy_model->hideNotValid(hide); hide = settings.value("proteinview/hidenotchecked", "false").toBool(); if (hide) { ui->hideNotCheckedCheckBox->setCheckState(Qt::Checked); } - _protein_table_model_p->hideNotChecked(hide); + _p_proxy_model->hideNotChecked(hide); hide = settings.value("proteinview/hidenotgrouped", "false").toBool(); if (hide) { ui->hideNotGroupedCheckBox->setCheckState(Qt::Checked); } - _protein_table_model_p->hideNotGrouped(settings.value("proteinview/hidenotgrouped", "false").toBool()); + _p_proxy_model->hideNotGrouped(settings.value("proteinview/hidenotgrouped", "false").toBool()); #if QT_VERSION >= 0x050000 @@ -72,9 +72,10 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent): */ #else // Qt4 code + 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->proteinSearchEdit, SIGNAL(textChanged(QString)), _protein_table_model_p, SLOT(onProteinSearchEdit(QString))); + connect(ui->proteinSearchEdit, SIGNAL(textChanged(QString)), _p_proxy_model, SLOT(onProteinSearchEdit(QString))); //connect( this, SIGNAL( focusReceived(bool) ),this, SLOT(doFocusReceived(bool)) ); @@ -82,7 +83,7 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent): this, SLOT(showContextMenu(const QPoint &))); //connect(_p_proxy_model, SIGNAL(layoutChanged()), // this, SLOT(doProxyLayoutChanged())); - //connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, SLOT(updateStatusBar())); + connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, SLOT(updateStatusBar())); #endif } @@ -160,54 +161,57 @@ void ProteinListWindow::edited() { } void ProteinListWindow::doNotValidHide(bool hide) { qDebug() << "ProteinListWindow::doNotValidHide begin"; - _protein_table_model_p->hideNotValid(hide); + _p_proxy_model->hideNotValid(hide); QSettings settings; settings.setValue("proteinview/hidenotvalid", QString("%1").arg(hide)); + emit proteinDataChanged(); qDebug() << "ProteinListWindow::doNotValidHide end"; } void ProteinListWindow::doNotCheckedHide(bool hide) { qDebug() << "ProteinListWindow::doNotCheckedHide begin"; - _protein_table_model_p->hideNotChecked(hide); + _p_proxy_model->hideNotChecked(hide); QSettings settings; settings.setValue("proteinview/hidenotchecked", QString("%1").arg(hide)); + emit proteinDataChanged(); qDebug() << "ProteinListWindow::doNotCheckedHide end"; } void ProteinListWindow::doNotGroupedHide(bool hide) { qDebug() << "ProteinListWindow::doNotGroupedHide begin"; - _protein_table_model_p->hideNotGrouped(hide); + _p_proxy_model->hideNotGrouped(hide); QSettings settings; settings.setValue("proteinview/hidenotgrouped", QString("%1").arg(hide)); + emit proteinDataChanged(); qDebug() << "ProteinListWindow::doNotGroupedHide end"; } void ProteinListWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) { qDebug() << "ProteinListWindow::doIdentificationGroupGrouped begin"; if (_p_identification_group == p_identification_group) { + //_protein_table_model_p->setIdentificationGroup(p_identification_group); //_p_proxy_model->setSourceModel(_protein_table_model_p); + emit proteinDataChanged(); } + qDebug() << "ProteinListWindow::doIdentificationGroupGrouped end"; } void ProteinListWindow::setIdentificationGroup(IdentificationGroup * p_identification_group) { - qDebug() << "ProteinListWindow::setIdentificationGroup begin"; - if (_p_identification_group != p_identification_group) { + 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); + //_p_proxy_model->setSourceModel(_protein_table_model_p); + + + } + else { + qDebug() << "ProteinListWindow::setIdentificationGroup null"; } - qDebug() << "ProteinListWindow::setIdentificationGroup end"; -} - - -void ProteinListWindow::refresh() { - if (_p_identification_group == nullptr) return; - qDebug() << "ProteinListWindow::refresh begin " << _p_identification_group->getProteinMatchList().size(); - //_p_proxy_model->setSourceModel(_protein_table_model_p); - qDebug() << "ProteinListWindow::refresh end "; + qDebug() << "ProteinListWindow::setIdentificationGroup end"; } - void ProteinListWindow::updateStatusBar() { if (_p_identification_group == nullptr) { } diff --git a/src/gui/protein_list_view/proteinlistwindow.h b/src/gui/protein_list_view/proteinlistwindow.h index b0840f4c..3c070ee0 100644 --- a/src/gui/protein_list_view/proteinlistwindow.h +++ b/src/gui/protein_list_view/proteinlistwindow.h @@ -56,6 +56,7 @@ public slots: // void setShape(Shape shape); signals: void identificationGroupEdited(IdentificationGroup * p_identification_group); + void proteinDataChanged(); protected slots: @@ -66,9 +67,8 @@ protected slots: void showContextMenu(const QPoint &); void showEvalueColumn(bool show); void showAccessionColumn(bool show); -protected : - void refresh(); void updateStatusBar(); +protected : void askProteinDetailView(ProteinMatch * p_protein_match); void askPeptideListView(ProteinMatch * p_protein_match); diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp index eb0d5dfc..b71d4cc8 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -38,7 +38,57 @@ ProteinTableProxyModel::ProteinTableProxyModel(ProteinListWindow * p_protein_lis } bool ProteinTableProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { - return _protein_table_model_p->acceptRow(source_row); + try { + qDebug() << "ProteinTableProxyModel::filterAcceptsRow begin " << source_row; + ProteinMatch * protein_match = _protein_table_model_p->getIdentificationGroup()->getProteinMatchList().at(source_row); + qDebug() << "ProteinTableProxyModel::filterAcceptsRow protein_match " << source_row; + /* + if (!_protein_search_string.isEmpty()) { + if (!protein_match->getProteinXtpSp().get()->getDescription().contains(_protein_search_string)) { + return false; + } + } + */ + qDebug() << "ProteinTableProxyModel::filterAcceptsRow valid "; + if (_hide_not_valid) { + if (! protein_match->isValid()) { + return false; + } + } + qDebug() << "ProteinTableProxyModel::filterAcceptsRow checked "; + if (_hide_not_checked) { + if (! protein_match->isChecked()) { + return false; + } + } + + qDebug() << "ProteinTableProxyModel::filterAcceptsRow grouped "; + pappso::GrpProtein * p_grp_prot = protein_match->getGrpProteinSp().get(); + if (_hide_not_grouped) { + if (p_grp_prot == nullptr) { + return false; + } + + qDebug() << "ProteinTableProxyModel::filterAcceptsRow grouped 2"; + if (p_grp_prot->getGroupingId().isEmpty()) { + return false; + } + } + } + + catch (pappso::PappsoException exception_pappso) { + //QMessageBox::warning(this, + // tr("Error in ProteinTableModel::acceptRow :"), exception_pappso.qwhat()); + qDebug() << "Error in ProteinTableModel::acceptRow :" << exception_pappso.qwhat(); + } + catch (std::exception exception_std) { + //QMessageBox::warning(this, + // tr("Error in ProteinTableModel::acceptRow :"), exception_std.what()); + qDebug() << "Error in ProteinTableModel::acceptRow :" << exception_std.what(); + } + + return true; + //return true; } @@ -114,57 +164,35 @@ QVariant ProteinTableProxyModel::headerData(int section, Qt::Orientation orienta role); } -IdentificationGroup * ProteinTableModel::getIdentificationGroup() { - return _p_identification_group; -} -ProteinTableModel::ProteinTableModel(ProteinListWindow * p_protein_list_window) - :QAbstractTableModel(p_protein_list_window) -{ - _p_protein_list_window = p_protein_list_window; - _p_identification_group = nullptr; - //ui->tableView->show(); - // QModelIndex topLeft = createIndex(0,0); - //emit a signal to make the view reread identified data - //emit dataChanged(topLeft, topLeft); -} - -void ProteinTableModel::refresh() { - if (_p_identification_group == nullptr) return; - qDebug() << "ProteinTableModel::refresh begin " << _p_identification_group->getProteinMatchList().size(); - _p_protein_list_window->refresh(); - //emit layoutAboutToBeChanged(); - QModelIndex topLeft = createIndex(0,0); - QModelIndex bottomRight = createIndex(rowCount(),columnCount()); - qDebug() << "ProteinTableModel::refresh emit dataChanged "; - emit dataChanged(topLeft, bottomRight); - //emit layoutChanged(); - qDebug() << "ProteinTableModel::refresh end "; -} - -void ProteinTableModel::hideNotValid(bool hide) { +void ProteinTableProxyModel::hideNotValid(bool hide) { _hide_not_valid = hide; - refresh(); } -void ProteinTableModel::hideNotChecked(bool hide) { - qDebug() << "ProteinTableModel::hideNotChecked begin "; +void ProteinTableProxyModel::hideNotChecked(bool hide) { + qDebug() << "ProteinTableProxyModel::hideNotChecked begin "; _hide_not_checked = hide; - refresh(); - qDebug() << "ProteinTableModel::hideNotChecked end "; + qDebug() << "ProteinTableProxyModel::hideNotChecked end "; } -void ProteinTableModel::hideNotGrouped(bool hide) { +void ProteinTableProxyModel::hideNotGrouped(bool hide) { _hide_not_grouped = hide; - refresh(); } -void ProteinTableModel::onProteinSearchEdit(QString protein_search_string) { - qDebug() << "ProteinTableModel::onProteinSearchEdit begin " << protein_search_string; +void ProteinTableProxyModel::onProteinSearchEdit(QString protein_search_string) { + qDebug() << "ProteinTableProxyModel::onProteinSearchEdit begin " << protein_search_string; _protein_search_string = protein_search_string; - QModelIndex topLeft = createIndex(0,0); - QModelIndex bottomRight = createIndex(rowCount(),columnCount()); - emit dataChanged(topLeft, bottomRight); //emit layoutChanged(); } + +IdentificationGroup * ProteinTableModel::getIdentificationGroup() { + return _p_identification_group; +} +ProteinTableModel::ProteinTableModel(ProteinListWindow * p_protein_list_window) + :QAbstractTableModel(p_protein_list_window) +{ + _p_protein_list_window = p_protein_list_window; + _p_identification_group = nullptr; +} + void ProteinTableModel::setIdentificationGroup(IdentificationGroup * p_identification_group) { qDebug() << "ProteinTableModel::setIdentificationGroup begin " << p_identification_group->getProteinMatchList().size(); beginResetModel(); @@ -172,20 +200,21 @@ void ProteinTableModel::setIdentificationGroup(IdentificationGroup * p_identific //emit headerDataChanged(Qt::Horizontal, 0,11); //refresh(); - endResetModel(); qDebug() << "ProteinTableModel::setIdentificationGroup end "; + endResetModel(); } + int ProteinTableModel::rowCount(const QModelIndex &parent ) const { - qDebug() << "ProteinTableModel::rowCount begin "; + qDebug() << "ProteinTableModel::rowCount begin "; if (_p_identification_group != nullptr) { - //qDebug() << "ProteinTableModel::rowCount(const QModelIndex &parent ) " << _p_identification_group->getProteinMatchList().size(); - return _p_identification_group->getProteinMatchList().size(); + qDebug() << "ProteinTableModel::rowCount(const QModelIndex &parent ) " << _p_identification_group->getProteinMatchList().size(); + return (int) _p_identification_group->getProteinMatchList().size(); } return 0; } int ProteinTableModel::columnCount(const QModelIndex &parent ) const { - qDebug() << "ProteinTableModel::columnCount begin "; + qDebug() << "ProteinTableModel::columnCount begin "; if (_p_identification_group != nullptr) { return 11; } @@ -193,6 +222,7 @@ int ProteinTableModel::columnCount(const QModelIndex &parent ) const { } QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, int role) const { + if (_p_identification_group == nullptr) return QVariant(); if (role == Qt::DisplayRole) { if (orientation == Qt::Horizontal) { @@ -227,12 +257,12 @@ QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation, } QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { // generate a log message when this method gets called + if (_p_identification_group == nullptr) return QVariant(); int row = index.row(); int col = index.column(); // qDebug() << QString("row %1, col%2, role %3") // .arg(row).arg(col).arg(role); - switch(role) { case Qt::CheckStateRole: @@ -317,46 +347,8 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const { return QVariant(); } -bool ProteinTableModel::acceptRow(int source_row) { - try { - ProteinMatch * protein_match = _p_identification_group->getProteinMatchList().at(source_row); - - if (!_protein_search_string.isEmpty()) { - if (!protein_match->getProteinXtpSp().get()->getDescription().contains(_protein_search_string)) { - return false; - } - } - - if (_hide_not_valid) { - if (! protein_match->isValid()) { - return false; - } - } - if (_hide_not_checked) { - if (! protein_match->isChecked()) { - return false; - } - } - pappso::GrpProtein * p_grp_prot = protein_match->getGrpProteinSp().get(); - if (_hide_not_grouped) { - if (p_grp_prot == nullptr) - return false; - } - if (p_grp_prot->getGroupingId().isEmpty()) { - return false; - } - } - - catch (pappso::PappsoException exception_pappso) { - //QMessageBox::warning(this, - // tr("Error in ProteinTableModel::acceptRow :"), exception_pappso.qwhat()); - qDebug() << "Error in ProteinTableModel::acceptRow :" << exception_pappso.qwhat(); - } - catch (std::exception exception_std) { - //QMessageBox::warning(this, - // tr("Error in ProteinTableModel::acceptRow :"), exception_std.what()); - qDebug() << "Error in ProteinTableModel::acceptRow :" << exception_std.what(); - } - - return true; +void ProteinTableModel::onProteinDataChanged() { + qDebug() << "ProteinTableModel::onProteinDataChanged begin " << rowCount(); + emit layoutAboutToBeChanged(); + emit layoutChanged(); } diff --git a/src/gui/protein_list_view/proteintablemodel.h b/src/gui/protein_list_view/proteintablemodel.h index 47c38557..829a3dfe 100644 --- a/src/gui/protein_list_view/proteintablemodel.h +++ b/src/gui/protein_list_view/proteintablemodel.h @@ -42,12 +42,22 @@ public: QVariant headerData(int section, Qt::Orientation orientation, int role) const override; bool lessThan(const QModelIndex & left, const QModelIndex & right) const override; + + void hideNotValid(bool hide); + void hideNotChecked(bool hide); + void hideNotGrouped(bool hide); public slots: void onTableClicked(const QModelIndex &index); + void onProteinSearchEdit(QString protein_search_string); + private: ProteinTableModel* _protein_table_model_p; ProteinListWindow * _p_protein_list_window; + QString _protein_search_string; + bool _hide_not_valid = true; + bool _hide_not_checked = true; + bool _hide_not_grouped = true; }; class ProteinTableModel: public QAbstractTableModel @@ -63,24 +73,13 @@ public: void setIdentificationGroup(IdentificationGroup * p_identification_group); IdentificationGroup * getIdentificationGroup(); - bool acceptRow(int source_row); - - void hideNotValid(bool hide); - void hideNotChecked(bool hide); - void hideNotGrouped(bool hide); - public slots: - void onProteinSearchEdit(QString protein_search_string); - + void onProteinDataChanged(); private : void refresh(); private : IdentificationGroup * _p_identification_group = nullptr; ProteinListWindow * _p_protein_list_window; - QString _protein_search_string; - bool _hide_not_valid = true; - bool _hide_not_checked = true; - bool _hide_not_grouped = true; }; #endif // PROTEINTABLEMODEL_H diff --git a/src/gui/protein_view/proteinwindow.cpp b/src/gui/protein_view/proteinwindow.cpp index cd01270a..9fea5f2e 100644 --- a/src/gui/protein_view/proteinwindow.cpp +++ b/src/gui/protein_view/proteinwindow.cpp @@ -26,6 +26,7 @@ #include "ui_protein_detail_view.h" #include <pappsomspp/pappsoexception.h> #include <QMessageBox> +#include <cmath> ProteinWindow::ProteinWindow(ProjectWindow *parent): QMainWindow(parent), @@ -62,7 +63,7 @@ void ProteinWindow::setProteinMatch(ProteinMatch * p_protein_match) { ui->coverage_label->setText(QString("%1 %").arg(p_protein_match->getCoverage()*100)); pappso::Peptide peptide(p_protein_match->getProteinXtpSp().get()->getSequence()); ui->mw_label->setText(QString("%1 kDa").arg(peptide.getMass()/1000)); - ui->evalue_label->setText(QString("%1 (log10: %2)").arg(p_protein_match->getEvalue()).arg(log10(p_protein_match->getEvalue()))); + ui->evalue_label->setText(QString("%1 (log10: %2)").arg(p_protein_match->getEvalue()).arg(std::log10(p_protein_match->getEvalue()))); } catch (pappso::PappsoException exception_pappso) { QMessageBox::warning(this, -- GitLab