mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-30 23:00:21 -04:00
IGN:Fix minor bug in advanced search dialog if only a none term is specified
This commit is contained in:
parent
d6903d4def
commit
b1357eae0c
@ -6,13 +6,13 @@ from PyQt4.QtGui import QDialog
|
|||||||
from calibre.gui2.dialogs.search_ui import Ui_Dialog
|
from calibre.gui2.dialogs.search_ui import Ui_Dialog
|
||||||
from calibre.gui2 import qstring_to_unicode
|
from calibre.gui2 import qstring_to_unicode
|
||||||
|
|
||||||
|
|
||||||
class SearchDialog(QDialog, Ui_Dialog):
|
class SearchDialog(QDialog, Ui_Dialog):
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
QDialog.__init__(self, *args)
|
QDialog.__init__(self, *args)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
def tokens(self, raw):
|
def tokens(self, raw):
|
||||||
phrases = re.findall(r'\s+".*?"\s+', raw)
|
phrases = re.findall(r'\s+".*?"\s+', raw)
|
||||||
for f in phrases:
|
for f in phrases:
|
||||||
@ -20,7 +20,8 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
return [t.strip() for t in phrases + raw.split()]
|
return [t.strip() for t in phrases + raw.split()]
|
||||||
|
|
||||||
def search_string(self):
|
def search_string(self):
|
||||||
all, any, phrase, none = map(lambda x: unicode(x.text()), (self.all, self.any, self.phrase, self.none))
|
all, any, phrase, none = map(lambda x: unicode(x.text()),
|
||||||
|
(self.all, self.any, self.phrase, self.none))
|
||||||
all, any, none = map(self.tokens, (all, any, none))
|
all, any, none = map(self.tokens, (all, any, none))
|
||||||
phrase = phrase.strip()
|
phrase = phrase.strip()
|
||||||
all = ' and '.join(all)
|
all = ' and '.join(all)
|
||||||
@ -32,11 +33,11 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
if all:
|
if all:
|
||||||
ans += (' and ' if ans else '') + all
|
ans += (' and ' if ans else '') + all
|
||||||
if none:
|
if none:
|
||||||
ans += (' and not ' if ans else '') + none
|
ans += (' and not ' if ans else 'not') + none
|
||||||
if any:
|
if any:
|
||||||
ans += (' or ' if ans else '') + any
|
ans += (' or ' if ans else '') + any
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
def token(self):
|
def token(self):
|
||||||
txt = qstring_to_unicode(self.text.text()).strip()
|
txt = qstring_to_unicode(self.text.text()).strip()
|
||||||
if txt:
|
if txt:
|
||||||
@ -46,4 +47,4 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
if re.search(r'\s', tok):
|
if re.search(r'\s', tok):
|
||||||
tok = '"%s"'%tok
|
tok = '"%s"'%tok
|
||||||
return tok
|
return tok
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user