The enitities and containers of the catalog now go into catalog subfolder Models go into model
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#include "QueryParamListController.h"
|
|
#include "OpenDatabase.h"
|
|
#include "catalog/PgDatabaseCatalog.h"
|
|
#include "catalog/PgTypeContainer.h"
|
|
#include <QTableView>
|
|
|
|
|
|
QueryParamListController::QueryParamListController(QTableView *tv,
|
|
std::shared_ptr<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->catalog()->types();
|
|
for (auto e : m_paramList.GetParams()) {
|
|
// some types have two names that are in seperate fields
|
|
// this function only checks one field currently :(
|
|
// for example integer vs int4, bigint vs int8
|
|
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);
|
|
}
|