Module can register action Window adds this action to its menu Clicking the menu item for the action has the expected result But menu structure still needs work (everything is now put into one dropdown menu)
175 lines
4.1 KiB
C++
175 lines
4.1 KiB
C++
#ifndef MAINWINDOW_H
|
|
#define MAINWINDOW_H
|
|
|
|
#include "ASyncDBConnection.h"
|
|
#include "ConnectionConfig.h"
|
|
#include "OpenDatabase.h"
|
|
#include <QLabel>
|
|
#include <QLabel>
|
|
#include <QRunnable>
|
|
#include <QSocketNotifier>
|
|
#include <memory>
|
|
#include <future>
|
|
#include "Pgsql_Connection.h"
|
|
#include "ControllableTask.h"
|
|
#include <chrono>
|
|
#include <deque>
|
|
#include <mutex>
|
|
|
|
#include <QMutex>
|
|
#include <QWaitCondition>
|
|
#include <QMainWindow>
|
|
#include <QFuture>
|
|
#include <QFutureWatcher>
|
|
|
|
namespace Ui {
|
|
class DatabaseWindow;
|
|
}
|
|
|
|
namespace Pgsql {
|
|
class Connection;
|
|
}
|
|
|
|
class MenuAction;
|
|
class QueryTab;
|
|
class MasterController;
|
|
class QCloseEvent;
|
|
class OpenDatabase;
|
|
class PgClass;
|
|
class PluginContentWidget;
|
|
|
|
namespace DatabaseWindow_details {
|
|
class DatabaseWindowContentContext;
|
|
}
|
|
|
|
class LMainWindow : public QMainWindow {
|
|
Q_OBJECT
|
|
public:
|
|
|
|
LMainWindow(QWidget *parent = nullptr);
|
|
|
|
void initModuleMenus();
|
|
protected:
|
|
|
|
DatabaseWindow_details::DatabaseWindowContentContext *m_context;
|
|
|
|
void addModuleMenuActions();
|
|
|
|
private:
|
|
QMenu *m_fileMenu = nullptr;
|
|
|
|
void addMenuAction(const MenuAction &ma);
|
|
};
|
|
|
|
|
|
/** This is the class for windows that handle tasks for a specific database/catalog
|
|
*
|
|
*/
|
|
class DatabaseWindow : public LMainWindow {
|
|
Q_OBJECT
|
|
public:
|
|
DatabaseWindow(MasterController *master, QWidget *parent);
|
|
~DatabaseWindow();
|
|
|
|
void setConfig(const ConnectionConfig &config);
|
|
|
|
std::shared_ptr<OpenDatabase> getDatabase() { return m_database; }
|
|
|
|
void newCodeGenPage(QString query, std::shared_ptr<const Pgsql::Result> dbres);
|
|
|
|
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(PluginContentWidget* page, QString caption);
|
|
private:
|
|
|
|
Ui::DatabaseWindow *ui;
|
|
|
|
ConnectionConfig m_config;
|
|
std::shared_ptr<OpenDatabase> m_database;
|
|
|
|
MasterController *m_masterController;
|
|
PluginContentWidget *m_previousPage = nullptr; ///< tracks which pages buttons were previously being displayed
|
|
|
|
// 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:
|
|
LoadCatalog(ConnectionConfig config)
|
|
: m_config(config)
|
|
{}
|
|
|
|
OpenDatabase::OpenDatabaseSPtr run(TaskControl& ) override
|
|
{
|
|
auto res = OpenDatabase::createOpenDatabase(m_config);
|
|
return res.get();
|
|
}
|
|
|
|
private:
|
|
ConnectionConfig m_config;
|
|
};
|
|
|
|
QFutureWatcher<LoadCatalog::Result> loadWatcher;
|
|
|
|
QueryTab *GetActiveQueryTab();
|
|
|
|
void closeEvent(QCloseEvent *event);
|
|
void showEvent(QShowEvent *event);
|
|
QueryTab *newSqlPage();
|
|
void newCreateTablePage();
|
|
|
|
|
|
/// Called when a page is completely removed from the QTabWidget
|
|
void removePage(PluginContentWidget *page);
|
|
|
|
void addToolBarButtonsForPage(PluginContentWidget *page);
|
|
void removeToolBarButtonsForPage(PluginContentWidget *page);
|
|
//class PageData
|
|
private slots:
|
|
|
|
void catalogLoaded();
|
|
|
|
void on_actionLoad_SQL_triggered();
|
|
void on_actionSave_SQL_triggered();
|
|
void on_actionExport_data_triggered();
|
|
void on_actionClose_triggered();
|
|
void on_actionAbout_triggered();
|
|
void on_actionSave_SQL_as_triggered();
|
|
void on_actionSave_copy_of_SQL_as_triggered();
|
|
void on_actionNew_SQL_triggered();
|
|
void on_tabWidget_tabCloseRequested(int index);
|
|
void on_actionShow_connection_manager_triggered();
|
|
void on_actionCopy_triggered();
|
|
void on_actionCopy_as_C_string_triggered();
|
|
void on_actionCopy_as_raw_Cpp_string_triggered();
|
|
void on_tabWidget_currentChanged(int index);
|
|
void on_actionGenerate_code_triggered();
|
|
};
|
|
|
|
#endif // MAINWINDOW_H
|