From 47fc22e7d21fab3e892fbc67b37e353221b66f04 Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Thu, 20 Apr 2017 15:16:53 +0200
Subject: [PATCH] new window to edite modifications

---
 src/CMakeLists.txt                            |  4 +-
 .../edit_modifications/edit_modifications.ui  | 57 ++++++++++++++++
 .../edit_modifications/editmodifications.cpp  | 36 ++++++++++
 .../edit_modifications/editmodifications.h    | 47 ++++++++++++++
 .../load_results_dialog.ui                    | 65 +++++++++++++++----
 .../load_results_dialog/loadresultsdialog.cpp |  4 +-
 .../load_results_dialog/loadresultsdialog.h   |  1 +
 src/gui/mainwindow.cpp                        |  7 +-
 8 files changed, 205 insertions(+), 16 deletions(-)
 create mode 100644 src/gui/edit_modifications/edit_modifications.ui
 create mode 100644 src/gui/edit_modifications/editmodifications.cpp
 create mode 100644 src/gui/edit_modifications/editmodifications.h

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ed180bf2..6b845843 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -86,6 +86,7 @@ set(QTLIBS ${Qt5Xml_LIBRARIES} ${Qt5Gui_LIBRARIES}  ${Qt5Svg_LIBRARIES})
 # (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)
 
 SET(XTPCPP_SRCS
+  ./gui/edit_modifications/editmodifications.cpp
   ./gui/export_spreadsheet_dialog/exportspreadsheetdialog.cpp
   ./gui/load_results_dialog/loadresultsdialog.cpp
   ./gui/mainwindow.cpp
@@ -105,6 +106,7 @@ SET(XTPCPP_SRCS
 )
 
 SET (GUI_UIS
+  ./gui/edit_modifications/edit_modifications.ui
   ./gui/export_spreadsheet_dialog/export_spreadsheet_dialog.ui
   ./gui/load_results_dialog/load_results_dialog.ui
   ./gui/main.ui
@@ -118,7 +120,7 @@ SET (GUI_UIS
 )
 
 SET(XTPCPP_MOC_HDRS
-
+  ./gui/edit_modifications/editmodifications.h
   ./gui/export_spreadsheet_dialog/exportspreadsheetdialog.h
   ./gui/load_results_dialog/loadresultsdialog.h
   ./gui/mainwindow.h
diff --git a/src/gui/edit_modifications/edit_modifications.ui b/src/gui/edit_modifications/edit_modifications.ui
new file mode 100644
index 00000000..61b2f51a
--- /dev/null
+++ b/src/gui/edit_modifications/edit_modifications.ui
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EditModificationView</class>
+ <widget class="QMainWindow" name="EditModificationView">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>826</width>
+    <height>404</height>
+   </rect>
+  </property>
+  <property name="contextMenuPolicy">
+   <enum>Qt::CustomContextMenu</enum>
+  </property>
+  <property name="windowTitle">
+   <string>Protein list</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <property name="contextMenuPolicy">
+    <enum>Qt::CustomContextMenu</enum>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <item>
+     <widget class="QGroupBox" name="groupBox">
+      <property name="title">
+       <string>Modification list</string>
+      </property>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <widget class="QListView" name="modification_list_view"/>
+       </item>
+      </layout>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>826</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+ <slots>
+  <slot>doNotValidHide(bool)</slot>
+  <slot>doNotCheckedHide(bool)</slot>
+  <slot>doNotGroupedHide(bool)</slot>
+ </slots>
+</ui>
diff --git a/src/gui/edit_modifications/editmodifications.cpp b/src/gui/edit_modifications/editmodifications.cpp
new file mode 100644
index 00000000..035ba973
--- /dev/null
+++ b/src/gui/edit_modifications/editmodifications.cpp
@@ -0,0 +1,36 @@
+
+/*******************************************************************************
+* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
+*
+* This file is part of XTPcpp.
+*
+*     XTPcpp is free software: you can redistribute it and/or modify
+*     it under the terms of the GNU General Public License as published by
+*     the Free Software Foundation, either version 3 of the License, or
+*     (at your option) any later version.
+*
+*     XTPcpp is distributed in the hope that it will be useful,
+*     but WITHOUT ANY WARRANTY; without even the implied warranty of
+*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*     GNU General Public License for more details.
+*
+*     You should have received a copy of the GNU General Public License
+*     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
+*
+* Contributors:
+*     Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
+******************************************************************************/
+
+#include "editmodifications.h"
+#include "../project_view/projectwindow.h"
+
+#include "ui_edit_modifications.h"
+
+EditModifications::EditModifications(ProjectWindow *parent):
+    QMainWindow(parent),
+    ui(new Ui::EditModificationView)
+{
+    ui->setupUi(this);
+}
+EditModifications::~EditModifications(){
+}
diff --git a/src/gui/edit_modifications/editmodifications.h b/src/gui/edit_modifications/editmodifications.h
new file mode 100644
index 00000000..6abd1592
--- /dev/null
+++ b/src/gui/edit_modifications/editmodifications.h
@@ -0,0 +1,47 @@
+
+/*******************************************************************************
+* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
+*
+* This file is part of XTPcpp.
+*
+*     XTPcpp is free software: you can redistribute it and/or modify
+*     it under the terms of the GNU General Public License as published by
+*     the Free Software Foundation, either version 3 of the License, or
+*     (at your option) any later version.
+*
+*     XTPcpp is distributed in the hope that it will be useful,
+*     but WITHOUT ANY WARRANTY; without even the implied warranty of
+*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*     GNU General Public License for more details.
+*
+*     You should have received a copy of the GNU General Public License
+*     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
+*
+* Contributors:
+*     Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
+******************************************************************************/
+
+#ifndef EDITMODIFICATIONS_H
+#define EDITMODIFICATIONS_H
+
+
+#include <QMainWindow>
+
+class ProjectWindow;
+
+//http://doc.qt.io/qt-4.8/qt-itemviews-chart-mainwindow-cpp.html
+namespace Ui {
+class EditModificationView;
+}
+
+class EditModifications: public QMainWindow {
+    Q_OBJECT
+public:
+
+    explicit EditModifications(ProjectWindow * parent = 0);
+    ~EditModifications();
+
+private:
+    Ui::EditModificationView *ui;
+};
+#endif // EDITMODIFICATIONS_H
diff --git a/src/gui/load_results_dialog/load_results_dialog.ui b/src/gui/load_results_dialog/load_results_dialog.ui
index 1a4abe2a..bacd1716 100644
--- a/src/gui/load_results_dialog/load_results_dialog.ui
+++ b/src/gui/load_results_dialog/load_results_dialog.ui
@@ -49,12 +49,36 @@
       <item row="0" column="0">
        <widget class="QListView" name="file_list_view"/>
       </item>
-      <item row="1" column="0">
-       <widget class="QPushButton" name="add_files_button">
-        <property name="text">
-         <string>add files</string>
-        </property>
-       </widget>
+      <item row="4" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <item>
+         <spacer name="horizontalSpacer_2">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+        <item>
+         <widget class="QPushButton" name="clear_list_button">
+          <property name="text">
+           <string>clear list</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="add_files_button">
+          <property name="text">
+           <string>add files</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </item>
      </layout>
     </widget>
@@ -109,8 +133,8 @@
    <slot>chooseFiles()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>345</x>
-     <y>202</y>
+     <x>550</x>
+     <y>447</y>
     </hint>
     <hint type="destinationlabel">
      <x>550</x>
@@ -125,8 +149,8 @@
    <slot>reject()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>371</x>
-     <y>271</y>
+     <x>476</x>
+     <y>548</y>
     </hint>
     <hint type="destinationlabel">
      <x>568</x>
@@ -141,8 +165,8 @@
    <slot>accept()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>508</x>
-     <y>275</y>
+     <x>562</x>
+     <y>548</y>
     </hint>
     <hint type="destinationlabel">
      <x>648</x>
@@ -150,10 +174,27 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>clear_list_button</sender>
+   <signal>clicked()</signal>
+   <receiver>LoadResultsDialog</receiver>
+   <slot>clearFileList()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>434</x>
+     <y>441</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>606</x>
+     <y>468</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>chooseFiles()</slot>
   <slot>reject()</slot>
   <slot>accept()</slot>
+  <slot>clearFileList()</slot>
  </slots>
 </ui>
diff --git a/src/gui/load_results_dialog/loadresultsdialog.cpp b/src/gui/load_results_dialog/loadresultsdialog.cpp
index 765d5ce8..df7ab306 100644
--- a/src/gui/load_results_dialog/loadresultsdialog.cpp
+++ b/src/gui/load_results_dialog/loadresultsdialog.cpp
@@ -87,7 +87,9 @@ QStringList LoadResultsDialog::getFileList() const {
 AutomaticFilterParameters LoadResultsDialog::getAutomaticFilterParameters() const {
     return _p_automatic_filter_widget->getAutomaticFilterParameters();
 }
-
+    void LoadResultsDialog::clearFileList() {
+        _p_file_list->removeRows( 0, _p_file_list->rowCount() );
+    }
 void LoadResultsDialog::chooseFiles() {
     try {
         QSettings settings;
diff --git a/src/gui/load_results_dialog/loadresultsdialog.h b/src/gui/load_results_dialog/loadresultsdialog.h
index fd339531..08717ae8 100644
--- a/src/gui/load_results_dialog/loadresultsdialog.h
+++ b/src/gui/load_results_dialog/loadresultsdialog.h
@@ -48,6 +48,7 @@ public:
 
 public slots:
     void chooseFiles();
+    void clearFileList();
 
 signals:
 
diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp
index 1068cfe0..da9b94d8 100644
--- a/src/gui/mainwindow.cpp
+++ b/src/gui/mainwindow.cpp
@@ -60,6 +60,9 @@ void XtpLoaderThread::doLoadingResults(bool is_individual, AutomaticFilterParame
 
     qDebug() << "XtpLoaderThread::doLoadingResults begin ";
     try {
+        if (file_list.size() == 0) {
+            throw pappso::PappsoException(QObject::tr("file list is empty"));
+        }
         ProjectSp project_sp = Project().makeProjectSp();
         project_sp.get()->setCombineMode(!is_individual);
 
@@ -74,7 +77,7 @@ void XtpLoaderThread::doLoadingResults(bool is_individual, AutomaticFilterParame
 
     }
     catch (pappso::PappsoException & error) {
-        emit projectNotReady(tr("Error while reading XPIP file :\n%1").arg(error.qwhat()));
+        emit projectNotReady(tr("Error while reading result files :\n%1").arg(error.qwhat()));
     }
     qDebug() << "XtpLoaderThread::doLoadingResults end ";
 }
@@ -228,7 +231,7 @@ void MainWindow::doProjectReady(ProjectSp project_sp) {
 
 
 void MainWindow::doProjectNotReady(QString error) {
-    viewError(tr("Error while grouping :\n%1").arg(error));
+    viewError(error);
 }
 void MainWindow::loadResults() {
 
-- 
GitLab