diff options
Diffstat (limited to 'module/gui')
-rw-r--r-- | module/gui/Collector.py | 9 | ||||
-rw-r--r-- | module/gui/ConnectionManager.py | 42 | ||||
-rw-r--r-- | module/gui/MainWindow.py | 15 | ||||
-rw-r--r-- | module/gui/connector.py | 24 |
4 files changed, 78 insertions, 12 deletions
diff --git a/module/gui/Collector.py b/module/gui/Collector.py index 8b421001e..356ab36ec 100644 --- a/module/gui/Collector.py +++ b/module/gui/Collector.py @@ -112,6 +112,15 @@ class PackageCollector(QThread): remove.reverse() for k in remove: self.rootItem.takeChild(k) + for pack in ItemIterator(self.rootItem): + if pack.getPackData()["id"] == "fixed": + return + item = self.PackageCollectorPack(self) + item.setPackData({"id":"fixed"}) + item.setData(0, Qt.DisplayRole, QVariant("Single Links")) + item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) + self.rootItem.addChild(item) + self.linkCollector = item def pauseItemUpdate(self, pid, pause=True): locker = QMutexLocker(self.mutex) 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) + diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py index 5237436f0..6daa0aa55 100644 --- a/module/gui/MainWindow.py +++ b/module/gui/MainWindow.py @@ -187,10 +187,13 @@ class MainWindow(QMainWindow): self.queueContext.item = (None, None) self.queueContext.buttons["remove"] = QAction(QIcon("icons/gui/remove_small.png"), "Remove", self.queueContext) self.queueContext.buttons["restart"] = QAction(QIcon("icons/gui/refresh_small.png"), "Restart", self.queueContext) + self.queueContext.buttons["pull"] = QAction(QIcon("icons/gui/pull_small.png"), "Pull out", self.queueContext) + self.queueContext.addAction(self.queueContext.buttons["pull"]) self.queueContext.addAction(self.queueContext.buttons["remove"]) self.queueContext.addAction(self.queueContext.buttons["restart"]) self.connect(self.queueContext.buttons["remove"], SIGNAL("triggered()"), self.slotRemoveDownload) self.connect(self.queueContext.buttons["restart"], SIGNAL("triggered()"), self.slotRestartDownload) + self.connect(self.queueContext.buttons["pull"], SIGNAL("triggered()"), self.slotPullOutPackage) #collector self.collectorContext = QMenu() @@ -341,6 +344,10 @@ class MainWindow(QMainWindow): menuPos = QCursor.pos() menuPos.setX(menuPos.x()+2) self.activeMenu = self.queueContext + if hasattr(i, "getPackData"): + self.queueContext.buttons["pull"].setVisible(True) + else: + self.queueContext.buttons["pull"].setVisible(False) self.queueContext.exec_(menuPos) def slotCollectorContextMenu(self, pos): @@ -402,4 +409,12 @@ class MainWindow(QMainWindow): print type(pid) self.emit(SIGNAL("changePackageName"), pid, editor.text()) self.emit(SIGNAL("pauseItemUpdate"), pid, False) + + def slotPullOutPackage(self): + """ + pull package out of the queue + """ + id, isTopLevel = self.activeMenu.item + if not id == None: + self.emit(SIGNAL("pullOutPackage"), id, isTopLevel) diff --git a/module/gui/connector.py b/module/gui/connector.py index 8a2909c5e..2915cf568 100644 --- a/module/gui/connector.py +++ b/module/gui/connector.py @@ -51,11 +51,14 @@ class connector(QThread): start thread (called from thread.start()) """ - self.connectProxy(self.addr) + self.canConnect() while self.running: sleep(1) self.getError() + def canConnect(self): + return self.connectProxy(self.addr) + def stop(self): """ stop thread @@ -67,9 +70,14 @@ class connector(QThread): connect to remote server """ self.proxy = ServerProxy(addr, allow_none=True) - server_version = self.proxy.get_server_version() + try: + server_version = self.proxy.get_server_version() + except: + return False if not server_version == SERVER_VERSION: self.emit(SIGNAL("error_box"), "server is version %s client accepts version %s" % (server_version, SERVER_VERSION)) + return False + return True def _proxyError(self, func, e): """ @@ -365,4 +373,16 @@ class connector(QThread): self.emit(SIGNAL("proxy_error"), "setPackageName", e) finally: self.mutex.unlock() + + def slotPullOutPackage(self, pid): + """ + pull out package + """ + self.mutex.lock() + try: + return self.proxy.pull_out_package(pid) + except Exception, e: + self.emit(SIGNAL("proxy_error"), "slotPullOutPackage", e) + finally: + self.mutex.unlock() |