summaryrefslogtreecommitdiffstats
path: root/module/gui
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-12-28 22:21:35 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-12-28 22:21:35 +0100
commit86949a6240bc6d5a5fd5e5677925e0d945686d3e (patch)
treeb421a1388ae4dc931469d7dd94f70cf5300f2a96 /module/gui
parentyou can now drop single links directly into a package (diff)
downloadpyload-86949a6240bc6d5a5fd5e5677925e0d945686d3e.tar.xz
package renaming in collector works
Diffstat (limited to 'module/gui')
-rw-r--r--module/gui/Collector.py23
-rw-r--r--module/gui/MainWindow.py25
-rw-r--r--module/gui/connector.py12
3 files changed, 53 insertions, 7 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()