OpenDatabase::createOpenDatabase now uses QException derived exception to report failure. This makes it possible to catch the exception in a background thread and rethrow it when the Future is read. Which makes it possible for the database window to properly report the problem.
74 lines
1.5 KiB
C++
74 lines
1.5 KiB
C++
#ifndef MAINWINDOW_H
|
|
#define MAINWINDOW_H
|
|
|
|
#include "plugin_support/LMainWindow.h"
|
|
#include "ConnectionConfig.h"
|
|
#include "OpenDatabase.h"
|
|
#include "Pgsql_Connection.h"
|
|
#include "ControllableTask.h"
|
|
#include <QFutureWatcher>
|
|
#include <memory>
|
|
|
|
namespace Pgsql {
|
|
class Connection;
|
|
}
|
|
|
|
class MasterController;
|
|
class QCloseEvent;
|
|
class OpenDatabase;
|
|
class PgClass;
|
|
|
|
class QTabWidget;
|
|
|
|
|
|
/** 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);
|
|
|
|
private:
|
|
|
|
ConnectionConfig m_config;
|
|
std::shared_ptr<OpenDatabase> m_database;
|
|
|
|
MasterController *m_masterController;
|
|
|
|
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();
|
|
|
|
private slots:
|
|
|
|
void catalogLoaded();
|
|
|
|
void on_actionAbout_triggered();
|
|
void on_actionShow_connection_manager_triggered();
|
|
void on_actionCopy_triggered();
|
|
};
|
|
|
|
#endif // MAINWINDOW_H
|