From 5391af4fd264b3271dd655f8ae64f37cb64b204b Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Fri, 25 Jan 2019 15:15:47 +0100
Subject: [PATCH] connecting new masschroq dialog box and main window

---
 src/CMakeLists.txt                            |  1 +
 .../export_masschroq_dialog.ui                | 48 ++++++++++--
 .../exportmasschroqdialog.cpp                 |  4 +-
 src/gui/mainwindow.cpp                        | 75 ++++++++++++++-----
 src/gui/mainwindow.h                          |  9 ++-
 5 files changed, 107 insertions(+), 30 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d620a5003..681bbd3e0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -173,6 +173,7 @@ SET(XTPCPP_SRCS
   ./gui/edit_label_methods/editlabelmethods.cpp
   ./gui/edit_modifications/editmodifications.cpp
   ./gui/edit_tandem_preset_dialog/edittandempresetdialog.cpp
+  ./gui/export/export_masschroq_dialog/exportmasschroqdialog.cpp
   ./gui/export/export_spreadsheet_dialog/exportspreadsheetdialog.cpp
   ./gui/load_results_dialog/loadresultsdialog.cpp
   ./gui/mainwindow.cpp
diff --git a/src/gui/export/export_masschroq_dialog/export_masschroq_dialog.ui b/src/gui/export/export_masschroq_dialog/export_masschroq_dialog.ui
index bb1823237..f4919e5fd 100644
--- a/src/gui/export/export_masschroq_dialog/export_masschroq_dialog.ui
+++ b/src/gui/export/export_masschroq_dialog/export_masschroq_dialog.ui
@@ -23,14 +23,14 @@
       <item>
        <widget class="QLabel" name="label">
         <property name="text">
-         <string>Peptide quantification result file</string>
+         <string>Peptide quantification result file name</string>
         </property>
        </widget>
       </item>
       <item>
        <layout class="QHBoxLayout" name="horizontalLayout_2">
         <property name="spacing">
-         <number>0</number>
+         <number>6</number>
         </property>
         <item>
          <widget class="QLineEdit" name="outputFileEdit"/>
@@ -51,6 +51,42 @@
         </item>
        </layout>
       </item>
+      <item>
+       <widget class="QGroupBox" name="comparFileGroupBox">
+        <property name="title">
+         <string>Compa&amp;r file name</string>
+        </property>
+        <property name="checkable">
+         <bool>true</bool>
+        </property>
+        <layout class="QVBoxLayout" name="verticalLayout">
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout_3">
+           <property name="spacing">
+            <number>6</number>
+           </property>
+           <item>
+            <widget class="QLineEdit" name="comparFileEdit"/>
+           </item>
+           <item>
+            <widget class="QComboBox" name="comparFileFormatComboBox">
+             <item>
+              <property name="text">
+               <string>ODS</string>
+              </property>
+             </item>
+             <item>
+              <property name="text">
+               <string>TSV</string>
+              </property>
+             </item>
+            </widget>
+           </item>
+          </layout>
+         </item>
+        </layout>
+       </widget>
+      </item>
       <item>
        <spacer name="verticalSpacer">
         <property name="orientation">
@@ -83,14 +119,14 @@
       </spacer>
      </item>
      <item>
-      <widget class="QPushButton" name="pushButton_2">
+      <widget class="QPushButton" name="cancelButton">
        <property name="text">
         <string>Cancel</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QPushButton" name="pushButton">
+      <widget class="QPushButton" name="okButton">
        <property name="text">
         <string>OK</string>
        </property>
@@ -103,7 +139,7 @@
  <resources/>
  <connections>
   <connection>
-   <sender>pushButton</sender>
+   <sender>okButton</sender>
    <signal>clicked()</signal>
    <receiver>ExportMasschroqDialog</receiver>
    <slot>accept()</slot>
@@ -119,7 +155,7 @@
    </hints>
   </connection>
   <connection>
-   <sender>pushButton_2</sender>
+   <sender>cancelButton</sender>
    <signal>clicked()</signal>
    <receiver>ExportMasschroqDialog</receiver>
    <slot>reject()</slot>
diff --git a/src/gui/export/export_masschroq_dialog/exportmasschroqdialog.cpp b/src/gui/export/export_masschroq_dialog/exportmasschroqdialog.cpp
index 2e4b9a35b..1d9d24108 100644
--- a/src/gui/export/export_masschroq_dialog/exportmasschroqdialog.cpp
+++ b/src/gui/export/export_masschroq_dialog/exportmasschroqdialog.cpp
@@ -30,8 +30,8 @@
 
 #include "exportmasschroqdialog.h"
 
-#include "ui_export_spreadsheet_dialog.h"
-#include "exportspreadsheetdialog.h"
+#include "ui_export_masschroq_dialog.h"
+#include "exportmasschroqdialog.h"
 #include <QDebug>
 #include <QSettings>
 
diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp
index 6faee7ac8..8e38874ea 100644
--- a/src/gui/mainwindow.cpp
+++ b/src/gui/mainwindow.cpp
@@ -246,16 +246,16 @@ MainWindow::doAcceptedExportSpreadsheetDialog()
 void
 MainWindow::doAcceptedTandemRunDialog()
 {
-  qDebug() << "MainWindow::doAcceptedTandemRunDialog begin";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
   showWaitingMessage(tr("Running X!Tandem"));
   emit operateRunningXtandem(_p_tandem_run_dialog->getTandemRunBatch());
-  qDebug() << "MainWindow::doAcceptedTandemRunDialog end";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
 
 void
 MainWindow::doAcceptedLoadResultDialog()
 {
-  qDebug() << "MainWindow::doAcceptedLoadResultDialog begin";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
   AutomaticFilterParameters param =
     _p_load_results_dialog->getAutomaticFilterParameters();
   QSettings settings;
@@ -274,7 +274,7 @@ MainWindow::doAcceptedLoadResultDialog()
 
   showWaitingMessage(tr("Loading files"));
   emit operateLoadingResults(is_individual, param, file_list);
-  qDebug() << "MainWindow::doAcceptedLoadResultDialog end";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
 
 void
@@ -297,25 +297,22 @@ MainWindow::doGroupingFinished()
 void
 MainWindow::doLoadingResultsReady(ProjectSp project_sp)
 {
-  qDebug() << "MainWindow::doLoadingResultsReady begin";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
   if(_p_load_results_dialog != nullptr)
     {
       _p_load_results_dialog->setProjectContaminants(project_sp.get());
     }
   doProjectReady(project_sp);
-  qDebug() << "MainWindow::doLoadingResultsReady end";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
 
 void
 MainWindow::doProjectReady(ProjectSp project_sp)
 {
-
-  qDebug() << "MainWindow::doProjectReady begin";
-  qDebug() << "MainWindow::doProjectReady begin a "
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
            << project_sp.get()->getFastaFileStore().getFastaFileList().size();
   _project_sp = project_sp;
-
-  qDebug() << "MainWindow::doProjectReady begin b "
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
            << _project_sp.get()->getFastaFileStore().getFastaFileList().size();
 
   showWaitingMessage(tr("grouping proteins"));
@@ -328,8 +325,7 @@ MainWindow::doProjectReady(ProjectSp project_sp)
   _project_window->show();
   ui->default_display_widget->hide();
   ui->action_save_project->setDisabled(false);
-
-  qDebug() << "MainWindow::doProjectReady end";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
 
 void
@@ -451,7 +447,7 @@ MainWindow::doActionSaveProject()
 void
 MainWindow::doActionSpreadsheet()
 {
-  qDebug() << "MainWindow::doActionSpreadsheet begin";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
   try
     {
       if(_project_sp.get() != nullptr)
@@ -466,13 +462,13 @@ MainWindow::doActionSpreadsheet()
     {
       viewError(tr("Error doActionSpreadsheet :\n%1").arg(error.qwhat()));
     }
-  qDebug() << "MainWindow::doActionSpreadsheet end";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
 
 void
 MainWindow::doActionSpectralCountingMcq()
 {
-  qDebug() << "MainWindow::doActionSpectralCountingMcq begin";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 
   QSettings settings;
   QString default_location = settings.value("path/scmcqfile", "").toString();
@@ -493,8 +489,7 @@ MainWindow::doActionSpectralCountingMcq()
   showWaitingMessage(tr("Writing %1 spectral count file for MassChroqR")
                        .arg(QFileInfo(filename).fileName()));
   emit operateWritingMcqrSpectralCountFile(filename, _project_sp);
-
-  qDebug() << "MainWindow::doActionSpectralCountingMcq end";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
 
 void
@@ -576,10 +571,52 @@ void
 MainWindow::doActionMassChroQ()
 {
   qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
+
+  try
+    {
+      if(_p_export_masschroq_dialog == nullptr)
+        {
+          _p_export_masschroq_dialog = new ExportMasschroqDialog(this);
+          connect(_p_export_masschroq_dialog,
+                  &ExportMasschroqDialog::accepted,
+                  this,
+                  &MainWindow::doAcceptedExportMasschroqDialog);
+        }
+
+      if(_project_sp.get() != nullptr)
+        {
+          //_p_export_masschroq_dialog->setProject(_project_sp.get());
+        }
+      _p_export_masschroq_dialog->show();
+      _p_export_masschroq_dialog->raise();
+      _p_export_masschroq_dialog->activateWindow();
+    }
+  catch(pappso::PappsoException &error)
+    {
+      viewError(tr("Error doActionMassChroQ :\n%1").arg(error.qwhat()));
+    }
   try
     {
       _project_sp.get()->checkPsimodCompliance();
 
+      // emit operateXpipFile(filename);
+    }
+  catch(pappso::PappsoException &error)
+    {
+      viewError(
+        tr("Error while writing MassChroqML file :\n%1").arg(error.qwhat()));
+    }
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
+}
+
+
+void
+MainWindow::doAcceptedExportMasschroqDialog()
+{
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
+  try
+    {
+
       QSettings settings;
       QString default_location = settings.value("path/mcqfile", "").toString();
 
@@ -599,13 +636,13 @@ MainWindow::doActionMassChroQ()
       showWaitingMessage(
         tr("Writing %1 MassChroqML file").arg(QFileInfo(filename).fileName()));
       emit operateWritingMassChroqFile(filename, _project_sp);
-      // emit operateXpipFile(filename);
     }
   catch(pappso::PappsoException &error)
     {
       viewError(
         tr("Error while writing MassChroqML file :\n%1").arg(error.qwhat()));
     }
+
   qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
 
diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h
index 988ad3df3..f3cc9cf84 100644
--- a/src/gui/mainwindow.h
+++ b/src/gui/mainwindow.h
@@ -41,6 +41,7 @@
 #include "tandem_run_dialog/tandemrundialog.h"
 #include "core/tandem_run/tandemrunbatch.h"
 #include "utils/httpversion.h"
+#include "gui/export/export_masschroq_dialog/exportmasschroqdialog.h"
 
 
 namespace Ui
@@ -89,6 +90,7 @@ class MainWindow : public QMainWindow
   void doAcceptedLoadResultDialog();
   void doAcceptedTandemRunDialog();
   void doAcceptedExportSpreadsheetDialog();
+  void doAcceptedExportMasschroqDialog();
   void doOperationFailed(QString);
   void doOperationFinished();
   void doGroupingFinished();
@@ -133,9 +135,10 @@ class MainWindow : public QMainWindow
   QThread _worker_thread;
   ProjectSp _project_sp = nullptr;
 
-  ProjectWindow *_project_window            = nullptr;
-  LoadResultsDialog *_p_load_results_dialog = nullptr;
-  ExportSpreadsheetDialog *_p_export_spreadsheet_dialog;
+  ProjectWindow *_project_window                        = nullptr;
+  LoadResultsDialog *_p_load_results_dialog             = nullptr;
+  ExportSpreadsheetDialog *_p_export_spreadsheet_dialog = nullptr;
+  ExportMasschroqDialog *_p_export_masschroq_dialog     = nullptr;
   WaitingMessageDialog *_p_waiting_message_dialog;
   AboutDialog *_p_about_dialog          = nullptr;
   TandemRunDialog *_p_tandem_run_dialog = nullptr;
-- 
GitLab