From bb18288add4763b0431479c1d0546282ec167781 Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Tue, 21 Mar 2017 22:01:31 +0100 Subject: [PATCH] display status bar --- src/core/identificationgroup.cpp | 22 ++++++++++++++++++- src/core/identificationgroup.h | 4 ++++ .../protein_list_view/proteinlistwindow.cpp | 12 ++++++++-- src/gui/protein_list_view/proteinlistwindow.h | 3 +++ .../protein_list_view/proteintablemodel.cpp | 8 ++++--- src/gui/protein_list_view/proteintablemodel.h | 4 ++-- 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index 87ab4a8b..7b86a908 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -46,7 +46,7 @@ void IdentificationGroup::updateAutomaticFilters(const AutomaticFilterParameters if (_p_grp_experiment != nullptr) { } - + } void IdentificationGroup::addProteinMatch(ProteinMatch * protein_match) { _protein_match_list.push_back(protein_match); @@ -57,3 +57,23 @@ void IdentificationGroup::addMsRunIdSp(pappso::MsRunIdSp ms_run_sp) { std::vector<ProteinMatch *> & IdentificationGroup::getProteinMatchList() { return _protein_match_list; } + +size_t IdentificationGroup::countValidAndChecked()const { + size_t i=0; + for (auto & p_protein_match : _protein_match_list) { + if (p_protein_match->isValidAndChecked()) { + i++; + } + } + return i; +} + +size_t IdentificationGroup::countValid()const { + size_t i=0; + for (auto & p_protein_match : _protein_match_list) { + if (p_protein_match->isValid()) { + i++; + } + } + return i; +} diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h index e981318a..75337244 100644 --- a/src/core/identificationgroup.h +++ b/src/core/identificationgroup.h @@ -45,6 +45,10 @@ public: void addProteinMatch(ProteinMatch * protein_match); std::vector<ProteinMatch *> & getProteinMatchList(); void addMsRunIdSp(pappso::MsRunIdSp ms_run_sp); + + + size_t countValid()const; + size_t countValidAndChecked()const; /** @brief validate or invalidate peptides and proteins based automatic filters and manual checks diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index 715b0026..60248bf1 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -36,10 +36,10 @@ ProteinListWindow::ProteinListWindow(MainWindow *parent): /* */ - _protein_table_model_p = new ProteinTableModel(this, this); + _protein_table_model_p = new ProteinTableModel(this); - _p_proxy_model = new ProteinTableProxyModel(this, _protein_table_model_p); + _p_proxy_model = new ProteinTableProxyModel(_protein_table_model_p); _p_proxy_model->setSourceModel(_protein_table_model_p); _p_proxy_model->setDynamicSortFilter(true); ui->tableView->setModel( _p_proxy_model ); @@ -58,12 +58,14 @@ ProteinListWindow::ProteinListWindow(MainWindow *parent): // Qt4 code connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &))); connect(ui->proteinSearchEdit, SIGNAL(textChanged(QString)), _protein_table_model_p, SLOT(onProteinSearchEdit(QString))); + //connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, SLOT(updateStatusBar())); #endif } void ProteinListWindow::clickOnproteinMatch(ProteinMatch * p_protein_match) { emit proteinMatchClicked(p_protein_match); + //updateStatusBar(); } ProteinListWindow::~ProteinListWindow() @@ -75,8 +77,14 @@ ProteinListWindow::~ProteinListWindow() void ProteinListWindow::setIdentificationGroup(IdentificationGroup * p_identification_group) { + _p_identification_group = p_identification_group; _protein_table_model_p->setIdentificationGroup(p_identification_group); _p_proxy_model->setSourceModel(_protein_table_model_p); + updateStatusBar(); + +} +void ProteinListWindow::updateStatusBar() { + ui->statusbar->showMessage(tr("proteins %1 valid, %2 checked, %3 displayed").arg(_p_identification_group->countValid()).arg(_p_identification_group->countValidAndChecked()).arg(_p_proxy_model->rowCount())); } diff --git a/src/gui/protein_list_view/proteinlistwindow.h b/src/gui/protein_list_view/proteinlistwindow.h index 919f7240..dea9dd09 100644 --- a/src/gui/protein_list_view/proteinlistwindow.h +++ b/src/gui/protein_list_view/proteinlistwindow.h @@ -44,6 +44,7 @@ public: ~ProteinListWindow(); void setIdentificationGroup(IdentificationGroup * p_identification_group); void clickOnproteinMatch(ProteinMatch * p_protein_match); + void updateStatusBar(); public slots: //void peptideEdited(QString peptideStr); @@ -51,7 +52,9 @@ public slots: // void setShape(Shape shape); signals: void proteinMatchClicked(ProteinMatch * p_protein_match); + private: + IdentificationGroup * _p_identification_group; Ui::ProteinView *ui; ProteinTableModel * _protein_table_model_p = nullptr; ProteinTableProxyModel * _p_proxy_model = nullptr; diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp index 7a88357c..17c8a1c9 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -27,7 +27,7 @@ #include <QDebug> -ProteinTableProxyModel::ProteinTableProxyModel(QObject *parent,ProteinTableModel* protein_table_model_p): QSortFilterProxyModel(parent), +ProteinTableProxyModel::ProteinTableProxyModel(ProteinTableModel* protein_table_model_p): QSortFilterProxyModel(protein_table_model_p), m_minGravity(0.0), m_minDensity(0.0) { _protein_table_model_p = protein_table_model_p; @@ -82,8 +82,8 @@ QVariant ProteinTableProxyModel::headerData(int section, Qt::Orientation orienta role); } -ProteinTableModel::ProteinTableModel(QObject *parent, ProteinListWindow * p_protein_list_window) - :QAbstractTableModel(parent) +ProteinTableModel::ProteinTableModel(ProteinListWindow * p_protein_list_window) + :QAbstractTableModel(p_protein_list_window) { _p_protein_list_window = p_protein_list_window; //ui->tableView->show(); @@ -99,6 +99,7 @@ void ProteinTableModel::onProteinSearchEdit(QString protein_search_string) { QModelIndex topLeft = createIndex(0,0); QModelIndex bottomRight = createIndex(rowCount(),columnCount()); emit dataChanged(topLeft, bottomRight); + _p_protein_list_window->updateStatusBar(); } void ProteinTableModel::setIdentificationGroup(IdentificationGroup * p_identification_group) { @@ -209,6 +210,7 @@ void ProteinTableModel::onTableClicked(const QModelIndex &index) _p_identification_group->getProteinMatchList().at(row)->setChecked(true); } //emit dataChanged(index, index); + _p_protein_list_window->updateStatusBar(); } else { diff --git a/src/gui/protein_list_view/proteintablemodel.h b/src/gui/protein_list_view/proteintablemodel.h index 464d60b2..715be598 100644 --- a/src/gui/protein_list_view/proteintablemodel.h +++ b/src/gui/protein_list_view/proteintablemodel.h @@ -35,7 +35,7 @@ class ProteinTableProxyModel : public QSortFilterProxyModel { Q_OBJECT public: - ProteinTableProxyModel(QObject* parent,ProteinTableModel* protein_table_model_p); + ProteinTableProxyModel(ProteinTableModel* protein_table_model_p); bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; QVariant headerData(int section, Qt::Orientation orientation, @@ -54,7 +54,7 @@ class ProteinTableModel: public QAbstractTableModel { Q_OBJECT public: - ProteinTableModel(QObject *parent, ProteinListWindow * p_protein_list_window); + ProteinTableModel(ProteinListWindow * p_protein_list_window); int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; -- GitLab