diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3539ce0f846d49cc931113408d4cef7461ab38f5..f2b16461bda55edcaa31785c9b00d5ffa8786d69 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,6 +129,7 @@ SET(XTPCPP_SRCS ./gui/ptm_island_list_view/ptmislandproxymodel.cpp ./gui/waiting_message_dialog/waitingmessagedialog.cpp ./gui/workerthread.cpp + ./utils/workmonitor.cpp ) SET (GUI_UIS @@ -174,6 +175,7 @@ SET(XTPCPP_MOC_HDRS ./gui/ptm_island_list_view/ptmislandproxymodel.h ./gui/waiting_message_dialog/waitingmessagedialog.h ./gui/workerthread.h + ./utils/workmonitor.h ) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 76b615e88f862f9ce1b59e8141d4b101524e4d5b..a5643923228dbaa2028d44a1f92d8263d5a48ce9 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -129,6 +129,12 @@ void MainWindow::doDisplayLoadingMessage(QString message) { _p_waiting_message_dialog->message(message); ui->statusbar->showMessage(message); } + +void MainWindow::doDisplayLoadingMessage(QString message, int value) { + qDebug() << "MainWindow::doDisplayLoadingMessage " << message << " " << value; + _p_waiting_message_dialog->message(message, value); + ui->statusbar->showMessage(message); +} void MainWindow::doActionQuit() { qDebug() << "MainWindow::doActionQuit begin"; this->close(); diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 362df421c6f242e002f92b50634a88b216e29071..c6152358daacebde76a9fbadfd756938f0888427 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -64,6 +64,7 @@ public slots: void doActionSpreadsheet(); void doActionModifications(); void doDisplayLoadingMessage(QString message); + void doDisplayLoadingMessage(QString message, int value); void doProjectReady(ProjectSp project_sp); void doProjectNotReady(QString error); void doAcceptedLoadResultDialog(); diff --git a/src/gui/workerthread.cpp b/src/gui/workerthread.cpp index 2ca0effa8645fe6f8032d0c598be2393447c7382..ca3fa70540c3d7b0016493e7569b3b91d6893758 100644 --- a/src/gui/workerthread.cpp +++ b/src/gui/workerthread.cpp @@ -41,6 +41,8 @@ WorkerThread::WorkerThread(MainWindow * p_main_window) { qDebug() << "WorkerThread::WorkerThread begin MainWindow"; + + _p_work_monitor = new WorkMonitor(); #if QT_VERSION >= 0x050000 // Qt5 code @@ -51,6 +53,9 @@ WorkerThread::WorkerThread(MainWindow * p_main_window) */ #else // Qt4 code + //worker message + connect(_p_work_monitor, SIGNAL(workerMessage(QString)), p_main_window,SLOT(doDisplayLoadingMessage(QString))); + connect(_p_work_monitor, SIGNAL(workerMessage(QString, int)), p_main_window,SLOT(doDisplayLoadingMessage(QString, int))); connect(p_main_window, SIGNAL(operateXpipFile(QString)), this,SLOT(doXpipFileLoad(QString))); connect(this, SIGNAL(projectReady(ProjectSp)), p_main_window,SLOT(doProjectReady(ProjectSp))); diff --git a/src/gui/workerthread.h b/src/gui/workerthread.h index 7ebca755222c18c0a7cca351357399fea4f7e97c..b177ce61771da8b52f68d3fbd65f4adc9a3d071a 100644 --- a/src/gui/workerthread.h +++ b/src/gui/workerthread.h @@ -34,6 +34,7 @@ #include <QCloseEvent> #include "../core/automaticfilterparameters.h" #include "../core/project.h" +#include "../utils/workmonitor.h" class MainWindow; class ProjectWindow; @@ -73,6 +74,9 @@ signals: void ptmGroupingOnIdentificationFinished(IdentificationGroup * p_identification_group); void operationFinished(); void operationFailed(QString error); + +private: + WorkMonitor * _p_work_monitor; }; #endif // WORKERTHREAD_H diff --git a/src/utils/workmonitor.cpp b/src/utils/workmonitor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..738be3c5394a8f8ab8b913d420220073cc802ece --- /dev/null +++ b/src/utils/workmonitor.cpp @@ -0,0 +1,39 @@ +/** + * \file utils/workmonitor.cpp + * \date 10/6/2017 + * \author Olivier Langella + * \brief monitoring progress in any worker thread + */ + + +/******************************************************************************* +* 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 "workmonitor.h" + +void WorkMonitor::message(const QString & message) { + emit workerMessage(message); +} +void WorkMonitor::message(const QString & message, int value) { + + emit workerMessage(message,value); +} diff --git a/src/utils/workmonitor.h b/src/utils/workmonitor.h new file mode 100644 index 0000000000000000000000000000000000000000..3b857ca3d71023d81b500ce28dae40b83c9e95a7 --- /dev/null +++ b/src/utils/workmonitor.h @@ -0,0 +1,57 @@ +/** + * \file utils/workmonitor.h + * \date 10/6/2017 + * \author Olivier Langella + * \brief monitoring progress in any worker thread + */ + + +/******************************************************************************* +* 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 WORKMONITOR_H +#define WORKMONITOR_H + +#include <QObject> + +class WorkMonitorInterface +{ +public: + virtual void message(const QString & message) = 0; + virtual void message(const QString & message, int value) = 0; +}; + +class WorkMonitor: public QObject, WorkMonitorInterface +{ + Q_OBJECT +public: + void message(const QString & message) override; + void message(const QString & message, int value) override; + + signals: + void workerMessage(QString message); + void workerMessage(QString message, int value); + + +}; + +#endif // WORKMONITOR_H