From a274860b3a26f14a12e0548472fe7d5c47f50895 Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Fri, 21 Jul 2017 07:55:42 +0200
Subject: [PATCH] no more column assignment in ptm list

---
 .../proteintableproxymodel.cpp                |  2 +-
 .../ptmislandlistwindow.cpp                   |  1 +
 .../ptmislandproxymodel.cpp                   | 24 +++++++++++++++++++
 .../ptmislandproxymodel.h                     |  5 ++++
 .../ptmislandtablemodel.cpp                   | 19 +++------------
 .../ptmislandtablemodel.h                     | 24 ++++++++-----------
 6 files changed, 44 insertions(+), 31 deletions(-)

diff --git a/src/gui/protein_list_view/proteintableproxymodel.cpp b/src/gui/protein_list_view/proteintableproxymodel.cpp
index 3f5b2bb7..d1169018 100644
--- a/src/gui/protein_list_view/proteintableproxymodel.cpp
+++ b/src/gui/protein_list_view/proteintableproxymodel.cpp
@@ -154,7 +154,7 @@ void ProteinTableProxyModel::onTableClicked(const QModelIndex &index)
         _p_protein_list_window->edited();
     }
     else {
-        if ((col == 2)||(col == 3)) {
+        if ((col == (std::int8_t) ProteinListColumn::accession)||(col == (std::int8_t) ProteinListColumn::description)) {
             _p_protein_list_window->askProteinDetailView(p_protein_match);
         }
         else {
diff --git a/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp b/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp
index e2fba683..699d5b0a 100644
--- a/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp
+++ b/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp
@@ -68,6 +68,7 @@ PtmIslandListWindow::PtmIslandListWindow(ProjectWindow *parent):
 
     connect (_project_window, SIGNAL(identificationPtmGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationPtmGroupGrouped(IdentificationGroup *)));
     connect (_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *)));
+    connect(ui->ptm_island_tableview, SIGNAL(clicked(const QModelIndex &)), _ptm_table_model_p, SLOT(onTableClicked(const QModelIndex &)));
 
 #endif
 }
diff --git a/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp b/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp
index 7f7a3c03..331995b8 100644
--- a/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp
+++ b/src/gui/ptm_island_list_view/ptmislandproxymodel.cpp
@@ -72,3 +72,27 @@ bool PtmIslandProxyModel::filterAcceptsRow(int source_row,
 
     //return true;
 }
+
+
+void PtmIslandProxyModel::onTableClicked(const QModelIndex &index)
+{
+    qDebug() << "PtmIslandProxyModel::onTableClicked begin " << index.row();
+    qDebug() << "PtmIslandProxyModel::onTableClicked begin " << this->mapToSource(index).row();
+
+    //_protein_table_model_p->onTableClicked(this->mapToSource(index));
+    QModelIndex source_index(this->mapToSource(index));
+    int row = source_index.row();
+    int col = source_index.column();
+    /*
+    ProteinMatch* p_protein_match = _p_ptm_island_table_model->getIdentificationGroup()->getProteinMatchList().at(row);
+
+        if ((col == 2)||(col == 3)) {
+            _p_ptm_island_table_model->askPtmProteinDetailView(p_protein_match);
+        }
+        else {
+            _p_ptm_island_table_model->askPtmPeptideListView(p_protein_match);
+        }
+    */
+    qDebug() << "PtmIslandProxyModel::onTableClicked end " << index.row();
+
+}
diff --git a/src/gui/ptm_island_list_view/ptmislandproxymodel.h b/src/gui/ptm_island_list_view/ptmislandproxymodel.h
index f35e988f..c55ab779 100644
--- a/src/gui/ptm_island_list_view/ptmislandproxymodel.h
+++ b/src/gui/ptm_island_list_view/ptmislandproxymodel.h
@@ -45,6 +45,11 @@ public:
     ~PtmIslandProxyModel();
     bool filterAcceptsRow(int source_row,
                           const QModelIndex &source_parent) const override;
