From baa168303137fb6f7ba1346b5066fbe86110029c Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Fri, 28 Oct 2016 16:06:21 +0200 Subject: [PATCH] new proxy model --- .../protein_list_view/proteinlistwindow.cpp | 8 ++++++-- src/gui/protein_list_view/proteinlistwindow.h | 1 + .../protein_list_view/proteintablemodel.cpp | 6 ++++++ src/gui/protein_list_view/proteintablemodel.h | 20 +++++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index 55f272bc..02c29b85 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -51,7 +51,11 @@ ProteinListWindow::ProteinListWindow(QWidget *parent): */ _protein_table_model_p = new ProteinTableModel(0); - ui->tableView->setModel( _protein_table_model_p ); + + + _p_proxy_model = new ProteinTableProxyModel(); + _p_proxy_model->setSourceModel(_protein_table_model_p); + ui->tableView->setModel( _p_proxy_model ); } ProteinListWindow::~ProteinListWindow() @@ -64,4 +68,4 @@ ProteinListWindow::~ProteinListWindow() void ProteinListWindow::setProject(Project* project_p) { _protein_table_model_p->setProject(project_p); - } \ No newline at end of file + } diff --git a/src/gui/protein_list_view/proteinlistwindow.h b/src/gui/protein_list_view/proteinlistwindow.h index 826d7a2b..f4e337dc 100644 --- a/src/gui/protein_list_view/proteinlistwindow.h +++ b/src/gui/protein_list_view/proteinlistwindow.h @@ -52,6 +52,7 @@ signals: private: 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 5ec0ff14..2d46cd76 100644 --- a/src/gui/protein_list_view/proteintablemodel.cpp +++ b/src/gui/protein_list_view/proteintablemodel.cpp @@ -25,6 +25,12 @@ #include <QDebug> + +ProteinTableProxyModel::ProteinTableProxyModel(QObject *parent): QSortFilterProxyModel(parent), + m_minGravity(0.0), m_minDensity(0.0) +{ +} + ProteinTableModel::ProteinTableModel(QObject *parent) :QAbstractTableModel(parent) { diff --git a/src/gui/protein_list_view/proteintablemodel.h b/src/gui/protein_list_view/proteintablemodel.h index 3d80ff26..bc6aa5cd 100644 --- a/src/gui/protein_list_view/proteintablemodel.h +++ b/src/gui/protein_list_view/proteintablemodel.h @@ -25,8 +25,28 @@ #define PROTEINTABLEMODEL_H #include <QAbstractTableModel> +#include <QSortFilterProxyModel> #include "../../core/project.h" + +class ProteinTableProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT +public: + ProteinTableProxyModel(QObject* parent = 0); + //bool filterAcceptsRow(int source_row, + // const QModelIndex &source_parent) const; + // QVariant headerData(int section, Qt::Orientation orientation, + // int role) const; + +public slots: + //void setMinGravity(double minGravity); + // void setMinDensity(double minDensity); +private: + double m_minGravity; + double m_minDensity; +}; + class ProteinTableModel: public QAbstractTableModel { Q_OBJECT -- GitLab