mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
improve searching, don't trigger on space
This commit is contained in:
parent
95d907333e
commit
ef32247f30
1 changed files with 9 additions and 15 deletions
|
@ -49,6 +49,7 @@ class DeckModel(QAbstractTableModel):
|
||||||
[_("Due"), self.thirdColumn],
|
[_("Due"), self.thirdColumn],
|
||||||
]
|
]
|
||||||
self.searchStr = ""
|
self.searchStr = ""
|
||||||
|
self.lastSearch = ""
|
||||||
self.cards = []
|
self.cards = []
|
||||||
self.deleted = {}
|
self.deleted = {}
|
||||||
|
|
||||||
|
@ -102,19 +103,6 @@ class DeckModel(QAbstractTableModel):
|
||||||
# Filtering
|
# Filtering
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def parseSearch(self):
|
|
||||||
search = self.searchStr
|
|
||||||
d = {'str': [],
|
|
||||||
'tag': [],
|
|
||||||
}
|
|
||||||
if search:
|
|
||||||
for elem in search.split():
|
|
||||||
if len(elem) > 2 and elem.startswith("t:"):
|
|
||||||
d['tag'].append(elem[2:])
|
|
||||||
else:
|
|
||||||
d['str'].append(elem)
|
|
||||||
return d
|
|
||||||
|
|
||||||
def showMatching(self):
|
def showMatching(self):
|
||||||
if not self.sortKey:
|
if not self.sortKey:
|
||||||
self.cards = []
|
self.cards = []
|
||||||
|
@ -122,9 +110,15 @@ class DeckModel(QAbstractTableModel):
|
||||||
# sorting
|
# sorting
|
||||||
if not self.searchStr:
|
if not self.searchStr:
|
||||||
ads = ""
|
ads = ""
|
||||||
|
self.lastSearch = ""
|
||||||
else:
|
else:
|
||||||
ads = "cards.factId in %s" % ids2str(
|
if self.searchStr.strip() == self.lastSearch.strip():
|
||||||
self.deck.findFacts(self.searchStr))
|
# just whitespace
|
||||||
|
return
|
||||||
|
QApplication.instance().processEvents()
|
||||||
|
self.lastSearch = self.searchStr
|
||||||
|
ids = self.deck.findCards(self.searchStr)
|
||||||
|
ads = "cards.id in %s" % ids2str(ids)
|
||||||
sort = ""
|
sort = ""
|
||||||
if isinstance(self.sortKey, types.StringType):
|
if isinstance(self.sortKey, types.StringType):
|
||||||
# card property
|
# card property
|
||||||
|
|
Loading…
Reference in a new issue