summaryrefslogtreecommitdiffstats
path: root/module/gui/Collector.py
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-12-22 17:07:35 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-12-22 17:07:35 +0100
commited36dd5988907019cc9cc5b98265f00a52462c85 (patch)
tree855820996780a291b644d20d4424b5289b311e06 /module/gui/Collector.py
parentwebserver for win (diff)
downloadpyload-ed36dd5988907019cc9cc5b98265f00a52462c85.tar.xz
more docstrings, small design changes
Diffstat (limited to 'module/gui/Collector.py')
-rw-r--r--module/gui/Collector.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/module/gui/Collector.py b/module/gui/Collector.py
index 28cac097b..1d622b006 100644
--- a/module/gui/Collector.py
+++ b/module/gui/Collector.py
@@ -42,7 +42,9 @@ class PackageCollector(QThread):
def update(self):
locker = QMutexLocker(self.mutex)
packs = self.connector.getPackageCollector()
+ ids = []
for data in packs:
+ ids.append(data["id"])
pack = self.getPack(data["id"])
if not pack:
pack = self.PackageCollectorPack(self)
@@ -56,6 +58,8 @@ class PackageCollector(QThread):
child = self.PackageCollectorFile(self, pack)
child.setData(info)
pack.addChild(fid, child)
+ #pack.clear(files)
+ self.clear(ids)
def addPack(self, pid, newPack):
pos = None
@@ -83,6 +87,18 @@ class PackageCollector(QThread):
return pack
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:
+ return
+ self.collector = []
+ #self.view.clear()
+ self.view.emit(SIGNAL("clear"))
+
class PackageCollectorPack():
def __init__(self, collector):
self.collector = collector
@@ -111,6 +127,8 @@ class PackageCollector(QThread):
status = "%s (%s)" % (newChild.getData()["status_type"], newChild.getData()["plugin"])
item.setData(0, Qt.DisplayRole, QVariant(newChild.getData()["filename"]))
item.setData(0, Qt.UserRole, QVariant(cid))
+ flags = Qt.ItemIsEnabled
+ item.setFlags(flags)
def getChildren(self):
return self.children
@@ -129,6 +147,22 @@ class PackageCollector(QThread):
def getData(self):
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:
+ 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)
class PackageCollectorFile():
def __init__(self, collector, pack):