Split all connection related controller functionality off into seperate ConnectionController.
This commit is contained in:
parent
8c13bdc2ef
commit
35d1e75d35
8 changed files with 103 additions and 61 deletions
|
|
@ -27,10 +27,10 @@ ConnectionManagerWindow::ConnectionManagerWindow(MasterController *master, QWidg
|
|||
, ui(new Ui::ConnectionManagerWindow)
|
||||
// , m_listModel(new ConnectionListModel(this))
|
||||
, m_masterController(master)
|
||||
, m_connectionController(master->connectionController())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->listView->setModel(m_masterController->getConnectionListModel());
|
||||
ui->listView->setModel(m_connectionController->getConnectionListModel());
|
||||
|
||||
setupWidgetMappings();
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ void ConnectionManagerWindow::on_actionAdd_Connection_triggered()
|
|||
// c.setName("new");
|
||||
//m_listModel->add(c);
|
||||
|
||||
auto clm = m_masterController->getConnectionListModel();
|
||||
auto clm = m_connectionController->getConnectionListModel();
|
||||
clm->newItem();
|
||||
|
||||
// Select the new row
|
||||
|
|
@ -67,7 +67,7 @@ void ConnectionManagerWindow::on_currentChanged(const QModelIndex ¤t,
|
|||
const QModelIndex &)
|
||||
{
|
||||
int currow = current.row();
|
||||
auto clm = m_masterController->getConnectionListModel();
|
||||
auto clm = m_connectionController->getConnectionListModel();
|
||||
if (prevSelection)
|
||||
clm->save(*prevSelection);
|
||||
m_mapper->setCurrentIndex(currow);
|
||||
|
|
@ -81,11 +81,10 @@ void ConnectionManagerWindow::on_actionDelete_connection_triggered()
|
|||
{
|
||||
auto ci = ui->listView->selectionModel()->currentIndex();
|
||||
if (ci.isValid()) {
|
||||
|
||||
auto res = QMessageBox::question(this, "pglab",
|
||||
tr("Are you sure you want to remove this connection?"), QMessageBox::Yes, QMessageBox::No);
|
||||
if (res == QMessageBox::Yes) {
|
||||
auto clm = m_masterController->getConnectionListModel();
|
||||
auto clm = m_connectionController->getConnectionListModel();
|
||||
clm->removeRow(ci.row());
|
||||
}
|
||||
}
|
||||
|
|
@ -94,7 +93,7 @@ void ConnectionManagerWindow::on_actionDelete_connection_triggered()
|
|||
|
||||
void ConnectionManagerWindow::setupWidgetMappings()
|
||||
{
|
||||
auto clm = m_masterController->getConnectionListModel();
|
||||
auto clm = m_connectionController->getConnectionListModel();
|
||||
m_mapper = new QDataWidgetMapper(this);
|
||||
m_mapper->setModel(clm);
|
||||
m_mapper->addMapping(ui->edtName, 1);
|
||||
|
|
@ -110,7 +109,7 @@ void ConnectionManagerWindow::on_actionConnect_triggered()
|
|||
auto ci = ui->listView->selectionModel()->currentIndex();
|
||||
if (ci.isValid()) {
|
||||
auto r = static_cast<size_t>(ci.row());
|
||||
m_masterController->openSqlWindowForConnection(r);
|
||||
m_connectionController->openSqlWindowForConnection(r);
|
||||
}
|
||||
else {
|
||||
// TODO can we give unobtrusive message why it didn't work?
|
||||
|
|
@ -131,13 +130,13 @@ void ConnectionManagerWindow::on_actionQuit_application_triggered()
|
|||
void ConnectionManagerWindow::on_actionBackup_database_triggered()
|
||||
{
|
||||
auto ci = ui->listView->selectionModel()->currentIndex();
|
||||
m_masterController->openBackupDlgForConnection(ci.row());
|
||||
m_connectionController->openBackupDlgForConnection(ci.row());
|
||||
}
|
||||
|
||||
void ConnectionManagerWindow::on_actionManage_server_triggered()
|
||||
{
|
||||
auto ci = ui->listView->selectionModel()->currentIndex();
|
||||
m_masterController->openServerWindowForConnection(ci.row());
|
||||
m_connectionController->openServerWindowForConnection(ci.row());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue