예제 #1
0
    def _ext_sel_changed(self, selected: QItemSelection,
                         deselected: QItemSelection):
        """
        Selection changed for view.extList, save new selection
        :@param selected: QItemSelection
        :@param deselected: QItemSelection
        :@return: None
        """
        model = self.ui.extList.model()
        for id_ in selected.indexes():
            if model.rowCount(id_) > 0:
                self.ui.extList.setExpanded(id_, True)
                sel = QItemSelection(
                    model.index(0, 0, id_),
                    model.index(
                        model.rowCount(id_) - 1,
                        model.columnCount(id_) - 1, id_),
                )
                self.ui.extList.selectionModel().select(
                    sel, QItemSelectionModel.Select)

        for id_ in deselected.indexes():
            if id_.parent().isValid():
                self.ui.extList.selectionModel().select(
                    id_.parent(), QItemSelectionModel.Deselect)

        self._save_ext_selection()
예제 #2
0
    def update_dependency_fields(self, idx:QtCore.QItemSelection):
        """ Update single fields on dependency tab in relation to selected row in table view"""

        self.logger.debug("Update dependency fields")

        self.cmbDepAction.setEnabled(False)
        self.cmbDepProdID.setEnabled(False)
        self.cmbDepReqAction.setEnabled(False)
        self.cmbDepInstState.setEnabled(False)
        self.cmbDepRequirement.setEnabled(False)
        self.btnDepModify.setEnabled(False)
        self.btnDepAdd.setEnabled(True)

        # disconnect if there has been an editing event before
        try:
            self.cmbDepReqAction.currentIndexChanged.disconnect()
            self.cmbDepInstState.currentIndexChanged.disconnect()
        except:
            pass

        if self.datamapper_dependencies.model().item(0, 0) is not None:
            self.btnDepDelete.setEnabled(True)
            self.btnDepEdit.setEnabled(True)

            # indexes() returns list of selected items
            # as we only have 1 at a time, return first item and get corresponding row number
            if not idx.indexes() == []:
                row = idx.indexes()[0].row()
                self.datamapper_dependencies.setCurrentIndex(row)
            else:
                self.datamapper_dependencies.toFirst()

        else:
            self.btnDepDelete.setEnabled(False)
            self.btnDepEdit.setEnabled(False)
예제 #3
0
 def update_property_fields(self, idx:QtCore.QItemSelection):
     # indexes() returns list of selected items
     # as we only have 1 at a time, return first item and get corresponding row number
     self.logger.debug("Update property fields")
     if not idx.indexes() == []:
         row = idx.indexes()[0].row()
         if self._parent.model_properties.item(row, 1).text() == 'bool':
             self.datamapper_properties.removeMapping(self.inpPropDef)
             self.datamapper_properties.addMapping(self.cmbPropDef, 6)
             self.inpPropVal.setEnabled(False)
             self.inpPropDef.setEnabled(False)
             self.cmbPropMulti.setEnabled(False)
             self.cmbPropEdit.setEnabled(False)
             self.cmbPropDef.setEnabled(True)
         else:
             self.datamapper_properties.addMapping(self.inpPropDef, 6)
             self.datamapper_properties.removeMapping(self.cmbPropDef)
             self.inpPropVal.setEnabled(True)
             self.inpPropDef.setEnabled(True)
             self.cmbPropMulti.setEnabled(True)
             self.cmbPropEdit.setEnabled(True)
             self.cmbPropDef.setEnabled(False)
         self.datamapper_properties.setCurrentIndex(row)
     else:
         self.datamapper_properties.toFirst()
예제 #4
0
    def changedSelected(self, selected: QtCore.QItemSelection):
        if isinstance(selected, QtCore.QItemSelection):
            if len(selected.indexes()):
                i = selected.indexes()[0].row()
                item = self.fieldlistModel.item(i)

                for field in self.registerLayout.fields:
                    if field.listItem == item:
                        self.registerLayout.setSelected(field)
예제 #5
0
 def _restoreSelection(self):
     newSelection = QItemSelection()
     for index in self.model.selected_indexes:
         newSelection.select(self.createIndex(index, 0), self.createIndex(index, 0))
     self.view.selectionModel().select(newSelection, QItemSelectionModel.ClearAndSelect)
     if len(newSelection.indexes()):
         currentIndex = newSelection.indexes()[0]
         self.view.selectionModel().setCurrentIndex(currentIndex, QItemSelectionModel.Current)
         self.view.scrollTo(currentIndex)
