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));
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue