def accept(self): self.hide() n = 0 yes = [] no = [] for c in range(self.dialog.activeList.count()): # active item = self.dialog.activeList.item(c) idx = self.dialog.activeList.indexFromItem(item) if self.dialog.activeList.selectionModel().isSelected(idx): yes.append(self.tags[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[c]) types = [] if (self.dialog.newButton.isChecked() or self.dialog.bothButton.isChecked()): types.append(["newActive", "newInactive"]) if (self.dialog.revButton.isChecked() or self.dialog.bothButton.isChecked()): types.append(["revActive", "revInactive"]) for (active, inactive) in types: if self.dialog.activeCheck.isChecked(): self.deck.setVar(active, joinTags(yes)) else: self.deck.setVar(active, "") if self.dialog.inactiveCheck.isChecked(): self.deck.setVar(inactive, joinTags(no)) else: self.deck.setVar(inactive, "") self.parent.reset() saveGeom(self, "activeTags") QDialog.accept(self)
def accept(self): self.hide() n = 0 yes = [] no = [] for c in range(self.dialog.activeList.count()): # active item = self.dialog.activeList.item(c) idx = self.dialog.activeList.indexFromItem(item) if self.dialog.activeList.selectionModel().isSelected(idx): yes.append(self.tags[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[c]) if self.dialog.activeCheck.isChecked(): self.deck.setVar(self.active, joinTags(yes)) else: self.deck.setVar(self.active, "") if self.dialog.inactiveCheck.isChecked(): self.deck.setVar(self.inactive, joinTags(no)) else: self.deck.setVar(self.inactive, "") self.parent.reset() saveGeom(self, "activeTags") QDialog.accept(self)
def accept(self): self.hide() self.deck.startProgress() n = 0 suspended = [] for item in self.items: idx = self.dialog.list.indexFromItem(item) if self.dialog.list.selectionModel().isSelected(idx): suspended.append(self.tags[n]) n += 1 self.deck.suspended = canonifyTags(joinTags(suspended)) self.deck.setModified() self.deck.updateAllPriorities(partial=True, dirty=False) self.deck.finishProgress() QDialog.accept(self)
def opbutclick(self, widget, cmd): if cmd == 'save': if self.deck: self.deck_save() self.set_question() self.set_stats() elif cmd == 'answer': self.set_q_a() self.set_stats() elif cmd == 'close': if not self.deck: return if self.deck.modifiedSinceSave() and \ self.yesno_dlg(gtk.MESSAGE_QUESTION, "Save the current deck first?"): self.deck_save() self.deck.close() self.deck = None self.update_recent_menu(self.DECK_PATH) self.DECK_PATH = "" self.conf_client.set_string("/apps/anki/general/deck_path", self.DECK_PATH) self.opbuttonsbox.hide() self.answerbuttonbox.hide() self.resultbuttonbox.hide() self.set_html_doc('<center><div class="a"><br/><br/><br/>%s %s</div></center>' % (appname, appversion)) self.statslabel.set_markup("T: 0/0 (0.0%) A: <b>0.0%</b>. ETA: <b>Unknown</b>") self.missinglabel.set_markup('<span foreground="red">0</span>+0+<span foreground="blue">0</span>') elif cmd == 'replay': self.prepareMedia(self.currentCard.question) self.prepareMedia(self.currentCard.answer) elif cmd == 'sync': if not self.deck: return self.opbuttonsbox.hide() self.answerbuttonbox.hide() self.resultbuttonbox.hide() self.do_sync() self.set_question() self.set_stats() elif cmd == 'mark': if "marked" in self.currentCard.tags.lower(): t = parseTags(self.currentCard.tags) t.remove("Marked") self.currentCard.tags = joinTags(t) else: self.currentCard.tags = joinTags(parseTags(self.currentCard.tags) + ["Marked"]) self.currentCard.toDB(self.deck.s) if self.currentCard and "marked" in self.currentCard.tags.lower(): self.markbuttonlabel.set_markup('<span color="red">mark</span>') else: self.markbuttonlabel.set_markup('mark') elif cmd == 'learnmore': self.deck.extraNewCards += 5 self.deck.refresh() self.deck.updateAllPriorities() self.deck.rebuildCounts() self.deck.rebuildQueue() self.set_question() self.set_stats() elif cmd == 'reviewearly': self.deck.reviewEarly = True self.deck.refresh() self.deck.updateAllPriorities() self.deck.rebuildCounts() self.deck.rebuildQueue() self.set_question() self.set_stats()
if self.path == "/": # refresh if deck: deck.rebuildQueue() self.flushWrite(self._outer()) elif deck and self.path.startswith("/save"): deck.save() self.path = "/question#inner_top" elif deck and self.path.startswith("/mark"): if currentCard: f = deck.s.query(Fact).get(currentCard.factId) if "marked" in f.tags.lower(): t = parseTags(f.tags) t.remove("Marked") f.tags = joinTags(t) else: f.tags = joinTags(parseTags(f.tags) + ["Marked"]) f.setModified(textChanged=True) deck.updateFactTags([f.id]) f.setModified() deck.flushMod() deck.s.flush() deck.s.expunge(f) history.pop() self.path = "/question#inner_top" elif deck and self.path.startswith("/replay"): if currentCard: self.prepareMedia(currentCard.question) self.prepareMedia(currentCard.answer) self.disableMedia()
if self.path == "/": # refresh if deck: deck.reset() self.flushWrite(self._outer()) elif deck and self.path.startswith("/save"): deck.save() self.path = "/question#inner_top" elif deck and self.path.startswith("/mark"): if currentCard: f = deck.s.query(Fact).get(currentCard.factId) if "marked" in f.tags.lower(): t = parseTags(f.tags) t.remove("Marked") f.tags = joinTags(t) else: f.tags = joinTags(parseTags( f.tags) + ["Marked"]) f.setModified(textChanged=True, deck=deck) deck.updateFactTags([f.id]) f.setModified() deck.flushMod() deck.s.flush() deck.s.expunge(f) history.pop() self.path = "/question#inner_top" elif deck and self.path.startswith("/replay"): if currentCard: self.prepareMedia(currentCard.question) self.prepareMedia(currentCard.answer)