+                          
+                          
+public slots:
+    void onTableClicked(const QModelIndex &index);
+
 private:
     PtmIslandListWindow * _p_ptm_island_list_window;
     PtmIslandTableModel * _p_ptm_island_table_model;
diff --git a/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp b/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp
index 396fcff0..893d35eb 100644
--- a/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp
+++ b/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp
@@ -32,19 +32,6 @@
 
 
 
-PtmIslandTableModel::columnMap PtmIslandTableModel::_column_assignment = {
-    (std::int8_t)PtmIslandListColumn::ptm_island_id,
-    (std::int8_t)PtmIslandListColumn::accession,
-    (std::int8_t)PtmIslandListColumn::description,
-    (std::int8_t)PtmIslandListColumn::spectrum,
-    (std::int8_t)PtmIslandListColumn::sequence,
-    (std::int8_t)PtmIslandListColumn::ptm_position_list,
-    (std::int8_t)PtmIslandListColumn::multiptm,
-    (std::int8_t)PtmIslandListColumn::ptm_island_start,
-    (std::int8_t)PtmIslandListColumn::ptm_island_length
-};
-
-
 PtmIslandTableModel::PtmIslandTableModel(PtmIslandListWindow * p_ptm_island_list_window)
 {
 
@@ -184,10 +171,10 @@ QVariant PtmIslandTableModel::headerData(int section, Qt::Orientation orientatio
     {
         switch (role) {
         case Qt::DisplayRole :
-            return QVariant(getTitle(_column_assignment [section]));
+            return QVariant(getTitle(section));
             break;
 	case Qt::ToolTipRole :
-	   return QVariant(getDescription(_column_assignment [section]));
+	   return QVariant(getDescription(section));
             break;
 
         }
@@ -204,7 +191,7 @@ QVariant PtmIslandTableModel::data(const QModelIndex &index, int role ) const {
         if (_p_identification_group == nullptr) {
             return QVariant();
         }
-        switch (_column_assignment [col]) {
+        switch (col) {
 
         case (std::int8_t) PtmIslandListColumn::spectrum:
             return QVariant(getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->getPtmIslandSubroup()->countSampleScan());
diff --git a/src/gui/ptm_island_list_view/ptmislandtablemodel.h b/src/gui/ptm_island_list_view/ptmislandtablemodel.h
index d7e40067..575b7247 100644
--- a/src/gui/ptm_island_list_view/ptmislandtablemodel.h
+++ b/src/gui/ptm_island_list_view/ptmislandtablemodel.h
@@ -40,16 +40,16 @@
  *
  */
 
-enum class PtmIslandListColumn {
-    ptm_island_id, ///< ptm_island_id
-    accession, ///< protein accession
-    description, ///< protein description
-    ptm_position_list, ///< ptm position list
-    spectrum, ///< count sample scans
-    sequence, ///< unique sequence count
-    multiptm, ///< count multi ptm peptide match
-    ptm_island_start, ///< start position of the ptm island on the protein
-    ptm_island_length, ///< length of the ptm island
+enum class PtmIslandListColumn: std::int8_t {
+    ptm_island_id=0, ///< ptm_island_id
+    accession=1, ///< protein accession
+    description=2, ///< protein description
+    ptm_position_list=3, ///< ptm position list
+    spectrum=4, ///< count sample scans
+    sequence=5, ///< unique sequence count
+    multiptm=6, ///< count multi ptm peptide match
+    ptm_island_start=7, ///< start position of the ptm island on the protein
+    ptm_island_length=8, ///< length of the ptm island
 
 };
 
@@ -74,8 +74,6 @@ public:
 
     const PtmGroupingExperiment * getPtmGroupingExperiment() const;
 
-    using columnMap = std::int8_t[20];
-
 public slots:
     void onPtmIslandDataChanged();
 private :
@@ -83,8 +81,6 @@ private :
     static const QString getDescription(std::int8_t column);
 private :
     IdentificationGroup * _p_identification_group=nullptr;
-
-    static columnMap _column_assignment;
 };
 
 #endif // PTMISLANDTABLEMODEL_H
-- 
GitLab