move .reopen() to mw; fix exporting
This commit is contained in:
parent
fe59d11047
commit
fa12213e98
@ -262,14 +262,6 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
|
|||||||
self.media.close()
|
self.media.close()
|
||||||
self._closeLog()
|
self._closeLog()
|
||||||
|
|
||||||
def reopen(self) -> None:
|
|
||||||
"Reconnect to DB (after changing threads, etc)."
|
|
||||||
raise Exception("fixme")
|
|
||||||
# if not self.db:
|
|
||||||
# # self.db = DBProxy(self.path)
|
|
||||||
# self.media.connect()
|
|
||||||
# self._openLog()
|
|
||||||
|
|
||||||
def rollback(self) -> None:
|
def rollback(self) -> None:
|
||||||
self.db.rollback()
|
self.db.rollback()
|
||||||
self.db.begin()
|
self.db.begin()
|
||||||
|
@ -397,20 +397,20 @@ class AnkiCollectionPackageExporter(AnkiPackageExporter):
|
|||||||
AnkiPackageExporter.__init__(self, col)
|
AnkiPackageExporter.__init__(self, col)
|
||||||
|
|
||||||
def doExport(self, z, path):
|
def doExport(self, z, path):
|
||||||
# close our deck & write it into the zip file, and reopen
|
"Export collection. Caller must re-open afterwards."
|
||||||
|
# close our deck & write it into the zip file
|
||||||
self.count = self.col.cardCount()
|
self.count = self.col.cardCount()
|
||||||
v2 = self.col.schedVer() != 1
|
v2 = self.col.schedVer() != 1
|
||||||
|
mdir = self.col.media.dir()
|
||||||
self.col.close()
|
self.col.close()
|
||||||
if not v2:
|
if not v2:
|
||||||
z.write(self.col.path, "collection.anki2")
|
z.write(self.col.path, "collection.anki2")
|
||||||
else:
|
else:
|
||||||
self._addDummyCollection(z)
|
self._addDummyCollection(z)
|
||||||
z.write(self.col.path, "collection.anki21")
|
z.write(self.col.path, "collection.anki21")
|
||||||
self.col.reopen()
|
|
||||||
# copy all media
|
# copy all media
|
||||||
if not self.includeMedia:
|
if not self.includeMedia:
|
||||||
return {}
|
return {}
|
||||||
mdir = self.col.media.dir()
|
|
||||||
return self._exportMedia(z, os.listdir(mdir), mdir)
|
return self._exportMedia(z, os.listdir(mdir), mdir)
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class ExportDialog(QDialog):
|
|||||||
):
|
):
|
||||||
QDialog.__init__(self, mw, Qt.Window)
|
QDialog.__init__(self, mw, Qt.Window)
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.col = mw.col
|
self.col = mw.col.weakref()
|
||||||
self.frm = aqt.forms.exporting.Ui_ExportDialog()
|
self.frm = aqt.forms.exporting.Ui_ExportDialog()
|
||||||
self.frm.setupUi(self)
|
self.frm.setupUi(self)
|
||||||
self.exporter = None
|
self.exporter = None
|
||||||
@ -151,6 +151,7 @@ class ExportDialog(QDialog):
|
|||||||
period = 3000
|
period = 3000
|
||||||
if self.isVerbatim:
|
if self.isVerbatim:
|
||||||
msg = _("Collection exported.")
|
msg = _("Collection exported.")
|
||||||
|
self.mw.reopen()
|
||||||
else:
|
else:
|
||||||
if self.isTextNote:
|
if self.isTextNote:
|
||||||
msg = (
|
msg = (
|
||||||
|
@ -459,7 +459,6 @@ close the profile or restart Anki."""
|
|||||||
|
|
||||||
def _loadCollection(self) -> bool:
|
def _loadCollection(self) -> bool:
|
||||||
cpath = self.pm.collectionPath()
|
cpath = self.pm.collectionPath()
|
||||||
|
|
||||||
self.col = Collection(cpath)
|
self.col = Collection(cpath)
|
||||||
|
|
||||||
self.setEnabled(True)
|
self.setEnabled(True)
|
||||||
@ -467,6 +466,10 @@ close the profile or restart Anki."""
|
|||||||
self.moveToState("deckBrowser")
|
self.moveToState("deckBrowser")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def reopen(self):
|
||||||
|
cpath = self.pm.collectionPath()
|
||||||
|
self.col = Collection(cpath)
|
||||||
|
|
||||||
def unloadCollection(self, onsuccess: Callable) -> None:
|
def unloadCollection(self, onsuccess: Callable) -> None:
|
||||||
def callback():
|
def callback():
|
||||||
self.setEnabled(False)
|
self.setEnabled(False)
|
||||||
|
Loading…
Reference in New Issue
Block a user