Opening of a window for a database is now done by the MasterController.
The ConnectionManager just passes on the action now.
This commit is contained in:
parent
6370050204
commit
343390ff38
4 changed files with 24 additions and 17 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "connectionmanagerwindow.h"
|
||||
#include "ui_connectionmanagerwindow.h"
|
||||
#include "mainwindow.h"
|
||||
//#include "mainwindow.h"
|
||||
#include "MasterController.h"
|
||||
#include <QDataWidgetMapper>
|
||||
#include <QMessageBox>
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue