Moved QueryParamListController to its own translation unit.
This commit is contained in:
parent
3a13b7ffb4
commit
3bf1ef4fe0
5 changed files with 88 additions and 75 deletions
49
pglab/QueryParamListController.cpp
Normal file
49
pglab/QueryParamListController.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include "QueryParamListController.h"
|
||||
#include "OpenDatabase.h"
|
||||
#include "PgDatabaseCatalogue.h"
|
||||
#include "PgTypeContainer.h"
|
||||
#include <QTableView>
|
||||
|
||||
|
||||
QueryParamListController::QueryParamListController(QTableView *tv,
|
||||
OpenDatabase *opendb, QWidget *parent)
|
||||
: QObject(parent)
|
||||
, paramTableView(tv)
|
||||
, m_openDatabase(opendb)
|
||||
{
|
||||
if (opendb) {
|
||||
m_typeDelegate.setTypeSelectionModel(opendb->typeSelectionModel());
|
||||
}
|
||||
|
||||
paramTableView->setModel(&m_paramList);
|
||||
paramTableView->setItemDelegateForColumn(1, &m_typeDelegate);
|
||||
}
|
||||
|
||||
Pgsql::Params QueryParamListController::params() const
|
||||
{
|
||||
Pgsql::Params params;
|
||||
auto types = m_openDatabase->catalogue()->types();
|
||||
for (auto e : m_paramList) {
|
||||
Oid oid = types->getByName(e.type).oid;
|
||||
params.add(e.value, oid);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
bool QueryParamListController::empty() const
|
||||
{
|
||||
|
||||
return m_paramList.rowCount() == 0;
|
||||
}
|
||||
|
||||
void QueryParamListController::on_addParam()
|
||||
{
|
||||
m_paramList.insertRows(m_paramList.rowCount(), 1);
|
||||
}
|
||||
|
||||
void QueryParamListController::on_removeParam()
|
||||
{
|
||||
auto rc = m_paramList.rowCount();
|
||||
if (rc > 0)
|
||||
m_paramList.removeRows(rc-1, 1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue