summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-12-26 20:46:36 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-12-26 20:46:36 +0100
commit8888b714d748398e99f7425fa861f4e165579da6 (patch)
treecdd5818daeb9cd9283c94ae8bdec2deb74d88727 /module
parentfixed ddl-music, cleaned up, new status (starting), some more fixes (diff)
downloadpyload-8888b714d748398e99f7425fa861f4e165579da6.tar.xz
fixed view update
Diffstat (limited to 'module')
-rw-r--r--module/gui/Collector.py32
-rw-r--r--module/gui/Queue.py20
2 files changed, 32 insertions, 20 deletions
diff --git a/module/gui/Collector.py b/module/gui/Collector.py
index 1f89670ce..bf0e50349 100644
--- a/module/gui/Collector.py
+++ b/module/gui/Collector.py
@@ -29,6 +29,7 @@ class PackageCollector(QThread):
self.collector = []
self.interval = 2
self.running = True
+ self.rootItem = self.view.invisibleRootItem()
self.mutex = QMutex()
def run(self):
@@ -45,12 +46,16 @@ class PackageCollector(QThread):
ids = []
for data in packs:
ids.append(data["id"])
+ self.clear(ids)
+ for data in packs:
+ ids.append(data["id"])
pack = self.getPack(data["id"])
if not pack:
pack = self.PackageCollectorPack(self)
pack.setData(data)
self.addPack(data["id"], pack)
files = self.connector.getPackageFiles(data["id"])
+ pack.clear(files)
for fid in files:
info = self.connector.getLinkInfo(fid)
child = pack.getChild(fid)
@@ -58,8 +63,6 @@ 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
@@ -74,10 +77,10 @@ class PackageCollector(QThread):
except:
self.collector.append(newPack)
pos = self.collector.index(newPack)
- item = self.view.topLevelItem(pos)
+ item = self.rootItem.child(pos)
if not item:
item = QTreeWidgetItem()
- self.view.insertTopLevelItem(pos, item)
+ self.rootItem.insertChild(pos, item)
item.setData(0, Qt.DisplayRole, QVariant(newPack.getData()["package_name"]))
item.setData(0, Qt.UserRole, QVariant(pid))
@@ -95,8 +98,8 @@ class PackageCollector(QThread):
break
if not clear:
return
- self.collector = []
- self.view.emit(SIGNAL("clear"))
+ self.queue = []
+ self.rootItem.takeChildren()
class PackageCollectorPack():
def __init__(self, collector):
@@ -118,7 +121,7 @@ class PackageCollector(QThread):
self.children.append(newChild)
pos = self.children.index(newChild)
ppos = self.collector.collector.index(self)
- parent = self.collector.view.topLevelItem(ppos)
+ parent = self.collector.rootItem.child(ppos)
item = parent.child(pos)
if not item:
item = QTreeWidgetItem()
@@ -149,14 +152,23 @@ class PackageCollector(QThread):
def clear(self, ids):
clear = False
+ children = {}
for file in self.getChildren():
if not file.getData()["id"] in ids:
clear = True
break
+ try:
+ children[file.getData()["id"]]
+ clear = True
+ except:
+ children[file.getData()["id"]] = True
+
if not clear:
return
- self.collector.collector = []
- self.collector.view.emit(SIGNAL("clear"))
+ ppos = self.collector.collector.index(self)
+ parent = self.collector.rootItem.child(ppos)
+ parent.takeChildren()
+ self.children = []
class PackageCollectorFile():
def __init__(self, collector, pack):
@@ -193,6 +205,7 @@ class LinkCollector(QThread):
def update(self):
locker = QMutexLocker(self.mutex)
ids = self.connector.getLinkCollector()
+ self.clear(ids)
for id in ids:
data = self.connector.getLinkInfo(id)
file = self.getFile(id)
@@ -200,7 +213,6 @@ class LinkCollector(QThread):
file = self.LinkCollectorFile(self)
file.setData(data)
self.addFile(id, file)
- self.clear(ids)
def addFile(self, pid, newFile):
pos = None
diff --git a/module/gui/Queue.py b/module/gui/Queue.py
index f542c9a6b..0def31bf6 100644
--- a/module/gui/Queue.py
+++ b/module/gui/Queue.py
@@ -40,6 +40,7 @@ class Queue(QThread):
self.interval = 1
self.running = True
self.wait_dict = {}
+ self.rootItem = self.view.invisibleRootItem()
self.mutex = QMutex()
def run(self):
@@ -63,13 +64,16 @@ class Queue(QThread):
downloading[did] = d
ids = []
for data in packs:
- pack = self.getPack(data["id"])
ids.append(data["id"])
+ self.clear(ids)
+ for data in packs:
+ pack = self.getPack(data["id"])
if not pack:
pack = self.QueuePack(self)
pack.setData(data)
self.addPack(data["id"], pack)
files = self.connector.getPackageFiles(data["id"])
+ pack.clear(files)
for fid in files:
info = self.connector.getLinkInfo(fid)
child = pack.getChild(fid)
@@ -82,8 +86,6 @@ class Queue(QThread):
pass
child.setData(info)
pack.addChild(fid, child)
- pack.clear(files)
- self.clear(ids)
def addPack(self, pid, newPack):
pos = None
@@ -98,10 +100,10 @@ class Queue(QThread):
except:
self.queue.append(newPack)
pos = self.queue.index(newPack)
- item = self.view.topLevelItem(pos)
+ item = self.rootItem.child(pos)
if not item:
item = QTreeWidgetItem()
- self.view.insertTopLevelItem(pos, item)
+ self.rootItem.insertChild(pos, item)
item.setData(0, Qt.DisplayRole, QVariant(newPack.getData()["package_name"]))
status = -1
speed = self.getSpeed(newPack)
@@ -136,7 +138,7 @@ class Queue(QThread):
if not clear:
return
self.queue = []
- self.view.emit(SIGNAL("clear"))
+ self.rootItem.takeChildren()
def getWaitingProgress(self, q):
locker = QMutexLocker(self.mutex)
@@ -233,7 +235,7 @@ class Queue(QThread):
self.children.append(newChild)
pos = self.children.index(newChild)
ppos = self.queue.queue.index(self)
- parent = self.queue.view.topLevelItem(ppos)
+ parent = self.queue.rootItem.child(ppos)
item = parent.child(pos)
if not item:
item = QTreeWidgetItem()
@@ -283,11 +285,9 @@ class Queue(QThread):
if not clear:
return
ppos = self.queue.queue.index(self)
- parent = self.queue.view.topLevelItem(ppos)
+ parent = self.queue.rootItem.child(ppos)
parent.takeChildren()
self.children = []
- self.queue.queue = []
- self.queue.view.emit(SIGNAL("clear"))
class QueueFile():
def __init__(self, queue, pack):