DatabaseWindow no longer has to pass the config to QueryTab, QueryTab can now init itself from the supplied context.
This commit is contained in:
parent
2a7e505dbf
commit
a54a063c13
3 changed files with 8 additions and 15 deletions
|
|
@ -86,10 +86,9 @@ DatabaseWindow::~DatabaseWindow()
|
||||||
QueryTab* DatabaseWindow::newSqlPage()
|
QueryTab* DatabaseWindow::newSqlPage()
|
||||||
{
|
{
|
||||||
QueryTab *qt = new QueryTab(m_context);
|
QueryTab *qt = new QueryTab(m_context);
|
||||||
qt->setConfig(m_config, m_database->catalog());
|
|
||||||
addPage(qt, "Tab");
|
|
||||||
qt->newdoc();
|
qt->newdoc();
|
||||||
qt->focusEditor();
|
qt->focusEditor();
|
||||||
|
addPage(qt, "Tab");
|
||||||
return qt;
|
return qt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ QueryTab::QueryTab(IPluginContentWidgetContext *context_, QWidget *parent)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
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::onStateChanged, this, &QueryTab::connectionStateChanged);
|
||||||
connect(&m_dbConnection, &ASyncDBConnection::onNotice, this, &QueryTab::receiveNotice);
|
connect(&m_dbConnection, &ASyncDBConnection::onNotice, this, &QueryTab::receiveNotice);
|
||||||
|
|
||||||
|
|
@ -49,6 +52,8 @@ QueryTab::QueryTab(IPluginContentWidgetContext *context_, QWidget *parent)
|
||||||
&QueryParamListController::on_addParam);
|
&QueryParamListController::on_addParam);
|
||||||
connect(ui->removeButton, &QPushButton::clicked, m_queryParamListController,
|
connect(ui->removeButton, &QPushButton::clicked, m_queryParamListController,
|
||||||
&QueryParamListController::on_removeParam);
|
&QueryParamListController::on_removeParam);
|
||||||
|
|
||||||
|
context()->QueueTask([this]() { startConnect(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryTab::~QueryTab()
|
QueryTab::~QueryTab()
|
||||||
|
|
@ -58,14 +63,6 @@ QueryTab::~QueryTab()
|
||||||
delete ui;
|
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 QueryTab::canClose()
|
||||||
{
|
{
|
||||||
bool can_close;
|
bool can_close;
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,7 @@ public:
|
||||||
QueryTab(IPluginContentWidgetContext *context, QWidget *parent = nullptr);
|
QueryTab(IPluginContentWidgetContext *context, QWidget *parent = nullptr);
|
||||||
~QueryTab() override;
|
~QueryTab() override;
|
||||||
|
|
||||||
void setConfig(const ConnectionConfig &config, std::shared_ptr<PgDatabaseCatalog>cat);
|
|
||||||
|
|
||||||
void newdoc();
|
void newdoc();
|
||||||
// void open();
|
|
||||||
bool load(const QString &filename);
|
bool load(const QString &filename);
|
||||||
bool save();
|
bool save();
|
||||||
bool saveAs();
|
bool saveAs();
|
||||||
|
|
@ -50,7 +47,7 @@ public:
|
||||||
void explain(bool analyze);
|
void explain(bool analyze);
|
||||||
void cancel();
|
void cancel();
|
||||||
|
|
||||||
bool canClose();
|
bool canClose() override;
|
||||||
|
|
||||||
void copyQueryAsCString();
|
void copyQueryAsCString();
|
||||||
void copyQueryAsRawCppString();
|
void copyQueryAsRawCppString();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue