mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-25 09:36:20 +01:00
1) Fix problem with case sensitive matching when creating user categories
2) Fix problem in search where setting focus to the search box then removing it caused the item in history to replace the item in the search box case-insensitively. This broke tag state matching in the tag browser.
This commit is contained in:
parent
acb71725ba
commit
2aa275dad5
3 changed files with 15 additions and 8 deletions
|
|
@ -178,8 +178,10 @@ def add_category(self):
|
|||
'multiple periods in a row or spaces before '
|
||||
'or after periods.')).exec_()
|
||||
return False
|
||||
for c in self.categories:
|
||||
if strcmp(c, cat_name) == 0:
|
||||
for c in sorted(self.categories.keys(), key=sort_key):
|
||||
if strcmp(c, cat_name) == 0 or \
|
||||
(icu_lower(cat_name).startswith(icu_lower(c) + '.') and\
|
||||
not cat_name.startswith(c + '.')):
|
||||
error_dialog(self, _('Name already used'),
|
||||
_('That name is already used, perhaps with different case.')).exec_()
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -217,11 +217,15 @@ def set_search_string(self, txt, store_in_history=False, emit_changed=True):
|
|||
self.clear()
|
||||
else:
|
||||
self.normalize_state()
|
||||
self.lineEdit().setCompleter(None)
|
||||
self.setEditText(txt)
|
||||
self.line_edit.end(False)
|
||||
if emit_changed:
|
||||
self.changed.emit()
|
||||
self._do_search(store_in_history=store_in_history)
|
||||
c = QCompleter()
|
||||
self.lineEdit().setCompleter(c)
|
||||
c.setCompletionMode(c.PopupCompletion)
|
||||
self.focus_to_library.emit()
|
||||
finally:
|
||||
if not store_in_history:
|
||||
|
|
|
|||
|
|
@ -654,7 +654,6 @@ def toggle(self, set_to=None):
|
|||
'''
|
||||
set_to: None => advance the state, otherwise a value from TAG_SEARCH_STATES
|
||||
'''
|
||||
# if self.type == self.TAG:
|
||||
if set_to is None:
|
||||
while True:
|
||||
self.tag.state = (self.tag.state + 1)%5
|
||||
|
|
@ -1319,16 +1318,19 @@ def setData(self, index, value, role=Qt.EditRole):
|
|||
return False
|
||||
|
||||
user_cats = self.db.prefs.get('user_categories', {})
|
||||
user_cat_keys_lower = [icu_lower(k) for k in user_cats]
|
||||
ckey = item.category_key[1:]
|
||||
ckey_lower = icu_lower(ckey)
|
||||
dotpos = ckey.rfind('.')
|
||||
if dotpos < 0:
|
||||
nkey = val
|
||||
else:
|
||||
nkey = ckey[:dotpos+1] + val
|
||||
for c in user_cats:
|
||||
if c.startswith(ckey):
|
||||
nkey_lower = icu_lower(nkey)
|
||||
for c in sorted(user_cats.keys(), key=sort_key):
|
||||
if icu_lower(c).startswith(ckey_lower):
|
||||
if len(c) == len(ckey):
|
||||
if nkey in user_cats:
|
||||
if nkey_lower in user_cat_keys_lower:
|
||||
error_dialog(self.tags_view, _('Rename user category'),
|
||||
_('The name %s is already used')%nkey, show=True)
|
||||
return False
|
||||
|
|
@ -1336,7 +1338,7 @@ def setData(self, index, value, role=Qt.EditRole):
|
|||
del user_cats[ckey]
|
||||
elif c[len(ckey)] == '.':
|
||||
rest = c[len(ckey):]
|
||||
if (nkey + rest) in user_cats:
|
||||
if icu_lower(nkey + rest) in user_cat_keys_lower:
|
||||
error_dialog(self.tags_view, _('Rename user category'),
|
||||
_('The name %s is already used')%(nkey+rest), show=True)
|
||||
return False
|
||||
|
|
@ -1512,7 +1514,6 @@ def rowCount(self, parent):
|
|||
def reset_all_states(self, except_=None):
|
||||
update_list = []
|
||||
def process_tag(tag_item):
|
||||
# if tag_item.type != TagTreeItem.CATEGORY:
|
||||
tag = tag_item.tag
|
||||
if tag is except_:
|
||||
tag_index = self.createIndex(tag_item.row(), 0, tag_item)
|
||||
|
|
|
|||
Loading…
Reference in a new issue