summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-12-28 19:51:37 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-12-28 19:51:37 +0100
commitda359f8c770bac754234e0f899058b25126cd476 (patch)
treed519267334d9526f21a3cf39c86d5f8ba916ce7a
parentFixed DLC (diff)
downloadpyload-da359f8c770bac754234e0f899058b25126cd476.tar.xz
gui: easier package management
-rw-r--r--module/gui/Collector.py26
-rw-r--r--module/gui/MainWindow.py50
-rw-r--r--module/gui/PackageDock.py2
-rw-r--r--module/gui/Queue.py10
-rwxr-xr-xpyLoadGui.py57
5 files changed, 89 insertions, 56 deletions
diff --git a/module/gui/Collector.py b/module/gui/Collector.py
index c2d167291..07a5203e9 100644
--- a/module/gui/Collector.py
+++ b/module/gui/Collector.py
@@ -33,6 +33,12 @@ class PackageCollector(QThread):
self.running = True
self.rootItem = self.view.invisibleRootItem()
self.mutex = QMutex()
+ item = self.PackageCollectorPack(self)
+ item.setPackData({"id":"fixed"})
+ item.setData(0, Qt.DisplayRole, QVariant("Single Links"))
+ item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
+ self.rootItem.addChild(item)
+ self.linkCollector = item
def run(self):
while self.running:
@@ -78,10 +84,11 @@ class PackageCollector(QThread):
item = self.rootItem.child(pos)
item.setPackData(newPack.getPackData())
except:
- self.rootItem.addChild(newPack)
+ self.rootItem.insertChild(self.rootItem.childCount()-1, newPack)
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)
def getPack(self, pid):
for k, pack in enumerate(ItemIterator(self.rootItem)):
@@ -91,13 +98,17 @@ class PackageCollector(QThread):
def clear(self, ids):
clear = False
- for pack in ItemIterator(self.rootItem):
- if not pack.getPackData()["id"] in ids:
+ remove = []
+ for k, pack in enumerate(ItemIterator(self.rootItem)):
+ if not pack.getPackData()["id"] in ids and not pack.getPackData()["id"] == "fixed":
clear = True
- break
+ remove.append(k)
if not clear:
return
- self.rootItem.takeChildren()
+ remove.sort()
+ remove.reverse()
+ for k in remove:
+ self.rootItem.takeChild(k)
class PackageCollectorPack(QTreeWidgetItem):
def __init__(self, collector):
@@ -121,6 +132,7 @@ class PackageCollector(QThread):
item = newChild
item.setData(0, Qt.DisplayRole, QVariant(item.getFileData()["filename"]))
item.setData(0, Qt.UserRole, QVariant(cid))
+ item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
def setPackData(self, data):
self._data = data
@@ -177,13 +189,13 @@ class PackageCollector(QThread):
return self.pack
class LinkCollector(QThread):
- def __init__(self, view, connector):
+ def __init__(self, view, root, connector):
QThread.__init__(self)
self.view = view
self.connector = connector
self.interval = 2
self.running = True
- self.rootItem = self.view.invisibleRootItem()
+ self.rootItem = root
self.mutex = QMutex()
def run(self):
diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py
index 76f60a5bd..610d8e840 100644
--- a/module/gui/MainWindow.py
+++ b/module/gui/MainWindow.py
@@ -102,8 +102,9 @@ 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.slotPackageCollectorContextMenu)
- self.connect(self.tabs["collector"]["link_view"], SIGNAL('customContextMenuRequested(const QPoint &)'), self.slotLinkCollectorContextMenu)
+ self.connect(self.tabs["collector"]["package_view"], SIGNAL('customContextMenuRequested(const QPoint &)'), self.slotcollectorContextMenu)
+
+ self.lastAddedID = None
def init_toolbar(self):
"""
@@ -149,31 +150,21 @@ class MainWindow(QMainWindow):
#collector
groupPackage = QGroupBox("Packages")
- groupLinks = QGroupBox("Links")
groupPackage.setLayout(QVBoxLayout())
- groupLinks.setLayout(QVBoxLayout())
toQueue = QPushButton("Push selected packages to queue")
self.tabs["collector"]["l"] = QGridLayout()
self.tabs["collector"]["w"].setLayout(self.tabs["collector"]["l"])
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"])
self.tabs["collector"]["l"].addWidget(groupPackage, 0, 0)
- self.tabs["collector"]["l"].addWidget(groupLinks, 0, 1)
self.connect(toQueue, SIGNAL("clicked()"), self.slotPushPackageToQueue)
self.tabs["collector"]["package_view"].setContextMenuPolicy(Qt.CustomContextMenu)
- self.tabs["collector"]["link_view"].setContextMenuPolicy(Qt.CustomContextMenu)
self.tabs["queue"]["view"].setContextMenuPolicy(Qt.CustomContextMenu)
#settings
self.tabs["settings"]["l"] = QGridLayout()
self.tabs["settings"]["w"].setLayout(self.tabs["settings"]["l"])
- #self.tabs["settings"]["view"] = QTreeWidget()
- #self.tabs["settings"]["l"].addWidget(self.tabs["settings"]["view"])
#log
self.tabs["log"]["l"] = QGridLayout()
@@ -200,13 +191,16 @@ class MainWindow(QMainWindow):
self.connect(self.queueContext.buttons["remove"], SIGNAL("triggered()"), self.slotRemoveDownload)
self.connect(self.queueContext.buttons["restart"], SIGNAL("triggered()"), self.slotRestartDownload)
- #package collector
- self.packageCollectorContext = QMenu()
- self.packageCollectorContext.buttons = {}
- self.packageCollectorContext.item = (None, None)
- self.packageCollectorContext.buttons["remove"] = QAction(QIcon("icons/gui/remove_small.png"), "Remove", self.packageCollectorContext)
- self.packageCollectorContext.addAction(self.packageCollectorContext.buttons["remove"])
- self.connect(self.packageCollectorContext.buttons["remove"], SIGNAL("triggered()"), self.slotRemoveDownload)
+ #collector
+ self.collectorContext = QMenu()
+ self.collectorContext.buttons = {}
+ 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.addAction(self.collectorContext.buttons["push"])
+ 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)
def slotToggleStatus(self, status):
"""
@@ -282,10 +276,18 @@ class MainWindow(QMainWindow):
items = self.tabs["collector"]["package_view"].selectedItems()
for item in items:
try:
- id = item.getFileData()["id"]
+ item.getFileData()
id = item.parent().getPackData()["id"]
+ pack = item.parent()
except:
id = item.getPackData()["id"]
+ pack = item
+ if id == "fixed":
+ ids = []
+ for child in pack.getChildren():
+ ids.append(child.getFileData()["id"])
+ self.emit(SIGNAL("addPackage"), "Single Links", ids)
+ id = self.lastAddedID
self.emit(SIGNAL("pushPackageToQueue"), id)
def saveWindow(self):
@@ -337,7 +339,7 @@ class MainWindow(QMainWindow):
self.activeMenu = self.queueContext
self.queueContext.exec_(menuPos)
- def slotPackageCollectorContextMenu(self, pos):
+ def slotcollectorContextMenu(self, pos):
"""
custom context menu in package collector view requested
"""
@@ -346,11 +348,11 @@ class MainWindow(QMainWindow):
if not i:
return
i.setSelected(True)
- self.packageCollectorContext.item = (i.data(0, Qt.UserRole).toPyObject(), i.parent() == None)
+ self.collectorContext.item = (i.data(0, Qt.UserRole).toPyObject(), i.parent() == None)
menuPos = QCursor.pos()
menuPos.setX(menuPos.x()+2)
- self.activeMenu = self.packageCollectorContext
- self.packageCollectorContext.exec_(menuPos)
+ self.activeMenu = self.collectorContext
+ self.collectorContext.exec_(menuPos)
def slotLinkCollectorContextMenu(self, pos):
"""
diff --git a/module/gui/PackageDock.py b/module/gui/PackageDock.py
index b90e3533d..c81798935 100644
--- a/module/gui/PackageDock.py
+++ b/module/gui/PackageDock.py
@@ -53,7 +53,7 @@ class NewPackageWindow(QWidget):
linksLabel = QLabel("Links in this Package")
linkView = QTreeWidget()
linkView.setSelectionBehavior(QAbstractItemView.SelectRows)
- linkView.setSelectionMode(QAbstractItemView.SingleSelection)
+ linkView.setSelectionMode(QAbstractItemView.ExtendedSelection)
linkView.setColumnCount(1)
linkView.setHeaderLabels(["Name"])
linkView.setDragEnabled(True)
diff --git a/module/gui/Queue.py b/module/gui/Queue.py
index c0f43c740..499cb5199 100644
--- a/module/gui/Queue.py
+++ b/module/gui/Queue.py
@@ -133,13 +133,17 @@ class Queue(QThread):
def clear(self, ids):
clear = False
- for pack in ItemIterator(self.rootItem):
+ remove = []
+ for k, pack in enumerate(ItemIterator(self.rootItem)):
if not pack.getPackData()["id"] in ids:
clear = True
- break
+ remove.append(k)
if not clear:
return
- self.rootItem.takeChildren()
+ remove.sort()
+ remove.reverse()
+ for k in remove:
+ self.rootItem.takeChild(k)
def getWaitingProgress(self, q):
locker = QMutexLocker(self.mutex)
diff --git a/pyLoadGui.py b/pyLoadGui.py
index 681feec8a..5ce098fa0 100755
--- a/pyLoadGui.py
+++ b/pyLoadGui.py
@@ -154,39 +154,53 @@ class main(QObject):
* columns
* selection
* refresh thread
- """
- view = self.mainWindow.tabs["collector"]["package_view"]
- view.setColumnCount(1)
- view.setHeaderLabels(["Name"])
- view.setSelectionMode(QAbstractItemView.ExtendedSelection)
- self.packageCollector = PackageCollector(view, self.connector)
- self.packageCollector.start()
-
- def initLinkCollector(self):
- """
- init the link collector view
- * columns
- * selection
* drag'n'drop
- * refresh thread
"""
- view = self.mainWindow.tabs["collector"]["link_view"]
+ view = self.mainWindow.tabs["collector"]["package_view"]
view.setColumnCount(1)
view.setHeaderLabels(["Name"])
view.setSelectionBehavior(QAbstractItemView.SelectRows)
- view.setSelectionMode(QAbstractItemView.SingleSelection)
- def event(klass, event):
+ view.setSelectionMode(QAbstractItemView.ExtendedSelection)
+ def dropEvent(klass, event):
event.setDropAction(Qt.CopyAction)
event.accept()
view = event.source()
- row = view.currentIndex().row()
- view.takeTopLevelItem(row)
- view.dropEvent = event
+ if view == klass:
+ event.ignore()
+ return
+ items = view.selectedItems()
+ for item in items:
+ row = view.indexOfTopLevelItem(item)
+ view.takeTopLevelItem(row)
+ def dragEvent(klass, event):
+ view = event.source()
+ dragOkay = False
+ items = view.selectedItems()
+ for item in items:
+ if hasattr(item, "_data"):
+ if item._data["id"] == "fixed" or item.parent()._data["id"] == "fixed":
+ dragOkay = True
+ else:
+ dragOkay = True
+ if dragOkay:
+ event.accept()
+ else:
+ event.ignore()
+ view.dropEvent = dropEvent
+ view.dragEnterEvent = dragEvent
view.setDragEnabled(True)
view.setDragDropMode(QAbstractItemView.DragDrop)
view.setDropIndicatorShown(True)
view.setDragDropOverwriteMode(True)
- self.linkCollector = LinkCollector(view, self.connector)
+ self.packageCollector = PackageCollector(view, self.connector)
+ self.packageCollector.start()
+
+ def initLinkCollector(self):
+ """
+ init the link collector
+ * refresh thread
+ """
+ self.linkCollector = LinkCollector(self.mainWindow.tabs["collector"]["package_view"], self.packageCollector.linkCollector, self.connector)
self.linkCollector.start()
def initQueue(self):
@@ -411,6 +425,7 @@ class main(QObject):
packid = self.connector.newPackage(str(name))
for fileid in ids:
self.connector.addFileToPackage(fileid, packid)
+ self.mainWindow.lastAddedID = packid
def slotAddContainer(self, path):
"""