예제 #6
0
 def _restoreSelection(self):
     newSelection = QItemSelection()
     for index in self.model.selected_indexes:
         newSelection.select(self.createIndex(index, 0), self.createIndex(index, 0))
     self.view.selectionModel().select(newSelection, QItemSelectionModel.ClearAndSelect)
     if len(newSelection.indexes()):
         currentIndex = newSelection.indexes()[0]
         self.view.selectionModel().setCurrentIndex(currentIndex, QItemSelectionModel.Current)
         self.view.scrollTo(currentIndex)
예제 #7
0
    def on_selection_changed(self, selected: QItemSelection,
                             deselected: QItemSelection):
        for index in selected.indexes():
            item = index.data(AnnotationsModel.ItemRole)
            item.setSelected(True)

        for index in deselected.indexes():
            item = index.data(AnnotationsModel.ItemRole)
            item.setSelected(False)
예제 #8
0
 def update_dependency_fields(self, idx:QtCore.QItemSelection):
     # indexes() returns list of selected items
     # as we only have 1 at a time, return first item and get corresponding row number
     self.logger.debug("Update dependency fields")
     if not idx.indexes() == []:
         row = idx.indexes()[0].row()
         self.datamapper_dependencies.setCurrentIndex(row)
     else:
         self.datamapper_dependencies.toFirst()
 def selected_layer_selection_changed(self, selected: QtCore.QItemSelection,
                                      deselected: QtCore.QItemSelection):
     if len(selected.indexes()) > 0 and self.validate_layer_rb.isChecked():
         self.toggle_other_pages(True)
         # TODO: check if self.dataset is None
         self.dataset = self._get_current_layer()
     elif len(selected.indexes()) == 0 and self.validate_layer_rb.isChecked(
     ):
         self.toggle_other_pages(False)
         self.dataset = None
예제 #10
0
 def _on_selection_change(
     self,
     selected: QtCore.QItemSelection,
     _deselected: QtCore.QItemSelection,
 ) -> None:
     if len(selected.indexes()) == 1:
         self.setEnabled(True)
         self._mapper.set_current_index(selected.indexes()[0].row())
     else:
         self.setEnabled(False)
         self._mapper.set_current_index(None)
예제 #11
0
 def _updateViewSelection(self):
     # Takes the selection on the model's side and update the view with it.
     newSelection = QItemSelection()
     columnCount = self.columnCount(QModelIndex())
     for index in self.model.selected_indexes:
         newSelection.select(self.createIndex(index, 0), self.createIndex(index, columnCount-1))
     self.view.selectionModel().select(newSelection, QItemSelectionModel.ClearAndSelect)
     if len(newSelection.indexes()):
         currentIndex = newSelection.indexes()[0]
         self.view.selectionModel().setCurrentIndex(currentIndex, QItemSelectionModel.Current)
         self.view.scrollTo(currentIndex)
