From edc6df25daadc36aa0f9e9c654650451af08a268 Mon Sep 17 00:00:00 2001 From: Eelke Klein Date: Mon, 26 Dec 2016 16:06:55 +0100 Subject: [PATCH] Initial commit. Contains a simple query tool. --- .gitignore | 5 ++ Ivory.pro | 34 ++++++++ PgsqlConn.cpp | 139 ++++++++++++++++++++++++++++++ PgsqlConn.h | 196 ++++++++++++++++++++++++++++++++++++++++++ main.cpp | 11 +++ mainwindow.cpp | 51 +++++++++++ mainwindow.h | 32 +++++++ mainwindow.ui | 74 ++++++++++++++++ queryresultmodel.cpp | 58 +++++++++++++ queryresultmodel.h | 23 +++++ serverproperties.cpp | 14 +++ serverproperties.h | 22 +++++ serverproperties.ui | 161 ++++++++++++++++++++++++++++++++++ sqlhighlighter.cpp | 60 +++++++++++++ sqlhighlighter.h | 40 +++++++++ sqlparser.cpp | 30 +++++++ sqlparser.h | 11 +++ ui_mainwindow.h | 114 ++++++++++++++++++++++++ ui_serverproperties.h | 170 ++++++++++++++++++++++++++++++++++++ 19 files changed, 1245 insertions(+) create mode 100644 .gitignore create mode 100644 Ivory.pro create mode 100644 PgsqlConn.cpp create mode 100644 PgsqlConn.h create mode 100644 main.cpp create mode 100644 mainwindow.cpp create mode 100644 mainwindow.h create mode 100644 mainwindow.ui create mode 100644 queryresultmodel.cpp create mode 100644 queryresultmodel.h create mode 100644 serverproperties.cpp create mode 100644 serverproperties.h create mode 100644 serverproperties.ui create mode 100644 sqlhighlighter.cpp create mode 100644 sqlhighlighter.h create mode 100644 sqlparser.cpp create mode 100644 sqlparser.h create mode 100644 ui_mainwindow.h create mode 100644 ui_serverproperties.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f73482c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +debug/ +release/ +Makefile +Makefile.Debug +Makefile.Release \ No newline at end of file diff --git a/Ivory.pro b/Ivory.pro new file mode 100644 index 0000000..cf576eb --- /dev/null +++ b/Ivory.pro @@ -0,0 +1,34 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2016-11-11T09:17:13 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = Ivory +TEMPLATE = app + +INCLUDEPATH += C:\prog\include + +LIBS += c:\prog\lib\libpq.lib + +SOURCES += main.cpp\ + mainwindow.cpp \ + serverproperties.cpp \ + sqlparser.cpp \ + PgsqlConn.cpp \ + queryresultmodel.cpp \ + sqlhighlighter.cpp + +HEADERS += mainwindow.h \ + serverproperties.h \ + sqlparser.h \ + PgsqlConn.h \ + queryresultmodel.h \ + sqlhighlighter.h + +FORMS += mainwindow.ui \ + serverproperties.ui diff --git a/PgsqlConn.cpp b/PgsqlConn.cpp new file mode 100644 index 0000000..4573178 --- /dev/null +++ b/PgsqlConn.cpp @@ -0,0 +1,139 @@ +#include "PgsqlConn.h" + +#include + + +using namespace Pgsql; + + +Result::Result(PGresult *res) + : result(res) +{ + if (res == nullptr) { + throw std::runtime_error("Passing nullptr to Result::Result is not allowed"); + } +} + +Result::~Result() +{ + PQclear(result); +} + + +Result::Result(Result &&rhs) + : result(rhs.result) +{ + rhs.result = nullptr; +} + +Result& Result::operator=(Result &&rhs) +{ + if (result) { + PQclear(result); + } + result = rhs.result; + rhs.result = nullptr; + return *this; +} + +Result::operator bool() const +{ + return result != nullptr; +} + +ExecStatusType Result::getResultStatus() +{ + return PQresultStatus(result); +} + +std::string Result::getResStatus() +{ +// return PQresStatus(result); + return ""; +} + +int Result::getRows() const +{ + return PQntuples(result); +} + +int Result::getCols() const +{ + return PQnfields(result); +} + +const char* const Result::getColName(int idx) const +{ + return PQfname(result, idx); +} + +const char * Result::getVal(int col, int row) const +{ + return PQgetvalue(result, row, col); +} + + +Connection::Connection() = default; + +Connection::~Connection() +{ + close(); +} + +Connection::Connection(Connection &&rhs) + : conn(rhs.conn) +{ + rhs.conn = nullptr; +} + +Connection& Connection::operator=(Connection &&rhs) +{ + close(); + conn = rhs.conn; + rhs.conn = nullptr; + return *this; +} + +void Connection::close() +{ + if (conn) { + PQfinish(conn); + conn = nullptr; + } +} + + +bool Connection::connect(const char *params) +{ + bool result = false; + conn = PQconnectdb(params); + if (conn) { + ConnStatusType status = PQstatus(conn); + result = (status == CONNECTION_OK); + } + return result; +} + + +std::string Connection::getErrorMessage() const +{ + std::string result; + if (conn) { + result = PQerrorMessage(conn); + } + else { + result = "no connection"; + } + return result; +} + +Result Connection::Query(const char * query) +{ + PGresult *result = PQexec(conn, query); + if (result) { + return Result(result); + } + else { + throw std::runtime_error("Failed to allocate result object"); + } +} diff --git a/PgsqlConn.h b/PgsqlConn.h new file mode 100644 index 0000000..e1d712f --- /dev/null +++ b/PgsqlConn.h @@ -0,0 +1,196 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace Pgsql { + + /* + This library has multiple layers. + + Layer 1 delivers lowlevel C++ wrappers for the basic libpq functionality. Adding + automatic resource management. + + */ + + class ConnectionParams { + public: + std::string host; + std::string hostaddr; + unsigned short port = 5432; + std::string dbname; + std::string user; + std::string password; + int connect_timeout = -1; ///< -1 omit (ie uses default) + std::string application_name; + + }; + + /** Non-copyable but movable wrapper for a postgresql result. */ + class Result { + public: +// class iterator { +// public: +// iterator(Result &r, int rw) +// : result(r), row(rw) +// {} + +// iterator operator++() +// { +// iterator t(*this); +// ++row; +// return t; +// } + +// iterator& operator++(int) +// { +// ++row; +// return *this; +// } + +// bool operator!=(const iterator &rhs) +// { +// assert() +// } + +// private: +// Result &result; +// int row; +// }; + + Result(PGresult *result); + ~Result(); + + Result(const Result &rhs) = delete; + Result& operator=(const Result &rhs) = delete; + + Result(Result &&rhs); + Result& operator=(Result &&rhs); + + operator bool() const; + + ExecStatusType getResultStatus(); + std::string getResStatus(); + + + int getRows() const; + int getCols() const; + + const char* const getColName(int idx) const; + + const char * getVal(int col, int row) const; + +// iterator begin(); + private: + PGresult *result = nullptr; + }; + + class Connection { + public: + Connection(); + ~Connection(); + + Connection(const Connection &rhs) = delete; + Connection& operator=(const Connection &rhs) = delete; + + Connection(Connection &&rhs); + Connection& operator=(Connection &&rhs); + +// void connect(const ConnectionParams ¶ms); + bool connect(const char *params); + bool connect(const QString ¶ms) + { + return connect(params.toUtf8().data()); + } + + void close(); + + std::string getErrorMessage() const; + + Result Query(const char * query); + Result Query(const QString &query) + { + return Query(query.toUtf8().data()); + } + + private: + PGconn *conn = nullptr; + }; + + class Canceller { + public: + void Cancel(); + }; + + + + class Field { + public: + + std::string getName() const; + + private: + //Tuples tuples; + int field; + // + + }; + + class Tuples { + public: + int getRowCount() const; + int getColCount() const; + + Field getField(const std::string &fname); + Field getField(const int idx); + + class const_iterator { + public: + const_iterator& operator++(); + }; + + void rewind(); + + + }; + + class OkResult: public Result { + public: + /** If the result is a data result then returns an interface for processing this data. + + The returned interface remains valid as long as this OkResult exists. + */ + Tuples* hasTuples(); + }; + +// class ErrorResult: public Result { +// +// }; + +// class ITransaction { +// public: +// +// Canceller Query(std::string query, +// std::function on_success, +// std::function on_cancelled, +// std::function on_error); +// +// Canceller Query(std::string query, +// std::function on_success, +// std::function on_cancelled, +// std::function on_error); +// +// +// void Rollback( +// std::function on_success, +// std::function on_error); +// void Commit( +// std::function on_success, +// std::function on_cancelled, +// std::function on_error); +// +// }; +} diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..a080bdd --- /dev/null +++ b/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..46a30fc --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,51 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include "QueryResultModel.h" +#include "sqlhighlighter.h" + +namespace pg = Pgsql; + +const char * test_query = + "SELECT id, program, version, lic_bedrijf, lic_plaats, " + "lic_number, callstack_crc_1, callstack_crc_2, callstack_crc_3, exception_class, " + "exception_message \nFROM foutrapport"; + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + QFont font; + font.setFamily("Source Code Pro"); + font.setFixedPitch(true); + font.setPointSize(10); + ui->queryEdit->setFont(font); + highlighter.reset(new SqlHighlighter(ui->queryEdit->document())); + ui->queryEdit->setPlainText(test_query); + + ui->connectionStringEdit->setText("user=postgres dbname=foutrapport password=admin"); + + //performQuery(); + + QAction *action = ui->mainToolBar->addAction("execute"); + connect(action, &QAction::triggered, this, &MainWindow::performQuery); +} + +MainWindow::~MainWindow() +{} + +void MainWindow::performQuery() +{ + ui->ResultView->setModel(nullptr); + resultModel.reset(); + + QString connstr = ui->connectionStringEdit->text(); + pg::Connection conn; + if (conn.connect(connstr + " application_name=Ivory client_encoding=utf8")) { + pg::Result dbres = conn.Query(ui->queryEdit->toPlainText()); + resultModel.reset(new QueryResultModel(this , std::move(dbres))); + ui->ResultView->setModel(resultModel.get()); + } +} diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..c8ffca6 --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,32 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include + +class QueryResultModel; +class SqlHighlighter; + +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + std::unique_ptr ui; + std::unique_ptr highlighter; + + std::unique_ptr resultModel; + +private slots: + void performQuery(); +}; + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..7dace49 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,74 @@ + + + MainWindow + + + + 0 + 0 + 726 + 589 + + + + MainWindow + + + + + + + + + + Qt::Vertical + + + + + + Source Sans Pro + 10 + + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + + + + + + + + 0 + 0 + 726 + 26 + + + + + test + + + + + + + TopToolBarArea + + + false + + + + + + + + diff --git a/queryresultmodel.cpp b/queryresultmodel.cpp new file mode 100644 index 0000000..b154b3f --- /dev/null +++ b/queryresultmodel.cpp @@ -0,0 +1,58 @@ +#include "queryresultmodel.h" + +QueryResultModel::QueryResultModel(QObject *parent, Pgsql::Result &&r) + : QAbstractTableModel(parent) + , result(std::move(r)) +{} + + +int QueryResultModel::rowCount(const QModelIndex &) const +{ + int r = result.getRows(); + return r; +} + +int QueryResultModel::columnCount(const QModelIndex &) const +{ + int r = result.getCols(); + return r; +} + +QVariant QueryResultModel::data(const QModelIndex &index, int role) const +{ + QVariant r; + int rij = index.row(); + int col = index.column(); + if (role == Qt::DisplayRole) { + + r = QString(result.getVal(col, rij)); + } + else if (role == Qt::TextAlignmentRole) { + if (col == 0) { + r = Qt::AlignRight + Qt::AlignVCenter; + } + else { + r = Qt::AlignLeft + Qt::AlignVCenter; + } + } + return r; +} + +QVariant QueryResultModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + QVariant r; + if (role == Qt::DisplayRole) { + if (orientation == Qt::Horizontal) { + r = QString(result.getColName(section)); + } + else { + r = QString::number(section + 1); + } + } + return r; +} + +//Qt::ItemFlags QueryResultModel::flags(const QModelIndex &) const +//{ +// return Qt::ItemIsUserCheckable; +//} diff --git a/queryresultmodel.h b/queryresultmodel.h new file mode 100644 index 0000000..1d52f85 --- /dev/null +++ b/queryresultmodel.h @@ -0,0 +1,23 @@ +#ifndef QUERYRESULTMODEL_H +#define QUERYRESULTMODEL_H + +#include +#include "PgsqlConn.h" + +class QueryResultModel : public QAbstractTableModel +{ + Q_OBJECT +public: + QueryResultModel(QObject *parent, Pgsql::Result &&r); + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; +// virtual Qt::ItemFlags flags(const QModelIndex &index) const override; + +private: + Pgsql::Result result; +}; + +#endif // QUERYRESULTMODEL_H diff --git a/serverproperties.cpp b/serverproperties.cpp new file mode 100644 index 0000000..a644735 --- /dev/null +++ b/serverproperties.cpp @@ -0,0 +1,14 @@ +#include "serverproperties.h" +#include "ui_serverproperties.h" + +ServerProperties::ServerProperties(QWidget *parent) : + QDialog(parent), + ui(new Ui::ServerProperties) +{ + ui->setupUi(this); +} + +ServerProperties::~ServerProperties() +{ + delete ui; +} diff --git a/serverproperties.h b/serverproperties.h new file mode 100644 index 0000000..0baff08 --- /dev/null +++ b/serverproperties.h @@ -0,0 +1,22 @@ +#ifndef SERVERPROPERTIES_H +#define SERVERPROPERTIES_H + +#include + +namespace Ui { +class ServerProperties; +} + +class ServerProperties : public QDialog +{ + Q_OBJECT + +public: + explicit ServerProperties(QWidget *parent = 0); + ~ServerProperties(); + +private: + Ui::ServerProperties *ui; +}; + +#endif // SERVERPROPERTIES_H diff --git a/serverproperties.ui b/serverproperties.ui new file mode 100644 index 0000000..7fa8bb4 --- /dev/null +++ b/serverproperties.ui @@ -0,0 +1,161 @@ + + + ServerProperties + + + + 0 + 0 + 326 + 233 + + + + Dialog + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Name + + + + + + + + + + Host + + + + + + + + + + Port + + + + + + + 65535 + + + + + + + Maintenance DB + + + + + + + true + + + 0 + + + + postgres + + + + + template1 + + + + + + + + Username + + + + + + + + + + Password + + + + + + + QLineEdit::Password + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + ServerProperties + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ServerProperties + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/sqlhighlighter.cpp b/sqlhighlighter.cpp new file mode 100644 index 0000000..876ae74 --- /dev/null +++ b/sqlhighlighter.cpp @@ -0,0 +1,60 @@ +#include "SqlHighlighter.h" + +static const wchar_t *keywords[] = { + L"as", L"alter", L"all", L"and", L"any", L"by", L"column", L"create", L"database", L"from", L"full", L"group", L"having", + L"in", L"inner", L"join", L"left", L"not", L"or", L"order", L"outer", L"right", L"select", L"table", L"where" +}; +//static auto types = R"-(bigint|boolean|char|character varying|date|int[248]|integer|numeric|smallint|time|timestamp(?:tz)?|timestamp(?:\s+with\s+timezone)?|varchar)-"; +//static auto err = R"-(left|right|inner|outer)-"; + + static_assert(sizeof(keywords)/4 == 25, + "sizeof keywords"); + + +SqlHighlighter::SqlHighlighter(QTextDocument *parent) + : QSyntaxHighlighter(parent) +{ +// { +// static auto keywords = R"-(as|alter|all|and|any|by|column|create|database|from|group|having|in|not|or|order|select|table|where|(?:(?:inner|(?:left|right|full)(\s+outer)?)\s+)?join)-"; +// static auto types = R"-(bigint|boolean|char|character varying|date|int[248]|integer|numeric|smallint|time|timestamp(?:tz)?|timestamp(?:\s+with\s+timezone)?|varchar)-"; +// static auto err = R"-(left|right|inner|outer)-"; + +// QTextCharFormat errFormat; +// errFormat.setForeground(QColor(255, 128, 128)); +// errFormat.setFontWeight(QFont::Bold); +// highlightingRules.emplace_back(QRegExp(err, Qt::CaseInsensitive), errFormat); + +// QTextCharFormat keywordFormat; +// keywordFormat.setForeground(QColor(128, 128, 255)); +// keywordFormat.setFontWeight(QFont::Bold); +// highlightingRules.emplace_back(QRegExp(keywords, Qt::CaseInsensitive), keywordFormat); + +// QTextCharFormat typesFormat; +// typesFormat.setForeground(QColor(128, 255, 128)); +// typesFormat.setFontWeight(QFont::Bold); +// highlightingRules.emplace_back(QRegExp(types, Qt::CaseInsensitive), typesFormat); + +// } +} + +void NextBasicToken(const QString &in, int ofs, int &start, int &length) +{ + // Basically parses for white space and chops based on white space + // it does also recognize comments and quoted strings/identifiers + +} + +void SqlHighlighter::highlightBlock(const QString &text) +{ +// foreach (const HighlightingRule &rule, highlightingRules) { +// QRegExp expression(rule.pattern); +// int index = expression.indexIn(text); +// while (index >= 0) { +// int length = expression.matchedLength(); +// setFormat(index, length, rule.format); +// index = expression.indexIn(text, index + length); +// } +// } + setCurrentBlockState(0); +} + diff --git a/sqlhighlighter.h b/sqlhighlighter.h new file mode 100644 index 0000000..6cccf3b --- /dev/null +++ b/sqlhighlighter.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include + +#include + +class SqlHighlighter : public QSyntaxHighlighter +{ + Q_OBJECT + +public: + SqlHighlighter(QTextDocument *parent = 0); + +protected: + void highlightBlock(const QString &text) Q_DECL_OVERRIDE; + +private: +// struct HighlightingRule +// { +// QRegExp pattern; +// QTextCharFormat format; + +// HighlightingRule(const QRegExp ®ex, const QTextCharFormat &f) +// : pattern(regex), format(f) +// {} +// }; + //QVector highlightingRules; +// std::vector highlightingRules; + +// QRegExp commentStartExpression; + // QRegExp commentEndExpression; + +// QTextCharFormat keywordFormat; +// QTextCharFormat classFormat; +// QTextCharFormat singleLineCommentFormat; +// QTextCharFormat multiLineCommentFormat; +// QTextCharFormat quotationFormat; +// QTextCharFormat functionFormat; +}; diff --git a/sqlparser.cpp b/sqlparser.cpp new file mode 100644 index 0000000..3d960b0 --- /dev/null +++ b/sqlparser.cpp @@ -0,0 +1,30 @@ +#include "sqlparser.h" + +/** Responsible for splitting the query into logical elements. + * + * It first uses common seperators to split the input, then it tries + * to determine if the fields it gets have a special meaning. + * + * However because SQL is very forgiving about the use of keywords + * as names. + * + * The lexical analyzer does however distinguish between + * - symbols/keywords (symbols might be schema, table, columns, functions etc) + * - numbers + * - strings + * - quoted symbol (a symbol between "" must be the name of something) + * + * seperators + * whitespace + * special chars ;,. + * operators + */ +class LexicalAnalyser { +public: + +}; + +SqlParser::SqlParser() +{ + +} diff --git a/sqlparser.h b/sqlparser.h new file mode 100644 index 0000000..4dc8b4d --- /dev/null +++ b/sqlparser.h @@ -0,0 +1,11 @@ +#ifndef SQLPARSER_H +#define SQLPARSER_H + + +class SqlParser +{ +public: + SqlParser(); +}; + +#endif // SQLPARSER_H \ No newline at end of file diff --git a/ui_mainwindow.h b/ui_mainwindow.h new file mode 100644 index 0000000..383f82b --- /dev/null +++ b/ui_mainwindow.h @@ -0,0 +1,114 @@ +/******************************************************************************** +** Form generated from reading UI file 'mainwindow.ui' +** +** Created by: Qt User Interface Compiler version 5.7.1 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_MAINWINDOW_H +#define UI_MAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_MainWindow +{ +public: + QWidget *centralWidget; + QVBoxLayout *verticalLayout; + QLineEdit *connectionStringEdit; + QSplitter *splitter; + QTextEdit *queryEdit; + QTableView *ResultView; + QMenuBar *menuBar; + QMenu *menuTest; + QToolBar *mainToolBar; + QStatusBar *statusBar; + + void setupUi(QMainWindow *MainWindow) + { + if (MainWindow->objectName().isEmpty()) + MainWindow->setObjectName(QStringLiteral("MainWindow")); + MainWindow->resize(726, 589); + centralWidget = new QWidget(MainWindow); + centralWidget->setObjectName(QStringLiteral("centralWidget")); + verticalLayout = new QVBoxLayout(centralWidget); + verticalLayout->setSpacing(6); + verticalLayout->setContentsMargins(11, 11, 11, 11); + verticalLayout->setObjectName(QStringLiteral("verticalLayout")); + connectionStringEdit = new QLineEdit(centralWidget); + connectionStringEdit->setObjectName(QStringLiteral("connectionStringEdit")); + + verticalLayout->addWidget(connectionStringEdit); + + splitter = new QSplitter(centralWidget); + splitter->setObjectName(QStringLiteral("splitter")); + splitter->setOrientation(Qt::Vertical); + queryEdit = new QTextEdit(splitter); + queryEdit->setObjectName(QStringLiteral("queryEdit")); + splitter->addWidget(queryEdit); + ResultView = new QTableView(splitter); + ResultView->setObjectName(QStringLiteral("ResultView")); + QFont font; + font.setFamily(QStringLiteral("Source Sans Pro")); + font.setPointSize(10); + ResultView->setFont(font); + ResultView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + ResultView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); + splitter->addWidget(ResultView); + + verticalLayout->addWidget(splitter); + + MainWindow->setCentralWidget(centralWidget); + menuBar = new QMenuBar(MainWindow); + menuBar->setObjectName(QStringLiteral("menuBar")); + menuBar->setGeometry(QRect(0, 0, 726, 26)); + menuTest = new QMenu(menuBar); + menuTest->setObjectName(QStringLiteral("menuTest")); + MainWindow->setMenuBar(menuBar); + mainToolBar = new QToolBar(MainWindow); + mainToolBar->setObjectName(QStringLiteral("mainToolBar")); + MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar); + statusBar = new QStatusBar(MainWindow); + statusBar->setObjectName(QStringLiteral("statusBar")); + MainWindow->setStatusBar(statusBar); + + menuBar->addAction(menuTest->menuAction()); + + retranslateUi(MainWindow); + + QMetaObject::connectSlotsByName(MainWindow); + } // setupUi + + void retranslateUi(QMainWindow *MainWindow) + { + MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", Q_NULLPTR)); + menuTest->setTitle(QApplication::translate("MainWindow", "test", Q_NULLPTR)); + } // retranslateUi + +}; + +namespace Ui { + class MainWindow: public Ui_MainWindow {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_MAINWINDOW_H diff --git a/ui_serverproperties.h b/ui_serverproperties.h new file mode 100644 index 0000000..bd7000d --- /dev/null +++ b/ui_serverproperties.h @@ -0,0 +1,170 @@ +/******************************************************************************** +** Form generated from reading UI file 'serverproperties.ui' +** +** Created by: Qt User Interface Compiler version 5.7.1 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_SERVERPROPERTIES_H +#define UI_SERVERPROPERTIES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_ServerProperties +{ +public: + QVBoxLayout *verticalLayout; + QFrame *frame; + QFormLayout *formLayout; + QLabel *label; + QLineEdit *lineEdit; + QLabel *label_2; + QLineEdit *lineEdit_2; + QLabel *label_3; + QSpinBox *spinBox; + QLabel *label_4; + QComboBox *comboBox; + QLabel *label_5; + QLineEdit *lineEdit_3; + QLabel *label_6; + QLineEdit *lineEdit_4; + QDialogButtonBox *buttonBox; + + void setupUi(QDialog *ServerProperties) + { + if (ServerProperties->objectName().isEmpty()) + ServerProperties->setObjectName(QStringLiteral("ServerProperties")); + ServerProperties->resize(326, 233); + verticalLayout = new QVBoxLayout(ServerProperties); + verticalLayout->setObjectName(QStringLiteral("verticalLayout")); + frame = new QFrame(ServerProperties); + frame->setObjectName(QStringLiteral("frame")); + frame->setFrameShape(QFrame::StyledPanel); + frame->setFrameShadow(QFrame::Raised); + formLayout = new QFormLayout(frame); + formLayout->setObjectName(QStringLiteral("formLayout")); + label = new QLabel(frame); + label->setObjectName(QStringLiteral("label")); + + formLayout->setWidget(0, QFormLayout::LabelRole, label); + + lineEdit = new QLineEdit(frame); + lineEdit->setObjectName(QStringLiteral("lineEdit")); + + formLayout->setWidget(0, QFormLayout::FieldRole, lineEdit); + + label_2 = new QLabel(frame); + label_2->setObjectName(QStringLiteral("label_2")); + + formLayout->setWidget(1, QFormLayout::LabelRole, label_2); + + lineEdit_2 = new QLineEdit(frame); + lineEdit_2->setObjectName(QStringLiteral("lineEdit_2")); + + formLayout->setWidget(1, QFormLayout::FieldRole, lineEdit_2); + + label_3 = new QLabel(frame); + label_3->setObjectName(QStringLiteral("label_3")); + + formLayout->setWidget(2, QFormLayout::LabelRole, label_3); + + spinBox = new QSpinBox(frame); + spinBox->setObjectName(QStringLiteral("spinBox")); + spinBox->setMaximum(65535); + + formLayout->setWidget(2, QFormLayout::FieldRole, spinBox); + + label_4 = new QLabel(frame); + label_4->setObjectName(QStringLiteral("label_4")); + + formLayout->setWidget(3, QFormLayout::LabelRole, label_4); + + comboBox = new QComboBox(frame); + comboBox->setObjectName(QStringLiteral("comboBox")); + comboBox->setEditable(true); + + formLayout->setWidget(3, QFormLayout::FieldRole, comboBox); + + label_5 = new QLabel(frame); + label_5->setObjectName(QStringLiteral("label_5")); + + formLayout->setWidget(4, QFormLayout::LabelRole, label_5); + + lineEdit_3 = new QLineEdit(frame); + lineEdit_3->setObjectName(QStringLiteral("lineEdit_3")); + + formLayout->setWidget(4, QFormLayout::FieldRole, lineEdit_3); + + label_6 = new QLabel(frame); + label_6->setObjectName(QStringLiteral("label_6")); + + formLayout->setWidget(5, QFormLayout::LabelRole, label_6); + + lineEdit_4 = new QLineEdit(frame); + lineEdit_4->setObjectName(QStringLiteral("lineEdit_4")); + lineEdit_4->setEchoMode(QLineEdit::Password); + + formLayout->setWidget(5, QFormLayout::FieldRole, lineEdit_4); + + + verticalLayout->addWidget(frame); + + buttonBox = new QDialogButtonBox(ServerProperties); + buttonBox->setObjectName(QStringLiteral("buttonBox")); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + verticalLayout->addWidget(buttonBox); + + + retranslateUi(ServerProperties); + QObject::connect(buttonBox, SIGNAL(accepted()), ServerProperties, SLOT(accept())); + QObject::connect(buttonBox, SIGNAL(rejected()), ServerProperties, SLOT(reject())); + + comboBox->setCurrentIndex(0); + + + QMetaObject::connectSlotsByName(ServerProperties); + } // setupUi + + void retranslateUi(QDialog *ServerProperties) + { + ServerProperties->setWindowTitle(QApplication::translate("ServerProperties", "Dialog", Q_NULLPTR)); + label->setText(QApplication::translate("ServerProperties", "Name", Q_NULLPTR)); + label_2->setText(QApplication::translate("ServerProperties", "Host", Q_NULLPTR)); + label_3->setText(QApplication::translate("ServerProperties", "Port", Q_NULLPTR)); + label_4->setText(QApplication::translate("ServerProperties", "Maintenance DB", Q_NULLPTR)); + comboBox->clear(); + comboBox->insertItems(0, QStringList() + << QApplication::translate("ServerProperties", "postgres", Q_NULLPTR) + << QApplication::translate("ServerProperties", "template1", Q_NULLPTR) + ); + label_5->setText(QApplication::translate("ServerProperties", "Username", Q_NULLPTR)); + label_6->setText(QApplication::translate("ServerProperties", "Password", Q_NULLPTR)); + } // retranslateUi + +}; + +namespace Ui { + class ServerProperties: public Ui_ServerProperties {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_SERVERPROPERTIES_H