prevent accidental sync, hide source ids

This commit is contained in:
Damien Elmes 2008-10-10 17:37:11 +09:00
parent 8739e164ac
commit 17798b03f4
3 changed files with 56 additions and 43 deletions

View file

@ -444,16 +444,16 @@ class AnkiQt(QMainWindow):
return return
self.updateRecentFiles(self.deck.path) self.updateRecentFiles(self.deck.path)
if sync and self.config['syncOnLoad']: if sync and self.config['syncOnLoad']:
self.syncDeck(False) if self.syncDeck(interactive=False):
else: return
try: try:
self.rebuildQueue() self.rebuildQueue()
except OperationalError: except OperationalError:
ui.utils.showWarning(_( ui.utils.showWarning(_(
"Error building queue. Attempting recovery..")) "Error building queue. Attempting recovery.."))
self.onCheckDB() self.onCheckDB()
# try again # try again
self.rebuildQueue() self.rebuildQueue()
return True return True
def importOldDeck(self, deckPath): def importOldDeck(self, deckPath):
@ -1019,9 +1019,10 @@ class AnkiQt(QMainWindow):
u=self.config['syncUsername'] u=self.config['syncUsername']
p=self.config['syncPassword'] p=self.config['syncPassword']
if not u or not p: if not u or not p:
msg = _("Not syncing, username or password unset.") return
if self.deck and not self.deck.syncName:
if interactive: if interactive:
ui.utils.showWarning(msg) self.onDeckProperties()
return return
if self.deck is None and self.deckPath is None: if self.deck is None and self.deckPath is None:
# qt on linux incorrectly accepts shortcuts for disabled actions # qt on linux incorrectly accepts shortcuts for disabled actions

View file

@ -74,8 +74,8 @@ class Sync(QThread):
except SyncError, e: except SyncError, e:
return self.error(e) return self.error(e)
else: else:
self.emit(SIGNAL("noMatchingDeck"), proxy.decks.keys(), keys = [k for (k,v) in proxy.decks.items() if v[1] != -1]
not self.onlyMerge) self.emit(SIGNAL("noMatchingDeck"), keys, not self.onlyMerge)
self.setStatus("") self.setStatus("")
return return
timediff = abs(proxy.timestamp - time.time()) timediff = abs(proxy.timestamp - time.time())
@ -115,17 +115,18 @@ class Sync(QThread):
self.setStatus(_("No changes found.")) self.setStatus(_("No changes found."))
# check sources # check sources
if self.sourcesToCheck: if self.sourcesToCheck:
start = time.time()
self.setStatus(_("<br><br>Checking deck subscriptions..")) self.setStatus(_("<br><br>Checking deck subscriptions.."))
for source in self.sourcesToCheck: for source in self.sourcesToCheck:
proxy.deckName = str(source) proxy.deckName = str(source)
msg = "%s:" % client.syncOneWayDeckName() msg = "%s:" % client.syncOneWayDeckName()
if not proxy.hasDeck(str(source)): if not proxy.hasDeck(str(source)):
self.setStatus(_("%s no longer exists.") % msg) self.setStatus(_(" * %s no longer exists.") % msg)
continue continue
if not client.prepareOneWaySync(): if not client.prepareOneWaySync():
self.setStatus(_("%s no changes found.") % msg) self.setStatus(_(" * %s no changes found.") % msg)
continue continue
self.setStatus(_("%s fetching payload..") % msg) self.setStatus(_(" * %s fetching payload..") % msg)
payload = proxy.genOneWayPayload(client.lastSync) payload = proxy.genOneWayPayload(client.lastSync)
self.setStatus(msg + _(" applied %d modified cards.") % self.setStatus(msg + _(" applied %d modified cards.") %
len(payload['cards'])) len(payload['cards']))

View file

@ -8,15 +8,15 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>429</width> <width>366</width>
<height>451</height> <height>408</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
<string>Deck Properties</string> <string>Deck Properties</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5" > <layout class="QVBoxLayout" name="verticalLayout_2" >
<item row="0" column="0" > <item>
<widget class="QTabWidget" name="qtabwidget" > <widget class="QTabWidget" name="qtabwidget" >
<property name="whatsThis" > <property name="whatsThis" >
<string>&lt;a href="http://ichi2.net/anki/wiki/DeckProperties#Synchronization">Help&lt;/a></string> <string>&lt;a href="http://ichi2.net/anki/wiki/DeckProperties#Synchronization">Help&lt;/a></string>
@ -29,8 +29,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>407</width> <width>350</width>
<height>373</height> <height>342</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
@ -58,17 +58,7 @@
<item row="1" column="0" > <item row="1" column="0" >
<widget class="QCheckBox" name="doSync" > <widget class="QCheckBox" name="doSync" >
<property name="text" > <property name="text" >
<string>Synchronize this deck with name:</string> <string>Synchronize this deck</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLineEdit" name="syncName" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="whatsThis" >
<string>option</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -123,6 +113,27 @@ p, li { white-space: pre-wrap; }
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="0" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QLabel" name="label_18" >
<property name="text" >
<string>Name on server: </string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="syncName" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="whatsThis" >
<string>option</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -132,8 +143,8 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>413</width> <width>350</width>
<height>385</height> <height>342</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
@ -329,8 +340,8 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>413</width> <width>350</width>
<height>385</height> <height>342</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
@ -394,8 +405,8 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>413</width> <width>350</width>
<height>385</height> <height>342</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
@ -435,8 +446,8 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>413</width> <width>350</width>
<height>385</height> <height>342</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
@ -627,7 +638,7 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
</widget> </widget>
</item> </item>
<item row="2" column="0" > <item>
<widget class="QDialogButtonBox" name="buttonBox" > <widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>