diff --git a/src/gui/peptide_list_view/peptidetableproxymodel.cpp b/src/gui/peptide_list_view/peptidetableproxymodel.cpp index 7d03215a347d48834f61e8aa87725984fdb0fec9..b43cbb2f994c7e9fafba8994566d6ac8dbdef00f 100644 --- a/src/gui/peptide_list_view/peptidetableproxymodel.cpp +++ b/src/gui/peptide_list_view/peptidetableproxymodel.cpp @@ -44,6 +44,13 @@ PeptideTableProxyModel::PeptideTableProxyModel(PeptideListWindow * p_peptide_lis _second_delegate = new SecondItemDelegate(_p_peptide_list_window); } +PeptideTableProxyModel::~PeptideTableProxyModel() +{ + // delete _mass_delegate ; + // delete _minute_delegate ; + // delete _second_delegate ; +} + bool PeptideTableProxyModel::filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const { if (_peptide_table_model_p->getPeptideListColumn(source_column) == PeptideListColumn::label) { if (_p_peptide_list_window->getProjectWindow()->getProjectP()->getLabelingMethodSp().get() == nullptr) { @@ -257,7 +264,7 @@ void PeptideTableProxyModel::setPeptideListColumnDisplay(PeptideListColumn colum void PeptideTableProxyModel::resteItemDelegates() const { - + for (int i = 0; i < columnCount(); ++i) { _p_peptide_list_window->ui->tableView->setItemDelegateForColumn(i, _p_peptide_list_window->ui->tableView->itemDelegate()); if (mapToSource(index(0, i)).column() == (std::int8_t) PeptideListColumn::experimental_mhplus) { @@ -276,10 +283,10 @@ void PeptideTableProxyModel::resteItemDelegates() const { _p_peptide_list_window->ui->tableView->setItemDelegateForColumn(i, _second_delegate); } } - /* - MinuteItemDelegate * minute_delegate = new MinuteItemDelegate(ui->tableView); - ui->tableView->setItemDelegateForColumn((std::int8_t) PeptideListColumn::rtmin, minute_delegate); - SecondItemDelegate * second_delegate = new SecondItemDelegate(ui->tableView); - ui->tableView->setItemDelegateForColumn((std::int8_t) PeptideListColumn::rt, second_delegate); -*/ + /* + MinuteItemDelegate * minute_delegate = new MinuteItemDelegate(ui->tableView); + ui->tableView->setItemDelegateForColumn((std::int8_t) PeptideListColumn::rtmin, minute_delegate); + SecondItemDelegate * second_delegate = new SecondItemDelegate(ui->tableView); + ui->tableView->setItemDelegateForColumn((std::int8_t) PeptideListColumn::rt, second_delegate); + */ } diff --git a/src/gui/peptide_list_view/peptidetableproxymodel.h b/src/gui/peptide_list_view/peptidetableproxymodel.h index 866ea9edee9c73a70c8058ef886857187aa5a7ca..d8bd68652031fe21e3c157511d2355046273f33a 100644 --- a/src/gui/peptide_list_view/peptidetableproxymodel.h +++ b/src/gui/peptide_list_view/peptidetableproxymodel.h @@ -39,6 +39,7 @@ class PeptideTableProxyModel : public QSortFilterProxyModel Q_OBJECT public: PeptideTableProxyModel(PeptideListWindow * p_peptide_list_window, PeptideTableModel* peptide_table_model_p); + virtual ~PeptideTableProxyModel(); bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const override; diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index ff7b1be9b8f0e8cdd1921bb181adf24e9fe36be6..e71b9ecd24e37a61304bde62ab347616f397672b 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -25,7 +25,6 @@ #include "ui_protein_view.h" #include "../mainwindow.h" -#include "../widgets/massitemdelegate.h" #include <QSettings> ProteinListQactionColumn::ProteinListQactionColumn(ProteinListWindow * parent, ProteinListColumn column):QAction(parent) { @@ -81,10 +80,7 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent): ui->tableView->setModel( _p_proxy_model ); ui->tableView->setSortingEnabled(true); ui->tableView->setAlternatingRowColors(true); - - PercentItemDelegate * percent_delegate = new PercentItemDelegate(ui->tableView); - ui->tableView->setItemDelegateForColumn((std::int8_t) ProteinListColumn::coverage, percent_delegate); - + QSettings settings; bool hide = settings.value("proteinview/hidenotvalid", "true").toBool(); if (hide) { @@ -321,7 +317,7 @@ void ProteinListWindow::setIdentificationGroup(IdentificationGroup * p_identific completer->setFilterMode(Qt::MatchContains); ui->mod_auto_completion->setCompleter(completer); - + _p_proxy_model->resteItemDelegates(); } else { qDebug() << "ProteinListWindow::setIdentificationGroup null"; diff --git a/src/gui/protein_list_view/proteintableproxymodel.cpp b/src/gui/protein_list_view/proteintableproxymodel.cpp index ee4ffc0d89476ddb720241cbab1720f9204709d5..08806350a084598fa03c7eaec0e42375eb57dd53 100644 --- a/src/gui/protein_list_view/proteintableproxymodel.cpp +++ b/src/gui/protein_list_view/proteintableproxymodel.cpp @@ -40,8 +40,15 @@ ProteinTableProxyModel::ProteinTableProxyModel(ProteinListWindow * p_protein_lis _column_display[i] = settings.value(QString("protein_list_columns/%1").arg(_protein_table_model_p->getTitle((ProteinListColumn)i)), "true").toBool(); } + + _percent_delegate = new PercentItemDelegate(p_protein_list_window->ui->tableView); + } +ProteinTableProxyModel::~ProteinTableProxyModel() +{ + //delete _percent_delegate; +} bool ProteinTableProxyModel::filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const { return _column_display[source_column]; } @@ -271,7 +278,21 @@ void ProteinTableProxyModel::setProteinListColumnDisplay(ProteinListColumn colum _column_display[(std::int8_t) column] = toggled; endResetModel(); + + resteItemDelegates(); } bool ProteinTableProxyModel::getProteinListColumnDisplay(ProteinListColumn column) const { return _column_display[(std::int8_t) column]; } + + + +void ProteinTableProxyModel::resteItemDelegates() const { + + for (int i = 0; i < columnCount(); ++i) { + _p_protein_list_window->ui->tableView->setItemDelegateForColumn(i, _p_protein_list_window->ui->tableView->itemDelegate()); + if (mapToSource(index(0, i)).column() == (std::int8_t) ProteinListColumn::coverage) { + _p_protein_list_window->ui->tableView->setItemDelegateForColumn(i, _percent_delegate); + } + } +} diff --git a/src/gui/protein_list_view/proteintableproxymodel.h b/src/gui/protein_list_view/proteintableproxymodel.h index a71cf0a2e8945c2ef7a800116b82194bb286d7e9..13fe073b95b1be5c541ec4dff1067d9ceb429023 100644 --- a/src/gui/protein_list_view/proteintableproxymodel.h +++ b/src/gui/protein_list_view/proteintableproxymodel.h @@ -28,6 +28,7 @@ #include <QSortFilterProxyModel> #include "../../core/project.h" #include "proteintablemodel.h" +#include "../widgets/massitemdelegate.h" class ProteinListWindow; @@ -38,6 +39,8 @@ class ProteinTableProxyModel : public QSortFilterProxyModel Q_OBJECT public: ProteinTableProxyModel(ProteinListWindow * p_protein_list_window, ProteinTableModel* protein_table_model_p); + virtual ~ProteinTableProxyModel(); + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const override; @@ -54,9 +57,11 @@ public: void setSearchOn(QString search_on); void setProteinListColumnDisplay(ProteinListColumn column, bool toggled); bool getProteinListColumnDisplay(ProteinListColumn column) const; + void resteItemDelegates() const; public slots: void onTableClicked(const QModelIndex &index); + private: ProteinTableModel* _protein_table_model_p; @@ -67,6 +72,7 @@ private: bool _hide_not_checked = true; bool _hide_not_grouped = true; std::vector<bool> _column_display; + PercentItemDelegate * _percent_delegate; }; #endif // PROTEINTABLEPROXYMODEL_H