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

new peptide list context menu

parent 846e2eeb
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,9 @@
<string>Peptide list</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="accession_label">
......
......@@ -27,6 +27,42 @@
#include "ui_peptide_view.h"
PeptideListQactionColumn::PeptideListQactionColumn(PeptideListWindow * parent, PeptideListColumn column):QAction(parent) {
this->setText(PeptideTableModel::getTitle(column));
this->setCheckable(true);
this->setChecked(parent->getPeptideListColumnDisplay(column));
//evalue_action.setChecked(_display_evalue);
//connect(p_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool)));
_column = column;
_p_peptide_list_window = parent;
#if QT_VERSION >= 0x050000
// Qt5 code
connect (this, &PeptideListQactionColumn::toggled, this,&PeptideListQactionColumn::doToggled);
#else
// Qt4 code
connect (this, SIGNAL(toggled(bool)), this,SLOT(doToggled(bool)));
#endif
}
PeptideListQactionColumn::~PeptideListQactionColumn()
{
//if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
qDebug() << "PeptideListQactionColumn::~PeptideListQactionColumn begin ";
}
void PeptideListQactionColumn::doToggled(bool toggled) {
qDebug() << "PeptideListQactionColumn::doToggled begin " << toggled;
setChecked(toggled);
_p_peptide_list_window->setPeptideListColumnDisplay(_column, toggled);
qDebug() << "PeptideListQactionColumn::doToggled end";
}
PeptideListWindow::PeptideListWindow(ProjectWindow *parent):
QMainWindow(parent),
......@@ -77,6 +113,8 @@ PeptideListWindow::PeptideListWindow(ProjectWindow *parent):
connect(ui->tableView, &QTableView::clicked, _p_proxy_model, &PeptideTableProxyModel::onTableClicked);
connect(_peptide_table_model_p, &PeptideTableModel::layoutChanged, this, &PeptideListWindow::updateStatusBar);
connect(ui->centralwidget, &QWidget::customContextMenuRequested,
this, &PeptideListWindow::showContextMenu);
#else
// Qt4 code
connect (_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *)));
......@@ -229,3 +267,35 @@ void PeptideListWindow::updateStatusBar() {
void PeptideListWindow::resizeColumnsToContents() {
ui->tableView->resizeColumnsToContents();
}
void PeptideListWindow::showContextMenu(const QPoint & pos) {
if (_p_context_menu == nullptr) {
_p_context_menu = new QMenu(tr("Context menu"), this);
PeptideListQactionColumn * p_action;
for (unsigned int i=0; i < _peptide_table_model_p->columnCount(); i++) {
p_action = new PeptideListQactionColumn(this,PeptideTableModel::getPeptideListColumn(i));
_p_context_menu->addAction(p_action);
}
_p_context_menu->exec(mapToGlobal(pos));
}
_p_context_menu->show();
}
void PeptideListWindow::setPeptideListColumnDisplay(PeptideListColumn column, bool toggled) {
_p_proxy_model->setPeptideListColumnDisplay(column, toggled);
}
/*
void PeptideListWindow::resizeColumnsToContents() {
ui->tableView->resizeColumnsToContents();
}
*/
bool PeptideListWindow::getPeptideListColumnDisplay(PeptideListColumn column) const {
return _p_proxy_model->getPeptideListColumnDisplay(column);
}
......@@ -25,6 +25,7 @@
#define PEPTIDELISTWINDOW_H
#include <QMainWindow>
#include <QAction>
#include "peptidetablemodel.h"
#include "peptidetableproxymodel.h"
#include "../../core/proteinmatch.h"
......@@ -36,6 +37,23 @@ namespace Ui {
class PeptideView;
}
class PeptideListWindow;
class PeptideListQactionColumn: public QAction {
Q_OBJECT
public:
explicit PeptideListQactionColumn(PeptideListWindow * parent, PeptideListColumn column);
~PeptideListQactionColumn();
public slots:
void doToggled(bool toggled);
private:
PeptideListWindow * _p_peptide_list_window;
PeptideListColumn _column;
};
class PeptideListWindow: public QMainWindow {
Q_OBJECT
......@@ -50,12 +68,18 @@ public:
void resizeColumnsToContents();
void edited();
ProjectWindow * getProjectWindow();
bool getPeptideListColumnDisplay(PeptideListColumn column) const;
void setPeptideListColumnDisplay(PeptideListColumn column, bool toggled);
public slots:
//void peptideEdited(QString peptideStr);
// void setColor(const QColor &color);
// void setShape(Shape shape);
void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group);
protected slots:
void showContextMenu(const QPoint & pos);
signals:
void identificationGroupEdited(IdentificationGroup * p_identification_group);
void peptideDataChanged();
......@@ -82,6 +106,7 @@ private:
ProteinMatch* _p_protein_match;
ProjectWindow * _project_window;
IdentificationGroup * _p_identification_group=nullptr;
QMenu * _p_context_menu = nullptr;
};
......
......@@ -25,7 +25,6 @@
#include <pappsomspp/pappsoexception.h>
#include "ui_peptide_view.h"
#include "peptidetableproxymodel.h"
#include "peptidetablemodel.h"
#include "peptidelistwindow.h"
#include "../project_view/projectwindow.h"
......@@ -213,3 +212,12 @@ void PeptideTableProxyModel::setPeptideSearchString(QString peptide_search_strin
_peptide_search_string = peptide_search_string;
}
bool PeptideTableProxyModel::getPeptideListColumnDisplay(PeptideListColumn column) const {
return _column_display[(std::int8_t) column];
}
void PeptideTableProxyModel::setPeptideListColumnDisplay(PeptideListColumn column, bool toggled) {
qDebug() << "PeptideTableProxyModel::setPeptideListColumnDisplay begin " << toggled;
beginResetModel();
_column_display[(std::int8_t) column] = toggled;
endResetModel();
}
......@@ -27,10 +27,12 @@
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include "../../core/project.h"
#include "peptidetablemodel.h"
class PeptideListWindow;
class PeptideTableModel;
class PeptideTableProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
......@@ -49,6 +51,8 @@ public:
void hideNotGrouped(bool hide);
void setPeptideSearchString(QString peptide_search_string);
void setSearchOn(QString search_on);
void setPeptideListColumnDisplay(PeptideListColumn column, bool toggled);
bool getPeptideListColumnDisplay(PeptideListColumn column) const;
public slots:
void onTableClicked(const QModelIndex &index);
......
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