From 883028fb667079e277a415f689a1c4319ac746a6 Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Fri, 15 Mar 2019 09:35:36 +0100
Subject: [PATCH] writing protein list in ODS file

---
 src/gui/mainwindow.cpp                          | 10 +++++-----
 src/gui/protein_list_view/proteinlistwindow.cpp | 12 ++++++++++++
 src/gui/workerthread.cpp                        |  8 ++++----
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp
index eb0a90470..b76b6ad12 100644
--- a/src/gui/mainwindow.cpp
+++ b/src/gui/mainwindow.cpp
@@ -110,7 +110,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Main)
 
 MainWindow::~MainWindow()
 {
-  qDebug() << "MainWindow::~MainWindow";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
   _worker_thread.quit();
   _worker_thread.wait();
   // if (_p_ms_data_file != nullptr) delete _p_ms_data_file;
@@ -123,7 +123,7 @@ MainWindow::~MainWindow()
     {
       delete _p_export_masschroq_dialog;
     }
-  qDebug() << "MainWindow::~MainWindow end";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
 
 bool
@@ -191,7 +191,7 @@ MainWindow::doWorkerAppendText(char *text)
 void
 MainWindow::doActionQuit()
 {
-  qDebug() << "MainWindow::doActionQuit begin";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
   this->close();
 }
 
@@ -791,7 +791,7 @@ MainWindow::run()
 
   try
     {
-      qDebug() << "MainWindow::run() begin";
+      qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
       QCommandLineParser parser;
 
       // throw pappso::PappsoException("test");
@@ -803,7 +803,7 @@ MainWindow::run()
         "XPIP project file",
         QCoreApplication::translate("main", "Project file to open."));
 
-      qDebug() << "MainWindow::run() 1";
+      qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 
       // Process the actual command line arguments given by the user
       parser.process(*_p_app);
diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp
index 903243567..25f4f0d17 100644
--- a/src/gui/protein_list_view/proteinlistwindow.cpp
+++ b/src/gui/protein_list_view/proteinlistwindow.cpp
@@ -27,6 +27,8 @@
 #include "ui_protein_view.h"
 #include "../mainwindow.h"
 #include <QSettings>
+#include <odsstream/odsdocwriter.h>
+#include <odsstream/qtablewriter.h>
 
 ProteinListQactionColumn::ProteinListQactionColumn(ProteinListWindow *parent,
                                                    ProteinListColumn column)
@@ -475,4 +477,14 @@ void
 ProteinListWindow::doExportAsOdsFile()
 {
   qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
+
+  CalcWriterInterface *p_writer            = new OdsDocWriter("/tmp/test.ods");
+  const QAbstractProxyModel *p_table_model = _p_proxy_model;
+
+  QtableWriter table_writer(p_writer, p_table_model);
+
+  table_writer.writeSheet("protein list");
+
+  p_writer->close();
+  delete p_writer;
 }
diff --git a/src/gui/workerthread.cpp b/src/gui/workerthread.cpp
index 4db246aad..e4fb6277f 100644
--- a/src/gui/workerthread.cpp
+++ b/src/gui/workerthread.cpp
@@ -51,7 +51,7 @@
 WorkerThread::WorkerThread(MainWindow *p_main_window)
 {
   _p_main_window = p_main_window;
-  qDebug() << "WorkerThread::WorkerThread begin MainWindow";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 
   _p_work_monitor = new WorkMonitor();
 
@@ -237,7 +237,7 @@ WorkerThread::WorkerThread(MainWindow *p_main_window)
           SLOT(doOperationFinished()));
 #endif
 
-  qDebug() << "WorkerThread::WorkerThread end MainWindow";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
 
 WorkerThread::WorkerThread(ProjectWindow *p_project_window)
@@ -374,7 +374,7 @@ WorkerThread::~WorkerThread()
 void
 WorkerThread::doXpipFileLoad(QString filename)
 {
-  qDebug() << "WorkerThread::doXpipFileLoad begin " << filename;
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << filename;
   try
     {
       QFileInfo new_xpip_file(filename);
@@ -392,7 +392,7 @@ WorkerThread::doXpipFileLoad(QString filename)
         tr("Error while reading XPIP file :\n%1").arg(error.qwhat()));
     }
 
-  qDebug() << "WorkerThread::doXpipFileLoad end";
+  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
 }
 
 void
-- 
GitLab