diff options
author | mkaay <mkaay@mkaay.de> | 2009-12-28 22:21:35 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2009-12-28 22:21:35 +0100 |
commit | 86949a6240bc6d5a5fd5e5677925e0d945686d3e (patch) | |
tree | b421a1388ae4dc931469d7dd94f70cf5300f2a96 | |
parent | you can now drop single links directly into a package (diff) | |
download | pyload-86949a6240bc6d5a5fd5e5677925e0d945686d3e.tar.xz |
package renaming in collector works
-rw-r--r-- | module/gui/Collector.py | 23 | ||||
-rw-r--r-- | module/gui/MainWindow.py | 25 | ||||
-rw-r--r-- | module/gui/connector.py | 12 | ||||
-rwxr-xr-x | pyLoadCore.py | 5 | ||||
-rwxr-xr-x | pyLoadGui.py | 9 |
5 files changed, 66 insertions, 8 deletions
diff --git a/module/gui/Collector.py b/module/gui/Collector.py index 1b1a6b654..8b421001e 100644 --- a/module/gui/Collector.py +++ b/module/gui/Collector.py @@ -39,6 +39,7 @@ class PackageCollector(QThread): item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.rootItem.addChild(item) self.linkCollector = item + self.pauseIDs = [] def run(self): while self.running: @@ -56,6 +57,8 @@ class PackageCollector(QThread): ids.append(data["id"]) self.clear(ids) for data in packs: + if data["id"] in self.pauseIDs: + continue ids.append(data["id"]) pack = self.getPack(data["id"]) if not pack: @@ -88,7 +91,7 @@ class PackageCollector(QThread): item = newPack item.setData(0, Qt.DisplayRole, QVariant(item.getPackData()["package_name"])) item.setData(0, Qt.UserRole, QVariant(pid)) - item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDropEnabled) + item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDropEnabled | Qt.ItemIsEditable) def getPack(self, pid): for k, pack in enumerate(ItemIterator(self.rootItem)): @@ -110,6 +113,16 @@ class PackageCollector(QThread): for k in remove: self.rootItem.takeChild(k) + def pauseItemUpdate(self, pid, pause=True): + locker = QMutexLocker(self.mutex) + if pause and not pid in self.pauseIDs: + self.pauseIDs.append(int(pid)) + else: + try: + self.pauseIDs.remove(int(pid)) + except: + pass + class PackageCollectorPack(QTreeWidgetItem): def __init__(self, collector): QTreeWidgetItem.__init__(self) @@ -210,13 +223,13 @@ class LinkCollector(QThread): locker = QMutexLocker(self.mutex) ids = self.connector.getLinkCollector() self.clear(ids) - for id in ids: - data = self.connector.getLinkInfo(id) - file = self.getFile(id) + for fid in ids: + data = self.connector.getLinkInfo(fid) + file = self.getFile(fid) if not file: file = self.LinkCollectorFile(self) file.setFileData(data) - self.addFile(id, file) + self.addFile(fid, file) def addFile(self, pid, newFile): pos = None diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py index 610d8e840..5237436f0 100644 --- a/module/gui/MainWindow.py +++ b/module/gui/MainWindow.py @@ -102,7 +102,8 @@ class MainWindow(QMainWindow): self.connect(self.mactions["exit"], SIGNAL("triggered()"), self.close) self.connect(self.tabs["queue"]["view"], SIGNAL('customContextMenuRequested(const QPoint &)'), self.slotQueueContextMenu) - self.connect(self.tabs["collector"]["package_view"], SIGNAL('customContextMenuRequested(const QPoint &)'), self.slotcollectorContextMenu) + self.connect(self.tabs["collector"]["package_view"], SIGNAL('customContextMenuRequested(const QPoint &)'), self.slotCollectorContextMenu) + self.connect(self.tabs["collector"]["package_view"].itemDelegate(), SIGNAL("closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)"), self.slotCloseItemEditor) self.lastAddedID = None @@ -197,10 +198,13 @@ class MainWindow(QMainWindow): self.collectorContext.item = (None, None) self.collectorContext.buttons["remove"] = QAction(QIcon("icons/gui/remove_small.png"), "Remove", self.collectorContext) self.collectorContext.buttons["push"] = QAction(QIcon("icons/gui/push_small.png"), "Push to queue", self.collectorContext) + self.collectorContext.buttons["edit"] = QAction(QIcon("icons/gui/edit_small.png"), "Edit Name", self.collectorContext) self.collectorContext.addAction(self.collectorContext.buttons["push"]) + self.collectorContext.addAction(self.collectorContext.buttons["edit"]) self.collectorContext.addAction(self.collectorContext.buttons["remove"]) self.connect(self.collectorContext.buttons["remove"], SIGNAL("triggered()"), self.slotRemoveDownload) self.connect(self.collectorContext.buttons["push"], SIGNAL("triggered()"), self.slotPushPackageToQueue) + self.connect(self.collectorContext.buttons["edit"], SIGNAL("triggered()"), self.slotEditPackage) def slotToggleStatus(self, status): """ @@ -339,7 +343,7 @@ class MainWindow(QMainWindow): self.activeMenu = self.queueContext self.queueContext.exec_(menuPos) - def slotcollectorContextMenu(self, pos): + def slotCollectorContextMenu(self, pos): """ custom context menu in package collector view requested """ @@ -352,6 +356,10 @@ class MainWindow(QMainWindow): menuPos = QCursor.pos() menuPos.setX(menuPos.x()+2) self.activeMenu = self.collectorContext + if hasattr(i, "getPackData"): + self.collectorContext.buttons["edit"].setVisible(True) + else: + self.collectorContext.buttons["edit"].setVisible(False) self.collectorContext.exec_(menuPos) def slotLinkCollectorContextMenu(self, pos): @@ -381,4 +389,17 @@ class MainWindow(QMainWindow): check clipboard (toolbar) """ self.emit(SIGNAL("setClipboardStatus"), status) + + def slotEditPackage(self): + item = self.tabs["collector"]["package_view"].currentItem() + pid = self.tabs["collector"]["package_view"].currentItem().data(0, Qt.UserRole).toPyObject() + print type(pid) + self.emit(SIGNAL("pauseItemUpdate"), pid, True) + self.tabs["collector"]["package_view"].editItem(item, 0) + + def slotCloseItemEditor(self, editor, hint): + pid = self.tabs["collector"]["package_view"].currentItem().data(0, Qt.UserRole).toPyObject() + print type(pid) + self.emit(SIGNAL("changePackageName"), pid, editor.text()) + self.emit(SIGNAL("pauseItemUpdate"), pid, False) diff --git a/module/gui/connector.py b/module/gui/connector.py index 3f594d68e..8a2909c5e 100644 --- a/module/gui/connector.py +++ b/module/gui/connector.py @@ -353,4 +353,16 @@ class connector(QThread): self.emit(SIGNAL("proxy_error"), "updateAvailable", e) finally: self.mutex.unlock() + + def setPackageName(self, pid, name): + """ + set new package name + """ + self.mutex.lock() + try: + return self.proxy.set_package_name(pid, name) + except Exception, e: + self.emit(SIGNAL("proxy_error"), "setPackageName", e) + finally: + self.mutex.unlock() diff --git a/pyLoadCore.py b/pyLoadCore.py index aaa965901..8bd9a3995 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -550,7 +550,10 @@ class ServerMethods(): self.core.file_list.packager.abortFile(id) def update_available(self): - return self.core.update_available
+ return self.core.update_available + + def set_package_name(self, pid, name): + self.core.file_list.packager.setPackageData(pid, package_name=name)
#def move_urls_up(self, ids):
# for id in ids:
diff --git a/pyLoadGui.py b/pyLoadGui.py index 7ef267fcb..38013cd4c 100755 --- a/pyLoadGui.py +++ b/pyLoadGui.py @@ -78,6 +78,7 @@ class main(QObject): self.mainloop.start() self.clipboard = self.app.clipboard() self.connect(self.clipboard, SIGNAL('dataChanged()'), self.slotClipboardChange) + self.connect(self.mainWindow, SIGNAL("pauseItemUpdate"), self.packageCollector.pauseItemUpdate) self.mainWindow.actions["clipboard"].setChecked(self.checkClipboard) def stopMain(self): @@ -85,6 +86,7 @@ class main(QObject): stop all refresh threads and hide main window """ self.disconnect(self.clipboard, SIGNAL('dataChanged()'), self.slotClipboardChange) + self.disconnect(self.mainWindow, SIGNAL("pauseItemUpdate"), self.packageCollector.pauseItemUpdate) self.mainloop.stop() self.connector.stop() self.mainWindow.saveWindow() @@ -119,6 +121,7 @@ class main(QObject): self.connect(self.mainWindow, SIGNAL("addContainer"), self.slotAddContainer) self.connect(self.mainWindow, SIGNAL("stopAllDownloads"), self.slotStopAllDownloads) self.connect(self.mainWindow, SIGNAL("setClipboardStatus"), self.slotSetClipboardStatus) + self.connect(self.mainWindow, SIGNAL("changePackageName"), self.slotChangePackageName) def slotShowConnector(self): """ @@ -539,6 +542,12 @@ class main(QObject): """ self.checkClipboard = status + def slotChangePackageName(self, pid, name): + """ + package name edit finished + """ + self.connector.setPackageName(pid, str(name)) + class Loop(QThread): """ main loop (not application loop) |