def _openDeckFile(self, fname): """Open deck with givem file name.""" fname = str(fname) problem = False # FIXME running setCardModelIndex to empty # to clean all other views # I must redesign the model/view thing self.setCardModelIndex(QModelIndex()) self.cardModel().close() try: self.cardModel().open(fname) self.setCardModelIndex(self.cardModel().index(0, 0)) config.add_most_recent_file(fname) except: config.remove_recent_file(fname) self.setCardModelIndex(QModelIndex()) problem = True finally: self._refreshAppState() if problem: show_info('Problem opening deck file %s.' % fname)
def _newDeckFile(self, fname): """Creates a new deck with given file name.""" fname = str(fname) problem = False # FIXME running setCardModelIndex with QModelIndex is HACK to clean # all other views - it must be run before closing cardModel # I must redesign the model/view thing self.setCardModelIndex(QModelIndex()) self.cardModel().close() try: # we want to overwrite if os.path.isfile(fname): os.remove(fname) self.cardModel().open(fname) self.setCardModelIndex(self.cardModel().index(0, 0)) config.add_most_recent_file(fname) except: config.remove_most_recent_file(fname) self.setCardModelIndex(QModelIndex()) problem = True finally: self._refreshAppState() if problem: show_info('Problem creating a new deck file %s.' % fname)
def on_actAbout_triggered(self): show_info(tr("MENTOR version %s\nA learning tool\n\nDistributed under license: %s.\n\nAuthors: \n%s" \ % (__version__, __license__, str(__author__))), self)