2017-12-09 20:21:22 +01:00
|
|
|
|
#ifndef OPENDATABASE_H
|
2017-02-01 18:01:02 +01:00
|
|
|
|
#define OPENDATABASE_H
|
|
|
|
|
|
|
2017-08-23 13:27:23 +02:00
|
|
|
|
#include "ConnectionConfig.h"
|
2019-01-29 19:41:27 +01:00
|
|
|
|
#include <QException>
|
2017-12-09 20:21:22 +01:00
|
|
|
|
#include <memory>
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
2017-12-10 10:35:46 +01:00
|
|
|
|
class PgDatabaseCatalog;
|
2017-02-04 11:55:49 +01:00
|
|
|
|
class TypeSelectionItemModel;
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
2019-01-29 19:41:27 +01:00
|
|
|
|
class OpenDatabaseException : public QException {
|
|
|
|
|
|
public:
|
|
|
|
|
|
OpenDatabaseException(QString message)
|
|
|
|
|
|
: m_message(std::move(message))
|
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
QString text() const { return m_message; }
|
|
|
|
|
|
|
|
|
|
|
|
void raise() const override { throw *this; }
|
|
|
|
|
|
OpenDatabaseException *clone() const override { return new OpenDatabaseException(*this); }
|
|
|
|
|
|
private:
|
|
|
|
|
|
QString m_message;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2017-02-01 20:00:03 +01:00
|
|
|
|
/** Instances of this class represent a single database on which atleast one
|
|
|
|
|
|
* window is opened. This class is used to track details about that database.
|
|
|
|
|
|
*/
|
2017-12-25 10:31:58 +01:00
|
|
|
|
class OpenDatabase {
|
2017-02-01 18:01:02 +01:00
|
|
|
|
public:
|
2017-12-25 10:31:58 +01:00
|
|
|
|
using OpenDatabaseSPtr = std::shared_ptr<OpenDatabase>;
|
2019-01-29 19:41:27 +01:00
|
|
|
|
static OpenDatabaseSPtr createOpenDatabase(const ConnectionConfig &cfg);
|
2017-12-25 10:31:58 +01:00
|
|
|
|
|
2017-02-01 18:01:02 +01:00
|
|
|
|
OpenDatabase(const OpenDatabase &) = delete;
|
|
|
|
|
|
OpenDatabase& operator=(const OpenDatabase &) = delete;
|
|
|
|
|
|
~OpenDatabase();
|
|
|
|
|
|
|
2018-11-25 09:05:01 +01:00
|
|
|
|
std::shared_ptr<PgDatabaseCatalog> catalog();
|
2017-02-07 21:39:45 +01:00
|
|
|
|
TypeSelectionItemModel* typeSelectionModel();
|
2019-10-06 13:52:45 +02:00
|
|
|
|
void refresh();
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
2018-01-08 20:45:52 +01:00
|
|
|
|
const ConnectionConfig& config() const { return m_config; }
|
2017-02-01 18:01:02 +01:00
|
|
|
|
private:
|
|
|
|
|
|
ConnectionConfig m_config;
|
2018-11-25 09:05:01 +01:00
|
|
|
|
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
2017-02-01 18:01:02 +01:00
|
|
|
|
|
2017-02-04 11:55:49 +01:00
|
|
|
|
TypeSelectionItemModel *m_typeSelectionModel = nullptr;
|
|
|
|
|
|
|
2017-12-25 10:31:58 +01:00
|
|
|
|
OpenDatabase(const ConnectionConfig& cfg);
|
2018-12-23 08:43:43 +01:00
|
|
|
|
void Init();
|
2017-02-01 18:01:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // OPENDATABASE_H
|