def accept(self) -> None: include_tags = exclude_tags = [] # gather yes/no tags for c in range(self.dialog.activeList.count()): # active if self.dialog.activeCheck.isChecked(): item = self.dialog.activeList.item(c) idx = self.dialog.activeList.indexFromItem(item) if self.dialog.activeList.selectionModel().isSelected(idx): include_tags.append(self.tags_list[c]) # inactive item = self.dialog.inactiveList.item(c) idx = self.dialog.inactiveList.indexFromItem(item) if self.dialog.inactiveList.selectionModel().isSelected(idx): exclude_tags.append(self.tags_list[c]) if (len(include_tags) + len(exclude_tags)) > 100: showWarning(with_collapsed_whitespace(tr.errors_100_tags_max())) return self.hide() self.tags = (include_tags, exclude_tags) # save in the deck for future invocations self.deck["activeTags"] = include_tags self.deck["inactiveTags"] = exclude_tags self.mw.col.decks.save(self.deck) saveGeom(self, "tagLimit") QDialog.accept(self)
def accept(self) -> None: include_tags = [] exclude_tags = [] want_active = self.form.activeCheck.isChecked() for c, tag in enumerate(self.tags): # active if want_active: item = self.form.activeList.item(c) idx = self.form.activeList.indexFromItem(item) if self.form.activeList.selectionModel().isSelected(idx): include_tags.append(tag.name) # inactive item = self.form.inactiveList.item(c) idx = self.form.inactiveList.indexFromItem(item) if self.form.inactiveList.selectionModel().isSelected(idx): exclude_tags.append(tag.name) if (len(include_tags) + len(exclude_tags)) > 100: showWarning(with_collapsed_whitespace(tr.errors_100_tags_max())) return saveGeom(self, "tagLimit") QDialog.accept(self) self.on_success(include_tags, exclude_tags)
def accept(self) -> None: # gather yes/no tags yes = [] no = [] for c in range(self.dialog.activeList.count()): # active if self.dialog.activeCheck.isChecked(): item = self.dialog.activeList.item(c) idx = self.dialog.activeList.indexFromItem(item) if self.dialog.activeList.selectionModel().isSelected(idx): yes.append(self.tags_list[c]) # inactive item = self.dialog.inactiveList.item(c) idx = self.dialog.inactiveList.indexFromItem(item) if self.dialog.inactiveList.selectionModel().isSelected(idx): no.append(self.tags_list[c]) if (len(yes) + len(no)) > 100: showWarning(with_collapsed_whitespace(tr.errors_100_tags_max())) return self.hide() # save in the deck for future invocations self.deck["activeTags"] = yes self.deck["inactiveTags"] = no self.mw.col.decks.save(self.deck) # build query string self.tags = "" if yes: arr = [] for req in yes: arr.append(f'tag:"{req}"') self.tags += f"({' or '.join(arr)})" if no: arr = [] for req in no: arr.append(f'-tag:"{req}"') self.tags += f" {' '.join(arr)}" saveGeom(self, "tagLimit") QDialog.accept(self)