Some stuff I had on another machine and which might provide useful.
This commit is contained in:
parent
23e307f93a
commit
36e5526f5f
10 changed files with 325 additions and 13 deletions
14
pglab/CreateDatabaseDialog.cpp
Normal file
14
pglab/CreateDatabaseDialog.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "CreateDatabaseDialog.h"
|
||||
#include "ui_CreateDatabaseDialog.h"
|
||||
|
||||
CreateDatabaseDialog::CreateDatabaseDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CreateDatabaseDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
CreateDatabaseDialog::~CreateDatabaseDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
22
pglab/CreateDatabaseDialog.h
Normal file
22
pglab/CreateDatabaseDialog.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef CREATEDATABASEDIALOG_H
|
||||
#define CREATEDATABASEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class CreateDatabaseDialog;
|
||||
}
|
||||
|
||||
class CreateDatabaseDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CreateDatabaseDialog(QWidget *parent = 0);
|
||||
~CreateDatabaseDialog();
|
||||
|
||||
private:
|
||||
Ui::CreateDatabaseDialog *ui;
|
||||
};
|
||||
|
||||
#endif // CREATEDATABASEDIALOG_H
|
||||
162
pglab/CreateDatabaseDialog.ui
Normal file
162
pglab/CreateDatabaseDialog.ui
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CreateDatabaseDialog</class>
|
||||
<widget class="QDialog" name="CreateDatabaseDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>506</width>
|
||||
<height>371</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Template</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Encoding</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBox_2"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Collation order</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="comboBox_3"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Character classification</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="comboBox_4"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Connection limit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="spinBox"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Tablespace</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QComboBox" name="comboBox_5"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Owner</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QComboBox" name="comboBox_6"/>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>Template database</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_2">
|
||||
<property name="text">
|
||||
<string>Allow connections</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CreateDatabaseDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CreateDatabaseDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
@ -32,7 +32,7 @@ bool OpenDatabase::Init()
|
|||
auto kw = m_config.getKeywords();
|
||||
auto vals = m_config.getValues();
|
||||
if (conn.connect(kw, vals, 0)) {
|
||||
m_catalogue->loadAll(conn);
|
||||
m_catalogue->loadAll(conn, nullptr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "PgDatabaseCatalog.h"
|
||||
|
||||
#include "ASyncDBConnection.h"
|
||||
#include "PgAttributeContainer.h"
|
||||
#include "PgAuthIdContainer.h"
|
||||
#include "PgClassContainer.h"
|
||||
|
|
@ -11,6 +12,8 @@
|
|||
#include "Pgsql_Connection.h"
|
||||
#include "Pgsql_oids.h"
|
||||
|
||||
#include <QThread>
|
||||
|
||||
using namespace Pgsql;
|
||||
|
||||
QString getRoleNameFromOid(const PgDatabaseCatalog &cat, Oid oid)
|
||||
|
|
@ -100,17 +103,35 @@ PgDatabaseCatalog::~PgDatabaseCatalog()
|
|||
{
|
||||
}
|
||||
|
||||
void PgDatabaseCatalog::loadAll(Pgsql::Connection &conn)
|
||||
void PgDatabaseCatalog::loadAll(Pgsql::Connection &conn,
|
||||
std::function<bool(int, int)> progress_callback)
|
||||
{
|
||||
loadInfo(conn);
|
||||
if (progress_callback && !progress_callback(1, 9))
|
||||
return;
|
||||
load2(m_attributes, conn);
|
||||
if (progress_callback && !progress_callback(2, 9))
|
||||
return;
|
||||
load2(m_authIds, conn);
|
||||
if (progress_callback && !progress_callback(3, 9))
|
||||
return;
|
||||
load2(m_classes, conn);
|
||||
if (progress_callback && !progress_callback(4, 9))
|
||||
return;
|
||||
load2(m_constraints, conn);
|
||||
if (progress_callback && !progress_callback(5, 9))
|
||||
return;
|
||||
load2(m_databases, conn);
|
||||
if (progress_callback && !progress_callback(6, 9))
|
||||
return;
|
||||
load2(m_indexes, conn);
|
||||
if (progress_callback && !progress_callback(7, 9))
|
||||
return;
|
||||
load2(m_namespaces, conn);
|
||||
if (progress_callback && !progress_callback(8, 9))
|
||||
return;
|
||||
load2(m_types, conn);
|
||||
progress_callback && progress_callback(9, 9);
|
||||
}
|
||||
|
||||
void PgDatabaseCatalog::loadInfo(Pgsql::Connection &conn)
|
||||
|
|
@ -128,6 +149,7 @@ void PgDatabaseCatalog::loadInfo(Pgsql::Connection &conn)
|
|||
|
||||
void load(Pgsql::Connection &conn, IPgContainter &pg_cont)
|
||||
{
|
||||
QThread::msleep(400);
|
||||
std::string q = pg_cont.getLoadQuery();
|
||||
Pgsql::Result result = conn.query(q.c_str());
|
||||
if (result && result.resultStatus() == PGRES_TUPLES_OK)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <libpq-fe.h>
|
||||
#include <QString>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -26,22 +27,13 @@ public:
|
|||
PgDatabaseCatalog();
|
||||
PgDatabaseCatalog(const PgDatabaseCatalog&) = delete;
|
||||
PgDatabaseCatalog& operator = (const PgDatabaseCatalog&) = delete;
|
||||
|
||||
~PgDatabaseCatalog();
|
||||
|
||||
void loadAll(Pgsql::Connection &conn,
|
||||
std::function<bool(int, int)> progress_callback);
|
||||
|
||||
void loadAll(Pgsql::Connection &conn);
|
||||
void loadInfo(Pgsql::Connection &conn);
|
||||
|
||||
//void loadAttributes(Pgsql::Connection &conn);
|
||||
// void loadAuthIds(Pgsql::Connection &conn);
|
||||
// void loadClasses(Pgsql::Connection &conn);
|
||||
// void loadConstraints(Pgsql::Connection &conn);
|
||||
// void loadDatabases(Pgsql::Connection &conn);
|
||||
// void loadIndexes(Pgsql::Connection &conn);
|
||||
// void loadNamespaces(Pgsql::Connection &conn);
|
||||
// void loadTypes(Pgsql::Connection &conn);
|
||||
|
||||
const QString& serverVersionString() const;
|
||||
int serverVersion() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ SOURCES += main.cpp\
|
|||
QueryExplainModel.cpp \
|
||||
ASyncDBConnection.cpp \
|
||||
tsqueue.cpp \
|
||||
CreateDatabaseDialog.cpp \
|
||||
DatabaseWindow.cpp \
|
||||
ConnectionManagerWindow.cpp \
|
||||
ConnectionListModel.cpp \
|
||||
|
|
@ -89,6 +90,7 @@ HEADERS += \
|
|||
QueryExplainModel.h \
|
||||
ASyncDBConnection.h \
|
||||
tsqueue.h \
|
||||
CreateDatabaseDialog.h \
|
||||
DatabaseWindow.h \
|
||||
ConnectionManagerWindow.h \
|
||||
ConnectionListModel.h \
|
||||
|
|
@ -141,6 +143,7 @@ HEADERS += \
|
|||
FORMS += mainwindow.ui \
|
||||
DatabaseWindow.ui \
|
||||
ConnectionManagerWindow.ui \
|
||||
CreateDatabaseDialog.ui \
|
||||
DatabaseInspectorWidget.ui \
|
||||
TuplesResultWidget.ui \
|
||||
QueryTab.ui \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue