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

wip : contextual menu to hide/show protein list columns

parent 2de1a8c6
No related branches found
No related tags found
No related merge requests found
......@@ -75,7 +75,7 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent):
// Qt4 code
connect (_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *)));
connect (this, SIGNAL(proteinDataChanged()), _protein_table_model_p, SLOT(onProteinDataChanged()));
connect (this, SIGNAL(proteinDataChanged()), _protein_table_model_p, SLOT(onProteinDataChanged()));
connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &)));
//connect(ui->tableView, SIGNAL(doubleClicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableDoubleClicked(const QModelIndex &)));
//connect(ui->protein_search_edit, SIGNAL(textChanged(QString)), this, SLOT(onProteinSearchEdit(QString)));
......@@ -131,6 +131,7 @@ void ProteinListWindow::doFocusReceived(bool has_focus) {
void ProteinListWindow::showContextMenu(const QPoint & pos) {
QMenu contextMenu(tr("Context menu"), this);
QAction accession_action("accession", this);
accession_action.setCheckable(true);
accession_action.setChecked(_display_evalue);
......@@ -143,6 +144,16 @@ void ProteinListWindow::showContextMenu(const QPoint & pos) {
connect(&evalue_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool)));
contextMenu.addAction(&evalue_action);
QAction * 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)));
contextMenu.addAction(p_action);
}
contextMenu.exec(mapToGlobal(pos));
}
......@@ -214,14 +225,14 @@ void ProteinListWindow::doIdentificationGroupGrouped(IdentificationGroup * p_ide
}
void ProteinListWindow::setIdentificationGroup(IdentificationGroup * p_identification_group) {
qDebug() << "ProteinListWindow::setIdentificationGroup begin " ;
qDebug() << "ProteinListWindow::setIdentificationGroup begin " ;
if (p_identification_group != nullptr) {
qDebug() << "ProteinListWindow::setIdentificationGroup not null";
_p_identification_group = p_identification_group;
_protein_table_model_p->setIdentificationGroup(p_identification_group);
//_p_proxy_model->setSourceModel(_protein_table_model_p);
}
else {
qDebug() << "ProteinListWindow::setIdentificationGroup null";
......
......@@ -33,19 +33,19 @@
*/
enum class ProteinListColumn {
checked, ///< manual checked
protein_grouping_id, ///< protein grouping id
accession, ///< accession
description, ///< protein description
log_evalue, ///< log(Evalue)
evalue, ///< Evalue
spectrum, ///< spectrum count
specific_spectrum, ///< specific spectrum count
sequence, ///< unique sequence count
specific_sequence, ///< specific unique sequence
coverage, ///< protein coverage
pai, ///< PAI
empai, ///< emPAI
checked, ///< manual checked
protein_grouping_id, ///< protein grouping id
accession, ///< accession
description, ///< protein description
log_evalue, ///< log(Evalue)
evalue, ///< Evalue
spectrum, ///< spectrum count
specific_spectrum, ///< specific spectrum count
sequence, ///< unique sequence count
specific_sequence, ///< specific unique sequence
coverage, ///< protein coverage
pai, ///< PAI
empai, ///< emPAI
};
class ProteinListWindow;
......@@ -59,27 +59,27 @@ public:
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
static const QString getTitle(ProteinListColumn column);
static const QString getDescription(ProteinListColumn column);
static const QString getTitle(std::int8_t column);
static const QString getDescription(std::int8_t column);
void setIdentificationGroup(IdentificationGroup * p_identification_group);
IdentificationGroup * getIdentificationGroup();
using columnMap = std::int8_t[30];
public slots:
void onProteinDataChanged();
private :
static const QString getTitle(std::int8_t column);
static const QString getDescription(std::int8_t column);
void refresh();
private :
IdentificationGroup * _p_identification_group = nullptr;
ProteinListWindow * _p_protein_list_window;
QStringList _columns;
static columnMap _column_assignment;
};
......
......@@ -173,8 +173,11 @@ bool ProteinTableProxyModel::lessThan(const QModelIndex & left, const QModelInde
QVariant ProteinTableProxyModel::headerData(int section, Qt::Orientation orientation,
int role) const {
return sourceModel()->headerData(section, orientation,
int col = mapToSource(index(0,section)).column();
return sourceModel()->headerData(col, orientation,
role);
}
void ProteinTableProxyModel::hideNotValid(bool hide) {
......
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