From ff92760cdcce1041c42c394a4bb0356ee0c321df Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Sat, 10 Jun 2017 14:38:20 +0200 Subject: [PATCH] update ptm table model --- src/core/identificationgroup.cpp | 4 +++ .../ptmislandlistwindow.cpp | 16 +++++---- .../ptmislandproxymodel.cpp | 33 +++++++++++++++++++ .../ptmislandproxymodel.h | 6 ++-- .../ptmislandtablemodel.cpp | 17 ++++++++-- .../ptmislandtablemodel.h | 2 +- 6 files changed, 66 insertions(+), 12 deletions(-) diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index da181d529..b7de9ac35 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -208,6 +208,9 @@ void IdentificationGroup::startGrouping (const GroupingType & grouping_type) { p_protein_match->setGroupInstance(_group_store); } + if (_p_grp_ptm_experiment != nullptr) { + startPtmGrouping(); + } qDebug() << "IdentificationGroup::startGrouping end "; } @@ -215,6 +218,7 @@ void IdentificationGroup::startPtmGrouping () { qDebug() << "IdentificationGroup::startPtmGrouping begin "; if (_p_grp_ptm_experiment != nullptr) { delete _p_grp_ptm_experiment; + _p_grp_ptm_experiment = nullptr; } _p_grp_ptm_experiment = new PtmGroupingExperiment(); _p_grp_ptm_experiment->setValidationState(ValidationState::grouped); diff --git a/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp b/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp index af7b406f3..932bc8012 100644 --- a/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp +++ b/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp @@ -64,7 +64,7 @@ PtmIslandListWindow::PtmIslandListWindow(ProjectWindow *parent): */ #else // Qt4 code -connect (this, SIGNAL(ptmIslandDataChanged()), _ptm_table_model_p, SLOT(onPtmIslandDataChanged())); + connect (this, SIGNAL(ptmIslandDataChanged()), _ptm_table_model_p, SLOT(onPtmIslandDataChanged())); connect (_project_window, SIGNAL(identificationPtmGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationPtmGroupGrouped(IdentificationGroup *))); @@ -73,19 +73,20 @@ connect (this, SIGNAL(ptmIslandDataChanged()), _ptm_table_model_p, SLOT(onPtmIsl PtmIslandListWindow::~PtmIslandListWindow() { - + delete _ptm_table_model_p; + delete _ptm_proxy_model_p; } void PtmIslandListWindow::setIdentificationGroup(IdentificationGroup * p_identification_group) { - - qDebug() << "PtmIslandListWindow::setIdentificationGroup begin " ; + + qDebug() << "PtmIslandListWindow::setIdentificationGroup begin " ; if (p_identification_group != nullptr) { qDebug() << "PtmIslandListWindow::setIdentificationGroup not null"; _p_identification_group = p_identification_group; _ptm_table_model_p->setIdentificationGroup(p_identification_group); //_p_proxy_model->setSourceModel(_protein_table_model_p); - - + + } else { qDebug() << "PtmIslandListWindow::setIdentificationGroup null"; @@ -100,7 +101,10 @@ void PtmIslandListWindow::doIdentificationPtmGroupGrouped(IdentificationGroup * if (_p_identification_group == p_identification_group) { //_protein_table_model_p->setIdentificationGroup(p_identification_group); //_p_proxy_model->setSourceModel(_protein_table_model_p); + _ptm_table_model_p->setIdentificationGroup(p_identification_group); emit ptmIslandDataChanged(); + + ui->ptm_island_tableview->resizeRowToContents(_ptm_table_model_p->rowCount()); } qDebug() << "PtmIslandListWindow::doIdentificationPtmGroupGrouped end"; diff --git a/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp b/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp index c34250a01..7f7a3c034 100644 --- a/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp +++ b/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp @@ -28,6 +28,10 @@ ******************************************************************************/ #include "ptmislandproxymodel.h" +#include "ptmislandtablemodel.h" +#include "../../grouping/ptm/ptmgroupingexperiment.h" +#include "../../grouping/ptm/ptmisland.h" +#include <pappsomspp/pappsoexception.h> PtmIslandProxyModel::PtmIslandProxyModel(PtmIslandListWindow * p_ptm_island_list_window, PtmIslandTableModel* ptm_table_model_p) { @@ -39,3 +43,32 @@ PtmIslandProxyModel::~PtmIslandProxyModel() { } + +bool PtmIslandProxyModel::filterAcceptsRow(int source_row, + const QModelIndex &source_parent) const { + try { + //qDebug() << "ProteinTableProxyModel::filterAcceptsRow begin " << source_row; + PtmIslandSp sp_ptm_island = _p_ptm_island_table_model->getPtmGroupingExperiment()->getPtmIslandList().at(source_row); + //qDebug() << "ProteinTableProxyModel::filterAcceptsRow protein_match " << source_row; + + if (sp_ptm_island != nullptr) { + return true; + } + return false; + } + + catch (pappso::PappsoException exception_pappso) { + //QMessageBox::warning(this, + // tr("Error in ProteinTableModel::acceptRow :"), exception_pappso.qwhat()); + qDebug() << "Error in PtmIslandProxyModel::acceptRow :" << exception_pappso.qwhat(); + } + catch (std::exception exception_std) { + //QMessageBox::warning(this, + // tr("Error in ProteinTableModel::acceptRow :"), exception_std.what()); + qDebug() << "Error in PtmIslandProxyModel::acceptRow :" << exception_std.what(); + } + + return true; + + //return true; +} diff --git a/src/gui/ptm_island_list_view/ptmislandproxymodel.h b/src/gui/ptm_island_list_view/ptmislandproxymodel.h index bac67e6cc..f35e988ff 100644 --- a/src/gui/ptm_island_list_view/ptmislandproxymodel.h +++ b/src/gui/ptm_island_list_view/ptmislandproxymodel.h @@ -43,9 +43,11 @@ class PtmIslandProxyModel: public QSortFilterProxyModel public: PtmIslandProxyModel(PtmIslandListWindow * p_ptm_island_list_window, PtmIslandTableModel* ptm_table_model_p); ~PtmIslandProxyModel(); + bool filterAcceptsRow(int source_row, + const QModelIndex &source_parent) const override; private: - PtmIslandListWindow * _p_ptm_island_list_window; - PtmIslandTableModel * _p_ptm_island_table_model; + PtmIslandListWindow * _p_ptm_island_list_window; + PtmIslandTableModel * _p_ptm_island_table_model; }; #endif // PTMISLANDPROXYMODEL_H diff --git a/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp b/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp index 37457a85d..396fcff08 100644 --- a/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp +++ b/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp @@ -136,7 +136,8 @@ const QString PtmIslandTableModel::getDescription(std::int8_t column) { return ""; } void PtmIslandTableModel::setIdentificationGroup(IdentificationGroup * p_identification_group) { - qDebug() << "PtmIslandTableModel::setIdentificationGroup begin "; + qDebug() << "PtmIslandTableModel::setIdentificationGroup begin "; + beginResetModel(); _p_identification_group = p_identification_group; @@ -144,6 +145,16 @@ void PtmIslandTableModel::setIdentificationGroup(IdentificationGroup * p_identif //refresh(); qDebug() << "PtmIslandTableModel::setIdentificationGroup end "; endResetModel(); + + //emit layoutAboutToBeChanged(); + //emit layoutChanged(); + /* + QModelIndex topLeft = index(0, 0); + QModelIndex bottomRight = index(rowCount() - 1, columnCount() - 1); + + emit dataChanged(topLeft, bottomRight); + */ + } const PtmGroupingExperiment * PtmIslandTableModel::getPtmGroupingExperiment() const { if (_p_identification_group == nullptr) { @@ -152,9 +163,9 @@ const PtmGroupingExperiment * PtmIslandTableModel::getPtmGroupingExperiment() co return _p_identification_group->getPtmGroupingExperiment(); } int PtmIslandTableModel::rowCount(const QModelIndex &parent ) const { - //qDebug() << "ProteinTableModel::rowCount begin "; + qDebug() << "PtmIslandTableModel::rowCount begin "; if (getPtmGroupingExperiment() != nullptr) { - //qDebug() << "ProteinTableModel::rowCount(const QModelIndex &parent ) " << _p_identification_group->getProteinMatchList().size(); + qDebug() << "PtmIslandTableModel::rowCount(const QModelIndex &parent ) " << getPtmGroupingExperiment()->getPtmIslandList().size(); return (int) getPtmGroupingExperiment()->getPtmIslandList().size(); } return 0; diff --git a/src/gui/ptm_island_list_view/ptmislandtablemodel.h b/src/gui/ptm_island_list_view/ptmislandtablemodel.h index dfac66fec..d7e40067a 100644 --- a/src/gui/ptm_island_list_view/ptmislandtablemodel.h +++ b/src/gui/ptm_island_list_view/ptmislandtablemodel.h @@ -72,13 +72,13 @@ public: static const QString getTitle(PtmIslandListColumn column); static const QString getDescription(PtmIslandListColumn column); + const PtmGroupingExperiment * getPtmGroupingExperiment() const; using columnMap = std::int8_t[20]; public slots: void onPtmIslandDataChanged(); private : - const PtmGroupingExperiment * getPtmGroupingExperiment() const; static const QString getTitle(std::int8_t column); static const QString getDescription(std::int8_t column); private : -- GitLab