Skip to content
Snippets Groups Projects
Commit 3bb23f1e authored by Olivier Langella's avatar Olivier Langella
Browse files

new action menu

parent 3d5b8fac
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,19 @@
#include "../mainwindow.h"
#include <QSettings>
ProteinListQactionColumn::ProteinListQactionColumn(ProteinListWindow * parent, ProteinListColumn column):QAction(parent) {
this->setText(ProteinTableModel::getTitle(column));
this->setCheckable(true);
//evalue_action.setChecked(_display_evalue);
//connect(p_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool)));
}
ProteinListQactionColumn::~ProteinListQactionColumn()
{
//if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
}
ProteinListWindow::ProteinListWindow(ProjectWindow *parent):
QMainWindow(parent),
......@@ -144,13 +157,9 @@ void ProteinListWindow::showContextMenu(const QPoint & pos) {
connect(&evalue_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool)));
contextMenu.addAction(&evalue_action);
QAction * p_action;
ProteinListQactionColumn * p_action;
for (unsigned int i=0; i < _protein_table_model_p->columnCount(); i++) {
p_action = new QAction(_protein_table_model_p->getTitle(i),this);
p_action->setData(QVariant(i));
p_action->setCheckable(true);
//evalue_action.setChecked(_display_evalue);
//connect(p_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool)));
p_action = new ProteinListQactionColumn(this,ProteinTableModel::getProteinListColumn(i));
contextMenu.addAction(p_action);
}
......
......@@ -26,6 +26,7 @@
#include <QMainWindow>
#include <QAction>
#include "proteintablemodel.h"
#include "proteintableproxymodel.h"
......@@ -36,6 +37,15 @@ namespace Ui {
class ProteinView;
}
class ProteinListWindow;
class ProteinListQactionColumn: public QAction {
Q_OBJECT
public:
explicit ProteinListQactionColumn(ProteinListWindow * parent, ProteinListColumn column);
~ProteinListQactionColumn();
};
class ProteinListWindow: public QMainWindow {
Q_OBJECT
......
......@@ -192,6 +192,11 @@ QVariant ProteinTableModel::headerData(int section, Qt::Orientation orientation,
}
return QVariant();
}
ProteinListColumn ProteinTableModel::getProteinListColumn(std::int8_t column){
return static_cast<ProteinListColumn>(column);
}
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();
......
......@@ -64,6 +64,7 @@ public:
static const QString getDescription(ProteinListColumn column);
static const QString getTitle(std::int8_t column);
static const QString getDescription(std::int8_t column);
static ProteinListColumn getProteinListColumn(std::int8_t column);
void setIdentificationGroup(IdentificationGroup * p_identification_group);
......
......@@ -31,7 +31,16 @@ ProteinTableProxyModel::ProteinTableProxyModel(ProteinListWindow * p_protein_lis
{
_protein_table_model_p = protein_table_model_p;
_p_protein_list_window = p_protein_list_window;
_column_display.resize(30);
for (std::size_t i=0; i < _column_display.size(); i++) {
_column_display[i] = true;
}
}
bool ProteinTableProxyModel::filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const {
return _column_display[source_column];
}
bool ProteinTableProxyModel::filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const {
try {
......
......@@ -38,6 +38,7 @@ public:
ProteinTableProxyModel(ProteinListWindow * p_protein_list_window, ProteinTableModel* protein_table_model_p);
bool filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const override;
bool filterAcceptsColumn(int source_column, const QModelIndex & source_parent) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role) const override;
......@@ -60,6 +61,7 @@ private:
bool _hide_not_valid = true;
bool _hide_not_checked = true;
bool _hide_not_grouped = true;
std::vector<bool> _column_display;
};
#endif // PROTEINTABLEPROXYMODEL_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment