From 9884b625b8ead2a7911a48e28e134a769149c845 Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Mon, 3 Apr 2017 22:58:01 +0200
Subject: [PATCH] multi identification display

---
 .../identificationdatasource.cpp              |  4 +++
 .../identificationdatasource.h                |  1 +
 src/core/identificationgroup.cpp              |  4 +++
 src/core/identificationgroup.h                |  4 +++
 src/gui/project_view/projectwindow.cpp        | 27 ++++++++++++++-----
 src/gui/project_view/projectwindow.h          |  1 +
 src/input/xpipsaxhandler.cpp                  |  1 +
 7 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/src/core/identification_sources/identificationdatasource.cpp b/src/core/identification_sources/identificationdatasource.cpp
index 05b592838..dfaa29727 100644
--- a/src/core/identification_sources/identificationdatasource.cpp
+++ b/src/core/identification_sources/identificationdatasource.cpp
@@ -55,6 +55,10 @@ bool IdentificationDataSource::operator==(const IdentificationDataSource& other)
 
 }
 
+void IdentificationDataSource::clear() {
+    _map_identification_data_sources.clear();
+}
+
 IdentificationDataSource * IdentificationDataSource::getInstance(const QString & location) {
 
     std::map< QString, IdentificationDataSource* >::iterator it = IdentificationDataSource::_map_identification_data_sources.find(location);
diff --git a/src/core/identification_sources/identificationdatasource.h b/src/core/identification_sources/identificationdatasource.h
index 7dc5821e0..4205c18d3 100644
--- a/src/core/identification_sources/identificationdatasource.h
+++ b/src/core/identification_sources/identificationdatasource.h
@@ -34,6 +34,7 @@ class IdentificationDataSource
 public:
 
     using MapIdentificationDataSources = std::map<QString, IdentificationDataSource *>;
+    static void clear();
     static IdentificationDataSource * getInstance(const QString & location);
 
     IdentificationDataSource(const QString resource_name);
diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp
index 790e6ddb1..406c49d31 100644
--- a/src/core/identificationgroup.cpp
+++ b/src/core/identificationgroup.cpp
@@ -119,3 +119,7 @@ void IdentificationGroup::startGrouping (const GroupingType & grouping_type) {
 
     qDebug() << "IdentificationGroup::startGrouping end ";
 }
+
+const QString IdentificationGroup::getTabName() const {
+    return _ms_run_list[0]->getFilename();
+}
diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h
index ccce83c52..cc8f03a5f 100644
--- a/src/core/identificationgroup.h
+++ b/src/core/identificationgroup.h
@@ -75,6 +75,10 @@ public:
     void startGrouping (const GroupingType & grouping_type);
     
     const std::vector<pappso::MsRunIdSp> & getMsRunIdSpList() const; 
+    
+    /** @brief get tab name for qtabwidget
+     * */   
+    const QString getTabName() const;
 private :
     GroupingExperiment * _p_grp_experiment= nullptr;
 
diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp
index 944804971..55b2b56a2 100644
--- a/src/gui/project_view/projectwindow.cpp
+++ b/src/gui/project_view/projectwindow.cpp
@@ -175,7 +175,7 @@ void ProjectWindow::doViewPeptideList(IdentificationGroup * p_ident_group, Prote
 }
 
 void ProjectWindow::doViewPeptideDetail(PeptideMatch * peptide_match) {
-    
+
     qDebug() << "ProjectWindow::doViewPeptideDetail begin";
     if (_peptide_detail_window_collection.size() == 0) {
         connectNewPeptideDetailWindow();
@@ -188,7 +188,7 @@ void ProjectWindow::doViewPeptideDetail(PeptideMatch * peptide_match) {
 
     _p_current_peptide_detail_window->setPeptideMatch(peptide_match);
     _p_current_peptide_detail_window->show();
-    
+
     emit peptideMatchSelected(peptide_match);
     qDebug() << "ProjectWindow::doViewPeptideDetail end";
 }
@@ -214,7 +214,6 @@ void ProjectWindow::doViewProteinDetail(ProteinMatch * protein_match) {
 void ProjectWindow::doViewProteinList(IdentificationGroup* p_identification_group) {
     qDebug() << "ProjectWindow::doViewProteinList begin " << p_identification_group;
     //if (p_identification_group == nullptr) {
-    p_identification_group = _project_sp.get()->getCurrentIdentificationGroupP();
     //}
     if (_protein_list_window_collection.size() == 0) {
         connectNewProteinListWindow();
@@ -261,17 +260,33 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) {
     _p_current_peptide_detail_window = nullptr;
 
     _project_sp = project_sp;
-    
+
+    if (_p_identification_widget != nullptr) {
+        delete _p_identification_widget;
+    }
+
     std::vector<IdentificationGroup *> identification_list = _project_sp.get()->getIdentificationGroupList();
     qDebug() << " ProjectWindow::setProjectSp size=" << identification_list.size();
     if (identification_list.size() == 1) {
-        
+
         IdentificationGroupWidget * identification_widget = new IdentificationGroupWidget(this,identification_list[0]);
         ui->identifications_layout->addWidget(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);
+        for (IdentificationGroup * identification_group : identification_list) {
+            IdentificationGroupWidget * identification_widget = new IdentificationGroupWidget(this,identification_group);
+            p_tabwidget->addTab(identification_widget, identification_group->getTabName());
+
+            refreshGroup(identification_group);
+        }
     }
-    refreshGroup(_project_sp.get()->getCurrentIdentificationGroupP());
+
     //_protein_list_window->setIdentificationGroup(_project_sp.get()->getCurrentIdentificationGroupP());
     //_protein_list_window->show();
     this->setEnabled(true);
diff --git a/src/gui/project_view/projectwindow.h b/src/gui/project_view/projectwindow.h
index 1926e13d7..343f5c54f 100644
--- a/src/gui/project_view/projectwindow.h
+++ b/src/gui/project_view/projectwindow.h
@@ -75,6 +75,7 @@ private :
     
 private:
     Ui::ProjectView *ui;
+    QWidget * _p_identification_widget = nullptr; 
     MainWindow * main_window;
     std::list <ProteinListWindow *> _protein_list_window_collection;
     ProteinListWindow * _p_current_protein_list_window = nullptr;
diff --git a/src/input/xpipsaxhandler.cpp b/src/input/xpipsaxhandler.cpp
index ae2c6cdd8..432ccdc95 100644
--- a/src/input/xpipsaxhandler.cpp
+++ b/src/input/xpipsaxhandler.cpp
@@ -340,6 +340,7 @@ bool XpipSaxHandler::endDocument() {
 }
 
 bool XpipSaxHandler::startDocument() {
+    IdentificationDataSource::clear();
     return true;
 }
 
-- 
GitLab