Beispiel #1
0
 def update_review_widget(self):
     w = self.centralWidget()
     if w:
         w.close()
         del w
     ui_controller_review().widget = \
         component_manager.get_current("review_widget")(parent=self)
     self.setCentralWidget(ui_controller_review().widget)
Beispiel #2
0
 def editCards(self):
     stopwatch.pause()
     dlg = EditCardsDlg(self)
     dlg.exec_()
     rebuild_revision_queue()
     if not in_revision_queue(self.card):
         self.newQuestion()
     else:
         remove_from_revision_queue(self.card) # It's already being asked.
     ui_controller_review().update_dialog(redraw_all=True)
     self.updateDialog()
     stopwatch.unpause()
Beispiel #3
0
 def deleteCurrentCard(self):
     # TODO: ask user if he wants to delete all related cards, or only
     # deactivate this cardview?
     stopwatch.pause()
     status = QMessageBox.warning(None,
                                  _("Mnemosyne"),
                                  _("Delete current card?"),
                                  _("&Yes"), _("&No"),
                                  QString(), 1, -1)
     if status == 0:
         delete_card(self.card)
         self.newQuestion()
     ui_controller_review().update_dialog(redraw_all=True)
     stopwatch.unpause()
Beispiel #4
0
 def file_new(self):
     stopwatch.pause()
     out = self.widget.save_file_dialog(path=config().basedir,
                         filter=_("Mnemosyne databases (*.mem)"),
                         caption=_("New"))
     if not out:
         stopwatch.unpause()
         return
     if not out.endswith(".mem"):
         out += ".mem"
     db = database()
     db.unload()
     db.new(out)
     db.load(config()["path"])
     ui_controller_review().clear()
     ui_controller_review().update_dialog()
     stopwatch.unpause()
Beispiel #5
0
 def add_cards(self):
     stopwatch.pause()
     self.widget.run_add_cards_dialog()
     review_controller = ui_controller_review()
     if review_controller.card == None:
         review_controller.new_question()
     else:
         self.widget.update_status_bar()
     stopwatch.unpause()
Beispiel #6
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.setupUi(self)
     self.controller = ui_controller_review()
     self.controller.widget = self
     self.grade_buttons = QButtonGroup()
     self.grade_buttons.addButton(self.grade_0_button, 0)
     self.grade_buttons.addButton(self.grade_1_button, 1)
     self.grade_buttons.addButton(self.grade_2_button, 2)
     self.grade_buttons.addButton(self.grade_3_button, 3)
     self.grade_buttons.addButton(self.grade_4_button, 4)
     self.grade_buttons.addButton(self.grade_5_button, 5)
     self.connect(self.grade_buttons, SIGNAL("buttonClicked(int)"),\
                 self.grade_answer)
Beispiel #7
0
    def review_cb(self, widget):
        """ Start Review """

        ui_controller_review().start(self.w_tree)
Beispiel #8
0
 def do_review(line):
     """ Review mode """
     ui_controller_review().start()
Beispiel #9
0
 def edit_current_card(self):
     stopwatch.pause()
     review_controller = ui_controller_review()
     self.widget.run_edit_fact_dialog(review_controller.card.fact)
     review_controller.update_dialog(redraw_all=True)
     stopwatch.unpause()
Beispiel #10
0
            stopwatch.unpause()
            return
        try:
            database().unload()
        except MnemosyneError, e:
            self.widget.error_box(e)
            stopwatch.unpause()
            return            
        ui_controller_review().clear()
        try:
            database().load(out)
        except MnemosyneError, e:
            self.widget.error_box(e)
            stopwatch.unpause()
            return
        ui_controller_review().new_question()
        stopwatch.unpause()

    def file_save(self):
        stopwatch.pause()
        path = config()["path"]
        try:
            database().save(path)
        except MnemosyneError, e:
            self.widget.error_box(e)
        stopwatch.unpause()

    def file_save_as(self):
        stopwatch.pause()
        old_path = expand_path(config()["path"])
        out = self.widget.save_file_dialog(path=old_path,
Beispiel #11
0
        self.statusbar.setSizeGripEnabled(0)
        try:
            initialise_user_plugins()
        except MnemosyneError, e:
            self.error_box(e)
        if filename == None:
            filename = config()["path"]
        try:
            database().load(filename)
        except MnemosyneError, e:
            self.error_box(e)            
            filename = os.path.join(os.path.split(filename)[0],"___TMP___.mem")
            database().new(filename)
        ui_controller_main().widget = self
        self.update_review_widget()
        ui_controller_review().new_question()

    def information_box(self, message, OK_string):
        QMessageBox.information(None, _("Mnemosyne"), message, OK_string)

    def question_box(self, question, option0, option1, option2):
        return QMessageBox.question(None, _("Mnemosyne"),
                                    question, option0, option1, option2, 0, -1)

    def error_box(self, event):
        if event.info:
            event.msg += "\n" + event.info        
            QMessageBox.critical(None, _("Mnemosyne"), event.msg,
                                 _("&OK"), "", "", 0, -1)

    def save_file_dialog(self, path, filter, caption=""):