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:
parent
fe0681f19c
commit
b9bc00a389
4 changed files with 36 additions and 10 deletions
|
|
@ -4,6 +4,20 @@
|
||||||
|
|
||||||
using namespace boost::asio;
|
using namespace boost::asio;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class registerMetaTypes {
|
||||||
|
public:
|
||||||
|
registerMetaTypes()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<ASyncDBConnection::State>();
|
||||||
|
qRegisterMetaType<Pgsql::ErrorDetails>();
|
||||||
|
}
|
||||||
|
} registerMetaTypes_instance;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ASyncDBConnection::ASyncDBConnection(boost::asio::io_service &ios)
|
ASyncDBConnection::ASyncDBConnection(boost::asio::io_service &ios)
|
||||||
: m_asioSock(ios)
|
: m_asioSock(ios)
|
||||||
{}
|
{}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,13 @@ Pgsql::Params QueryParamListController::params() const
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QueryParamListController::empty() const
|
||||||
|
{
|
||||||
|
|
||||||
|
return m_paramList.rowCount() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QueryParamListController::on_addParam()
|
void QueryParamListController::on_addParam()
|
||||||
{
|
{
|
||||||
m_paramList.insertRows(m_paramList.rowCount(), 1);
|
m_paramList.insertRows(m_paramList.rowCount(), 1);
|
||||||
|
|
@ -195,6 +202,14 @@ void QueryTab::execute()
|
||||||
|
|
||||||
std::string cmd = getCommand();
|
std::string cmd = getCommand();
|
||||||
m_stopwatch.start();
|
m_stopwatch.start();
|
||||||
|
|
||||||
|
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_dbConnection.send(cmd,
|
||||||
m_queryParamListController->params(),
|
m_queryParamListController->params(),
|
||||||
[this](std::shared_ptr<Pgsql::Result> res, qint64 elapsedms)
|
[this](std::shared_ptr<Pgsql::Result> res, qint64 elapsedms)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ public:
|
||||||
QueryParamListController(QTableView *tv, OpenDatabase *opendb, QWidget *parent);
|
QueryParamListController(QTableView *tv, OpenDatabase *opendb, QWidget *parent);
|
||||||
|
|
||||||
Pgsql::Params params() const;
|
Pgsql::Params params() const;
|
||||||
|
bool empty() const;
|
||||||
public slots:
|
public slots:
|
||||||
void on_addParam();
|
void on_addParam();
|
||||||
void on_removeParam();
|
void on_removeParam();
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@
|
||||||
#endif
|
#endif
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "GlobalIoService.h"
|
#include "GlobalIoService.h"
|
||||||
#include "ASyncDBConnection.h"
|
|
||||||
#include "Pgsql_Result.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
@ -24,8 +22,6 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qRegisterMetaType<ASyncDBConnection::State>();
|
|
||||||
qRegisterMetaType<Pgsql::ErrorDetails>();
|
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue