Query, explain, cancel buttons are now enabled/disabled when the state of the connection changes.
This commit is contained in:
parent
d19741f111
commit
a32e2c83ca
3 changed files with 32 additions and 14 deletions
|
|
@ -177,6 +177,11 @@ void MainWindow::connectionStateChanged(ASyncDBConnection::State state)
|
|||
}
|
||||
addLog(status_str);
|
||||
statusBar()->showMessage(status_str);
|
||||
|
||||
bool connected = ASyncDBConnection::State::Connected == state;
|
||||
ui->actionExecute_SQL->setEnabled(connected);
|
||||
ui->actionExplain_Analyze->setEnabled(connected);
|
||||
ui->actionCancel->setEnabled(ASyncDBConnection::State::QuerySend == state);
|
||||
}
|
||||
|
||||
void MainWindow::startConnect()
|
||||
|
|
@ -188,20 +193,23 @@ void MainWindow::startConnect()
|
|||
|
||||
void MainWindow::performQuery()
|
||||
{
|
||||
addLog("Query clicked");
|
||||
if (m_dbConnection.state() == ASyncDBConnection::State::Connected) {
|
||||
addLog("Query clicked");
|
||||
|
||||
ui->ResultView->setModel(nullptr);
|
||||
resultModel.reset();
|
||||
ui->messagesEdit->clear();
|
||||
ui->ResultView->setModel(nullptr);
|
||||
resultModel.reset();
|
||||
ui->messagesEdit->clear();
|
||||
|
||||
QString command = ui->queryEdit->toPlainText();
|
||||
std::string cmd = command.toUtf8().data();
|
||||
startTimer();
|
||||
m_dbConnection.send(cmd,
|
||||
[this](std::shared_ptr<Pgsql::Result> res)
|
||||
{
|
||||
QueueTask([this, res]() { query_ready(res); });
|
||||
});
|
||||
|
||||
QString command = ui->queryEdit->toPlainText();
|
||||
std::string cmd = command.toUtf8().data();
|
||||
startTimer();
|
||||
m_dbConnection.send(cmd,
|
||||
[this](std::shared_ptr<Pgsql::Result> res)
|
||||
{
|
||||
QueueTask([this, res]() { query_ready(res); });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::query_ready(std::shared_ptr<Pgsql::Result> dbres)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue