Made step to remove ASyncWindow in favour of usage of Future and FutureWatcher.

This should allow concurrency in the plugins to be independent from their container.

Contains also some work on the system for registering plugins.
This commit is contained in:
eelke 2018-12-30 15:46:15 +01:00
parent a54a063c13
commit 15bee33076
25 changed files with 327 additions and 52 deletions

View file

@ -5,20 +5,24 @@
#include "ConnectionConfig.h"
#include "OpenDatabase.h"
#include <QLabel>
#include "ASyncWindow.h"
//#include "ASyncWindow.h"
#include <QLabel>
#include <QRunnable>
#include <QSocketNotifier>
#include <memory>
#include <future>
#include "Pgsql_Connection.h"
#include "QueuedBackgroundTask.h"
//#include "QueuedBackgroundTask.h"
#include "ControllableTask.h"
#include <chrono>
#include <deque>
#include <mutex>
#include <QMutex>
#include <QWaitCondition>
#include <QMainWindow>
#include <QFuture>
#include <QFutureWatcher>
namespace Ui {
class MainWindow;
@ -42,7 +46,7 @@ namespace DatabaseWindow_details {
/** This is the class for windows that handle tasks for a specific database/catalog
*
*/
class DatabaseWindow : public ASyncWindow {
class DatabaseWindow : public QMainWindow {
Q_OBJECT
public:
explicit DatabaseWindow(MasterController *master, QWidget *parent);
@ -68,33 +72,50 @@ private:
MasterController *m_masterController;
PluginContentWidget *m_previousPage = nullptr; ///< tracks which pages buttons were previously being displayed
class QLoad : public QueuedBackgroundTask {
// class QLoad : public QueuedBackgroundTask {
// public:
// explicit QLoad(ConnectionConfig config, CompletionFunction on_completion)
// : QueuedBackgroundTask(on_completion)
// , m_config(config)
// {}
// OpenDatabase::OpenDatabaseSPtr GetResult()
// {
// if (hasException()) rethrow();
// return result;
// }
// protected:
// OpenDatabase::OpenDatabaseSPtr result;
// virtual void doRun()
// {
// auto res = OpenDatabase::createOpenDatabase(m_config);
// result = res.get();
// }
// private:
// ConnectionConfig m_config;
// };
// std::shared_ptr<QLoad> loader;
class LoadCatalog: public ControllableTask<OpenDatabase::OpenDatabaseSPtr> {
public:
explicit QLoad(ConnectionConfig config, CompletionFunction on_completion)
: QueuedBackgroundTask(on_completion)
, m_config(config)
LoadCatalog(ConnectionConfig config)
: m_config(config)
{}
OpenDatabase::OpenDatabaseSPtr GetResult()
{
if (hasException()) rethrow();
return result;
}
protected:
OpenDatabase::OpenDatabaseSPtr result;
virtual void doRun()
OpenDatabase::OpenDatabaseSPtr run(TaskControl& ) override
{
auto res = OpenDatabase::createOpenDatabase(m_config);
result = res.get();
return res.get();
}
private:
private:
ConnectionConfig m_config;
};
std::shared_ptr<QLoad> loader;
QFutureWatcher<LoadCatalog::Result> loadWatcher;
QueryTab *GetActiveQueryTab();
@ -103,7 +124,6 @@ private:
QueryTab *newSqlPage();
void newCreateTablePage();
void catalogLoaded();
/// Called when a newly created page is added to the QTabWidget
void addPage(PluginContentWidget* page, QString caption);
@ -115,6 +135,8 @@ private:
//class PageData
private slots:
void catalogLoaded();
void on_actionLoad_SQL_triggered();
void on_actionSave_SQL_triggered();
void on_actionExport_data_triggered();