Using a global variable to register meta types instead of the main() function.

Prevents needing to have extra includes in the main.
This commit is contained in:
Eelke Klein 2017-09-03 14:37:12 +02:00
parent fe0681f19c
commit b9bc00a389
4 changed files with 36 additions and 10 deletions

View file

@ -45,6 +45,13 @@ Pgsql::Params QueryParamListController::params() const
return params;
}
bool QueryParamListController::empty() const
{
return m_paramList.rowCount() == 0;
}
void QueryParamListController::on_addParam()
{
m_paramList.insertRows(m_paramList.rowCount(), 1);
@ -195,12 +202,20 @@ void QueryTab::execute()
std::string cmd = getCommand();
m_stopwatch.start();
m_dbConnection.send(cmd,
m_queryParamListController->params(),
[this](std::shared_ptr<Pgsql::Result> res, qint64 elapsedms)
{
m_win->QueueTask([this, res, elapsedms]() { query_ready(res, elapsedms); });
});
if (m_queryParamListController->empty())
m_dbConnection.send(cmd,
[this](std::shared_ptr<Pgsql::Result> res, qint64 elapsedms)
{
m_win->QueueTask([this, res, elapsedms]() { query_ready(res, elapsedms); });
});
else
m_dbConnection.send(cmd,
m_queryParamListController->params(),
[this](std::shared_ptr<Pgsql::Result> res, qint64 elapsedms)
{
m_win->QueueTask([this, res, elapsedms]() { query_ready(res, elapsedms); });
});
}
}