2018-11-18 19:30:45 +01:00
|
|
|
|
#include "CreateDatabaseDialog.h"
|
2017-12-28 07:29:07 +01:00
|
|
|
|
#include "ui_CreateDatabaseDialog.h"
|
2022-05-24 18:54:13 +02:00
|
|
|
|
#include <QStringBuilder>
|
2017-12-28 07:29:07 +01:00
|
|
|
|
|
2022-05-24 18:54:13 +02:00
|
|
|
|
CreateDatabaseDialog::CreateDatabaseDialog(std::shared_ptr<PgDatabaseCatalog> catalog, QWidget *parent)
|
|
|
|
|
|
: QDialog(parent)
|
|
|
|
|
|
, ui(new Ui::CreateDatabaseDialog)
|
|
|
|
|
|
, m_catalog(catalog)
|
|
|
|
|
|
, definition(*catalog, InvalidOid, "")
|
2017-12-28 07:29:07 +01:00
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CreateDatabaseDialog::~CreateDatabaseDialog()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
2018-11-18 19:30:45 +01:00
|
|
|
|
|
|
|
|
|
|
//CREATE DATABASE name
|
|
|
|
|
|
// [ [ WITH ] [ OWNER [=] user_name ]
|
|
|
|
|
|
// [ TEMPLATE [=] template ]
|
|
|
|
|
|
// [ ENCODING [=] encoding ]
|
|
|
|
|
|
// [ LC_COLLATE [=] lc_collate ]
|
|
|
|
|
|
// [ LC_CTYPE [=] lc_ctype ]
|
|
|
|
|
|
// [ TABLESPACE [=] tablespace_name ]
|
|
|
|
|
|
// [ ALLOW_CONNECTIONS [=] allowconn ]
|
|
|
|
|
|
// [ CONNECTION LIMIT [=] connlimit ]
|
|
|
|
|
|
// [ IS_TEMPLATE [=] istemplate ] ]
|
2022-05-24 18:54:13 +02:00
|
|
|
|
|
|
|
|
|
|
void CreateDatabaseDialog::on_tabWidget_currentChanged(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index == 0)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// update the sql
|
|
|
|
|
|
definition.setObjectName(ui->name->text());
|
|
|
|
|
|
|
|
|
|
|
|
// definition.setOwnerOid()
|
|
|
|
|
|
definition.dbTemplate = ui->dbTemplate->currentText();
|
|
|
|
|
|
|
|
|
|
|
|
//QString drop_sql = definition.dropSql();
|
|
|
|
|
|
QString create_sql = definition.createSql();
|
|
|
|
|
|
ui->sqlPreview->setPlainText(create_sql);
|
|
|
|
|
|
|
|
|
|
|
|
// create_sql += "\n\n-- set Privileges\n";
|
|
|
|
|
|
// create_sql += definition.grantSql() % "\n";
|
|
|
|
|
|
|
|
|
|
|
|
// create_sql += "-- set comment\n";
|
|
|
|
|
|
// create_sql += definition.commentSql() % "\n";
|
|
|
|
|
|
|
|
|
|
|
|
// ui->sqlPreview->setPlainText(drop_sql % "\n\n" % create_sql);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|