From bb55ef12f35cdbc30807c6801893088e2cd7050b Mon Sep 17 00:00:00 2001 From: eelke Date: Fri, 29 Dec 2017 10:24:50 +0100 Subject: [PATCH] Removed unused DatabaseWindow --- pglab/DatabaseWindow.cpp | 102 --------------------------------------- pglab/DatabaseWindow.h | 43 ----------------- pglab/DatabaseWindow.ui | 56 --------------------- pglab/pglab.pro | 3 -- 4 files changed, 204 deletions(-) delete mode 100644 pglab/DatabaseWindow.cpp delete mode 100644 pglab/DatabaseWindow.h delete mode 100644 pglab/DatabaseWindow.ui diff --git a/pglab/DatabaseWindow.cpp b/pglab/DatabaseWindow.cpp deleted file mode 100644 index adf32bb..0000000 --- a/pglab/DatabaseWindow.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "DatabaseWindow.h" -#include "ui_DatabaseWindow.h" -#include -#include "GlobalIoService.h" - - -DatabaseWindow::DatabaseWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::DatabaseWindow), - m_dbConnection(*getGlobalAsioIoService()) -{ - ui->setupUi(this); - - m_dbConnection.setStateChangeReceiver( - [this](auto s) { QueueTask([this, s]() { connectionStateChanged(s); }); }); - m_dbConnection.setNoticeReceiver( - [this](auto n) { QueueTask([this, n]() { receiveNotice(n); }); }); -} - -DatabaseWindow::~DatabaseWindow() -{ - m_dbConnection.closeConnection(); - delete ui; -} - -void DatabaseWindow::setConfig(const ConnectionConfig &config) -{ - m_config = config; - QString title = "pglab - "; - title += m_config.name().c_str(); - setWindowTitle(title); - QueueTask([this]() { startConnect(); }); -} - -void DatabaseWindow::QueueTask(TSQueue::t_Callable c) -{ - m_taskQueue.add(c); - // Theoretically this needs to be only called if the queue was empty because otherwise it already would - // be busy emptying the queue. For now however I think it is safer to call it just to make sure. - QMetaObject::invokeMethod(this, "processCallableQueue", Qt::QueuedConnection); // queues on main thread -} - -void DatabaseWindow::processCallableQueue() -{ - if (!m_taskQueue.empty()) { - auto c = m_taskQueue.pop(); - c(); - if (!m_taskQueue.empty()) { - QTimer::singleShot(0, this, SLOT(processCallableQueue())); - } - } -} - -void DatabaseWindow::startConnect() -{ - m_dbConnection.setupConnection(m_config); -} - -void DatabaseWindow::connectionStateChanged(ASyncDBConnection::State state) -{ - QString status_str; - switch (state) { - case ASyncDBConnection::State::NotConnected: - status_str = tr("Geen verbinding"); - break; - case ASyncDBConnection::State::Connecting: - status_str = tr("Verbinden"); - break; - case ASyncDBConnection::State::Connected: - status_str = tr("Verbonden"); - break; - case ASyncDBConnection::State::QuerySend: - status_str = tr("Query verstuurd"); - break; - case ASyncDBConnection::State::CancelSend: - status_str = tr("Query geannuleerd"); - break; - case ASyncDBConnection::State::Terminating: - break; - } -// addLog(status_str); - statusBar()->showMessage(status_str); -} - - -void DatabaseWindow::receiveNotice(Pgsql::ErrorDetails notice) -{ -// QTextCursor cursor = ui->messagesEdit->textCursor(); -// cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); - -// QTextTable *table = cursor.insertTable(4, 2); -// if (table) { -// table->cellAt(1, 0).firstCursorPosition().insertText("State"); -// table->cellAt(1, 1).firstCursorPosition().insertText(QString::fromStdString(notice.state)); -// table->cellAt(2, 0).firstCursorPosition().insertText("Primary"); -// table->cellAt(2, 1).firstCursorPosition().insertText(QString::fromStdString(notice.messagePrimary)); -// table->cellAt(3, 0).firstCursorPosition().insertText("Detail"); -// table->cellAt(3, 1).firstCursorPosition().insertText(QString::fromStdString(notice.messageDetail)); -// } - -} - diff --git a/pglab/DatabaseWindow.h b/pglab/DatabaseWindow.h deleted file mode 100644 index d5a87d7..0000000 --- a/pglab/DatabaseWindow.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef DATABASEWINDOW_H -#define DATABASEWINDOW_H - -#include "ASyncDBConnection.h" -#include "tsqueue.h" -#include - - -namespace Ui { -class DatabaseWindow; -} - -class DatabaseWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit DatabaseWindow(QWidget *parent = 0); - ~DatabaseWindow(); - - void setConfig(const ConnectionConfig &config); - /* Meant to be called from other threads to pass a code block - * that has to be executed in the context of the thread of the window. - */ - void QueueTask(TSQueue::t_Callable c); - -private: - Ui::DatabaseWindow *ui; - TSQueue m_taskQueue; - ASyncDBConnection m_dbConnection; - ConnectionConfig m_config; - - - void connectionStateChanged(ASyncDBConnection::State state); - void receiveNotice(Pgsql::ErrorDetails notice); - - void startConnect(); -private slots: - - void processCallableQueue(); -}; - -#endif // DATABASEWINDOW_H diff --git a/pglab/DatabaseWindow.ui b/pglab/DatabaseWindow.ui deleted file mode 100644 index e3b9de2..0000000 --- a/pglab/DatabaseWindow.ui +++ /dev/null @@ -1,56 +0,0 @@ - - - DatabaseWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - - 0 - - - - Tab 1 - - - - - - - - - - Tab 2 - - - - - - - - - - 0 - 0 - 800 - 25 - - - - - - - - diff --git a/pglab/pglab.pro b/pglab/pglab.pro index 02a7389..72b46e7 100644 --- a/pglab/pglab.pro +++ b/pglab/pglab.pro @@ -34,7 +34,6 @@ SOURCES += main.cpp\ QueryExplainModel.cpp \ tsqueue.cpp \ CreateDatabaseDialog.cpp \ - DatabaseWindow.cpp \ ConnectionManagerWindow.cpp \ ConnectionListModel.cpp \ BackupRestore.cpp \ @@ -71,7 +70,6 @@ HEADERS += \ QueryExplainModel.h \ tsqueue.h \ CreateDatabaseDialog.h \ - DatabaseWindow.h \ ConnectionManagerWindow.h \ ConnectionListModel.h \ QueryTab.h \ @@ -103,7 +101,6 @@ HEADERS += \ NamespaceItemModel.h FORMS += mainwindow.ui \ - DatabaseWindow.ui \ ConnectionManagerWindow.ui \ CreateDatabaseDialog.ui \ DatabaseInspectorWidget.ui \