mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
remove note decks
This commit is contained in:
parent
eab18e9588
commit
3e0aed4e41
3 changed files with 23 additions and 72 deletions
|
@ -228,8 +228,6 @@ class DataModel(QAbstractTableModel):
|
|||
return "%d%%" % (c.factor/10)
|
||||
elif type == "deck":
|
||||
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):
|
||||
return self.formatQA(c.a())
|
||||
|
@ -395,7 +393,6 @@ class Browser(QMainWindow):
|
|||
('answer', _("Answer")),
|
||||
('template', _("Card")),
|
||||
('deck', _("Card Deck")),
|
||||
('ndeck', _("Note Deck")),
|
||||
('noteFld', _("Sort Field")),
|
||||
('noteCrt', _("Created")),
|
||||
('noteMod', _("Edited")),
|
||||
|
@ -885,20 +882,16 @@ where id in %s""" % ids2str(sf))
|
|||
# Deck change
|
||||
######################################################################
|
||||
|
||||
def setDeck(self, initial=False):
|
||||
def setDeck(self):
|
||||
d = QDialog(self)
|
||||
d.setWindowModality(Qt.WindowModal)
|
||||
frm = aqt.forms.setgroup.Ui_Dialog()
|
||||
frm.setupUi(d)
|
||||
from aqt.tagedit import TagEdit
|
||||
te = TagEdit(d, type=1)
|
||||
frm.groupBox.layout().insertWidget(0, te)
|
||||
frm.verticalLayout_2.insertWidget(1, te)
|
||||
te.setCol(self.col)
|
||||
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()
|
||||
te.setFocus()
|
||||
|
||||
|
@ -907,19 +900,10 @@ where id in %s""" % ids2str(sf))
|
|||
self.mw.checkpoint(_("Set Deck"))
|
||||
mod = intTime()
|
||||
usn = self.col.usn()
|
||||
if frm.setCur.isChecked():
|
||||
did = self.col.decks.id(unicode(te.text()))
|
||||
self.col.db.execute(
|
||||
"update cards set usn=?, mod=?, did=? where id in " + ids2str(
|
||||
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)
|
||||
did = self.col.decks.id(unicode(te.text()))
|
||||
self.col.db.execute(
|
||||
"update cards set usn=?, mod=?, did=? where id in " + ids2str(
|
||||
self.selectedCards()), usn, mod, did)
|
||||
self.onSearch(reset=False)
|
||||
self.mw.requireReset()
|
||||
self.model.endReset()
|
||||
|
|
|
@ -537,7 +537,7 @@ class Editor(object):
|
|||
self.deck.setCol(self.mw.col)
|
||||
self.tags.setCol(self.mw.col)
|
||||
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())
|
||||
|
||||
def saveTagsAndDeck(self):
|
||||
|
@ -547,12 +547,11 @@ class Editor(object):
|
|||
if self.addMode:
|
||||
name = self.deck.text()
|
||||
if not name.strip():
|
||||
self.note.did = 1
|
||||
self.note.model()['did'] = 1
|
||||
else:
|
||||
self.note.did = self.mw.col.decks.id(name)
|
||||
# save group and tags to model
|
||||
self.note.model()['did'] = self.mw.col.decks.id(name)
|
||||
# save tags to model
|
||||
m = self.note.model()
|
||||
m['did'] = self.note.did
|
||||
m['tags'] = self.note.tags
|
||||
self.mw.col.models.save(m)
|
||||
if not self.addMode:
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>291</width>
|
||||
<height>188</height>
|
||||
<width>276</width>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -15,37 +15,24 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="setCur">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Move card(s) to deck:</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<string>Move cards to deck:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string/>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="setInitial">
|
||||
<property name="text">
|
||||
<string>Move notes too</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="reset">
|
||||
<property name="text">
|
||||
<string>Move card(s) to their note's deck</string>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
|
@ -60,9 +47,6 @@
|
|||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>setCur</tabstop>
|
||||
<tabstop>setInitial</tabstop>
|
||||
<tabstop>reset</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
|
@ -99,21 +83,5 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</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>
|
||||
</ui>
|
||||
|
|
Loading…
Reference in a new issue