mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
improve filter dropdown box; add icons
This commit is contained in:
parent
94d7a74bca
commit
c58c6d9ca9
1 changed files with 47 additions and 8 deletions
|
@ -362,16 +362,51 @@ class EditDeck(QMainWindow):
|
||||||
self.sortChanged(self.sortIndex, refresh=False)
|
self.sortChanged(self.sortIndex, refresh=False)
|
||||||
|
|
||||||
def drawTags(self):
|
def drawTags(self):
|
||||||
|
self.dialog.tagList.view().setFixedWidth(200)
|
||||||
self.dialog.tagList.setMaxVisibleItems(30)
|
self.dialog.tagList.setMaxVisibleItems(30)
|
||||||
tags = self.deck.allTags()
|
|
||||||
self.alltags = tags
|
|
||||||
self.alltags.sort()
|
|
||||||
self.dialog.tagList.setFixedWidth(130)
|
self.dialog.tagList.setFixedWidth(130)
|
||||||
self.dialog.tagList.clear()
|
self.dialog.tagList.clear()
|
||||||
self.dialog.tagList.addItems(QStringList(
|
alltags = [None, "Marked", "Suspended", None, None]
|
||||||
[_('<Tag filter>'), _('No tags')] +
|
# system tags
|
||||||
[x.replace("_", " ") for x in self.alltags]))
|
self.dialog.tagList.addItem(_("<Filter>"))
|
||||||
self.dialog.tagList.view().setFixedWidth(200)
|
self.dialog.tagList.addItem(QIcon(":/icons/rating.png"),
|
||||||
|
_('Marked'))
|
||||||
|
self.dialog.tagList.addItem(QIcon(":/icons/media-playback-pause.png"),
|
||||||
|
_('Suspended'))
|
||||||
|
self.dialog.tagList.addItem(QIcon(":/icons/editclear.png"),
|
||||||
|
_('No fact tags'))
|
||||||
|
self.dialog.tagList.insertSeparator(
|
||||||
|
self.dialog.tagList.count())
|
||||||
|
# model and card templates
|
||||||
|
for (type, sql, icon) in (
|
||||||
|
("models", "select tags from models", "contents.png"),
|
||||||
|
("cms", "select name from cardModels", "Anki_Card.png")):
|
||||||
|
d = {}
|
||||||
|
tagss = self.deck.s.column0(sql)
|
||||||
|
for tags in tagss:
|
||||||
|
for tag in parseTags(tags):
|
||||||
|
d[tag] = 1
|
||||||
|
sortedtags = sorted(d.keys())
|
||||||
|
alltags.extend(sortedtags)
|
||||||
|
icon = QIcon(":/icons/" + icon)
|
||||||
|
for t in sortedtags:
|
||||||
|
self.dialog.tagList.addItem(icon, t)
|
||||||
|
alltags.append(None)
|
||||||
|
self.dialog.tagList.insertSeparator(
|
||||||
|
self.dialog.tagList.count())
|
||||||
|
# fact tags
|
||||||
|
alluser = sorted(self.deck.allTags())
|
||||||
|
for tag in alltags:
|
||||||
|
try:
|
||||||
|
alluser.remove(tag)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
icon = QIcon(":/icons/Anki_Fact.png")
|
||||||
|
for t in alluser:
|
||||||
|
t = t.replace("_", " ")
|
||||||
|
self.dialog.tagList.addItem(icon, t)
|
||||||
|
alltags.extend(alluser)
|
||||||
|
self.alltags = alltags
|
||||||
|
|
||||||
def drawSort(self):
|
def drawSort(self):
|
||||||
self.sortList = [
|
self.sortList = [
|
||||||
|
@ -451,9 +486,13 @@ class EditDeck(QMainWindow):
|
||||||
if idx == 0:
|
if idx == 0:
|
||||||
self.dialog.filterEdit.setText("")
|
self.dialog.filterEdit.setText("")
|
||||||
elif idx == 1:
|
elif idx == 1:
|
||||||
|
self.dialog.filterEdit.setText("tag:marked")
|
||||||
|
elif idx == 2:
|
||||||
|
self.dialog.filterEdit.setText("tag:suspended")
|
||||||
|
elif idx == 3:
|
||||||
self.dialog.filterEdit.setText("tag:none")
|
self.dialog.filterEdit.setText("tag:none")
|
||||||
else:
|
else:
|
||||||
self.dialog.filterEdit.setText("tag:" + self.alltags[idx-2])
|
self.dialog.filterEdit.setText("tag:" + self.alltags[idx])
|
||||||
self.showFilterNow()
|
self.showFilterNow()
|
||||||
self.dialog.tagList.setCurrentIndex(0)
|
self.dialog.tagList.setCurrentIndex(0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue