From ff2bd1158956f2fa563d424bf135aea9da9eed45 Mon Sep 17 00:00:00 2001 From: Olivier Langella <olivier.langella@u-psud.fr> Date: Tue, 9 Jan 2018 17:33:04 +0100 Subject: [PATCH] replacing identifications tabs with combo box --- .../identificationdatasource.cpp | 3 ++ src/core/identificationgroup.cpp | 2 +- .../identificationgroupwidget.cpp | 31 +++++++++------- .../identificationgroupwidget.h | 6 +++- src/gui/project_view/project_view.ui | 5 ++- src/gui/project_view/projectwindow.cpp | 35 ++++++++++++++----- 6 files changed, 59 insertions(+), 23 deletions(-) diff --git a/src/core/identification_sources/identificationdatasource.cpp b/src/core/identification_sources/identificationdatasource.cpp index 792d005a6..0cf8bcc2c 100644 --- a/src/core/identification_sources/identificationdatasource.cpp +++ b/src/core/identification_sources/identificationdatasource.cpp @@ -141,6 +141,9 @@ const QVariant IdentificationDataSource::getIdentificationEngineStatistics(Ident } pappso::SpectrumSp IdentificationDataSource::getSpectrumSp(unsigned int scan_number) const { + if (_ms_run_sp.get()->getMzFormat() == MzFormat::MGF) { + scan_number = scan_number-1; + } pappso::SpectrumSp spectrum_sp = SpectrumStore::getSpectrumSpFromMsRunSp(_ms_run_sp, scan_number); return spectrum_sp; } diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index 71c2ab936..067e9a26c 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -291,7 +291,7 @@ void IdentificationGroup::startPtmGrouping () { } const QString IdentificationGroup::getTabName() const { - return _ms_run_list[0]->getFilename(); + return _ms_run_list[0]->getSampleName(); } diff --git a/src/gui/project_view/identification_group_widget/identificationgroupwidget.cpp b/src/gui/project_view/identification_group_widget/identificationgroupwidget.cpp index d10b74842..23304334f 100644 --- a/src/gui/project_view/identification_group_widget/identificationgroupwidget.cpp +++ b/src/gui/project_view/identification_group_widget/identificationgroupwidget.cpp @@ -25,22 +25,13 @@ #include "ui_identification_group_widget.h" #include <QDebug> -IdentificationGroupWidget::IdentificationGroupWidget(ProjectWindow * parent, IdentificationGroup* p_identification_group): +IdentificationGroupWidget::IdentificationGroupWidget(QWidget * parent): QWidget(parent), ui(new Ui::IdentificationGroupWidget) { - qDebug() << "IdentificationGroupWidget::IdentificationGroupWidget begin"; - _p_project_window = parent; - _p_identification_group = p_identification_group; - ui->setupUi(this); -#if QT_VERSION >= 0x050000 - // Qt5 code - connect (_p_project_window, &ProjectWindow::identificationGroupGrouped, this,&IdentificationGroupWidget::doIdentificationGroupGrouped); -#else -// Qt4 code - connect (_p_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); -#endif + ui->setupUi(this); + qDebug() << "IdentificationGroupWidget::IdentificationGroupWidget begin"; qDebug() << "IdentificationGroupWidget::IdentificationGroupWidget end"; } @@ -52,6 +43,20 @@ IdentificationGroupWidget::~IdentificationGroupWidget() qDebug() << "IdentificationGroupWidget::~IdentificationGroupWidget end"; } +void IdentificationGroupWidget::setIdentificationGroup(ProjectWindow * parent, IdentificationGroup* p_identification_group) { + _p_identification_group = p_identification_group; + + _p_project_window = parent; +#if QT_VERSION >= 0x050000 + // Qt5 code + connect (_p_project_window, &ProjectWindow::identificationGroupGrouped, this,&IdentificationGroupWidget::doIdentificationGroupGrouped); +#else +// Qt4 code + + connect (_p_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); +#endif +} + void IdentificationGroupWidget::doViewPtmIslandList() { qDebug() << "IdentificationGroupWidget::doViewPtmIslandList begin " << _p_identification_group; _p_project_window->doViewPtmIslandList(_p_identification_group); @@ -66,6 +71,7 @@ void IdentificationGroupWidget::doViewProteinList() { } void IdentificationGroupWidget::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) { + qDebug() << "IdentificationGroupWidget::doIdentificationGroupGrouped begin " << _p_identification_group << " " << p_identification_group; if (_p_identification_group == p_identification_group) { vector< MsRunSp > ms_run_list = _p_identification_group->getMsRunSpList(); ui->sample_number_display->setText(QString("%1").arg(ms_run_list.size())); @@ -76,4 +82,5 @@ void IdentificationGroupWidget::doIdentificationGroupGrouped(IdentificationGroup ui->grouped_peptide_display->setText(QString("%1").arg(_p_identification_group->countPeptideMass(ValidationState::grouped))); _p_identification_group->countPeptideMatch(ValidationState::grouped); } + qDebug() << "IdentificationGroupWidget::doIdentificationGroupGrouped end " << _p_identification_group; } diff --git a/src/gui/project_view/identification_group_widget/identificationgroupwidget.h b/src/gui/project_view/identification_group_widget/identificationgroupwidget.h index c865d10c2..79ff9a1f8 100644 --- a/src/gui/project_view/identification_group_widget/identificationgroupwidget.h +++ b/src/gui/project_view/identification_group_widget/identificationgroupwidget.h @@ -37,8 +37,11 @@ class IdentificationGroupWidget : public QWidget public: - explicit IdentificationGroupWidget(ProjectWindow * parent, IdentificationGroup* p_identification_group); + explicit IdentificationGroupWidget(QWidget * parent); ~IdentificationGroupWidget(); + +public: + void setIdentificationGroup(ProjectWindow * parent, IdentificationGroup* p_identification_group); public slots: void doViewProteinList(); @@ -52,4 +55,5 @@ private: IdentificationGroup* _p_identification_group; }; +Q_DECLARE_METATYPE(IdentificationGroupWidget *) #endif // IDENTIFICATIONGROUPWIDGET_H diff --git a/src/gui/project_view/project_view.ui b/src/gui/project_view/project_view.ui index b897b34d9..4ad652d86 100644 --- a/src/gui/project_view/project_view.ui +++ b/src/gui/project_view/project_view.ui @@ -32,7 +32,10 @@ </attribute> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> - <layout class="QGridLayout" name="identifications_layout"/> + <widget class="QComboBox" name="identifications_combobox"/> + </item> + <item row="1" column="0"> + <widget class="QWidget" name="identifications_widget" native="true"/> </item> </layout> </widget> diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 55fe94e8d..7a6d0d606 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -87,6 +87,8 @@ ProjectWindow::ProjectWindow(MainWindow *parent): p_graph->setLineStyle(QCPGraph::LineStyle::lsStepCenter); //p_graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2.0)); + QVBoxLayout * p_layout = new QVBoxLayout(); + ui->identifications_widget->setLayout(p_layout); #if QT_VERSION >= 0x050000 // Qt5 code @@ -638,25 +640,42 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) { doViewProteinList(identification_list[0]); + + //qDeleteAll(ui->identifications_widget->children()); + QLayoutItem *wItem; + while (wItem = ui->identifications_widget->layout()->takeAt(0)) + delete wItem; + qDebug() << " ProjectWindow::setProjectSp size=" << identification_list.size(); if (identification_list.size() == 1) { + ui->identifications_combobox->setVisible(false); + + IdentificationGroupWidget * p_identification_widget = new IdentificationGroupWidget(this); + p_identification_widget->setIdentificationGroup(this, identification_list[0]); - IdentificationGroupWidget * identification_widget = new IdentificationGroupWidget(this,identification_list[0]); - ui->identifications_layout->addWidget(identification_widget); + ui->identifications_widget->layout()->addWidget(p_identification_widget); - _p_identification_widget = identification_widget; refreshGroup(identification_list[0]); } else { - QTabWidget * p_tabwidget = new QTabWidget(); - _p_identification_widget = p_tabwidget; - ui->identifications_layout->addWidget(p_tabwidget); + ui->identifications_combobox->clear(); + ui->identifications_combobox->setVisible(true); + for (IdentificationGroup * identification_group : identification_list) { - IdentificationGroupWidget * identification_widget = new IdentificationGroupWidget(this,identification_group); - p_tabwidget->addTab(identification_widget, identification_group->getTabName()); + IdentificationGroupWidget * p_identification_widget = new IdentificationGroupWidget(this); + p_identification_widget->setVisible(false); + + + ui->identifications_combobox->addItem(identification_group->getTabName(), QVariant::fromValue(p_identification_widget)); + + p_identification_widget->setIdentificationGroup(this, identification_group); + + ui->identifications_widget->layout()->addWidget(p_identification_widget); refreshGroup(identification_group); } + ui->identifications_combobox->setCurrentIndex(0); + qobject_cast<IdentificationGroupWidget*>(qvariant_cast<QObject*>(ui->identifications_combobox->itemData( ui->identifications_combobox->currentIndex())))->setVisible(true); } AutomaticFilterParameters params = _project_sp.get()->getAutomaticFilterParameters(); -- GitLab