mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
show error on invalid search
This commit is contained in:
parent
affede8079
commit
2fc47773b6
2 changed files with 14 additions and 3 deletions
|
@ -38,7 +38,7 @@ class Finder(object):
|
|||
tokens = self._tokenize(query)
|
||||
preds, args = self._where(tokens)
|
||||
if preds is None:
|
||||
return []
|
||||
raise Exception("invalidSearch")
|
||||
order, rev = self._order(order)
|
||||
sql = self._query(preds, order)
|
||||
try:
|
||||
|
|
|
@ -121,11 +121,22 @@ class DataModel(QAbstractTableModel):
|
|||
# the db progress handler may cause a refresh, so we need to zero out
|
||||
# old data first
|
||||
self.cards = []
|
||||
self.cards = self.col.findCards(txt, order=True)
|
||||
#self.browser.mw.pm.profile['fullSearch'])
|
||||
invalid = False
|
||||
try:
|
||||
self.cards = self.col.findCards(txt, order=True)
|
||||
except Exception as e:
|
||||
if str(e) == "invalidSearch":
|
||||
self.cards = []
|
||||
invalid = True
|
||||
else:
|
||||
raise
|
||||
#print "fetch cards in %dms" % ((time.time() - t)*1000)
|
||||
self.endReset()
|
||||
|
||||
if invalid:
|
||||
showWarning(_("Invalid search - please check for typing mistakes."))
|
||||
|
||||
|
||||
def reset(self):
|
||||
self.beginReset()
|
||||
self.endReset()
|
||||
|
|
Loading…
Reference in a new issue