WIP createdb dialog
This commit is contained in:
parent
c20427e10d
commit
d3080a08bb
10 changed files with 113 additions and 45 deletions
|
|
@ -1,9 +1,12 @@
|
|||
#include "CreateDatabaseDialog.h"
|
||||
#include "ui_CreateDatabaseDialog.h"
|
||||
#include <QStringBuilder>
|
||||
|
||||
CreateDatabaseDialog::CreateDatabaseDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CreateDatabaseDialog)
|
||||
CreateDatabaseDialog::CreateDatabaseDialog(std::shared_ptr<PgDatabaseCatalog> catalog, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::CreateDatabaseDialog)
|
||||
, m_catalog(catalog)
|
||||
, definition(*catalog, InvalidOid, "")
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
|
@ -23,3 +26,29 @@ CreateDatabaseDialog::~CreateDatabaseDialog()
|
|||
// [ ALLOW_CONNECTIONS [=] allowconn ]
|
||||
// [ CONNECTION LIMIT [=] connlimit ]
|
||||
// [ IS_TEMPLATE [=] istemplate ] ]
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
#include "catalog\PgDatabase.h"
|
||||
|
||||
class PgDatabaseCatalog;
|
||||
|
||||
namespace Ui {
|
||||
class CreateDatabaseDialog;
|
||||
}
|
||||
|
|
@ -12,11 +16,17 @@ class CreateDatabaseDialog : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CreateDatabaseDialog(QWidget *parent = 0);
|
||||
CreateDatabaseDialog(std::shared_ptr<PgDatabaseCatalog> catalog, QWidget *parent = 0);
|
||||
~CreateDatabaseDialog();
|
||||
|
||||
private slots:
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::CreateDatabaseDialog *ui;
|
||||
|
||||
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
||||
PgDatabase definition;
|
||||
};
|
||||
|
||||
#endif // CREATEDATABASEDIALOG_H
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>506</width>
|
||||
<height>371</height>
|
||||
<height>542</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -15,11 +15,11 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="Input" native="true">
|
||||
<widget class="QWidget" name="Input">
|
||||
<attribute name="title">
|
||||
<string>Input</string>
|
||||
</attribute>
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
<widget class="QLineEdit" name="name"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
<widget class="QComboBox" name="dbTemplate"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="comboBox_2"/>
|
||||
<widget class="QComboBox" name="encoding"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="comboBox_3"/>
|
||||
<widget class="QComboBox" name="collationOrder"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
|
|
@ -72,7 +72,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="comboBox_4"/>
|
||||
<widget class="QComboBox" name="characterClassification"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QSpinBox" name="spinBox"/>
|
||||
<widget class="QSpinBox" name="connectionLimit"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
|
|
@ -92,10 +92,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QComboBox" name="comboBox_5"/>
|
||||
<widget class="QComboBox" name="tablespace"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBox_6"/>
|
||||
<widget class="QComboBox" name="owner"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
|
|
@ -105,14 +105,14 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<widget class="QCheckBox" name="templateDatabase">
|
||||
<property name="text">
|
||||
<string>Template database</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_2">
|
||||
<widget class="QCheckBox" name="allowConnections">
|
||||
<property name="text">
|
||||
<string>Allow connections</string>
|
||||
</property>
|
||||
|
|
@ -124,6 +124,11 @@
|
|||
<attribute name="title">
|
||||
<string>SQL</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="CodeEditor" name="sqlPreview"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -139,6 +144,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CodeEditor</class>
|
||||
<extends>QPlainTextEdit</extends>
|
||||
<header>codeeditor\CodeEditor.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,23 @@
|
|||
#include "DatabasesPage.h"
|
||||
|
||||
#include "catalog/models/DatabasesTableModel.h"
|
||||
#include "widgets/SqlCodePreview.h"
|
||||
#include "SqlFormattingUtils.h"
|
||||
#include "catalog/PgDatabaseCatalog.h"
|
||||
#include "util/PgLabTableView.h"
|
||||
#include <CreateDatabaseDialog.h>
|
||||
#include <QAction>
|
||||
#include <QStringBuilder>
|
||||
|
||||
|
||||
DatabasesPage::DatabasesPage(std::shared_ptr<OpenDatabase> opendatabase, QWidget * parent)
|
||||
: QSplitter(Qt::Horizontal, parent)
|
||||
, m_databasesTableView(this, new DatabasesTableModel(opendatabase, this))
|
||||
{
|
||||
auto tv = m_databasesTableView.tableView();
|
||||
tv->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
tv->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
auto createDbAction = new QAction("Create database", this);
|
||||
tv->addAction(createDbAction);
|
||||
|
||||
addWidget(tv);
|
||||
m_tableSql = new SqlCodePreview(this);
|
||||
|
|
@ -21,6 +25,12 @@ DatabasesPage::DatabasesPage(std::shared_ptr<OpenDatabase> opendatabase, QWidget
|
|||
|
||||
connect(m_databasesTableView.tableView()->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||
this, &DatabasesPage::databaseSelectionChanged);
|
||||
connect(createDbAction, &QAction::triggered,
|
||||
[this](auto checked)
|
||||
{
|
||||
auto dlg = new CreateDatabaseDialog(this->m_catalog, this);
|
||||
dlg->show();
|
||||
});
|
||||
}
|
||||
|
||||
void DatabasesPage::setCatalog(std::shared_ptr<PgDatabaseCatalog> cat)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ public:
|
|||
|
||||
private:
|
||||
PgLabTableViewHelper<DatabasesTableModel> m_databasesTableView;
|
||||
// QTabWidget *m_detailsTabs = nullptr;
|
||||
SqlCodePreview *m_tableSql = nullptr;
|
||||
|
||||
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue