From 79202a275025b55f9f6e83db5bbc93036f869700 Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Sat, 1 Apr 2017 23:42:37 +0200
Subject: [PATCH] spectrum view is OK

---
 .../identificationdatasource.cpp                   | 14 +++++++++-----
 .../identificationdatasource.h                     |  1 +
 src/gui/peptide_detail_view/peptidewindow.cpp      |  3 ++-
 src/gui/peptide_list_view/peptidetablemodel.cpp    |  2 +-
 src/gui/project_view/project_view.ui               |  4 ++--
 5 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/core/identification_sources/identificationdatasource.cpp b/src/core/identification_sources/identificationdatasource.cpp
index 02b348175..05b592838 100644
--- a/src/core/identification_sources/identificationdatasource.cpp
+++ b/src/core/identification_sources/identificationdatasource.cpp
@@ -29,7 +29,7 @@
 
 IdentificationDataSource::MapIdentificationDataSources IdentificationDataSource::_map_identification_data_sources = []
 {
-     MapIdentificationDataSources ret;
+    MapIdentificationDataSources ret;
 
     return ret;
 }();
@@ -67,10 +67,10 @@ IdentificationDataSource * IdentificationDataSource::getInstance(const QString &
         //QString sample_name = location_file.baseName();
         if (ext.toLower() == "xml") {
             //X!Tandem result file
-	    IdentificationXtandemFile * p_xtfile = new IdentificationXtandemFile(location_file);
-	    _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSource* >(location, p_xtfile));
-	    _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSource* >(location_file.absoluteFilePath(), p_xtfile));
-	    return p_xtfile;
+            IdentificationXtandemFile * p_xtfile = new IdentificationXtandemFile(location_file);
+            _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSource* >(location, p_xtfile));
+            _map_identification_data_sources.insert(std::pair< QString, IdentificationDataSource* >(location_file.absoluteFilePath(), p_xtfile));
+            return p_xtfile;
         }
     }
     throw pappso::PappsoException(QObject::tr("Identification resource %1 not recognized").arg(location));
@@ -80,6 +80,10 @@ const QString & IdentificationDataSource::getResourceName () const {
     return _resource_name;
 }
 
+const QString IdentificationDataSource::getSampleName () const {
+    QFileInfo file(_ms_run_sp.get()->getFilename());
+    return file.baseName();
+}
 
 void IdentificationDataSource::setMsRunSp (pappso::MsRunIdSp ms_run_sp) {
     _ms_run_sp = ms_run_sp;
diff --git a/src/core/identification_sources/identificationdatasource.h b/src/core/identification_sources/identificationdatasource.h
index ebac8d5c8..7dc5821e0 100644
--- a/src/core/identification_sources/identificationdatasource.h
+++ b/src/core/identification_sources/identificationdatasource.h
@@ -42,6 +42,7 @@ public:
     bool operator==(const IdentificationDataSource& other) const;
 
     const QString & getResourceName () const;
+    const QString getSampleName () const;
     void setMsRunSp (pappso::MsRunIdSp ms_run_sp);
     pappso::MsRunIdSp getMsRunSp () const;
     /** @brief get the spectrum with scan number
diff --git a/src/gui/peptide_detail_view/peptidewindow.cpp b/src/gui/peptide_detail_view/peptidewindow.cpp
index 638bcdc3d..6b2f2db7a 100644
--- a/src/gui/peptide_detail_view/peptidewindow.cpp
+++ b/src/gui/peptide_detail_view/peptidewindow.cpp
@@ -99,11 +99,12 @@ void PeptideWindow::setPeptideMatch(PeptideMatch * p_peptide_match) {
     
     SpectrumSp spectrum = _p_peptide_match->getIdentificationDataSource()->getSpectrumSp(_p_peptide_match->getScan());  
     pappso::QualifiedSpectrum spectrum_copy;
+    spectrum_copy.setPrecursorCharge(_p_peptide_match->getCharge());
     spectrum_copy.setOriginalSpectrumSp(spectrum);
-    ui->spectrumWidget->setQualifiedSpectrum(spectrum_copy);
 
     pappso::PeptideSp peptide = p_peptide_match->getPeptideXtpSp();
     ui->spectrumWidget->setPrecision(_p_precision);
     ui->spectrumWidget->setPeptideSp(peptide);
+    ui->spectrumWidget->setQualifiedSpectrum(spectrum_copy);
     updateDisplay();
 }
diff --git a/src/gui/peptide_list_view/peptidetablemodel.cpp b/src/gui/peptide_list_view/peptidetablemodel.cpp
index 27d9e3d4a..1bd3e7760 100644
--- a/src/gui/peptide_list_view/peptidetablemodel.cpp
+++ b/src/gui/peptide_list_view/peptidetablemodel.cpp
@@ -145,7 +145,7 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
                 return QVariant();
             }
             if (col == 2) {
-                return _p_protein_match->getPeptideMatchList().at(row)->getIdentificationDataSource()->getResourceName();
+                return _p_protein_match->getPeptideMatchList().at(row)->getIdentificationDataSource()->getSampleName();
             }
             if (col == 3) {
                 return QVariant ((quint32) _p_protein_match->getPeptideMatchList().at(row)->getScan());
diff --git a/src/gui/project_view/project_view.ui b/src/gui/project_view/project_view.ui
index 464002757..e9e2a5661 100644
--- a/src/gui/project_view/project_view.ui
+++ b/src/gui/project_view/project_view.ui
@@ -29,7 +29,7 @@
        </attribute>
        <layout class="QGridLayout" name="gridLayout">
         <item row="0" column="0">
-         <layout class="QFormLayout" name="formLayout_2">
+         <layout class="QFormLayout" name="formLayout_1">
           <item row="0" column="0">
            <widget class="QPushButton" name="viewProteinListButton">
             <property name="toolTip">
@@ -128,7 +128,7 @@
        <attribute name="title">
         <string>FDR</string>
        </attribute>
-       <layout class="QGridLayout" name="gridLayout">
+       <layout class="QGridLayout" name="gridLayout2">
         <item row="0" column="0">
          <layout class="QFormLayout" name="formLayout_2"/>
         </item>
-- 
GitLab