DatabaseWindow no longer has to pass the config to QueryTab, QueryTab can now init itself from the supplied context.

This commit is contained in:
eelke 2018-12-30 15:44:05 +01:00
parent 2a7e505dbf
commit a54a063c13
3 changed files with 8 additions and 15 deletions

View file

@ -86,10 +86,9 @@ DatabaseWindow::~DatabaseWindow()
QueryTab* DatabaseWindow::newSqlPage()
{
QueryTab *qt = new QueryTab(m_context);
qt->setConfig(m_config, m_database->catalog());
addPage(qt, "Tab");
qt->newdoc();
qt->focusEditor();
addPage(qt, "Tab");
return qt;
}

View file

@ -30,6 +30,9 @@ QueryTab::QueryTab(IPluginContentWidgetContext *context_, QWidget *parent)
{
ui->setupUi(this);
m_config = context()->getDatabase()->config();
m_catalog = context()->getDatabase()->catalog();
connect(&m_dbConnection, &ASyncDBConnection::onStateChanged, this, &QueryTab::connectionStateChanged);
connect(&m_dbConnection, &ASyncDBConnection::onNotice, this, &QueryTab::receiveNotice);
@ -49,6 +52,8 @@ QueryTab::QueryTab(IPluginContentWidgetContext *context_, QWidget *parent)
&QueryParamListController::on_addParam);
connect(ui->removeButton, &QPushButton::clicked, m_queryParamListController,
&QueryParamListController::on_removeParam);
context()->QueueTask([this]() { startConnect(); });
}
QueryTab::~QueryTab()
@ -58,14 +63,6 @@ QueryTab::~QueryTab()
delete ui;
}
void QueryTab::setConfig(const ConnectionConfig &config,
std::shared_ptr<PgDatabaseCatalog> cat)
{
m_config = config;
m_catalog = cat;
context()->QueueTask([this]() { startConnect(); });
}
bool QueryTab::canClose()
{
bool can_close;

View file

@ -37,10 +37,7 @@ public:
QueryTab(IPluginContentWidgetContext *context, QWidget *parent = nullptr);
~QueryTab() override;
void setConfig(const ConnectionConfig &config, std::shared_ptr<PgDatabaseCatalog>cat);
void newdoc();
// void open();
bool load(const QString &filename);
bool save();
bool saveAs();
@ -50,7 +47,7 @@ public:
void explain(bool analyze);
void cancel();
bool canClose();
bool canClose() override;
void copyQueryAsCString();
void copyQueryAsRawCppString();