2016-12-26 16:06:55 +01:00
|
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
|
|
2017-08-23 13:27:23 +02:00
|
|
|
|
#include "ASyncDBConnection.h"
|
|
|
|
|
|
#include "ConnectionConfig.h"
|
2017-12-25 15:33:10 +01:00
|
|
|
|
#include "OpenDatabase.h"
|
2017-01-08 15:16:16 +01:00
|
|
|
|
#include <QLabel>
|
2017-02-12 14:03:42 +01:00
|
|
|
|
#include "ASyncWindow.h"
|
2017-12-28 07:23:20 +01:00
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
#include <QRunnable>
|
2016-12-27 15:41:11 +01:00
|
|
|
|
#include <QSocketNotifier>
|
2016-12-26 16:06:55 +01:00
|
|
|
|
#include <memory>
|
2016-12-27 21:22:49 +01:00
|
|
|
|
#include <future>
|
2017-08-26 11:45:50 +02:00
|
|
|
|
#include "Pgsql_Connection.h"
|
2017-12-28 07:23:20 +01:00
|
|
|
|
#include "QueuedBackgroundTask.h"
|
2017-01-16 18:56:07 +01:00
|
|
|
|
#include <chrono>
|
2017-01-15 21:01:40 +01:00
|
|
|
|
#include <deque>
|
|
|
|
|
|
#include <mutex>
|
2016-12-26 16:06:55 +01:00
|
|
|
|
|
2017-12-28 07:23:20 +01:00
|
|
|
|
#include <QMutex>
|
|
|
|
|
|
#include <QWaitCondition>
|
|
|
|
|
|
|
2016-12-26 16:06:55 +01:00
|
|
|
|
namespace Ui {
|
|
|
|
|
|
class MainWindow;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-27 15:41:11 +01:00
|
|
|
|
namespace Pgsql {
|
|
|
|
|
|
class Connection;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-01-21 08:09:12 +01:00
|
|
|
|
class QueryTab;
|
2017-02-01 18:01:02 +01:00
|
|
|
|
class MasterController;
|
2017-01-19 17:48:44 +01:00
|
|
|
|
class QCloseEvent;
|
2017-02-04 11:55:49 +01:00
|
|
|
|
class OpenDatabase;
|
2018-01-09 20:39:43 +01:00
|
|
|
|
class PgClass;
|
2018-05-14 20:24:41 +02:00
|
|
|
|
class PlgPage;
|
2016-12-30 10:14:26 +01:00
|
|
|
|
|
2017-02-12 14:03:42 +01:00
|
|
|
|
class MainWindow : public ASyncWindow {
|
2016-12-26 16:06:55 +01:00
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
2017-02-01 18:01:02 +01:00
|
|
|
|
explicit MainWindow(MasterController *master, QWidget *parent);
|
2016-12-26 16:06:55 +01:00
|
|
|
|
~MainWindow();
|
|
|
|
|
|
|
2017-01-15 21:01:40 +01:00
|
|
|
|
void setConfig(const ConnectionConfig &config);
|
2016-12-30 10:14:26 +01:00
|
|
|
|
|
2017-12-25 10:31:58 +01:00
|
|
|
|
std::shared_ptr<OpenDatabase> getDatabase() { return m_database; }
|
2018-01-09 20:39:43 +01:00
|
|
|
|
|
|
|
|
|
|
void newCrudPage(const PgClass &table);
|
2018-09-18 11:53:19 +02:00
|
|
|
|
void newCodeGenPage(QString query, std::shared_ptr<const Pgsql::Result> dbres);
|
2018-12-28 08:51:02 +01:00
|
|
|
|
|
2016-12-26 16:06:55 +01:00
|
|
|
|
private:
|
2017-01-25 06:54:21 +01:00
|
|
|
|
|
2017-01-22 08:50:41 +01:00
|
|
|
|
Ui::MainWindow *ui;
|
2017-01-21 18:16:57 +01:00
|
|
|
|
|
2017-01-15 21:01:40 +01:00
|
|
|
|
ConnectionConfig m_config;
|
2017-12-25 10:31:58 +01:00
|
|
|
|
std::shared_ptr<OpenDatabase> m_database;
|
2017-01-15 21:01:40 +01:00
|
|
|
|
|
2017-02-01 18:01:02 +01:00
|
|
|
|
MasterController *m_masterController;
|
2018-05-14 20:24:41 +02:00
|
|
|
|
PlgPage *m_previousPage = nullptr; ///< tracks which pages buttons were previously being displayed
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
2017-12-28 07:23:20 +01:00
|
|
|
|
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:
|
2017-02-12 08:13:38 +01:00
|
|
|
|
|
2017-12-28 07:23:20 +01:00
|
|
|
|
ConnectionConfig m_config;
|
|
|
|
|
|
};
|
2017-02-12 08:13:38 +01:00
|
|
|
|
|
2017-12-28 07:23:20 +01:00
|
|
|
|
std::shared_ptr<QLoad> loader;
|
2017-02-12 08:13:38 +01:00
|
|
|
|
|
2017-01-08 15:16:16 +01:00
|
|
|
|
|
2017-01-21 18:16:57 +01:00
|
|
|
|
QueryTab *GetActiveQueryTab();
|
2016-12-26 16:06:55 +01:00
|
|
|
|
|
2017-01-19 17:48:44 +01:00
|
|
|
|
void closeEvent(QCloseEvent *event);
|
2017-01-21 08:09:12 +01:00
|
|
|
|
void showEvent(QShowEvent *event);
|
2017-01-22 08:50:41 +01:00
|
|
|
|
QueryTab *newSqlPage();
|
2018-12-15 20:27:40 +01:00
|
|
|
|
void newCreateTablePage();
|
2017-01-25 06:54:21 +01:00
|
|
|
|
|
2017-12-28 07:23:20 +01:00
|
|
|
|
void catalogLoaded();
|
2017-12-25 15:33:10 +01:00
|
|
|
|
|
2018-05-14 20:24:41 +02:00
|
|
|
|
/// Called when a newly created page is added to the QTabWidget
|
|
|
|
|
|
void addPage(PlgPage* page, QString caption);
|
|
|
|
|
|
/// Called when a page is completely removed from the QTabWidget
|
|
|
|
|
|
void removePage(PlgPage *page);
|
|
|
|
|
|
|
|
|
|
|
|
void addToolBarButtonsForPage(PlgPage *page);
|
|
|
|
|
|
void removeToolBarButtonsForPage(PlgPage *page);
|
|
|
|
|
|
//class PageData
|
2016-12-26 16:06:55 +01:00
|
|
|
|
private slots:
|
2016-12-27 15:41:11 +01:00
|
|
|
|
|
2017-01-09 07:39:09 +01:00
|
|
|
|
void on_actionLoad_SQL_triggered();
|
|
|
|
|
|
void on_actionSave_SQL_triggered();
|
|
|
|
|
|
void on_actionExport_data_triggered();
|
|
|
|
|
|
void on_actionClose_triggered();
|
|
|
|
|
|
void on_actionAbout_triggered();
|
2017-01-21 08:09:12 +01:00
|
|
|
|
void on_actionSave_SQL_as_triggered();
|
2017-01-21 08:19:47 +01:00
|
|
|
|
void on_actionSave_copy_of_SQL_as_triggered();
|
2017-01-21 18:16:57 +01:00
|
|
|
|
void on_actionNew_SQL_triggered();
|
2017-01-22 08:50:41 +01:00
|
|
|
|
void on_tabWidget_tabCloseRequested(int index);
|
2017-02-01 18:01:02 +01:00
|
|
|
|
void on_actionShow_connection_manager_triggered();
|
2017-02-04 11:55:49 +01:00
|
|
|
|
void on_actionCopy_triggered();
|
2017-02-05 08:23:06 +01:00
|
|
|
|
void on_actionCopy_as_C_string_triggered();
|
2017-10-05 16:02:06 +02:00
|
|
|
|
void on_actionCopy_as_raw_Cpp_string_triggered();
|
2018-05-14 20:24:41 +02:00
|
|
|
|
void on_tabWidget_currentChanged(int index);
|
2018-09-18 11:53:19 +02:00
|
|
|
|
void on_actionGenerate_code_triggered();
|
2016-12-26 16:06:55 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|