예제 #12
0
    def selectionChanged(self, selected: QItemSelection,
                         deselected: QItemSelection) -> None:
        # WARNING: selectionChanged will be called before init()
        if not hasattr(self, "animation_data"):
            return

        for index in selected.indexes():
            name = self.model.itemFromIndex(index).text()
            self.animation_data.select(name)

        for index in deselected.indexes():
            name = self.model.itemFromIndex(index).text()
            self.animation_data.deselect(name)

        for sequence in self.animation_data.selected:
            sequence.select_all()

        self.animation_data_changed.emit()

        #
        # for index in deselected.indexes():
        # 	item = self.model.itemFromIndex(index)
        # 	if item.parent() is None:
        # 		pass
        # 	else:
        # 		deselected_frames.append(item)
        #
        # if len(selected_sequences) != 0:
        # 	# Change to this sequence
        # 	self.animation_data.active_sequence = self.animation_data.get_sequence(selected_sequences[0].text())
        # 	self.animation_data_changed_signal.emit()
        # 	self.clearSelection()
        # 	#self.selectionModel().select(selected_sequences[0].index(), QItemSelectionModel.Select)
        #
        # elif len(selected_frames) != 0 or len(deselected_frames) != 0:
        # 	# Only frames have been selected
        # 	for index in selected.indexes():
        # 		# Add frames to selection
        # 		item = self.model.itemFromIndex(index)
        # 		if item.parent() is not None:
        # 			self.animation_data.active_sequence.select(int(item.text()))
        #
        # 	for index in deselected.indexes():
        # 		# Remove frames from selection
        # 		item = self.model.itemFromIndex(index)
        # 		if item.parent() is not None:
        # 			self.animation_data.active_sequence.deselect(int(item.text()))
        #
        # 	self.animation_data_changed_signal.emit()

        super(SpritesheetAnimationList,
              self).selectionChanged(selected, deselected)
    def selectionFilter(self, selected_items: QItemSelection,
                        deselected_items: QItemSelection):
        """Disables selections of items not in the active filter set.
        I had issues with segfaults subclassing QItemSelectionModel so
        this is the next best thing I think
        """

        # NOTE: prevent selection when select is not pressed
        is_not_select_tool = not self._window.action_global_select.isChecked()

        document = self._document
        # print("!!!!!!!!filter", len(selected_items), len(deselected_items))
        if self.selection_filter_disabled:
            return
        filter_set = document.filter_set
        filter_set.add('part')
        out_deselection = []
        out_selection = []
        flags = QItemSelectionModel.Current | QItemSelectionModel.Deselect
        for index in selected_items.indexes():
            item = self.itemFromIndex(index)
            if is_not_select_tool or item.FILTER_NAME not in filter_set:
                if index.column() == 0:
                    # print("deselect", item.FILTER_NAME, filter_set,
                    #                     index.row(), index.column())
                    out_deselection.append(index)
            else:
                out_selection.append(index)
        sm = self.selectionModel()
        if len(out_deselection) > 0:
            self.indexFromItem(item)
            deselection = QItemSelection(out_deselection[0],
                                         out_deselection[-1])
            sm.blockSignals(True)
            sm.select(deselection, flags)
            sm.blockSignals(False)

        # now group the indices into items in sets
        tbs, tbd = self.model_selection_changes
        # print("sets:", tbs, tbd)
        for idx in out_selection:
            item = self.itemFromIndex(idx)
            # print("did select", item)
            tbs.add(item)
        for idx in deselected_items.indexes():
            # print("could deselect?", self.itemFromIndex(idx))
            item = self.itemFromIndex(idx)
            if item not in tbd and item.isModelSelected(document):
                tbd.add(item)
        self.processSelections(deselect_only=True)
예제 #14
0
 def _on_selection_change(
     self,
     selected: QItemSelection,
     _deselected: QItemSelection,
 ) -> None:
     anything_selected = len(selected.indexes()) > 0
     self._remove_button.setEnabled(anything_selected)
     self._rename_button.setEnabled(anything_selected)
     self._duplicate_button.setEnabled(anything_selected)
     self._move_up_button.setEnabled(anything_selected
                                     and selected.indexes()[0].row() > 0)
     self._move_down_button.setEnabled(
         anything_selected
         and selected.indexes()[0].row() < len(self._api.subs.styles) - 1)
예제 #15
0
    def _on_selection_changed(self, selection: QItemSelection):
        if len(selection.indexes()) != 0:
            modelIndex: QModelIndex = selection.indexes()[0]
            index = modelIndex.row()
            tables = self._appModel.get_tables()
            if index not in self._listViewIndexToTabIndex:
                table_name = tables[index]
                new_tab = self._create_new_tab(table_name)
                self.tablesTabs.addTab(new_tab.view, table_name)
                self._listViewIndexToTabIndex[index] = self.tablesTabs.count(
                ) - 1

            self.tablesTabs.setCurrentIndex(
                self._listViewIndexToTabIndex[index])
예제 #16
0
    def selectionFilter(self,   selected_items: QItemSelection,
                                deselected_items: QItemSelection):
        """Disables selections of items not in the active filter set.
        I had issues with segfaults subclassing QItemSelectionModel so
        this is the next best thing I think
        """

        # NOTE: prevent selection when select is not pressed
        is_not_select_tool = not self._window.action_global_select.isChecked()

        document = self._document
        # print("!!!!!!!!filter", len(selected_items), len(deselected_items))
        if self.selection_filter_disabled:
            return
        filter_set = document.filter_set
        filter_set.add('part')
        out_deselection = []
        out_selection = []
        flags = QItemSelectionModel.Current | QItemSelectionModel.Deselect
        for index in selected_items.indexes():
            item = self.itemFromIndex(index)
            if is_not_select_tool or item.FILTER_NAME not in filter_set:
                if index.column() == 0:
                    # print("deselect", item.FILTER_NAME, filter_set,
                    #                     index.row(), index.column())
                    out_deselection.append(index)
            else:
                out_selection.append(index)
        sm = self.selectionModel()
        if len(out_deselection) > 0:
            self.indexFromItem(item)
            deselection = QItemSelection(out_deselection[0], out_deselection[-1])
            sm.blockSignals(True)
            sm.select(deselection, flags)
            sm.blockSignals(False)

        # now group the indices into items in sets
        tbs, tbd = self.model_selection_changes
        # print("sets:", tbs, tbd)
        for idx in out_selection:
            item = self.itemFromIndex(idx)
            # print("did select", item)
            tbs.add(item)
        for idx in deselected_items.indexes():
            # print("could deselect?", self.itemFromIndex(idx))
            item = self.itemFromIndex(idx)
            if item not in tbd and item.isModelSelected(document):
                tbd.add(item)
        self.processSelections(deselect_only=True)
예제 #17
0
    def _event_selection_changed(self, selected: QItemSelection, deselected: QItemSelection) \
            -> None:
        # Selecting an entry should change the page elements to be ready to either move to another
        # page, or whatever else is applicable.
        if len(selected.indexes()):
            wallet_path = self._recent_wallet_paths[selected.indexes()[0].row()]
            entry = self._recent_wallet_entries[wallet_path]
            if entry.requires_upgrade:
                self._next_page_id = WalletPage.MIGRATE_OLDER_WALLET
            else:
                self._next_page_id = -1
        else:
            self._clear_selection()

        self.completeChanged.emit()
예제 #18
0
    def mapSelectionRightToLeft(self,
                                selection: QItemSelection) -> QItemSelection:
        if not selection.indexes() or not self.connected:
            return QItemSelection()

        if selection[0].model() != self._right_model:
            print("FAIL", selection[0].model(), self._left_model,
                  self._right_model)
        # assert selection[0].model() == self._right_model

        seek_selection = selection
        # assert self.assertSelectionValid(seek_selection)

        for proxy in self._proxy_chain_down[::-1]:
            if not proxy:
                return QItemSelection()
            seek_selection = proxy.mapSelectionToSource(seek_selection)
            # assert self.assertSelectionValid(seek_selection)

        for proxy in self._proxy_chain_up[::-1]:
            if not proxy:
                return QItemSelection()
            seek_selection = proxy.mapSelectionFromSource(seek_selection)
            # assert self.assertSelectionValid(seek_selection)

        return seek_selection
예제 #19
0
 def onSelectionChanged(self, selection: QItemSelection):
     if selection.isEmpty():
         return
     item = selection.indexes()[0]
     data = item.data(ROLE_HTTP_MESSAGE)
     if data:
         self.selected.emit(data)
예제 #20
0
 def update_fields(self, idx: QtCore.QItemSelection):
     """
     Updates dialog label from table selection
     :param idx: selected table row index
     :return:
     """
     # indexes() returns list of selected items
     # as we only have 1 at a time, return first item and get corresponding row number
     if not idx.indexes() == []:
         row = idx.indexes()[0].row()
         self.datamapper.setCurrentIndex(row)
         self.lblHeader.setText(
             self.model.item(row, 0).text() + " " +
             self.model.item(row, 1).text())
     else:
         self.datamapper.toFirst()
예제 #21
0
    def _on_selection_changed(self, selected: QItemSelection,
                              deselected: QItemSelection) -> None:
        # Selecting an entry should change the page elements to be ready to either move to another
        # page, or whatever else is applicable.
        selected_page = False
        if len(selected.indexes()):
            wallet_path = self._recent_wallet_entries[selected.indexes()
                                                      [0].row()]['path']
            selected_page = self._attempt_open_wallet(wallet_path)

        # Therefore if there was nothing valid selected with this event, then disable those
        # elements.
        if not selected_page:
            self._reset()

        self.completeChanged.emit()
예제 #22
0
    def dataColumnView_selectionChanged(self, selected: QtCore.QItemSelection,
                                        deselected: QtCore.QItemSelection):
        """
        The selection has been changed. Used to enable/disable the actions (add ingredient/delete) and to
        load the stacked widget

        Args:
            selected (): Selected indexes
            deselected (): Deselected index

        Returns:

        """

        self.toggle_actions(selected.indexes())
        self.load_stackedwidget(selected.indexes())
