From 60bbb4c4450389fd6e574c93c6016b9fe66ea997 Mon Sep 17 00:00:00 2001 From: eelke Date: Sat, 10 Apr 2021 14:44:10 +0200 Subject: [PATCH] Cleanup old seperate server window. --- pglab/ConnectionController.cpp | 17 +--- pglab/ConnectionController.h | 1 - pglab/ConnectionManagerWindow.cpp | 6 -- pglab/ConnectionManagerWindow.h | 1 - pglab/ConnectionManagerWindow.ui | 21 ++-- pglab/ServerWindow.cpp | 55 ----------- pglab/ServerWindow.h | 34 ------- pglab/ServerWindow.ui | 156 ------------------------------ pglab/pglab.pro | 3 - 9 files changed, 7 insertions(+), 287 deletions(-) delete mode 100644 pglab/ServerWindow.cpp delete mode 100644 pglab/ServerWindow.h delete mode 100644 pglab/ServerWindow.ui diff --git a/pglab/ConnectionController.cpp b/pglab/ConnectionController.cpp index 4e05cc3..b75358d 100644 --- a/pglab/ConnectionController.cpp +++ b/pglab/ConnectionController.cpp @@ -4,7 +4,6 @@ #include "ConnectionListModel.h" #include "PasswordManager.h" #include "DatabaseWindow.h" -#include "ServerWindow.h" #include "BackupDialog.h" #include "PasswordPromptDialog.h" #include "ConnectionConfigurationWidget.h" @@ -72,7 +71,7 @@ void ConnectionController::openBackupDlgForConnection(QModelIndex index) if (config) { if (retrieveConnectionPassword(*config)) { m_connectionTreeModel->save(*config); - auto w = new BackupDialog(nullptr); //new ServerWindow(this, nullptr); + auto w = new BackupDialog(nullptr); w->setAttribute( Qt::WA_DeleteOnClose ); w->setConfig(*config); w->show(); @@ -138,20 +137,6 @@ std::shared_ptr ConnectionController::passwordManager() return m_passwordManager; } -void ConnectionController::openServerWindowForConnection(QModelIndex index) -{ - auto config = ConnectionTreeModel::getConfigFromModelIndex(index); - if (config) { - if (retrieveConnectionPassword(*config)) { - m_connectionTreeModel->save(*config); - auto w = new ServerWindow(m_masterController, nullptr); - w->setAttribute( Qt::WA_DeleteOnClose ); - w->setConfig(*config); - w->show(); - } - } -} - bool ConnectionController::retrieveConnectionPassword(ConnectionConfig &cc) { auto enc_pwd = cc.encodedPassword(); diff --git a/pglab/ConnectionController.h b/pglab/ConnectionController.h index 35e4e88..7057bdf 100644 --- a/pglab/ConnectionController.h +++ b/pglab/ConnectionController.h @@ -27,7 +27,6 @@ public: void showConnectionManager(); void openSqlWindowForConnection(QModelIndex index); - void openServerWindowForConnection(QModelIndex index); void openBackupDlgForConnection(QModelIndex index); /// Starts the form for creating a new conncetion. diff --git a/pglab/ConnectionManagerWindow.cpp b/pglab/ConnectionManagerWindow.cpp index d7fb587..0e57c48 100644 --- a/pglab/ConnectionManagerWindow.cpp +++ b/pglab/ConnectionManagerWindow.cpp @@ -73,12 +73,6 @@ void ConnectionManagerWindow::on_actionBackup_database_triggered() m_connectionController->openBackupDlgForConnection(ci); } -void ConnectionManagerWindow::on_actionManage_server_triggered() -{ - auto ci = ui->treeView->selectionModel()->currentIndex(); - m_connectionController->openServerWindowForConnection(ci); -} - void ConnectionManagerWindow::connectionActivated(const QModelIndex &index) { if (index.isValid()) { diff --git a/pglab/ConnectionManagerWindow.h b/pglab/ConnectionManagerWindow.h index 5112163..b740ed1 100644 --- a/pglab/ConnectionManagerWindow.h +++ b/pglab/ConnectionManagerWindow.h @@ -28,7 +28,6 @@ private slots: void on_actionConnect_triggered(); void on_actionQuit_application_triggered(); void on_actionBackup_database_triggered(); - void on_actionManage_server_triggered(); void connectionActivated(const QModelIndex &index); diff --git a/pglab/ConnectionManagerWindow.ui b/pglab/ConnectionManagerWindow.ui index ec23549..64ab8e6 100644 --- a/pglab/ConnectionManagerWindow.ui +++ b/pglab/ConnectionManagerWindow.ui @@ -67,7 +67,6 @@ QToolButton { false - @@ -80,7 +79,7 @@ QToolButton { - + :/icons/add_connection.png:/icons/add_connection.png @@ -89,7 +88,7 @@ QToolButton { - + :/icons/delete_connection.png :/icons/delete_connection.png:/icons/delete_connection.png @@ -117,7 +116,7 @@ QToolButton { - + :/icons/backup_database.png :/icons/backups.png:/icons/backup_database.png @@ -125,16 +124,6 @@ QToolButton { Backup database - - - - :/icons/manage_server.png - - - - Manage server - - @@ -176,6 +165,8 @@ QToolButton { - + + + diff --git a/pglab/ServerWindow.cpp b/pglab/ServerWindow.cpp deleted file mode 100644 index 49ba67c..0000000 --- a/pglab/ServerWindow.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "ServerWindow.h" -#include "ui_ServerWindow.h" -#include "OpenDatabase.h" -#include "DatabasesTableModel.h" -#include "RolesTableModel.h" -#include "catalog/PgDatabaseCatalog.h" -#include -#include - -ServerWindow::ServerWindow(MasterController *master, QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::ServerWindow) - , m_masterController(master) -{ - ui->setupUi(this); - - m_databasesModel = new DatabasesTableModel(this); - auto databasesSortFilter = new QSortFilterProxyModel(this); - databasesSortFilter->setSourceModel(m_databasesModel); - ui->databasesTableView->setModel(databasesSortFilter); - ui->databasesTableView->setSortingEnabled(true); - - m_rolesModel = new RolesTableModel(this); - auto rolesSortFilter = new QSortFilterProxyModel(this); - rolesSortFilter->setSourceModel(m_rolesModel); - ui->rolesTableView->setModel(rolesSortFilter); - ui->rolesTableView->setSortingEnabled(true); -} - -ServerWindow::~ServerWindow() -{ - delete ui; -} - -void ServerWindow::setConfig(const ConnectionConfig &config) -{ - m_config = config; - try { - m_database = OpenDatabase::createOpenDatabase(config); - auto cat = m_database->catalog(); - if (cat) { - m_databasesModel->setDatabaseList(cat); - ui->databasesTableView->resizeColumnsToContents(); - - m_rolesModel->setRoleList(cat->authIds()); - ui->rolesTableView->resizeColumnsToContents(); - } - } - catch (const OpenDatabaseException &ex) { - qWarning() << ex.text(); - } - QString title = "pglab - "; - title += m_config.name(); - setWindowTitle(title); -} diff --git a/pglab/ServerWindow.h b/pglab/ServerWindow.h deleted file mode 100644 index d9a9d39..0000000 --- a/pglab/ServerWindow.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef SERVERWINDOW_H -#define SERVERWINDOW_H - -#include "ConnectionConfig.h" -#include -#include - -namespace Ui { -class ServerWindow; -} - -class MasterController; -class OpenDatabase; -class DatabasesTableModel; -class RolesTableModel; - -class ServerWindow : public QMainWindow { - Q_OBJECT -public: - explicit ServerWindow(MasterController *master, QWidget *parent ); - ~ServerWindow(); - - void setConfig(const ConnectionConfig &config); -private: - Ui::ServerWindow *ui; - - MasterController *m_masterController = nullptr; - ConnectionConfig m_config; - std::shared_ptr m_database; - DatabasesTableModel *m_databasesModel = nullptr; - RolesTableModel *m_rolesModel = nullptr; -}; - -#endif // SERVERWINDOW_H diff --git a/pglab/ServerWindow.ui b/pglab/ServerWindow.ui deleted file mode 100644 index 6b3d1db..0000000 --- a/pglab/ServerWindow.ui +++ /dev/null @@ -1,156 +0,0 @@ - - - ServerWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - 2 - - - - Databases - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - true - - - 16 - - - 20 - - - - - - - - Tablespaces - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - true - - - 16 - - - 20 - - - - - - - - Roles/users - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - true - - - 16 - - - 20 - - - - - - - - - - - - - 0 - 0 - 800 - 30 - - - - - - - - PgLabTableView - QTableView -
PgLabTableView.h
-
-
- - -
diff --git a/pglab/pglab.pro b/pglab/pglab.pro index 2d8608b..84868c6 100644 --- a/pglab/pglab.pro +++ b/pglab/pglab.pro @@ -46,7 +46,6 @@ SOURCES += main.cpp\ ParamTypeDelegate.cpp \ OpenDatabase.cpp \ SqlSyntaxHighlighter.cpp \ - ServerWindow.cpp \ DatabasesTableModel.cpp \ RolesTableModel.cpp \ ProcessStdioWidget.cpp \ @@ -121,7 +120,6 @@ HEADERS += \ ParamTypeDelegate.h \ OpenDatabase.h \ SqlSyntaxHighlighter.h \ - ServerWindow.h \ DatabasesTableModel.h \ RolesTableModel.h \ ProcessStdioWidget.h \ @@ -176,7 +174,6 @@ FORMS += \ CreateDatabaseDialog.ui \ TuplesResultWidget.ui \ QueryTab.ui \ - ServerWindow.ui \ ProcessStdioWidget.ui \ NamespaceFilterWidget.ui \ CrudTab.ui \