71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
#include "MasterController.h"
|
|
#include "ConnectionManagerWindow.h"
|
|
#include "ConnectionList.h"
|
|
#include "ConnectionListModel.h"
|
|
#include "MainWindow.h"
|
|
#include "ServerWindow.h"
|
|
#include "BackupDialog.h"
|
|
|
|
|
|
MasterController::MasterController(QObject *parent) : QObject(parent)
|
|
{}
|
|
|
|
MasterController::~MasterController()
|
|
{
|
|
delete m_connectionManagerWindow;
|
|
delete m_connectionListModel;
|
|
delete m_connectionList;
|
|
}
|
|
|
|
void MasterController::init()
|
|
{
|
|
m_connectionList = new ConnectionList;
|
|
m_connectionList->load();
|
|
m_connectionListModel = new ConnectionListModel(m_connectionList, this);
|
|
|
|
m_connectionManagerWindow = new ConnectionManagerWindow(this, nullptr);
|
|
m_connectionManagerWindow->show();
|
|
|
|
}
|
|
|
|
void MasterController::showConnectionManager()
|
|
{
|
|
m_connectionManagerWindow->show();
|
|
}
|
|
|
|
void MasterController::openSqlWindowForConnection(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();
|
|
}
|
|
|
|
}
|
|
|
|
void MasterController::openBackupDlgForConnection(int connection_index)
|
|
{
|
|
auto cc = m_connectionListModel->get(connection_index);
|
|
m_connectionListModel->save(connection_index);
|
|
if (cc.valid()) {
|
|
auto w = new BackupDialog(nullptr); //new ServerWindow(this, nullptr);
|
|
w->setAttribute( Qt::WA_DeleteOnClose );
|
|
w->setConfig(cc.get());
|
|
w->show();
|
|
}
|
|
}
|
|
|
|
void MasterController::openServerWindowForConnection(int connection_index)
|
|
{
|
|
auto cc = m_connectionListModel->get(connection_index);
|
|
m_connectionListModel->save(connection_index);
|
|
if (cc.valid()) {
|
|
auto w = new ServerWindow(this, nullptr);
|
|
w->setAttribute( Qt::WA_DeleteOnClose );
|
|
w->setConfig(cc.get());
|
|
w->show();
|
|
}
|
|
}
|