예제 #23
0
    def _on_user_selected(self, selection: QItemSelection):
        if len(selection.indexes()) != 0:
            model_index: QModelIndex = selection.indexes()[0]
            index = model_index.row()

            room = self._appModel.list_users[index]

            if index not in self.tab_index_to_user_index.values():
                self._appModel.create_room(room)
                tab = self._create_new_tab(room)
                self._room_to_tab[room] = tab
                self.chatroomsTabs.addTab(tab, room)
                self.tab_index_to_user_index[len(self.tab_index_to_user_index)] =\
                    self._appModel.list_users.index(room)

            self.room = room
예제 #24
0
    def __on_row_selection_changed(self, selected: QItemSelection,
                                   deselected: QItemSelection) -> None:
        is_valid_selected = bool(selected)

        if is_valid_selected:
            self.__mode = PreferenceCommentTypesWidget.__Mode.EDIT
            self.__line_edit.setText(self.__get_selected_item().text())
            self.__line_edit.setFocus()
        else:
            self.__mode = PreferenceCommentTypesWidget.__Mode.ADD

        self.__button_remove.setEnabled(is_valid_selected)
        self.__button_up.setEnabled(is_valid_selected
                                    and selected.indexes()[0].row() != 0)
        self.__button_down.setEnabled(
            is_valid_selected and selected.indexes()[0].row() !=
            self.__list_widget.model().rowCount() - 1)
예제 #25
0
 def on_selected_changed(self, selected: QItemSelection,
                         deselected: QItemSelection):
     if not selected.indexes():
         return
     sender = self._window.sender()
     if sender == self._window.lv_file.selectionModel():
         file_name = selected.indexes()[0].data()
         label_list = FileManager().get_label_list(file_name)
         self.show_message("{}:标签为{}".format(file_name, str(label_list)))
     elif sender == self._window.lv_label.selectionModel():
         label_name = selected.indexes()[0].data()
         file_name_list = FileLabelManager().get_file_name_list(label_name)
         self.show_message("{}:文件为{}".format(label_name,
                                             str(file_name_list)))
     elif sender == self._window.tv_catalogue.selectionModel():
         path = selected.indexes()[1].data()
         if not path:
             path = "root"
         self._window.le_path.setText(path)
예제 #26
0
    def update_property_fields(self, idx:QtCore.QItemSelection):
        """ Update single fields on property tab in relation to selected row in table view"""

        self.logger.debug("Update property fields")

        self.inpPropName.setEnabled(False)
        self.cmbPropType.setEnabled(False)
        self.cmbPropMulti.setEnabled(False)
        self.cmbPropEdit.setEnabled(False)
        self.inpPropDesc.setEnabled(False)
        self.inpPropVal.setEnabled(False)
        self.inpPropDef.setEnabled(False)
        self.cmbPropDef.setEnabled(False)
        self.btnPropModify.setEnabled(False)
        self.btnPropAdd.setEnabled(True)

        # disconnect if there has been an editing event before
        try:
            self.cmbPropType.currentIndexChanged.disconnect()
        except:
            pass

        if self.datamapper_properties.model().item(0, 0) is not None:
            self.btnPropDelete.setEnabled(True)
            self.btnPropEdit.setEnabled(True)

            # indexes() returns list of selected items
            # as we only have 1 at a time, return first item and get corresponding row number
            if not idx.indexes() == []:
                row = idx.indexes()[0].row()
                self.datamapper_properties.setCurrentIndex(row)
            else:
                self.datamapper_properties.toFirst()
        else:
            self.btnPropDelete.setEnabled(False)
            self.btnPropEdit.setEnabled(False)

            self.inpPropName.setText("")
            self.inpPropDesc.setText("")
            self.inpPropVal.setText("")
            self.inpPropDef.setText("")
예제 #27
0
 def update_description(self, desc_label: QLabel, selected: QItemSelection):
     indexes = selected.indexes()
     if indexes:
         index = indexes[0]
         plugin = index.data(InstalledPluginsModel.PluginRole)
         if plugin:
             try:
                 desc_label.setText(plugin.__description__)
             except AttributeError:
                 try:
                     desc_label.setText(plugin['description'])
                 except KeyError:
                     desc_label.setText("")
예제 #28
0
 def on_treeview_selectionChanged(self, selected: QItemSelection,
                                  deselected: QItemSelection):
     selectedIndex = selected.indexes()
     abandon, no = self.askIf_WantAbandon_CurrentEntry(selected, deselected)
     if abandon == no:
         return
     if len(selectedIndex) == 0:
         self.clearDetailsFields()
         self.removeButton.setEnabled(False)
     else:
         index_of_selectedBook = selectedIndex[0].row()
         self.displayBookDetails(self.library.books[index_of_selectedBook])
         self.removeButton.setEnabled(True)
         self.newButton.setEnabled(True)
     self.saveButton.setEnabled(False)
예제 #29
0
 def setChanged(self,
                topLeft: QModelIndex,
                bottomRight: QModelIndex = None):
     """Set the item and all parents as changed"""
     bottomRight = topLeft if bottomRight is None else bottomRight
     if topLeft.isValid() and bottomRight.isValid():
         selection = QItemSelection(topLeft, bottomRight)
         for index in selection.indexes():
             self.objByIndex(index).changed = True
             if index.parent().isValid():
                 self.setChanged(index.parent())
             else:
                 packItem: QModelIndex = index.data(PACK_ITEM_ROLE)
                 if packItem and packItem.isValid():
                     packItem.model().dataChanged.emit(packItem, packItem)
예제 #30
0
 def dataChangedSlot(self, top_left: QModelIndex , bottom_right: QModelIndex):
     if self.is_child_adding == 0:
         if top_left == bottom_right:    # single item
             item = self.itemFromIndex(top_left)
             if isinstance(item, (OutlineVirtualHelixItem, OutlineNucleicAcidPartItem, OutlineOligoItem)):
                 # print("dataChanged", item.__class__.__name__)
                 item.updateCNModel()
         else:
             selection = QItemSelection(top_left, bottom_right)
             for index in selection.indexes():
                 if index.column() == 0:
                     item = self.itemFromIndex(index)
                     # if isinstance(item, OutlineVirtualHelixItem):
                     #     print("slap", item.idNum())
                     if isinstance(item, (OutlineVirtualHelixItem, OutlineNucleicAcidPartItem, OutlineOligoItem)):
                         item.updateCNModel()
 def dataChangedSlot(self, top_left: QModelIndex , bottom_right: QModelIndex):
     if self.is_child_adding == 0:
         if top_left == bottom_right:    # single item
             item = self.itemFromIndex(top_left)
             if isinstance(item, (OutlineVirtualHelixItem, OutlineNucleicAcidPartItem, OutlineOligoItem)):
                 # print("dataChanged", item.__class__.__name__)
                 item.updateCNModel()
         else:
             selection = QItemSelection(top_left, bottom_right)
             for index in selection.indexes():
                 if index.column() == 0:
                     item = self.itemFromIndex(index)
                     # if isinstance(item, OutlineVirtualHelixItem):
                     #     print("slap", item.idNum())
                     if isinstance(item, (OutlineVirtualHelixItem, OutlineNucleicAcidPartItem, OutlineOligoItem)):
                         item.updateCNModel()
예제 #32
0
    def selectionChanged(self, selected: QItemSelection, deselected: QItemSelection) -> None:
        '''
        Process event of change of selection: set selected matter as a topmost
        chart series.
        (overriden internal function)

        :param selected: Newly-selected items
        :param selected: Just-deselected items
        '''
        super().selectionChanged(selected, deselected)
        selected_indexes = selected.indexes()
        if len(selected_indexes) > 0:
            # If a row was selected, get its index
            index = selected_indexes[0].row()
        else:
            index = None
        self.window().chart.setTopSeriesIndex(index)
예제 #33
0
    def on_selection_changed(self, new: QItemSelection) -> None:
        """Actions to do when a folder is (de)selected."""
        try:
            # Get the index of the current selection
            index = new.indexes()[0]
        except IndexError:
            # The selection has been cleared
            path = ""
        else:
            # Get the selected folder's path
            path = self.model().itemFromIndex(index).data(
                Qt.UserRole).get_path()

        # Set the remote folder acording to the selected folder
        self.parent.remote_folder.setText(path)

        # Set the OK button state depending of the current selection
        self.parent.button_ok_state()
예제 #34
0
 def _selectionChanged(self,
                       selected: QItemSelection,
                       deselected: QItemSelection = None):
     try:
         idx = selected.indexes()[
             0]  # We only support a single selection anyways.
     except IndexError:
         return  # Sometime this can get fired with no selected indexes.
     step: SequencerStep = idx.internalPointer()
     coordSteps = []
     while step is not self.model().invisibleRootItem(
     ):  # This will break out once we reach the root item.
         coordStep = step.data(
             QtCore.Qt.EditRole
         )  # The item delegate saves an tuple indicated the range of iterations selected in the `editRole` data slot of steps.
         if coordStep is None:
             coordSteps.append((step.id, None))
         else:
             coordSteps.append(coordStep)
         step = step.parent(
         )  # On the next iteration look at the parent of the selected step.
     self._currentCoordRange = SequencerCoordinateRange(
         list(reversed(coordSteps)))
     self.newCoordSelected.emit(self._currentCoordRange)
예제 #35
0
	def onActionChanged(self, selected: QItemSelection, deselected: QItemSelection = []):
		"""Update the UI when the selected action is changed.
			
			This function updates the trigger list, invert,
				and debounce elements. The trigger list will
				sync the active configuration pane, because
				it needs to do that anyway when the operator
				changes the trigger."""
		
		action = actionData[selected.indexes()[0].data(Qt.UserRole)]
		config = api.apiValues.get('ioMapping')[action['id']]
		newConfig = self.newIOMapping[action['id']]
		virtuals = settings.value('virtually triggered actions', {})
		
		if action['id'] in virtuals:
			source = newConfig['source'] or 'virtual'
			virtual = source == 'virtual'
		else:
			source = newConfig['source'] or config['source']
			virtual = None
		
		dataIndex = [trigger['id'] for trigger in triggerData].index(source)
		
		listIndex = self.uiTriggerList.findData(dataIndex)
		assert listIndex is not -1, f"Could not find index for {config['source']} ({dataIndex}) in uiTriggerList."
		
		try: #Fix for state getting marked dirty when we view a different action.
			self.uiTriggerList.currentIndexChanged.disconnect(self.markStateDirty)
			self.uiTriggerList.setCurrentIndex(listIndex)
			self.uiTriggerList.currentIndexChanged.connect(self.markStateDirty)
		except TypeError: #'method' object is not connected, whatever, just set index then.
			self.uiTriggerList.setCurrentIndex(listIndex)
		
		self.uiInvertCondition.blockSignals(True) #We can block these signals because nothing else depends on them. A few things depend on the Trigger for Action combobox, so it is just a little smarter about it's updates to deal with this changing.
		self.uiInvertCondition.setChecked(bool(default(
			newConfig['invert'], 
			(virtuals[action['id']].get('invert') or False) if virtual else None, #.get returns False or None, we always want False so default stops here if this is a virtual trigger.
			config['invert'],
		)))
		self.uiInvertCondition.blockSignals(False)
		
		self.uiDebounce.blockSignals(True)
		self.uiDebounce.setChecked(bool(default(
			newConfig['debounce'], 
			(virtuals[action['id']].get('debounce') or False) if virtual else None,
			config['debounce'],
		)))
		self.uiDebounce.blockSignals(False)
		
		#Update action label text for action level/edge triggering.
		assert ('level' in action['tags']) != ('edge' in action['tags']), f"actionData['{action['id']}'] needs to be tagged as either 'level' or 'edge' triggered."
		if not deselected or not deselected.indexes():
			return
		if 'level' in action['tags'] == 'level' in actionData[deselected.indexes()[0].data(Qt.UserRole)]['tags']:
			return
		
		whenLevelOrEdge = 'whenLevelTriggered' if 'level' in action['tags'] else 'whenEdgeTriggered'
		for triggerListIndex in range(self.uiTriggerList.count()):
			triggerDataIndex = self.uiTriggerList.itemData(triggerListIndex)
			self.uiTriggerList.setItemText(triggerListIndex,
				triggerData[triggerDataIndex]['name'][whenLevelOrEdge] )
예제 #36
0
 def selectionChanged(self, selected: QtCore.QItemSelection,
                      deselected: QtCore.QItemSelection):
     if not selected.indexes():
         return
     self.rowSelected.emit(self.getSelectedRow())
예제 #37
0
 def enable_checklist_actions(self, selected: QtCore.QItemSelection,
                              deselected: QtCore.QItemSelection):
     button = self.button_box.button(self.button_box.Ok)
     button.setEnabled(bool(len(selected.indexes())))
     self.delete_checklist_pb.setEnabled(bool(len(selected.indexes())))