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
|
|
@ -15,54 +15,11 @@
|
|||
#include "json/json.h"
|
||||
#include "MainWindow.h"
|
||||
#include "OpenDatabase.h"
|
||||
#include "PgTypeContainer.h"
|
||||
#include "PgDatabaseCatalogue.h"
|
||||
#include "QueryParamListController.h"
|
||||
#include "util.h"
|
||||
#include "GlobalIoService.h"
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -295,21 +252,15 @@ bool QueryTab::continueWithoutSavingWarning()
|
|||
bool QueryTab::saveSqlTo(const QString &filename)
|
||||
{
|
||||
bool result = false;
|
||||
QFileInfo fileinfo(filename);
|
||||
|
||||
|
||||
QFile file(filename);
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
QTextStream stream(&file);
|
||||
stream.setCodec("utf-8");
|
||||
QString text = ui->queryEdit->toPlainText();
|
||||
stream << text;
|
||||
/*
|
||||
QTextDocument *doc = ui->queryEdit->document();
|
||||
QTextBlock block = doc->firstBlock();
|
||||
while (stream.status() == QTextStream::Ok && block.isValid()) {
|
||||
QString plain = block.text();
|
||||
stream << plain << "\n";
|
||||
block = block.next();
|
||||
}
|
||||
*/
|
||||
|
||||
stream.flush();
|
||||
if (stream.status() == QTextStream::Ok) {
|
||||
|
|
@ -320,6 +271,7 @@ bool QueryTab::saveSqlTo(const QString &filename)
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
QString QueryTab::promptUserForSaveSqlFilename()
|
||||
{
|
||||
QString home_dir = QStandardPaths::locate(QStandardPaths::HomeLocation, "", QStandardPaths::LocateDirectory);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue