diff --git a/MasterController.cpp b/MasterController.cpp index 4e55203..ee1f375 100644 --- a/MasterController.cpp +++ b/MasterController.cpp @@ -1,6 +1,7 @@ #include "MasterController.h" #include "connectionmanagerwindow.h" #include "connectionlistmodel.h" +#include "mainwindow.h" MasterController::MasterController(QObject *parent) : QObject(parent) @@ -25,3 +26,16 @@ void MasterController::showConnectionManager() { m_connectionManagerWindow->show(); } + +void MasterController::openWindowForConnection(int connection_index) +{ + auto cc = m_connectionListModel->get(connection_index); + m_connectionListModel->save(connection_index); + if (cc.valid()) { + auto w = new MainWindow(this, nullptr); + w->setAttribute( Qt::WA_DeleteOnClose ); + w->setConfig(cc.get()); + w->show(); + } + +} diff --git a/MasterController.h b/MasterController.h index 3dd5fe1..d1a465b 100644 --- a/MasterController.h +++ b/MasterController.h @@ -8,6 +8,8 @@ class ConnectionConfig; class ConnectionListModel; class ConnectionManagerWindow; +/** \brief Controller class responsible for all things global. + */ class MasterController : public QObject { Q_OBJECT @@ -24,11 +26,14 @@ public: void showConnectionManager(); + void openWindowForConnection(int connection_index); + signals: public slots: private: + ConnectionListModel *m_connectionListModel = nullptr; ConnectionManagerWindow *m_connectionManagerWindow = nullptr; }; diff --git a/connectionmanagerwindow.cpp b/connectionmanagerwindow.cpp index 7ea6963..451a17c 100644 --- a/connectionmanagerwindow.cpp +++ b/connectionmanagerwindow.cpp @@ -1,6 +1,6 @@ #include "connectionmanagerwindow.h" #include "ui_connectionmanagerwindow.h" -#include "mainwindow.h" +//#include "mainwindow.h" #include "MasterController.h" #include #include @@ -85,23 +85,8 @@ void ConnectionManagerWindow::setupWidgetMappings() void ConnectionManagerWindow::on_actionConnect_triggered() { - // maybe we should first check the connection? - - // Have we loaded the catalogue? - // If not do so now - - - auto clm = m_masterController->getConnectionListModel(); - // Open a window for this connection, auto ci = ui->listView->selectionModel()->currentIndex(); - auto cc = clm->get(ci.row()); - clm->save(ci.row()); - if (cc.valid()) { - auto w = new MainWindow(m_masterController, nullptr); - w->setAttribute( Qt::WA_DeleteOnClose ); - w->setConfig(cc.get()); - w->show(); - } + m_masterController->openWindowForConnection(ci.row()); } void ConnectionManagerWindow::on_actionQuit_application_triggered() diff --git a/connectionmanagerwindow.h b/connectionmanagerwindow.h index 3794a60..f0180d4 100644 --- a/connectionmanagerwindow.h +++ b/connectionmanagerwindow.h @@ -12,6 +12,9 @@ class MasterController; class QDataWidgetMapper; class QStandardItemModel; +/** \brief Class that holds glue code for the ConnectionManager UI. + * + */ class ConnectionManagerWindow : public QMainWindow { Q_OBJECT