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"
|
2019-08-16 10:49:38 +02:00
|
|
|
|
#include "CatalogInspector.h"
|
2017-12-25 15:33:10 +01:00
|
|
|
|
#include "OpenDatabase.h"
|
2017-08-26 11:45:50 +02:00
|
|
|
|
#include "Pgsql_Connection.h"
|
2019-08-16 08:29:27 +02:00
|
|
|
|
#include "IDatabaseWindow.h"
|
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
|
|
|
|
|
2022-04-08 20:16:42 +02:00
|
|
|
|
namespace Ui {
|
|
|
|
|
|
class DatabaseWindow;
|
|
|
|
|
|
}
|
2016-12-27 15:41:11 +01:00
|
|
|
|
namespace Pgsql {
|
|
|
|
|
|
class Connection;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-10-13 07:31:48 +02:00
|
|
|
|
class CrudTab;
|
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
|
|
|
|
|
2018-12-28 12:55:11 +01:00
|
|
|
|
/** This is the class for windows that handle tasks for a specific database/catalog
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2019-08-16 08:29:27 +02:00
|
|
|
|
class DatabaseWindow : public QMainWindow, public IDatabaseWindow {
|
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-19 10:05:05 +02:00
|
|
|
|
virtual void newCodeGenPage(QString query, std::shared_ptr<const Pgsql::Result> dbres) override;
|
2019-08-15 19:32:33 +02:00
|
|
|
|
|
|
|
|
|
|
QueryTool *GetActiveQueryTool();
|
2019-10-13 07:31:48 +02:00
|
|
|
|
CrudTab *GetActiveCrud();
|
2020-04-04 13:23:43 +02:00
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
virtual void closeEvent(QCloseEvent *event) override;
|
|
|
|
|
|
|
2016-12-26 16:06:55 +01:00
|
|
|
|
private:
|
2022-04-08 20:16:42 +02:00
|
|
|
|
Ui::DatabaseWindow *ui;
|
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-10-13 07:31:48 +02:00
|
|
|
|
void newCreateTablePage();
|
|
|
|
|
|
void newCrudPage(Oid tableoid);
|
|
|
|
|
|
void newCatalogInspectorPage(QString caption, NamespaceFilter filter);
|
2021-04-10 14:27:04 +02:00
|
|
|
|
void newServerInspectorPage();
|
2019-08-16 10:49:59 +02:00
|
|
|
|
void closeTab(int index);
|
2021-07-04 20:24:05 +02:00
|
|
|
|
bool canCloseTab(int index) const;
|
2021-06-16 19:20:03 +02:00
|
|
|
|
void openSqlFile(QString file_name);
|
|
|
|
|
|
|
2021-07-04 20:24:05 +02:00
|
|
|
|
/// Uses introspection to determine if the specific widget has a copy function.
|
|
|
|
|
|
/// If it has it invokes this method using reflection.
|
|
|
|
|
|
static void InvokeCopyIfPresent(QWidget *w);
|
|
|
|
|
|
|
2019-08-15 16:18:47 +02:00
|
|
|
|
private slots:
|
2022-01-16 18:21:18 +01:00
|
|
|
|
void catalogLoaded(OpenDatabase::OpenDatabaseSPtr db);
|
2019-08-16 10:49:38 +02:00
|
|
|
|
void tableSelected(Oid tableoid);
|
2022-04-08 20:16:42 +02:00
|
|
|
|
void mainTabCloseRequested(int index);
|
|
|
|
|
|
void currentMainTabChanged(int index);
|
|
|
|
|
|
|
|
|
|
|
|
void on_actionAbout_triggered();
|
|
|
|
|
|
void on_actionCancel_query_triggered();
|
|
|
|
|
|
void on_actionClose_triggered();
|
|
|
|
|
|
void on_actionCopy_triggered();
|
|
|
|
|
|
void on_actionCopy_as_C_string_triggered();
|
|
|
|
|
|
void on_actionCopy_as_raw_C_string_triggered();
|
|
|
|
|
|
void on_actionExecute_query_triggered();
|
|
|
|
|
|
void on_actionExplain_triggered();
|
|
|
|
|
|
void on_actionExplain_analyze_triggered();
|
|
|
|
|
|
void on_actionExport_data_triggered();
|
|
|
|
|
|
void on_actionGenerate_code_triggered();
|
|
|
|
|
|
void on_actionInspect_information_schema_triggered();
|
|
|
|
|
|
void on_actionInspect_pg_catalog_triggered();
|
|
|
|
|
|
void on_actionInspect_user_schemas_triggered();
|
|
|
|
|
|
void on_actionInspect_server_triggered();
|
|
|
|
|
|
void on_actionNew_Query_triggered();
|
|
|
|
|
|
void on_actionOpen_Query_triggered();
|
|
|
|
|
|
void on_actionSave_Query_triggered();
|
|
|
|
|
|
void on_actionPaste_lang_string_triggered();
|
|
|
|
|
|
void on_actionRefreshCatalog_triggered();
|
|
|
|
|
|
void on_actionRefreshCrud_triggered();
|
|
|
|
|
|
void on_actionSave_query_as_triggered();
|
|
|
|
|
|
void on_actionSave_copy_of_query_as_triggered();
|
|
|
|
|
|
void on_actionShow_connection_manager_triggered();
|
2018-12-30 15:46:15 +01:00
|
|
|
|
|
2019-08-16 08:29:27 +02:00
|
|
|
|
public:
|
|
|
|
|
|
virtual void setTitleForWidget(QWidget *widget, QString title, QString hint) override;
|
|
|
|
|
|
virtual void setIconForWidget(QWidget *widget, QIcon icon) override;
|
|
|
|
|
|
virtual std::shared_ptr<OpenDatabase> openDatabase() override;
|
|
|
|
|
|
virtual void showStatusBarMessage(QString message) override;
|
2021-06-16 19:20:03 +02:00
|
|
|
|
|
|
|
|
|
|
// QWidget interface
|
|
|
|
|
|
protected:
|
|
|
|
|
|
virtual void dragEnterEvent(QDragEnterEvent *event) override;
|
|
|
|
|
|
virtual void dropEvent(QDropEvent *event) override;
|
2022-04-08 20:16:42 +02:00
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T, class... Params>
|
|
|
|
|
|
void CallOnActiveQueryTool(T (QueryTool::*Func)(Params...), Params... args)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto query_tool = GetActiveQueryTool();
|
|
|
|
|
|
if (query_tool)
|
|
|
|
|
|
(query_tool->*Func)(&args...);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T, class... Params>
|
|
|
|
|
|
void CallOnActiveCrud(T (CrudTab::*Func)(Params...), Params... args)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto crud = GetActiveCrud();
|
|
|
|
|
|
if (crud)
|
|
|
|
|
|
(crud->*Func)(&args...);
|
|
|
|
|
|
}
|
2016-12-26 16:06:55 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|