mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
move tag search to libanki, remove quotes from tag search
This commit is contained in:
parent
7f0832fd61
commit
c70a8d1b55
1 changed files with 3 additions and 22 deletions
|
@ -139,26 +139,9 @@ class DeckModel(QAbstractTableModel):
|
||||||
if search['tag']:
|
if search['tag']:
|
||||||
ids = None
|
ids = None
|
||||||
if "none" in search['tag']:
|
if "none" in search['tag']:
|
||||||
search['tag'].remove("none")
|
|
||||||
ids = set(self.deck.cardsWithNoTags())
|
ids = set(self.deck.cardsWithNoTags())
|
||||||
if search['tag']:
|
else:
|
||||||
def find(tag, tags):
|
ids = self.deck.cardsWithTags(" ".join(search['tag']))
|
||||||
if tag.startswith('"'):
|
|
||||||
# direct match
|
|
||||||
return findTag(tag.replace('"', ""), parseTags(tags))
|
|
||||||
else:
|
|
||||||
return tag.lower() in tags.lower()
|
|
||||||
for tag in search['tag']:
|
|
||||||
like = "%" + tag.replace('"', "") + "%"
|
|
||||||
i = [id for (id, tags, pri) in self.deck.tagsList(
|
|
||||||
where="""
|
|
||||||
and (facts.tags like :s or models.tags like :s or cardModels.name like :s)""",
|
|
||||||
kwargs = {'s': like})
|
|
||||||
if find(tag, tags)]
|
|
||||||
if not ids:
|
|
||||||
ids = set(i)
|
|
||||||
else:
|
|
||||||
ids.intersection_update(i)
|
|
||||||
if not ids:
|
if not ids:
|
||||||
ids = []
|
ids = []
|
||||||
tagLimit = "cards.id in %s" % ids2str(ids)
|
tagLimit = "cards.id in %s" % ids2str(ids)
|
||||||
|
@ -374,7 +357,6 @@ class EditDeck(QMainWindow):
|
||||||
[_('<Select Tag>'), _('No tags')] + self.alltags))
|
[_('<Select Tag>'), _('No tags')] + self.alltags))
|
||||||
self.dialog.tagList.view().setFixedWidth(300)
|
self.dialog.tagList.view().setFixedWidth(300)
|
||||||
|
|
||||||
|
|
||||||
def drawSort(self):
|
def drawSort(self):
|
||||||
self.sortList = [
|
self.sortList = [
|
||||||
_("Question"),
|
_("Question"),
|
||||||
|
@ -453,8 +435,7 @@ class EditDeck(QMainWindow):
|
||||||
elif idx == 1:
|
elif idx == 1:
|
||||||
self.dialog.filterEdit.setText("t:none")
|
self.dialog.filterEdit.setText("t:none")
|
||||||
else:
|
else:
|
||||||
self.dialog.filterEdit.setText(
|
self.dialog.filterEdit.setText("t:" + self.alltags[idx-2])
|
||||||
"t:\"" + self.alltags[idx-2] + "\"")
|
|
||||||
self.showFilterNow()
|
self.showFilterNow()
|
||||||
self.dialog.tagList.setCurrentIndex(0)
|
self.dialog.tagList.setCurrentIndex(0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue