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

problem to hide column

parent 228f0a70
No related branches found
No related tags found
No related merge requests found
......@@ -10,10 +10,16 @@
<height>404</height>
</rect>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="windowTitle">
<string>Protein list</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
......@@ -48,7 +54,11 @@
</layout>
</item>
<item>
<widget class="QTableView" name="tableView"/>
<widget class="QTableView" name="tableView">
<property name="contextMenuPolicy">
<enum>Qt::DefaultContextMenu</enum>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="proteinSearchEdit"/>
......
......@@ -39,7 +39,7 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent):
_protein_table_model_p = new ProteinTableModel(this);
_p_proxy_model = new ProteinTableProxyModel(_protein_table_model_p);
_p_proxy_model = new ProteinTableProxyModel(this, _protein_table_model_p);
_p_proxy_model->setSourceModel(_protein_table_model_p);
_p_proxy_model->setDynamicSortFilter(true);
ui->tableView->setModel( _p_proxy_model );
......@@ -78,11 +78,17 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent):
connect( this, SIGNAL( focusReceived(bool) ),this, SLOT(doFocusReceived(bool)) );
connect(ui->centralwidget, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showContextMenu(const QPoint &)));
//connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, SLOT(updateStatusBar()));
#endif
}
void ProteinListWindow::showEvalueColumn(bool show) {
_display_evalue = show;
ui->tableView->setColumnHidden(4,!show);
}
void ProteinListWindow::doubleclickOnproteinMatch(ProteinMatch * p_protein_match) {
emit proteinMatchClicked(p_protein_match);
//updateStatusBar();
......@@ -93,6 +99,20 @@ void ProteinListWindow::doFocusReceived(bool has_focus) {
}
}
void ProteinListWindow::showContextMenu(const QPoint & pos) {
QMenu contextMenu(tr("Context menu"), this);
QAction evalue_action("Evalue", this);
evalue_action.setCheckable(true);
evalue_action.setChecked(_display_evalue);
connect(&evalue_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool)));
contextMenu.addAction(&evalue_action);
contextMenu.exec(mapToGlobal(pos));
}
ProteinListWindow::~ProteinListWindow()
{
//if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
......
......@@ -58,18 +58,26 @@ signals:
void proteinMatchClicked(ProteinMatch * p_protein_match);
void identificationGroupEdited(IdentificationGroup * p_identification_group);
protected slots:
void doNotValidHide(bool hide);
void doNotCheckedHide(bool hide);
void doNotGroupedHide(bool hide);
void showContextMenu(const QPoint &);
protected :
void updateStatusBar();
private :
void showEvalueColumn(bool show);
private:
IdentificationGroup * _p_identification_group;
Ui::ProteinView *ui;
ProteinTableModel * _protein_table_model_p = nullptr;
ProteinTableProxyModel * _p_proxy_model = nullptr;
ProjectWindow * _project_window;
bool _display_evalue = true;
};
......
......@@ -28,17 +28,17 @@
#include <QDebug>
ProteinTableProxyModel::ProteinTableProxyModel(ProteinTableModel* protein_table_model_p): QSortFilterProxyModel(protein_table_model_p),
m_minGravity(0.0), m_minDensity(0.0)
ProteinTableProxyModel::ProteinTableProxyModel(ProteinListWindow * p_protein_list_window, ProteinTableModel* protein_table_model_p): QSortFilterProxyModel(protein_table_model_p)
{
_protein_table_model_p = protein_table_model_p;
_p_protein_list_window = p_protein_list_window;
}
bool ProteinTableProxyModel::filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const {
return _protein_table_model_p->acceptRow(source_row);
//return true;
}
void ProteinTableProxyModel::onTableClicked(const QModelIndex &index)
{
qDebug() << "ProteinTableProxyModel::onTableClicked begin " << index.row();
......
......@@ -35,9 +35,10 @@ class ProteinTableProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
ProteinTableProxyModel(ProteinTableModel* protein_table_model_p);
ProteinTableProxyModel(ProteinListWindow * p_protein_list_window, ProteinTableModel* protein_table_model_p);
bool filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role) const override;
bool lessThan(const QModelIndex & left, const QModelIndex & right) const override;
......@@ -46,9 +47,8 @@ public slots:
void onTableClicked(const QModelIndex &index);
void onTableDoubleClicked(const QModelIndex &index);
private:
double m_minGravity;
double m_minDensity;
ProteinTableModel* _protein_table_model_p;
ProteinListWindow * _p_protein_list_window;
};
class ProteinTableModel: public QAbstractTableModel
......
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