2016-12-26 16:06:55 +01:00
|
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
|
|
2017-08-23 13:27:23 +02:00
|
|
|
|
#include "ConnectionConfig.h"
|
2017-12-25 15:33:10 +01:00
|
|
|
|
#include "OpenDatabase.h"
|
2017-08-26 11:45:50 +02:00
|
|
|
|
#include "Pgsql_Connection.h"
|
2018-12-30 15:46:15 +01:00
|
|
|
|
#include "ControllableTask.h"
|
|
|
|
|
|
#include <QFutureWatcher>
|
2019-08-15 16:18:47 +02:00
|
|
|
|
#include <QMainWindow>
|
2019-01-06 08:17:37 +01:00
|
|
|
|
#include <memory>
|
2017-12-28 07:23:20 +01:00
|
|
|
|
|
2016-12-27 15:41:11 +01:00
|
|
|
|
namespace Pgsql {
|
|
|
|
|
|
class Connection;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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;
|
2019-08-15 19:32:33 +02:00
|
|
|
|
class QueryTool;
|
2018-01-09 20:39:43 +01:00
|
|
|
|
class PgClass;
|
2018-12-29 18:59:54 +01:00
|
|
|
|
|
2019-08-15 16:18:47 +02:00
|
|
|
|
class QAction;
|
|
|
|
|
|
class QMenu;
|
2019-01-01 14:34:14 +01:00
|
|
|
|
class QTabWidget;
|
2019-08-15 16:18:47 +02:00
|
|
|
|
class QToolBar;
|
2019-01-01 14:34:14 +01:00
|
|
|
|
|
2019-01-01 11:15:16 +01:00
|
|
|
|
|
2018-12-28 12:55:11 +01:00
|
|
|
|
/** This is the class for windows that handle tasks for a specific database/catalog
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2019-08-15 16:18:47 +02:00
|
|
|
|
class DatabaseWindow : public QMainWindow {
|
2016-12-26 16:06:55 +01:00
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
2019-01-01 11:15:16 +01:00
|
|
|
|
DatabaseWindow(MasterController *master, QWidget *parent);
|
2018-12-28 12:55:11 +01:00
|
|
|
|
~DatabaseWindow();
|
2016-12-26 16:06:55 +01:00
|
|
|
|
|
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
|
|
|
|
|
2019-08-15 16:18:47 +02:00
|
|
|
|
void setTabCaptionForWidget(QWidget *widget, const QString &caption, const QString &hint);
|
|
|
|
|
|
void setTabIcon(QWidget *widget, const QString &iconname);
|
|
|
|
|
|
|
|
|
|
|
|
/// Called when a newly created page is added to the QTabWidget
|
|
|
|
|
|
void addPage(QWidget* page, QString caption);
|
2018-12-28 08:51:02 +01:00
|
|
|
|
|
2019-08-15 16:18:47 +02:00
|
|
|
|
void newCodeGenPage(QString query, std::shared_ptr<const Pgsql::Result> dbres);
|
2019-08-15 19:32:33 +02:00
|
|
|
|
|
|
|
|
|
|
QueryTool *GetActiveQueryTool();
|
2016-12-26 16:06:55 +01:00
|
|
|
|
private:
|
2019-08-15 16:18:47 +02:00
|
|
|
|
QTabWidget *m_tabWidget = nullptr;
|
|
|
|
|
|
QToolBar *m_mainToolBar = nullptr;
|
2017-01-25 06:54:21 +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-12-30 15:46:15 +01:00
|
|
|
|
|
2019-08-15 16:18:47 +02:00
|
|
|
|
// Standard menu's
|
|
|
|
|
|
QMenu *m_fileMenu = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
// Standard actions
|
|
|
|
|
|
QAction *actionAbout = nullptr;
|
2019-08-16 08:27:05 +02:00
|
|
|
|
QAction *actionCancelQuery = nullptr;
|
2019-08-15 16:18:47 +02:00
|
|
|
|
QAction *actionClose = nullptr;
|
2019-08-15 19:32:33 +02:00
|
|
|
|
QAction *actionCopy = nullptr;
|
|
|
|
|
|
QAction *actionCopyAsCString = nullptr;
|
|
|
|
|
|
QAction *actionCopyAsRawCppString = nullptr;
|
2019-08-16 07:23:18 +02:00
|
|
|
|
QAction *actionExecuteQuery = nullptr;
|
|
|
|
|
|
QAction *actionExplain = nullptr;
|
|
|
|
|
|
QAction *actionExplainAnalyze = nullptr;
|
2019-08-15 19:32:33 +02:00
|
|
|
|
QAction *actionExportData = nullptr;
|
|
|
|
|
|
QAction *actionGenerateCode = nullptr;
|
2019-08-15 16:38:01 +02:00
|
|
|
|
QAction *actionInspectInformationSchema = nullptr; ///< Create or switch to pgcatalog tab
|
|
|
|
|
|
QAction *actionInspectPgCatalog = nullptr; ///< Create or switch to pgcatalog tab
|
|
|
|
|
|
QAction *actionInspectUserSchemas = nullptr; ///< Create or switch to pgcatalog tab
|
2019-08-15 16:18:47 +02:00
|
|
|
|
QAction *actionNewSql = nullptr;
|
|
|
|
|
|
QAction *actionOpenSql = nullptr;
|
2019-08-15 19:32:33 +02:00
|
|
|
|
QAction *actionSaveSql = nullptr;
|
|
|
|
|
|
QAction *actionSaveSqlAs = nullptr;
|
|
|
|
|
|
QAction *actionSaveCopyOfSqlAs = nullptr;
|
|
|
|
|
|
QAction *actionShowConnectionManager = nullptr;
|
2019-08-15 16:18:47 +02:00
|
|
|
|
|
2019-08-15 19:32:33 +02:00
|
|
|
|
QMenu *menuEdit = nullptr;
|
2019-08-15 16:18:47 +02:00
|
|
|
|
QMenu *menuFile = nullptr;
|
|
|
|
|
|
QMenu *menuHelp = nullptr;
|
2019-08-16 07:23:18 +02:00
|
|
|
|
QMenu *menuQuery = nullptr;
|
2019-08-15 19:32:33 +02:00
|
|
|
|
QMenu *menuWindow = nullptr;
|
2019-08-15 16:18:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
2018-12-30 15:46:15 +01:00
|
|
|
|
class LoadCatalog: public ControllableTask<OpenDatabase::OpenDatabaseSPtr> {
|
2017-12-28 07:23:20 +01:00
|
|
|
|
public:
|
2018-12-30 15:46:15 +01:00
|
|
|
|
LoadCatalog(ConnectionConfig config)
|
|
|
|
|
|
: m_config(config)
|
2017-12-28 07:23:20 +01:00
|
|
|
|
{}
|
|
|
|
|
|
|
2018-12-30 15:46:15 +01:00
|
|
|
|
OpenDatabase::OpenDatabaseSPtr run(TaskControl& ) override
|
2017-12-28 07:23:20 +01:00
|
|
|
|
{
|
2019-01-29 19:41:27 +01:00
|
|
|
|
return OpenDatabase::createOpenDatabase(m_config);
|
2017-12-28 07:23:20 +01:00
|
|
|
|
}
|
2017-02-12 08:13:38 +01:00
|
|
|
|
|
2018-12-30 15:46:15 +01:00
|
|
|
|
private:
|
2017-12-28 07:23:20 +01:00
|
|
|
|
ConnectionConfig m_config;
|
|
|
|
|
|
};
|
2017-02-12 08:13:38 +01:00
|
|
|
|
|
2018-12-30 15:46:15 +01:00
|
|
|
|
QFutureWatcher<LoadCatalog::Result> loadWatcher;
|
2017-01-08 15:16:16 +01:00
|
|
|
|
|
2018-12-15 20:27:40 +01:00
|
|
|
|
void newCreateTablePage();
|
2017-01-25 06:54:21 +01:00
|
|
|
|
|
2019-08-15 16:18:47 +02:00
|
|
|
|
void createActions();
|
|
|
|
|
|
void initMenus();
|
2016-12-27 15:41:11 +01:00
|
|
|
|
|
2019-08-15 19:32:33 +02:00
|
|
|
|
QAction* seperator();
|
2019-08-15 16:18:47 +02:00
|
|
|
|
private slots:
|
2018-12-30 15:46:15 +01:00
|
|
|
|
void catalogLoaded();
|
2019-08-15 16:18:47 +02:00
|
|
|
|
// void tabWidget_tabCloseRequested(int index);
|
|
|
|
|
|
// void tabWidget_currentChanged(int index);
|
2018-12-30 15:46:15 +01:00
|
|
|
|
|
2019-08-15 19:32:33 +02:00
|
|
|
|
void on_actionAbout_triggered();
|
2019-08-16 08:27:05 +02:00
|
|
|
|
void on_actionCancelQuery_triggered();
|
2019-08-15 16:18:47 +02:00
|
|
|
|
void on_actionClose_triggered();
|
2019-08-15 19:32:33 +02:00
|
|
|
|
void on_actionCopy_triggered();
|
|
|
|
|
|
void on_actionCopyAsCString_triggered();
|
|
|
|
|
|
void on_actionCopyAsRawCppString_triggered();
|
2019-08-16 07:23:18 +02:00
|
|
|
|
void on_actionExecuteQuery_triggered();
|
|
|
|
|
|
void on_actionExplain_triggered();
|
|
|
|
|
|
void on_actionExplainAnalyze_triggered();
|
2019-08-15 19:32:33 +02:00
|
|
|
|
void on_actionExportData_triggered();
|
|
|
|
|
|
void on_actionGenerateCode_triggered();
|
2019-08-15 16:38:01 +02:00
|
|
|
|
void on_actionInspectInformationSchema_triggered();
|
|
|
|
|
|
void on_actionInspectPgCatalog_triggered();
|
|
|
|
|
|
void on_actionInspectUserSchemas_triggered();
|
2019-08-15 19:32:33 +02:00
|
|
|
|
void on_actionNewSql_triggered();
|
2019-08-15 16:18:47 +02:00
|
|
|
|
void on_actionOpenSql_triggered();
|
2019-08-15 19:32:33 +02:00
|
|
|
|
void on_actionSaveSql_triggered();
|
|
|
|
|
|
void on_actionSaveSqlAs_triggered();
|
|
|
|
|
|
void on_actionSaveCopyOfSqlAs_triggered();
|
|
|
|
|
|
void on_actionShowConnectionManager_triggered();
|
2016-12-26 16:06:55 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|