Ejemplo n.º 1
0
 def setup(self, did):
     """
     
     keyword arguments:
     did -- if None, then export whole anki. If did, export this deck (at least as default). 
     """
     self.exporters = exporters()
     # if a deck specified, start with .apkg type selected
     idx = 0
     if did:
         for c, (k, e) in enumerate(self.exporters):
             if e.ext == ".apkg":
                 idx = c
                 break
     self.frm.format.insertItems(0, [e[0] for e in self.exporters])
     self.frm.format.setCurrentIndex(idx)
     self.frm.format.activated.connect(self.exporterChanged)
     self.exporterChanged(idx)
     # deck list
     self.decks = [_("All Decks")] + sorted(self.col.decks.allNames())
     self.frm.deck.addItems(self.decks)
     # save button
     b = QPushButton(_("Export..."))
     self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
     # set default option if accessed through deck button
     if did:
         name = self.mw.col.decks.get(did)['name']
         index = self.frm.deck.findText(name)
         self.frm.deck.setCurrentIndex(index)
Ejemplo n.º 2
0
 def setup(self, did: Optional[int]) -> None:
     self.exporters = exporters(self.col)
     # if a deck specified, start with .apkg type selected
     idx = 0
     if did or self.cids:
         for c, (k, e) in enumerate(self.exporters):
             if e.ext == ".apkg":
                 idx = c
                 break
     self.frm.format.insertItems(0, [e[0] for e in self.exporters])
     self.frm.format.setCurrentIndex(idx)
     qconnect(self.frm.format.activated, self.exporterChanged)
     self.exporterChanged(idx)
     # deck list
     if self.cids is None:
         self.decks = [tr(TR.EXPORTING_ALL_DECKS)]
         self.decks.extend(d.name
                           for d in self.col.decks.all_names_and_ids())
     else:
         self.decks = [tr(TR.EXPORTING_SELECTED_NOTES)]
     self.frm.deck.addItems(self.decks)
     # save button
     b = QPushButton(tr(TR.EXPORTING_EXPORT))
     self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
     # set default option if accessed through deck button
     if did:
         name = self.mw.col.decks.get(did)["name"]
         index = self.frm.deck.findText(name)
         self.frm.deck.setCurrentIndex(index)
Ejemplo n.º 3
0
 def setup(self, did: Optional[int]):
     self.exporters = exporters()
     # if a deck specified, start with .apkg type selected
     idx = 0
     if did or self.cids:
         for c, (k, e) in enumerate(self.exporters):
             if e.ext == ".apkg":
                 idx = c
                 break
     self.frm.format.insertItems(0, [e[0] for e in self.exporters])
     self.frm.format.setCurrentIndex(idx)
     self.frm.format.activated.connect(self.exporterChanged)
     self.exporterChanged(idx)
     # deck list
     if self.cids is None:
         self.decks = [_("All Decks")] + sorted(self.col.decks.allNames())
     else:
         self.decks = [_("Selected Notes")]
     self.frm.deck.addItems(self.decks)
     # save button
     b = QPushButton(_("Export..."))
     self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
     # set default option if accessed through deck button
     if did:
         name = self.mw.col.decks.get(did)["name"]
         index = self.frm.deck.findText(name)
         self.frm.deck.setCurrentIndex(index)
Ejemplo n.º 4
0
 def exporterChanged(self, idx):
     self.exporter = exporters()[idx][1](self.col)
     self.isApkg = hasattr(self.exporter, "includeSched")
     self.hideTags = hasattr(self.exporter, "hideTags")
     self.frm.includeSched.setVisible(self.isApkg)
     self.frm.includeMedia.setVisible(self.isApkg)
     self.frm.includeTags.setVisible(not self.isApkg and not self.hideTags)
Ejemplo n.º 5
0
 def exporterChanged(self, idx):
     self.exporter = exporters()[idx][1](self.col)
     self.isApkg = hasattr(self.exporter, "includeSched")
     self.hideTags = hasattr(self.exporter, "hideTags")
     self.frm.includeSched.setVisible(self.isApkg)
     self.frm.includeMedia.setVisible(self.isApkg)
     self.frm.includeTags.setVisible(not self.isApkg and not self.hideTags)
Ejemplo n.º 6
0
 def setup(self):
     self.frm.format.insertItems(0, list(zip(*exporters())[0]))
     self.connect(self.frm.format, SIGNAL("activated(int)"), self.exporterChanged)
     self.exporterChanged(0)
     self.decks = [_("All Decks")] + sorted(self.col.decks.allNames())
     self.frm.deck.addItems(self.decks)
     # save button
     b = QPushButton(_("Export..."))
     self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
Ejemplo n.º 7
0
 def setup(self):
     self.frm.format.insertItems(0, list(zip(*exporters())[0]))
     self.connect(self.frm.format, SIGNAL("activated(int)"),
                  self.exporterChanged)
     self.exporterChanged(0)
     self.decks = [_("All Decks")] + sorted(self.col.decks.allNames())
     self.frm.deck.addItems(self.decks)
     # save button
     b = QPushButton(_("Export..."))
     self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
Ejemplo n.º 8
0
 def setup(self, did):
     self.frm.format.insertItems(0, list(zip(*exporters()))[0])
     self.frm.format.activated.connect(self.exporterChanged)
     self.exporterChanged(0)
     self.decks = [_("All Decks")] + sorted(self.col.decks.allNames())
     self.frm.deck.addItems(self.decks)
     # save button
     b = QPushButton(_("Export..."))
     self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
     # set default option if accessed through deck button
     if did:
         name = self.mw.col.decks.get(did)['name']
         index = self.frm.deck.findText(name)
         self.frm.deck.setCurrentIndex(index)
Ejemplo n.º 9
0
def exporterChanged(self, idx):
    """Ability to only show includeSched checkbutton for our exporters"""
    from anki.exporting import exporters
    self.exporter = exporters()[idx][1](self.col)
    self.isApkg = (hasattr(self.exporter, "includeSched")
                   and not hasattr(self.exporter, "glossary"))
    hasSchedToggle = hasattr(self.exporter, "glossary")
    self.isTextNote = hasattr(self.exporter, "includeTags")
    self.hideTags = hasattr(self.exporter, "hideTags")
    self.frm.includeSched.setVisible(self.isApkg or hasSchedToggle)
    if hasSchedToggle:
        self.frm.includeSched.setChecked(False)
    self.frm.includeMedia.setVisible(self.isApkg)
    self.frm.includeTags.setVisible(not self.isApkg and not self.hideTags)
Ejemplo n.º 10
0
 def setup(self, did):
     self.frm.format.insertItems(0, list(zip(*exporters()))[0])
     self.frm.format.activated.connect(self.exporterChanged)
     self.exporterChanged(0)
     self.decks = [_("All Decks")] + sorted(self.col.decks.allNames())
     self.frm.deck.addItems(self.decks)
     # save button
     b = QPushButton(_("Export..."))
     self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
     # set default option if accessed through deck button
     if did:
         name = self.mw.col.decks.get(did)['name']
         index = self.frm.deck.findText(name)
         self.frm.deck.setCurrentIndex(index)
Ejemplo n.º 11
0
 def setup(self, did):
     self.exporters = exporters()
     # if a deck specified, start with .apkg type selected
     idx = 0
     if did:
         for c, (k,e) in enumerate(self.exporters):
             if e.ext == ".apkg":
                 idx = c
                 break
     self.frm.format.insertItems(0, [e[0] for e in self.exporters])
     self.frm.format.setCurrentIndex(idx)
     self.frm.format.activated.connect(self.exporterChanged)
     self.exporterChanged(idx)
     # deck list
     self.decks = [_("All Decks")] + sorted(self.col.decks.allNames())
     self.frm.deck.addItems(self.decks)
     # save button
     b = QPushButton(_("Export..."))
     self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
     # set default option if accessed through deck button
     if did:
         name = self.mw.col.decks.get(did)['name']
         index = self.frm.deck.findText(name)
         self.frm.deck.setCurrentIndex(index)
Ejemplo n.º 12
0
 def exporterChanged(self, idx):
     self.exporter = exporters()[idx][1](self.col)
     isAnki = hasattr(self.exporter, "includeSched")
     self.frm.includeSched.setShown(isAnki)
     self.frm.includeMedia.setShown(isAnki)
     self.frm.includeTags.setShown(not isAnki)
Ejemplo n.º 13
0
 def exporterChanged(self, idx):
     self.exporter = exporters()[idx][1](self.col)
     isAnki = hasattr(self.exporter, "includeSched")
     self.frm.includeSched.setShown(isAnki)
     self.frm.includeMedia.setShown(isAnki)
     self.frm.includeTags.setShown(not isAnki)