remove note decks

This commit is contained in:
Damien Elmes 2012-03-09 09:41:12 +09:00
parent eab18e9588
commit 3e0aed4e41
3 changed files with 23 additions and 72 deletions

View file

@ -228,8 +228,6 @@ class DataModel(QAbstractTableModel):
return "%d%%" % (c.factor/10) return "%d%%" % (c.factor/10)
elif type == "deck": elif type == "deck":
return self.browser.mw.col.decks.name(c.did) return self.browser.mw.col.decks.name(c.did)
elif type == "ndeck":
return self.browser.mw.col.decks.name(c.note().did)
def question(self, c): def question(self, c):
return self.formatQA(c.a()) return self.formatQA(c.a())
@ -395,7 +393,6 @@ class Browser(QMainWindow):
('answer', _("Answer")), ('answer', _("Answer")),
('template', _("Card")), ('template', _("Card")),
('deck', _("Card Deck")), ('deck', _("Card Deck")),
('ndeck', _("Note Deck")),
('noteFld', _("Sort Field")), ('noteFld', _("Sort Field")),
('noteCrt', _("Created")), ('noteCrt', _("Created")),
('noteMod', _("Edited")), ('noteMod', _("Edited")),
@ -885,20 +882,16 @@ where id in %s""" % ids2str(sf))
# Deck change # Deck change
###################################################################### ######################################################################
def setDeck(self, initial=False): def setDeck(self):
d = QDialog(self) d = QDialog(self)
d.setWindowModality(Qt.WindowModal) d.setWindowModality(Qt.WindowModal)
frm = aqt.forms.setgroup.Ui_Dialog() frm = aqt.forms.setgroup.Ui_Dialog()
frm.setupUi(d) frm.setupUi(d)
from aqt.tagedit import TagEdit from aqt.tagedit import TagEdit
te = TagEdit(d, type=1) te = TagEdit(d, type=1)
frm.groupBox.layout().insertWidget(0, te) frm.verticalLayout_2.insertWidget(1, te)
te.setCol(self.col) te.setCol(self.col)
d.connect(d, SIGNAL("accepted()"), lambda: self._onSetDeck(frm, te)) d.connect(d, SIGNAL("accepted()"), lambda: self._onSetDeck(frm, te))
self.setTabOrder(frm.setCur, te)
self.setTabOrder(te, frm.setInitial)
if initial:
frm.setInitial.setChecked(True)
d.show() d.show()
te.setFocus() te.setFocus()
@ -907,19 +900,10 @@ where id in %s""" % ids2str(sf))
self.mw.checkpoint(_("Set Deck")) self.mw.checkpoint(_("Set Deck"))
mod = intTime() mod = intTime()
usn = self.col.usn() usn = self.col.usn()
if frm.setCur.isChecked():
did = self.col.decks.id(unicode(te.text())) did = self.col.decks.id(unicode(te.text()))
self.col.db.execute( self.col.db.execute(
"update cards set usn=?, mod=?, did=? where id in " + ids2str( "update cards set usn=?, mod=?, did=? where id in " + ids2str(
self.selectedCards()), usn, mod, did) self.selectedCards()), usn, mod, did)
if frm.setInitial.isChecked():
self.col.db.execute(
"update notes set usn=?, mod=?, did=? where id in " + ids2str(
self.selectedNotes()), usn, mod, did)
else:
self.col.db.execute("""
update cards set usn=?, mod=?, did=(select did from notes where id = cards.nid)
where id in %s""" % ids2str(self.selectedCards()), usn, mod)
self.onSearch(reset=False) self.onSearch(reset=False)
self.mw.requireReset() self.mw.requireReset()
self.model.endReset() self.model.endReset()

View file

@ -537,7 +537,7 @@ class Editor(object):
self.deck.setCol(self.mw.col) self.deck.setCol(self.mw.col)
self.tags.setCol(self.mw.col) self.tags.setCol(self.mw.col)
if self.addMode: if self.addMode:
self.deck.setText(self.mw.col.decks.name(self.note.did)) self.deck.setText(self.mw.col.decks.name(self.note.model()['did']))
self.tags.setText(self.note.stringTags().strip()) self.tags.setText(self.note.stringTags().strip())
def saveTagsAndDeck(self): def saveTagsAndDeck(self):
@ -547,12 +547,11 @@ class Editor(object):
if self.addMode: if self.addMode:
name = self.deck.text() name = self.deck.text()
if not name.strip(): if not name.strip():
self.note.did = 1 self.note.model()['did'] = 1
else: else:
self.note.did = self.mw.col.decks.id(name) self.note.model()['did'] = self.mw.col.decks.id(name)
# save group and tags to model # save tags to model
m = self.note.model() m = self.note.model()
m['did'] = self.note.did
m['tags'] = self.note.tags m['tags'] = self.note.tags
self.mw.col.models.save(m) self.mw.col.models.save(m)
if not self.addMode: if not self.addMode:

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>291</width> <width>276</width>
<height>188</height> <height>151</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,37 +15,24 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QRadioButton" name="setCur"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Move card(s) to deck:</string> <string>Move cards to deck:</string>
</property>
<property name="checked">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox"> <spacer name="verticalSpacer">
<property name="title"> <property name="orientation">
<string/> <enum>Qt::Vertical</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <property name="sizeHint" stdset="0">
<item> <size>
<widget class="QCheckBox" name="setInitial"> <width>20</width>
<property name="text"> <height>40</height>
<string>Move notes too</string> </size>
</property> </property>
</widget> </spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QRadioButton" name="reset">
<property name="text">
<string>Move card(s) to their note's deck</string>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
@ -60,9 +47,6 @@
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>setCur</tabstop>
<tabstop>setInitial</tabstop>
<tabstop>reset</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
@ -99,21 +83,5 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>setCur</sender>
<signal>toggled(bool)</signal>
<receiver>groupBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>188</x>
<y>19</y>
</hint>
<hint type="destinationlabel">
<x>343</x>
<y>53</y>
</hint>
</hints>
</connection>
</connections> </connections>
</ui> </ui>