Mercurial > hg > RemoteViewer
changeset 19:a949d4849c6a
implement deleting a connection
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Thu, 25 Sep 2014 01:39:24 +0200 |
parents | 4f8e85589dae |
children | e7c5aeba8a94 |
files | RemoteViewer/RemoteViewer.py RemoteViewer/RemoteViewer.ui RemoteViewer/Settings.py |
diffstat | 3 files changed, 42 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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):
--- 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 @@ </property> <addaction name="actionNew"/> <addaction name="actionEdit"/> + <addaction name="actionDelete"/> <addaction name="separator"/> <addaction name="actionQuit"/> </widget> @@ -68,6 +69,17 @@ <string>Ctrl+E</string> </property> </action> + <action name="actionDelete"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Delete</string> + </property> + <property name="shortcut"> + <string>Ctrl+D</string> + </property> + </action> </widget> <resources/> <connections> @@ -151,11 +163,28 @@ </hint> </hints> </connection> + <connection> + <sender>actionDelete</sender> + <signal>triggered()</signal> + <receiver>RemoteViewer</receiver> + <slot>deleteConnection()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>219</x> + <y>204</y> + </hint> + </hints> + </connection> </connections> <slots> <slot>newConnection()</slot> <slot>openConnection(QModelIndex)</slot> <slot>editConnection()</slot> <slot>connectionSelected(QModelIndex)</slot> + <slot>deleteConnection()</slot> </slots> </ui>
--- 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: