summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/gui/Collector.py21
-rw-r--r--module/gui/MainWindow.py4
-rw-r--r--module/gui/PackageDock.py28
-rw-r--r--module/gui/connector.py20
-rwxr-xr-xpyLoadGui.py19
5 files changed, 89 insertions, 3 deletions
diff --git a/module/gui/Collector.py b/module/gui/Collector.py
index 0dbccab1f..28cac097b 100644
--- a/module/gui/Collector.py
+++ b/module/gui/Collector.py
@@ -102,8 +102,8 @@ class PackageCollector(QThread):
except:
self.children.append(newChild)
pos = self.children.index(newChild)
- ppos = self.queue.queue.index(self)
- parent = self.queue.view.topLevelItem(ppos)
+ ppos = self.collector.collector.index(self)
+ parent = self.collector.view.topLevelItem(ppos)
item = parent.child(pos)
if not item:
item = QTreeWidgetItem()
@@ -172,6 +172,7 @@ class LinkCollector(QThread):
file = self.LinkCollectorFile(self)
file.setData(data)
self.addFile(id, file)
+ self.clear(ids)
def addFile(self, pid, newFile):
pos = None
@@ -192,12 +193,28 @@ class LinkCollector(QThread):
self.view.insertTopLevelItem(pos, item)
item.setData(0, Qt.DisplayRole, QVariant(newFile.getData()["filename"]))
item.setData(0, Qt.UserRole, QVariant(pid))
+ flags = Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsEnabled
+ item.setFlags(flags)
def getFile(self, pid):
for k, file in enumerate(self.collector):
if file.getData()["id"] == pid:
return file
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:
+ return
+ toremove.sort()
+ toremove.reverse()
+ for pos in toremove:
+ del self.collector[k]
+ self.view.takeTopLevelItem(k)
class LinkCollectorFile():
def __init__(self, collector):
diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py
index 6d68f4d7a..63ffb86a0 100644
--- a/module/gui/MainWindow.py
+++ b/module/gui/MainWindow.py
@@ -39,6 +39,7 @@ class MainWindow(QMainWindow):
self.newLinkDock = NewLinkDock()
self.addDockWidget(Qt.RightDockWidgetArea, self.newLinkDock)
self.connect(self.newLinkDock, SIGNAL("done"), self.slotAddLinks)
+ self.connect(self.newPackDock, SIGNAL("done"), self.slotAddPackage)
#central widget, layout
self.masterlayout = QVBoxLayout()
@@ -156,3 +157,6 @@ class MainWindow(QMainWindow):
def slotAddLinks(self, links):
self.emit(SIGNAL("addLinks"), links)
+
+ def slotAddPackage(self, name, ids):
+ self.emit(SIGNAL("addPackage"), name, ids)
diff --git a/module/gui/PackageDock.py b/module/gui/PackageDock.py
index c97e9d645..7367efda4 100644
--- a/module/gui/PackageDock.py
+++ b/module/gui/PackageDock.py
@@ -26,6 +26,18 @@ class NewPackageDock(QDockWidget):
self.setWidget(self.widget)
self.setAllowedAreas(Qt.RightDockWidgetArea|Qt.LeftDockWidgetArea)
self.hide()
+
+ def slotDone(self):
+ view = self.widget.view
+ count = view.topLevelItemCount()
+ ids = []
+ for i in range(count):
+ item = view.topLevelItem(i)
+ if item:
+ ids.append(item.data(0, Qt.UserRole).toInt()[0])
+ self.emit(SIGNAL("done"), self.widget.nameInput.text(), ids)
+ view.clear()
+ self.hide()
class NewPackageWindow(QWidget):
def __init__(self, dock):
@@ -38,7 +50,19 @@ class NewPackageWindow(QWidget):
nameInput = QLineEdit()
linksLabel = QLabel("Links in this Package")
- linkView = QListWidget()
+ linkView = QTreeWidget()
+ linkView.setSelectionBehavior(QAbstractItemView.SelectRows)
+ linkView.setSelectionMode(QAbstractItemView.SingleSelection)
+ linkView.setColumnCount(1)
+ linkView.setHeaderLabels(["Name"])
+ linkView.setDragEnabled(True)
+ linkView.setDragDropMode(QAbstractItemView.DragDrop)
+ linkView.setDropIndicatorShown(True)
+ linkView.setAcceptDrops(True)
+ linkView.setDragDropOverwriteMode(True)
+
+ self.view = linkView
+ self.nameInput = nameInput
save = QPushButton("Create")
@@ -47,3 +71,5 @@ class NewPackageWindow(QWidget):
layout.addWidget(linksLabel, 1, 0, 1, 2)
layout.addWidget(linkView, 2, 0, 1, 2)
layout.addWidget(save, 3, 0, 1, 2)
+
+ self.connect(save, SIGNAL("clicked()"), self.dock.slotDone)
diff --git a/module/gui/connector.py b/module/gui/connector.py
index 32da29bba..e7a151c5e 100644
--- a/module/gui/connector.py
+++ b/module/gui/connector.py
@@ -177,3 +177,23 @@ class connector(QThread):
self.proxy.unpause_server()
finally:
self.mutex.unlock()
+
+ def newPackage(self, name):
+ """
+ create a new package and return id
+ """
+ self.mutex.lock()
+ try:
+ return self.proxy.new_package(name)
+ finally:
+ self.mutex.unlock()
+
+ def addFileToPackage(self, fileid, packid):
+ """
+ add a file from collector to package
+ """
+ self.mutex.lock()
+ try:
+ self.proxy.move_file_2_package(fileid, packid)
+ finally:
+ self.mutex.unlock()
diff --git a/pyLoadGui.py b/pyLoadGui.py
index 6c3bae1dd..ccab8ba64 100755
--- a/pyLoadGui.py
+++ b/pyLoadGui.py
@@ -88,6 +88,7 @@ class main(QObject):
self.connect(self.pwWindow, SIGNAL("cancel"), self.quit)
self.connect(self.mainWindow, SIGNAL("connector"), self.slotShowConnector)
self.connect(self.mainWindow, SIGNAL("addLinks"), self.slotAddLinks)
+ self.connect(self.mainWindow, SIGNAL("addPackage"), self.slotAddPackage)
self.connect(self.mainWindow, SIGNAL("setDownloadStatus"), self.slotSetDownloadStatus)
def slotShowConnector(self):
@@ -120,6 +121,19 @@ class main(QObject):
view = self.mainWindow.tabs["collector"]["link_view"]
view.setColumnCount(1)
view.setHeaderLabels(["Name"])
+ view.setSelectionBehavior(QAbstractItemView.SelectRows)
+ view.setSelectionMode(QAbstractItemView.SingleSelection)
+ def event(klass, event):
+ event.setDropAction(Qt.CopyAction)
+ event.accept()
+ view = event.source()
+ row = view.currentIndex().row()
+ view.takeTopLevelItem(row)
+ view.dropEvent = event
+ view.setDragEnabled(True)
+ view.setDragDropMode(QAbstractItemView.DragDrop)
+ view.setDropIndicatorShown(True)
+ view.setDragDropOverwriteMode(True)
self.linkCollector = LinkCollector(view, self.connector)
self.linkCollector.start()
@@ -274,6 +288,11 @@ class main(QObject):
def slotSetDownloadStatus(self, status):
self.connector.setPause(not status)
+ def slotAddPackage(self, name, ids):
+ packid = self.connector.newPackage(str(name))
+ for fileid in ids:
+ self.connector.addFileToPackage(fileid, packid)
+
class Loop(QThread):
def __init__(self, parent):
QThread.__init__(self)