pgLab/pglab/MainWindow.h

122 lines
2.8 KiB
C
Raw Normal View History

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "ASyncDBConnection.h"
#include "ConnectionConfig.h"
#include "OpenDatabase.h"
#include <QLabel>
#include "ASyncWindow.h"
#include <QLabel>
#include <QRunnable>
#include <QSocketNotifier>
#include <memory>
2016-12-27 21:22:49 +01:00
#include <future>
#include "Pgsql_Connection.h"
#include "QueuedBackgroundTask.h"
#include <chrono>
#include <deque>
#include <mutex>
#include <QMutex>
#include <QWaitCondition>
namespace Ui {
class MainWindow;
}
namespace Pgsql {
class Connection;
}
class QueryTab;
class MasterController;
class QCloseEvent;
class OpenDatabase;
class PgClass;
class PlgPage;
class MainWindow : public ASyncWindow {
Q_OBJECT
public:
explicit MainWindow(MasterController *master, QWidget *parent);
~MainWindow();
void setConfig(const ConnectionConfig &config);
std::shared_ptr<OpenDatabase> getDatabase() { return m_database; }
void newCrudPage(const PgClass &table);
private:
Ui::MainWindow *ui;
ConnectionConfig m_config;
std::shared_ptr<OpenDatabase> m_database;
MasterController *m_masterController;
PlgPage *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;
QueryTab *GetActiveQueryTab();
void closeEvent(QCloseEvent *event);
void showEvent(QShowEvent *event);
QueryTab *newSqlPage();
void catalogLoaded();
/// 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
private slots:
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();
2017-02-05 08:23:06 +01:00
void on_actionCopy_as_C_string_triggered();
void on_actionCopy_as_raw_Cpp_string_triggered();
void on_tabWidget_currentChanged(int index);
};
#endif // MAINWINDOW_H