summaryrefslogtreecommitdiffstats
path: root/module/gui/ConnectionManager.py
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-12-29 16:50:13 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-12-29 16:50:13 +0100
commitfa9cce4987da585f5bf21274cfbe5f046f46f703 (patch)
tree94fa0f16d8b72b09c1e59d27d2bb70aeed3c09ff /module/gui/ConnectionManager.py
parentUploadedTo indirect download fix (diff)
downloadpyload-fa9cce4987da585f5bf21274cfbe5f046f46f703.tar.xz
: Bitte gib eine Versions-Meldung ein. Zeilen beginnend mit 'HG:' werden entfernt.
Diffstat (limited to 'module/gui/ConnectionManager.py')
-rw-r--r--module/gui/ConnectionManager.py42
1 files changed, 32 insertions, 10 deletions
diff --git a/module/gui/ConnectionManager.py b/module/gui/ConnectionManager.py
index c997eee19..57aed3a18 100644
--- a/module/gui/ConnectionManager.py
+++ b/module/gui/ConnectionManager.py
@@ -53,6 +53,8 @@ class ConnectionManager(QWidget):
self.connList = connList
self.edit = self.EditWindow()
self.connectSignals()
+
+ self.defaultStates = {}
def connectSignals(self):
self.connect(self, SIGNAL("setConnections(connections)"), self.setConnections)
@@ -61,6 +63,7 @@ class ConnectionManager(QWidget):
self.connect(self.remove, SIGNAL("clicked()"), self.slotRemove)
self.connect(self.connectb, SIGNAL("clicked()"), self.slotConnect)
self.connect(self.edit, SIGNAL("save"), self.slotSave)
+ self.connect(self.connList, SIGNAL("itemDoubleClicked(QListWidgetItem *)"), self.slotItemDoubleClicked)
def setConnections(self, connections):
self.connList.clear()
@@ -70,6 +73,7 @@ class ConnectionManager(QWidget):
item.setData(Qt.UserRole, QVariant(conn))
self.connList.addItem(item)
if conn["default"]:
+ item.setData(Qt.DisplayRole, QVariant("%s (Default)" % conn["name"]))
self.connList.setCurrentItem(item)
def slotNew(self):
@@ -80,34 +84,51 @@ class ConnectionManager(QWidget):
def slotEdit(self):
item = self.connList.currentItem()
data = item.data(Qt.UserRole).toPyObject()
- tmp = {}
- for k, d in data.items():
- tmp[str(k)] = d
- data = tmp
+ data = self.cleanDict(data)
self.edit.setData(data)
self.edit.show()
def slotRemove(self):
item = self.connList.currentItem()
data = item.data(Qt.UserRole).toPyObject()
- tmp = {}
- for k, d in data.items():
- tmp[str(k)] = d
- data = tmp
+ data = self.cleanDict(data)
self.emit(SIGNAL("removeConnection"), data)
def slotConnect(self):
item = self.connList.currentItem()
data = item.data(Qt.UserRole).toPyObject()
+ data = self.cleanDict(data)
+ self.emit(SIGNAL("connect"), data)
+
+ def cleanDict(self, data):
tmp = {}
for k, d in data.items():
tmp[str(k)] = d
- data = tmp
- self.emit(SIGNAL("connect"), data)
+ return tmp
def slotSave(self, data):
self.emit(SIGNAL("saveConnection"), data)
+ def slotItemDoubleClicked(self, defaultItem):
+ data = defaultItem.data(Qt.UserRole).toPyObject()
+ self.setDefault(data, True)
+ did = self.cleanDict(data)["id"]
+ allItems = self.connList.findItems("*", Qt.MatchWildcard)
+ count = self.connList.count()
+ for i in range(count):
+ item = self.connList.item(i)
+ data = item.data(Qt.UserRole).toPyObject()
+ if self.cleanDict(data)["id"] == did:
+ continue
+ self.setDefault(data, False)
+
+ def setDefault(self, data, state):
+ data = self.cleanDict(data)
+ self.edit.setData(data)
+ data = self.edit.getData()
+ data["default"] = state
+ self.edit.emit(SIGNAL("save"), data)
+
class EditWindow(QWidget):
def __init__(self):
QWidget.__init__(self)
@@ -225,3 +246,4 @@ class ConnectionManager(QWidget):
data = self.getData()
self.hide()
self.emit(SIGNAL("save"), data)
+