From 99c148fd1302cee451bc86128e6d45a21bb57ac2 Mon Sep 17 00:00:00 2001
From: Thomas Renne <thomas.renne@u-psud.fr>
Date: Wed, 28 Oct 2020 14:16:35 +0100
Subject: [PATCH] Use same object for Protein checked in PTM and Protein
 windows

---
 .../ptmislandlistwindow.cpp                   |  4 ++
 .../ptmislandlistwindow.h                     |  3 +-
 .../ptmislandproxymodel.cpp                   |  6 +-
 .../ptmislandtablemodel.cpp                   |  4 +-
 src/output/masschroqml.cpp                    | 72 ++++++++++---------
 5 files changed, 46 insertions(+), 43 deletions(-)

diff --git a/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp b/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp
index 2514d5cf..63f1c128 100644
--- a/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp
+++ b/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp
@@ -198,6 +198,10 @@ PtmIslandListWindow::setColumnMenuList()
     }
 }
 
+void PtmIslandListWindow::edited()
+{
+   _project_window->doIdentificationGroupEdited(_p_identification_group);
+}
 
 void
 PtmIslandListWindow::doNotCheckedHide(bool hide)
diff --git a/src/gui/ptm_island_list_view/ptmislandlistwindow.h b/src/gui/ptm_island_list_view/ptmislandlistwindow.h
index a4cfea46..6130ba50 100644
--- a/src/gui/ptm_island_list_view/ptmislandlistwindow.h
+++ b/src/gui/ptm_island_list_view/ptmislandlistwindow.h
@@ -79,7 +79,8 @@ class PtmIslandListWindow : public QMainWindow
   void setPtmIslandListColumnDisplay(PtmIslandListColumn column, bool toggled);
   bool getPtmIslandListColumnDisplay(PtmIslandListColumn column) const;
   void setColumnMenuList();
-
+  void edited();
+  
   public slots:
   void
   doIdentificationPtmGroupGrouped(IdentificationGroup *p_identification_group);
diff --git a/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp b/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp
index bd90592f..a67a3d0c 100644
--- a/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp
+++ b/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp
@@ -83,10 +83,7 @@ PtmIslandProxyModel::filterAcceptsRow(int source_row,
         _p_ptm_island_table_model->getPtmGroupingExperiment()
           ->getPtmIslandList()
           .at(source_row);
-      ProteinMatch *protein_match =
-        _p_ptm_island_table_model->getIdentificationGroup()
-          ->getProteinMatchList()
-          .at(source_row);
+      ProteinMatch *protein_match = sp_ptm_island->getProteinMatch();
       // qDebug() << "Prote
       // qDebug() << "ProteinTableProxyModel::filterAcceptsRow protein_match "
       // << source_row;
@@ -222,6 +219,7 @@ PtmIslandProxyModel::onTableClicked(const QModelIndex &index)
         {
           p_protein_match->setChecked(true);
         }
+      _p_ptm_island_list_window->edited();
     }
   else if((col == (std::int8_t)PtmIslandListColumn::accession) ||
           (col == (std::int8_t)PtmIslandListColumn::description))
diff --git a/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp b/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp
index ef47c324..1af9875f 100644
--- a/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp
+++ b/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp
@@ -234,9 +234,7 @@ PtmIslandTableModel::data(const QModelIndex &index, int role) const
         if(col == (std::int8_t)
                     PtmIslandListColumn::checked) // add a checkbox to cell(1,0)
           {
-            if(_p_identification_group->getProteinMatchList()
-                 .at(row)
-                 ->isChecked())
+            if(getPtmGroupingExperiment()->getPtmIslandList().at(row)->getProteinMatch()->isChecked())
               {
                 return Qt::Checked;
               }
diff --git a/src/output/masschroqml.cpp b/src/output/masschroqml.cpp
index 3b6fcb9d..10dd89fe 100644
--- a/src/output/masschroqml.cpp
+++ b/src/output/masschroqml.cpp
@@ -263,47 +263,49 @@ MassChroQml::writeQuantificationTraces()
 void
 MassChroQml::writeQuantify()
 {
-    for(MsRunAlignmentGroupSp group_sp : m_params.alignment_groups)
+  for(MsRunAlignmentGroupSp group_sp : m_params.alignment_groups)
     {
-  //<quantify id="q1" withingroup="G1" quantification_method_id="my_qzivy">
-  _output_stream->writeStartElement("quantify");
-  _output_stream->writeAttribute("id", "q1");
-  
-  _output_stream->writeAttribute("withingroup", group_sp->getMsRunAlignmentGroupName());
-  _output_stream->writeAttribute("quantification_method_id", "quant1");
-  //<peptides_in_peptide_list mode="real_or_mean" />
-  //</quantify>
-  //<quantify id="q2" withingroup="G2" quantification_method_id="my_moulon">
-  //<peptides_in_peptide_list mode="post_matching"
-  //	isotope_label_refs="iso1 iso2" />
-
-  _output_stream->writeStartElement("peptides_in_peptide_list");
-  _output_stream->writeAttribute("mode", "post_matching");
-  _output_stream->writeAttribute("ni_min_abundance", "0.8");
+      //<quantify id="q1" withingroup="G1" quantification_method_id="my_qzivy">
+      _output_stream->writeStartElement("quantify");
+      _output_stream->writeAttribute("id", "q1");
 
-  LabelingMethod *p_labeling_method =
-    _sp_project.get()->getLabelingMethodSp().get();
-  if(p_labeling_method != nullptr)
-    {
-      QStringList isotope_label_ref;
-      for(const Label *p_label : p_labeling_method->getLabelList())
+      _output_stream->writeAttribute("withingroup",
+                                     group_sp->getMsRunAlignmentGroupName());
+      _output_stream->writeAttribute("quantification_method_id", "quant1");
+      //<peptides_in_peptide_list mode="real_or_mean" />
+      //</quantify>
+      //<quantify id="q2" withingroup="G2" quantification_method_id="my_moulon">
+      //<peptides_in_peptide_list mode="post_matching"
+      //	isotope_label_refs="iso1 iso2" />
+
+      _output_stream->writeStartElement("peptides_in_peptide_list");
+      _output_stream->writeAttribute("mode", "post_matching");
+      _output_stream->writeAttribute("ni_min_abundance", "0.8");
+
+      LabelingMethod *p_labeling_method =
+        _sp_project.get()->getLabelingMethodSp().get();
+      if(p_labeling_method != nullptr)
         {
-          isotope_label_ref << p_label->getXmlId();
+          QStringList isotope_label_ref;
+          for(const Label *p_label : p_labeling_method->getLabelList())
+            {
+              isotope_label_ref << p_label->getXmlId();
+            }
+          _output_stream->writeAttribute("isotope_label_refs",
+                                         isotope_label_ref.join(" "));
         }
-      _output_stream->writeAttribute("isotope_label_refs",
-                                     isotope_label_ref.join(" "));
-    }
-  _output_stream->writeEndElement();
+      _output_stream->writeEndElement();
 
-  _output_stream->writeComment(
-    "<mz_list>732.317 449.754 552.234 464.251 "
-    "381.577 569.771 575.256</mz_list>");
-  _output_stream->writeComment(
-    "<mzrt_list>\n				<mzrt mz=\"732.317\" rt=\"230.712\" />\n			<mzrt "
-    "mz=\"575.256\" rt=\"254.788\" />\n			</mzrt_list>");
+      _output_stream->writeComment(
+        "<mz_list>732.317 449.754 552.234 464.251 "
+        "381.577 569.771 575.256</mz_list>");
+      _output_stream->writeComment(
+        "<mzrt_list>\n				<mzrt mz=\"732.317\" rt=\"230.712\" />\n			"
+        "<mzrt "
+        "mz=\"575.256\" rt=\"254.788\" />\n			</mzrt_list>");
 
-  //</quantify>
-  _output_stream->writeEndElement();
+      //</quantify>
+      _output_stream->writeEndElement();
     }
 }
 
-- 
GitLab