Esempio n. 1
0
 def __init__(self, parent):
     if parent.config['standaloneWindows']:
         windParent = None
     else:
         windParent = parent
     QDialog.__init__(self, windParent, Qt.Window)
     self.parent = parent
     ui.utils.applyStyles(self)
     self.config = parent.config
     self.dialog = ankiqt.forms.addcards.Ui_AddCards()
     self.dialog.setupUi(self)
     self.setWindowTitle(_("Add Items - %s") % parent.deck.name())
     self.setupEditor()
     self.addChooser()
     self.addButtons()
     self.setupStatus()
     self.modelChanged()
     self.addedItems = 0
     self.forceClose = False
     restoreGeom(self, "add")
     restoreSplitter(self.dialog.splitter, "add")
     self.dialog.splitter.setChildrenCollapsible(False)
     self.show()
     addHook('guiReset', self.modelChanged)
     ui.dialogs.open("AddCards", self)
Esempio n. 2
0
 def __init__(self, parent):
     if parent.config['standaloneWindows']:
         windParent = None
     else:
         windParent = parent
     QDialog.__init__(self, windParent, Qt.Window)
     self.parent = parent
     ui.utils.applyStyles(self)
     self.config = parent.config
     self.dialog = ankiqt.forms.addcards.Ui_AddCards()
     self.dialog.setupUi(self)
     self.setWindowTitle(_("Add Items - %s") % parent.deck.name())
     self.setupEditor()
     self.addChooser()
     self.addButtons()
     self.setupStatus()
     self.modelChanged()
     self.addedItems = 0
     self.forceClose = False
     restoreGeom(self, "add")
     restoreSplitter(self.dialog.splitter, "add")
     self.dialog.splitter.setChildrenCollapsible(True)
     self.show()
     addHook('guiReset', self.modelChanged)
     ui.dialogs.open("AddCards", self)
Esempio n. 3
0
 def __init__(self, parent):
     if parent.config['standaloneWindows']:
         windParent = None
     else:
         windParent = parent
     QMainWindow.__init__(self, windParent)
     self.parent = parent
     self.deck = self.parent.deck
     self.config = parent.config
     self.forceClose = False
     self.origModTime = parent.deck.modified
     self.currentRow = None
     self.lastFilter = ""
     self.dialog = ankiqt.forms.cardlist.Ui_MainWindow()
     self.dialog.setupUi(self)
     restoreGeom(self, "editor")
     restoreSplitter(self.dialog.splitter, "editor")
     # flush all changes before we load
     self.deck.s.flush()
     self.model = DeckModel(self.parent, self.parent.deck)
     self.dialog.tableView.setSortingEnabled(False)
     self.dialog.tableView.setShowGrid(False)
     self.dialog.tableView.setModel(self.model)
     self.dialog.tableView.selectionModel()
     self.connect(self.dialog.tableView.selectionModel(),
                  SIGNAL("selectionChanged(QItemSelection,QItemSelection)"),
                  self.updateFilterLabel)
     self.dialog.tableView.setItemDelegate(StatusDelegate(self, self.model))
     if self.deck.getInt("reverseOrder"):
         self.dialog.actionReverseOrder.setChecked(True)
     self.updateFont()
     self.setupMenus()
     self.setupFilter()
     self.setupSort()
     self.setupHeaders()
     self.setupHooks()
     self.setupEditor()
     self.setupCardInfo()
     self.dialog.filterEdit.setFocus()
     ui.dialogs.open("CardList", self)
     self.drawTags()
     self.updateFilterLabel()
     self.show()
     if self.parent.currentCard:
         self.currentCard = self.parent.currentCard
     self.updateSearch()
     if sys.platform.startswith("darwin"):
         self.macCloseShortcut = QShortcut(QKeySequence("Ctrl+w"), self)
         self.connect(self.macCloseShortcut, SIGNAL("activated()"),
                      self.close)
Esempio n. 4
0
 def __init__(self, parent, factedit, factOrModel, card=None):
     self.parent = parent
     QDialog.__init__(self, parent, Qt.Window)
     self.mw = ankiqt.mw
     self.deck = self.mw.deck
     self.factedit = factedit
     self.card = card
     if factedit is not None:
         self.fact = factOrModel
         self.model = self.fact.model
     else:
         self.model = factOrModel
         # see if there's an available fact
         id = self.deck.s.scalar("select id from facts where modelId = :id", id=self.model.id)
         if id:
             self.fact = self.deck.s.query(Fact).get(id)
         else:
             # generate a dummy one
             self.fact = self.deck.newFact(self.model)
             for f in self.fact.keys():
                 self.fact[f] = f
     self.plastiqueStyle = None
     if sys.platform.startswith("darwin") or sys.platform.startswith("win32"):
         self.plastiqueStyle = QStyleFactory.create("plastique")
     if self.card:
         # limited to an existing template
         self.cards = [
             self.deck.s.query(Card).get(id)
             for id in self.deck.s.column0(
                 "select id from cards where factId = :fid " "order by ordinal", fid=self.fact.id
             )
         ]
         type = 0
     else:
         if factedit:
             # active & possible
             self.cards = self.deck.previewFact(self.fact)
             type = 1
         else:
             # all
             self.cards = self.deck.previewFact(self.fact, cms=self.model.cardModels)
             type = 2
         if not self.cards:
             ui.utils.showInfo(_("Please enter some text first."), parent=self.parent)
             return
     self.form = ankiqt.forms.clayout.Ui_Dialog()
     self.form.setupUi(self)
     restoreSplitter(self.form.splitter, "clayout")
     if type == 0:
         self.form.templateType.setText(_("Templates used by fact:"))
     elif type == 1:
         self.form.templateType.setText(_("Templates that will be created:"))
     else:
         self.form.templateType.setText(_("All templates:"))
     # FIXME: add this
     self.form.editTemplates.hide()
     self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), self.onHelp)
     self.setupCards()
     self.setupFields()
     restoreGeom(self, "CardLayout")
     # hack to ensure we're focused on the active template in the model
     # properties
     if type == 2 and factOrModel.currentCard.ordinal != 0:
         idx = factOrModel.currentCard.ordinal
         self.form.cardList.setCurrentIndex(idx)
         self.cardChanged(idx)
     self.exec_()
Esempio n. 5
0
 def __init__(self, parent, factedit, factOrModel, card=None):
     self.parent = parent
     QDialog.__init__(self, parent, Qt.Window)
     self.mw = ankiqt.mw
     self.deck = self.mw.deck
     self.factedit = factedit
     self.card = card
     if factedit is not None:
         self.fact = factOrModel
         self.model = self.fact.model
     else:
         self.model = factOrModel
         # see if there's an available fact
         id = self.deck.s.scalar("select id from facts where modelId = :id",
                                 id=self.model.id)
         if id:
             self.fact = self.deck.s.query(Fact).get(id)
         else:
             # generate a dummy one
             self.fact = self.deck.newFact(self.model)
             for f in self.fact.keys():
                 self.fact[f] = f
     self.plastiqueStyle = None
     if (sys.platform.startswith("darwin")
             or sys.platform.startswith("win32")):
         self.plastiqueStyle = QStyleFactory.create("plastique")
     if self.card:
         # limited to an existing template
         self.cards = [
             self.deck.s.query(Card).get(id) for id in self.deck.s.column0(
                 "select id from cards where factId = :fid "
                 "order by ordinal",
                 fid=self.fact.id)
         ]
         type = 0
     else:
         if factedit:
             # active & possible
             self.cards = self.deck.previewFact(self.fact)
             type = 1
         else:
             # all
             self.cards = self.deck.previewFact(self.fact,
                                                cms=self.model.cardModels)
             type = 2
         if not self.cards:
             ui.utils.showInfo(_("Please enter some text first."),
                               parent=self.parent)
             return
     self.form = ankiqt.forms.clayout.Ui_Dialog()
     self.form.setupUi(self)
     restoreSplitter(self.form.splitter, "clayout")
     if type == 0:
         self.form.templateType.setText(_("Templates used by fact:"))
     elif type == 1:
         self.form.templateType.setText(
             _("Templates that will be created:"))
     else:
         self.form.templateType.setText(_("All templates:"))
     # FIXME: add this
     self.form.editTemplates.hide()
     self.connect(self.form.buttonBox, SIGNAL("helpRequested()"),
                  self.onHelp)
     self.setupCards()
     self.setupFields()
     restoreGeom(self, "CardLayout")
     # hack to ensure we're focused on the active template in the model
     # properties
     if type == 2 and factOrModel.currentCard.ordinal != 0:
         idx = factOrModel.currentCard.ordinal
         self.form.cardList.setCurrentIndex(idx)
         self.cardChanged(idx)
     self.exec_()