139 lines
3.8 KiB
C++
139 lines
3.8 KiB
C++
#ifndef MAINWINDOW_H
|
|
#define MAINWINDOW_H
|
|
|
|
#include "ConnectionConfig.h"
|
|
#include "OpenDatabase.h"
|
|
#include "Pgsql_Connection.h"
|
|
#include "ControllableTask.h"
|
|
#include <QFutureWatcher>
|
|
#include <QMainWindow>
|
|
#include <memory>
|
|
|
|
namespace Pgsql {
|
|
class Connection;
|
|
}
|
|
|
|
class MasterController;
|
|
class QCloseEvent;
|
|
class OpenDatabase;
|
|
class QueryTool;
|
|
class PgClass;
|
|
|
|
class QAction;
|
|
class QMenu;
|
|
class QTabWidget;
|
|
class QToolBar;
|
|
|
|
|
|
/** This is the class for windows that handle tasks for a specific database/catalog
|
|
*
|
|
*/
|
|
class DatabaseWindow : public QMainWindow {
|
|
Q_OBJECT
|
|
public:
|
|
DatabaseWindow(MasterController *master, QWidget *parent);
|
|
~DatabaseWindow();
|
|
|
|
void setConfig(const ConnectionConfig &config);
|
|
|
|
std::shared_ptr<OpenDatabase> getDatabase() { return m_database; }
|
|
|
|
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);
|
|
|
|
void newCodeGenPage(QString query, std::shared_ptr<const Pgsql::Result> dbres);
|
|
|
|
QueryTool *GetActiveQueryTool();
|
|
private:
|
|
QTabWidget *m_tabWidget = nullptr;
|
|
QToolBar *m_mainToolBar = nullptr;
|
|
|
|
ConnectionConfig m_config;
|
|
std::shared_ptr<OpenDatabase> m_database;
|
|
|
|
MasterController *m_masterController;
|
|
|
|
// Standard menu's
|
|
QMenu *m_fileMenu = nullptr;
|
|
|
|
// Standard actions
|
|
QAction *actionAbout = nullptr;
|
|
QAction *actionClose = nullptr;
|
|
QAction *actionCopy = nullptr;
|
|
QAction *actionCopyAsCString = nullptr;
|
|
QAction *actionCopyAsRawCppString = nullptr;
|
|
QAction *actionExecuteQuery = nullptr;
|
|
QAction *actionExplain = nullptr;
|
|
QAction *actionExplainAnalyze = nullptr;
|
|
QAction *actionExportData = nullptr;
|
|
QAction *actionGenerateCode = nullptr;
|
|
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
|
|
QAction *actionNewSql = nullptr;
|
|
QAction *actionOpenSql = nullptr;
|
|
QAction *actionSaveSql = nullptr;
|
|
QAction *actionSaveSqlAs = nullptr;
|
|
QAction *actionSaveCopyOfSqlAs = nullptr;
|
|
QAction *actionShowConnectionManager = nullptr;
|
|
|
|
QMenu *menuEdit = nullptr;
|
|
QMenu *menuFile = nullptr;
|
|
QMenu *menuHelp = nullptr;
|
|
QMenu *menuQuery = nullptr;
|
|
QMenu *menuWindow = nullptr;
|
|
|
|
|
|
class LoadCatalog: public ControllableTask<OpenDatabase::OpenDatabaseSPtr> {
|
|
public:
|
|
LoadCatalog(ConnectionConfig config)
|
|
: m_config(config)
|
|
{}
|
|
|
|
OpenDatabase::OpenDatabaseSPtr run(TaskControl& ) override
|
|
{
|
|
return OpenDatabase::createOpenDatabase(m_config);
|
|
}
|
|
|
|
private:
|
|
ConnectionConfig m_config;
|
|
};
|
|
|
|
QFutureWatcher<LoadCatalog::Result> loadWatcher;
|
|
|
|
void newCreateTablePage();
|
|
|
|
void createActions();
|
|
void initMenus();
|
|
|
|
QAction* seperator();
|
|
private slots:
|
|
void catalogLoaded();
|
|
// void tabWidget_tabCloseRequested(int index);
|
|
// void tabWidget_currentChanged(int index);
|
|
|
|
void on_actionAbout_triggered();
|
|
void on_actionClose_triggered();
|
|
void on_actionCopy_triggered();
|
|
void on_actionCopyAsCString_triggered();
|
|
void on_actionCopyAsRawCppString_triggered();
|
|
void on_actionExecuteQuery_triggered();
|
|
void on_actionExplain_triggered();
|
|
void on_actionExplainAnalyze_triggered();
|
|
void on_actionExportData_triggered();
|
|
void on_actionGenerateCode_triggered();
|
|
void on_actionInspectInformationSchema_triggered();
|
|
void on_actionInspectPgCatalog_triggered();
|
|
void on_actionInspectUserSchemas_triggered();
|
|
void on_actionNewSql_triggered();
|
|
void on_actionOpenSql_triggered();
|
|
void on_actionSaveSql_triggered();
|
|
void on_actionSaveSqlAs_triggered();
|
|
void on_actionSaveCopyOfSqlAs_triggered();
|
|
void on_actionShowConnectionManager_triggered();
|
|
};
|
|
|
|
#endif // MAINWINDOW_H
|