diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/gui/Collector.py | 21 | ||||
-rw-r--r-- | module/gui/MainWindow.py | 4 | ||||
-rw-r--r-- | module/gui/PackageDock.py | 28 | ||||
-rw-r--r-- | module/gui/connector.py | 20 |
4 files changed, 70 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() |