Removed unused DatabaseWindow
This commit is contained in:
parent
f4538069cb
commit
bb55ef12f3
4 changed files with 0 additions and 204 deletions
|
|
@ -1,102 +0,0 @@
|
|||
#include "DatabaseWindow.h"
|
||||
#include "ui_DatabaseWindow.h"
|
||||
#include <QTimer>
|
||||
#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));
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
#ifndef DATABASEWINDOW_H
|
||||
#define DATABASEWINDOW_H
|
||||
|
||||
#include "ASyncDBConnection.h"
|
||||
#include "tsqueue.h"
|
||||
#include <QMainWindow>
|
||||
|
||||
|
||||
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
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DatabaseWindow</class>
|
||||
<widget class="QMainWindow" name="DatabaseWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Tab 1</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Tab 2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -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 \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue