Connection manager can now open a query window for selected connection.

Query window has now buttons with icons made in the designer for better looks.
Depending on received responses from the database the tabcontrol with the message, data and explain tab
now switches to the appropriate tab.
This commit is contained in:
Eelke Klein 2017-01-15 21:01:40 +01:00
parent 88fcc0338d
commit d19741f111
26 changed files with 408 additions and 116 deletions

View file

@ -1,6 +1,8 @@
#include "connectionmanagerwindow.h"
#include "ui_connectionmanagerwindow.h"
#include "mainwindow.h"
#include <QDataWidgetMapper>
#include <QMessageBox>
#include <QStandardItemModel>
#include "connectionlistmodel.h"
@ -42,24 +44,15 @@ void ConnectionManagerWindow::on_currentChanged(const QModelIndex &current,
const QModelIndex &previous)
{
int currow = current.row();
// int prevrow = previous.row();
m_mapper->setCurrentIndex(currow);
// ui->lineEdit->setText(QString::number(currow));
// ui->lineEdit_2->setText(QString::number(prevrow));
// if(selection.indexes().isEmpty()) {
// clearMyView();
// } else {
// displayModelIndexInMyView(selection.indexes().first());
// }
}
void ConnectionManagerWindow::on_actionDelete_connection_triggered()
{
auto ci = ui->listView->selectionModel()->currentIndex();
if (ci.isValid()) {
//m_listModel->removeRow(ci.row());
m_listModel->removeRow(ci.row());
}
}
@ -76,3 +69,27 @@ void ConnectionManagerWindow::setupWidgetMappings()
m_mapper->addMapping(ui->edtDbname, 6);
m_mapper->toFirst();
}
void ConnectionManagerWindow::on_actionConnect_triggered()
{
// Open a window for this connection, maybe we should first check the connection?
auto ci = ui->listView->selectionModel()->currentIndex();
auto cc = m_listModel->get(ci.row());
if (cc.valid()) {
auto w = new MainWindow;
w->setAttribute( Qt::WA_DeleteOnClose );
w->setConfig(cc.get());
w->show();
}
}
void ConnectionManagerWindow::on_actionQuit_application_triggered()
{
auto res = QMessageBox::question(this, "pglab",
tr("Close ALL windows?"), QMessageBox::Yes, QMessageBox::No);
if (res == QMessageBox::Yes) {
QApplication::quit();
}
//closeAllWindows();
}