summaryrefslogtreecommitdiffstats
path: root/module/gui
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-12-24 01:28:08 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-12-24 01:28:08 +0100
commitea04c11ce1fb52895449a56e862eff5448ea456a (patch)
treeb0eb5c841b082ee5777ad072d5754a67cff383fc /module/gui
parentdownload speed limit (diff)
downloadpyload-ea04c11ce1fb52895449a56e862eff5448ea456a.tar.xz
downloads are now aborted correctly, gui: remove downloads, new icons
Diffstat (limited to 'module/gui')
-rw-r--r--module/gui/Collector.py55
-rw-r--r--module/gui/MainWindow.py20
-rw-r--r--module/gui/Queue.py30
-rw-r--r--module/gui/connector.py20
4 files changed, 88 insertions, 37 deletions
diff --git a/module/gui/Collector.py b/module/gui/Collector.py
index 1d622b006..1f89670ce 100644
--- a/module/gui/Collector.py
+++ b/module/gui/Collector.py
@@ -58,7 +58,7 @@ class PackageCollector(QThread):
child = self.PackageCollectorFile(self, pack)
child.setData(info)
pack.addChild(fid, child)
- #pack.clear(files)
+ pack.clear(files)
self.clear(ids)
def addPack(self, pid, newPack):
@@ -88,15 +88,14 @@ class PackageCollector(QThread):
return None
def clear(self, ids):
- toremove = []
- for k, pack in enumerate(self.collector):
- id = pack.getData()["id"]
- if not id in ids:
- toremove.append(k)
- if not toremove:
+ clear = False
+ for pack in self.collector:
+ if not pack.getData()["id"] in ids:
+ clear = True
+ break
+ if not clear:
return
self.collector = []
- #self.view.clear()
self.view.emit(SIGNAL("clear"))
class PackageCollectorPack():
@@ -149,20 +148,15 @@ class PackageCollector(QThread):
return self.data
def clear(self, ids):
- toremove = []
- for k, file in enumerate(self.getChildren()):
- id = file.getData()["id"]
- if not id in ids:
- toremove.append(k)
- if not toremove:
+ clear = False
+ for file in self.getChildren():
+ if not file.getData()["id"] in ids:
+ clear = True
+ break
+ if not clear:
return
- ppos = self.collector.collector.index(self)
- parent = self.collector.view.topLevelItem(ppos)
- toremove.sort()
- toremove.reverse()
- for pos in toremove:
- del self.children[k]
- parent.takeChild(k)
+ self.collector.collector = []
+ self.collector.view.emit(SIGNAL("clear"))
class PackageCollectorFile():
def __init__(self, collector, pack):
@@ -237,18 +231,15 @@ class LinkCollector(QThread):
return None
def clear(self, ids):
- toremove = []
- for k, file in enumerate(self.collector):
- id = file.getData()["id"]
- if not id in ids:
- toremove.append(k)
- if not toremove:
+ clear = False
+ for pack in self.collector:
+ if not pack.getData()["id"] in ids:
+ clear = True
+ break
+ if not clear:
return
- toremove.sort()
- toremove.reverse()
- for pos in toremove:
- del self.collector[k]
- self.view.takeTopLevelItem(k)
+ self.collector = []
+ self.view.emit(SIGNAL("clear"))
class LinkCollectorFile():
def __init__(self, collector):
diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py
index 837125263..53de8cd54 100644
--- a/module/gui/MainWindow.py
+++ b/module/gui/MainWindow.py
@@ -147,6 +147,7 @@ class MainWindow(QMainWindow):
self.tabs["collector"]["package_view"] = QTreeWidget()
self.connect(self.tabs["collector"]["package_view"], SIGNAL("clear"), self.tabs["collector"]["package_view"].clear)
self.tabs["collector"]["link_view"] = QTreeWidget()
+ self.connect(self.tabs["collector"]["link_view"], SIGNAL("clear"), self.tabs["collector"]["link_view"].clear)
groupPackage.layout().addWidget(self.tabs["collector"]["package_view"])
groupPackage.layout().addWidget(toQueue)
groupLinks.layout().addWidget(self.tabs["collector"]["link_view"])
@@ -164,10 +165,11 @@ class MainWindow(QMainWindow):
self.queueContext = QMenu()
self.queueContext.buttons = {}
self.queueContext.item = (None, None)
- self.queueContext.buttons["remove"] = QAction("Remove", self.queueContext)
- self.queueContext.buttons["restart"] = QAction("Restart", self.queueContext)
+ 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.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)
def slotToggleStatus(self, status):
@@ -279,9 +281,13 @@ class MainWindow(QMainWindow):
"""
globalPos = self.tabs["queue"]["view"].mapToGlobal(pos)
i = self.tabs["queue"]["view"].itemAt(pos)
+ if not i:
+ return
i.setSelected(True)
self.queueContext.item = (i.data(0, Qt.UserRole).toPyObject(), i.parent() == None)
- self.queueContext.exec_(globalPos)
+ menuPos = QCursor.pos()
+ menuPos.setX(menuPos.x()+2)
+ self.queueContext.exec_(menuPos)
def slotPackageCollectorContextMenu(self, pos):
"""
@@ -302,4 +308,12 @@ class MainWindow(QMainWindow):
id, isTopLevel = self.queueContext.item
if not id == None:
self.emit(SIGNAL("restartDownload"), id, isTopLevel)
+
+ def slotRemoveDownload(self):
+ """
+ remove download action is triggered
+ """
+ id, isTopLevel = self.queueContext.item
+ if not id == None:
+ self.emit(SIGNAL("removeDownload"), id, isTopLevel)
diff --git a/module/gui/Queue.py b/module/gui/Queue.py
index c9a3e858b..35e1163b9 100644
--- a/module/gui/Queue.py
+++ b/module/gui/Queue.py
@@ -61,8 +61,10 @@ class Queue(QThread):
del d["name"]
del d["status"]
downloading[did] = d
+ ids = []
for data in packs:
pack = self.getPack(data["id"])
+ ids.append(data["id"])
if not pack:
pack = self.QueuePack(self)
pack.setData(data)
@@ -73,12 +75,15 @@ class Queue(QThread):
child = pack.getChild(fid)
if not child:
child = self.QueueFile(self, pack)
+ info["downloading"] = None
try:
info["downloading"] = downloading[info["id"]]
except:
- info["downloading"] = None
+ pass
child.setData(info)
pack.addChild(fid, child)
+ pack.clear(files)
+ self.clear(ids)
def addPack(self, pid, newPack):
pos = None
@@ -122,6 +127,17 @@ class Queue(QThread):
return pack
return None
+ def clear(self, ids):
+ clear = False
+ for pack in self.queue:
+ if not pack.getData()["id"] in ids:
+ clear = True
+ break
+ if not clear:
+ return
+ self.queue = []
+ self.view.emit(SIGNAL("clear"))
+
def getWaitingProgress(self, q):
locker = QMutexLocker(self.mutex)
if isinstance(q, self.QueueFile):
@@ -173,7 +189,6 @@ class Queue(QThread):
return 0
def getSpeed(self, q):
- #locker = QMutexLocker(self.mutex)
if isinstance(q, self.QueueFile):
data = q.getData()
if data["downloading"]:
@@ -251,6 +266,17 @@ class Queue(QThread):
def getData(self):
return self.data
+
+ def clear(self, ids):
+ clear = False
+ for file in self.getChildren():
+ if not file.getData()["id"] in ids:
+ clear = True
+ break
+ if not clear:
+ return
+ self.queue.queue = []
+ self.queue.view.emit(SIGNAL("clear"))
class QueueFile():
def __init__(self, queue, pack):
diff --git a/module/gui/connector.py b/module/gui/connector.py
index 75781ebb1..4d3af0d61 100644
--- a/module/gui/connector.py
+++ b/module/gui/connector.py
@@ -230,3 +230,23 @@ class connector(QThread):
self.proxy.restart_file(fileid)
finally:
self.mutex.unlock()
+
+ def removePackage(self, packid):
+ """
+ remove a package
+ """
+ self.mutex.lock()
+ try:
+ self.proxy.del_packages([packid,])
+ finally:
+ self.mutex.unlock()
+
+ def removeFile(self, fileid):
+ """
+ remove a file
+ """
+ self.mutex.lock()
+ try:
+ self.proxy.del_links([fileid,])
+ finally:
+ self.mutex.unlock()