From 02900d8c9dab4afed382fb20f7a9aa25dbf33996 Mon Sep 17 00:00:00 2001 From: Sally Date: Tue, 12 Mar 2019 11:04:20 +0100 Subject: [PATCH] Markierte Items/Dateipfade erscheinen im Lineedit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ein in der Liste markiertes Item erscheint im Lineedit. Wenn mehrere ausgewählt sind, erscheint das zuletzt gewählte im Lineedit. Wenn kein Item ausgewählt ist, wird das Lineedit geleert. --- pylot/core/util/widgets.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 13e7f74f..1d0b1844 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -227,6 +227,8 @@ class AddMetadataWidget(QWidget): self.list_model = QtGui.QStandardItemModel(self.list_view) self.list_view.setModel(self.list_model) self.list_layout.insertWidget(1, self.list_view, 1) + self.sel_model = self.list_view.selectionModel() + self.sel_model.selectionChanged.connect(self.on_clicked) def init_accept_cancel_buttons(self): self.accept_cancel_layout = QHBoxLayout() @@ -265,6 +267,18 @@ class AddMetadataWidget(QWidget): return return fninv + def on_clicked(self): + #for index in self.list_view.selectionModel().selectedIndexes(): + # item = self.list_model.itemData(index) + # inventory_path = item[0] + indices = self.list_view.selectionModel().selectedIndexes() + try: + item = self.list_model.itemData(indices[-1]) + inventory_path = item[0] + except IndexError: + inventory_path = "" + self.selection_box.setText(inventory_path) + def add_item_from_lineedit(self): """ checks if the inventory path is already in the list and if it leads to a directory;