editCopy in connection manager

Allows to edit an existing connection as a new one.
This commit is contained in:
eelke 2021-03-31 16:03:34 +02:00
parent f21a59e030
commit a3ba4d7c98
5 changed files with 37 additions and 9 deletions

View file

@ -95,6 +95,16 @@ void ConnectionController::editConnection(QModelIndex index)
} }
} }
void ConnectionController::editCopy(QModelIndex index)
{
auto config = ConnectionTreeModel::getConfigFromModelIndex(index);
if (config) {
auto cc = *config;
cc.setUuid(QUuid::createUuid());
ConnectionConfigurationWidget::editExistingInWindow(this, cc);
}
}
void ConnectionController::addGroup() void ConnectionController::addGroup()
{ {
auto result = QInputDialog::getText(nullptr, tr("Add new connection group"), auto result = QInputDialog::getText(nullptr, tr("Add new connection group"),

View file

@ -36,6 +36,7 @@ public:
/// Starts the form for editing a conncetion. /// Starts the form for editing a conncetion.
/// This function returns immidiatly! /// This function returns immidiatly!
void editConnection(QModelIndex index); void editConnection(QModelIndex index);
void editCopy(QModelIndex index);
void addGroup(); void addGroup();
void removeGroup(QModelIndex index); void removeGroup(QModelIndex index);

View file

@ -102,3 +102,9 @@ void ConnectionManagerWindow::on_actionRemove_group_triggered()
auto ci = ui->treeView->selectionModel()->currentIndex(); auto ci = ui->treeView->selectionModel()->currentIndex();
m_connectionController->removeGroup(ci); m_connectionController->removeGroup(ci);
} }
void ConnectionManagerWindow::on_actionConfigureCopy_triggered()
{
auto ci = ui->treeView->selectionModel()->currentIndex();
m_connectionController->editCopy(ci);
}

View file

@ -38,6 +38,8 @@ private slots:
void on_actionRemove_group_triggered(); void on_actionRemove_group_triggered();
void on_actionConfigureCopy_triggered();
private: private:
Ui::ConnectionManagerWindow *ui; Ui::ConnectionManagerWindow *ui;
MasterController *m_masterController; MasterController *m_masterController;

View file

@ -26,7 +26,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>413</width> <width>413</width>
<height>20</height> <height>30</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -74,12 +74,13 @@ QToolButton {
<addaction name="actionRemove_group"/> <addaction name="actionRemove_group"/>
<addaction name="actionAdd_Connection"/> <addaction name="actionAdd_Connection"/>
<addaction name="actionConfigure_connection"/> <addaction name="actionConfigure_connection"/>
<addaction name="actionConfigureCopy"/>
<addaction name="actionDelete_connection"/> <addaction name="actionDelete_connection"/>
<addaction name="separator"/> <addaction name="separator"/>
</widget> </widget>
<action name="actionAdd_Connection"> <action name="actionAdd_Connection">
<property name="icon"> <property name="icon">
<iconset resource="resources.qrc"> <iconset>
<normaloff>:/icons/add_connection.png</normaloff>:/icons/add_connection.png</iconset> <normaloff>:/icons/add_connection.png</normaloff>:/icons/add_connection.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -88,7 +89,7 @@ QToolButton {
</action> </action>
<action name="actionDelete_connection"> <action name="actionDelete_connection">
<property name="icon"> <property name="icon">
<iconset resource="resources.qrc"> <iconset>
<normaloff>:/icons/delete_connection.png</normaloff> <normaloff>:/icons/delete_connection.png</normaloff>
<normalon>:/icons/delete_connection.png</normalon>:/icons/delete_connection.png</iconset> <normalon>:/icons/delete_connection.png</normalon>:/icons/delete_connection.png</iconset>
</property> </property>
@ -116,7 +117,7 @@ QToolButton {
</action> </action>
<action name="actionBackup_database"> <action name="actionBackup_database">
<property name="icon"> <property name="icon">
<iconset resource="resources.qrc"> <iconset>
<normaloff>:/icons/backup_database.png</normaloff> <normaloff>:/icons/backup_database.png</normaloff>
<normalon>:/icons/backups.png</normalon>:/icons/backup_database.png</iconset> <normalon>:/icons/backups.png</normalon>:/icons/backup_database.png</iconset>
</property> </property>
@ -164,9 +165,17 @@ QToolButton {
<string>Remove group</string> <string>Remove group</string>
</property> </property>
</action> </action>
<action name="actionConfigureCopy">
<property name="icon">
<iconset>
<normalon>:/icons/server_configuration.png</normalon>
</iconset>
</property>
<property name="text">
<string>Configure copy</string>
</property>
</action>
</widget> </widget>
<resources> <resources/>
<include location="resources.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>