# HG changeset patch # User Dirk Olmes # Date 1411601964 -7200 # Node ID a949d4849c6a92b2023c4e1f7e25ab9b8d0396e8 # Parent 4f8e85589dae9583e48a4d9387b824da130c8e8e implement deleting a connection diff -r 4f8e85589dae -r a949d4849c6a RemoteViewer/RemoteViewer.py --- a/RemoteViewer/RemoteViewer.py Thu Sep 25 01:33:40 2014 +0200 +++ b/RemoteViewer/RemoteViewer.py Thu Sep 25 01:39:24 2014 +0200 @@ -26,6 +26,7 @@ def connectionSelected(self, index): self.activeConnection = index.internalPointer() self.ui.actionEdit.setEnabled(True) + self.ui.actionDelete.setEnabled(True) @ExceptionSafeSlot() def newConnection(self): @@ -41,7 +42,12 @@ title = 'Edit {}'.format(self.activeConnection.displayString()) dialog = ConnectionDialog(title, self.activeConnection) dialog.exec_() - self.settings.update(self.activeConnection) + self.settings.updateConnection(self.activeConnection) + + @ExceptionSafeSlot() + def deleteConnection(self): + self.settings.deleteConnection(self.activeConnection) + self.__initHostList() @ExceptionSafeSlot('QModelIndex') def openConnection(self, index): diff -r 4f8e85589dae -r a949d4849c6a RemoteViewer/RemoteViewer.ui --- a/RemoteViewer/RemoteViewer.ui Thu Sep 25 01:33:40 2014 +0200 +++ b/RemoteViewer/RemoteViewer.ui Thu Sep 25 01:39:24 2014 +0200 @@ -35,6 +35,7 @@ + @@ -68,6 +69,17 @@ Ctrl+E + + + false + + + Delete + + + Ctrl+D + + @@ -151,11 +163,28 @@ + + actionDelete + triggered() + RemoteViewer + deleteConnection() + + + -1 + -1 + + + 219 + 204 + + + newConnection() openConnection(QModelIndex) editConnection() connectionSelected(QModelIndex) + deleteConnection() diff -r 4f8e85589dae -r a949d4849c6a RemoteViewer/Settings.py --- a/RemoteViewer/Settings.py Thu Sep 25 01:33:40 2014 +0200 +++ b/RemoteViewer/Settings.py Thu Sep 25 01:39:24 2014 +0200 @@ -38,11 +38,16 @@ connections.append(json) self.persist() - def update(self, connection): + def updateConnection(self, connection): id = connection.id self.__remove(id) self.addConnection(connection) + def deleteConnection(self, connection): + id = connection.id + self.__remove(id) + self.persist() + def __remove(self, id): allConnections = self.config[CONNECTIONS_KEY] for conn in allConnections: