strip html option on import, and option to customize deck import location

This commit is contained in:
Damien Elmes 2012-10-25 00:24:26 +09:00
parent b0c28d33b2
commit 8ec9572265
2 changed files with 18 additions and 1 deletions

View file

@ -139,6 +139,7 @@ you can enter it here. Use \\t to represent tab."""),
_("The first field of the note type must be mapped."))
return
self.importer.importMode = self.frm.importMode.currentIndex()
self.importer.allowHTML = self.frm.allowHTML.isChecked()
did = self.deck.selectedId()
if did != self.importer.model['did']:
self.importer.model['did'] = did
@ -291,6 +292,13 @@ backup, please see the 'Backups' section of the user manual."""))
if importer.__class__.__name__ == "AnkiPackageImporter":
if not setupApkgImport(mw, importer):
return
def prepareImportPrefix(name):
mw.progress.finish()
new = getOnlyText(_("""\
Deck to import into (if blank, will import into current deck):"""), default=name)
mw.progress.start()
return new or mw.col.decks.current()['name']
addHook("prepareImportPrefix", prepareImportPrefix)
mw.progress.start(immediate=True)
try:
importer.run()
@ -316,12 +324,14 @@ Unable to import from a read-only file."""))
showText(log)
finally:
mw.progress.finish()
remHook("prepareImportPrefix", prepareImportPrefix)
mw.reset()
def setupApkgImport(mw, importer):
base = os.path.basename(importer.file).lower()
full = (base == "collection.apkg") or re.match("backup-\d+.apkg", base)
if not full:
# adding
return True
if not askUser(_("""\
This will delete your existing collection and replace it with the data in \

View file

@ -70,6 +70,13 @@
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="allowHTML">
<property name="text">
<string>Allow HTML in fields</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -127,7 +134,7 @@
<x>0</x>
<y>0</y>
<width>402</width>
<height>229</height>
<height>206</height>
</rect>
</property>
</widget>