diff --git a/src/calibre/gui2/dialogs/tag_categories.py b/src/calibre/gui2/dialogs/tag_categories.py index 9f55738000..ab2d8c52d1 100644 --- a/src/calibre/gui2/dialogs/tag_categories.py +++ b/src/calibre/gui2/dialogs/tag_categories.py @@ -22,7 +22,7 @@ class Item: return 'name=%s, label=%s, index=%s, exists='%(self.name, self.label, self.index, self.exists) class TagCategories(QDialog, Ui_TagCategories): - category_labels = ['', 'author', 'series', 'publisher', 'tag'] + category_labels_orig = ['', 'author', 'series', 'publisher', 'tag'] def __init__(self, window, db, index=None): QDialog.__init__(self, window) @@ -33,6 +33,9 @@ class TagCategories(QDialog, Ui_TagCategories): self.index = index self.applied_items = [] + cc_icon = QIcon(I('column.svg')) + + self.category_labels = self.category_labels_orig[:] category_icons = [None, QIcon(I('user_profile.svg')), QIcon(I('series.svg')), QIcon(I('publisher.png')), QIcon(I('tags.svg'))] category_values = [None, @@ -43,6 +46,14 @@ class TagCategories(QDialog, Ui_TagCategories): ] category_names = ['', _('Authors'), _('Series'), _('Publishers'), _('Tags')] + cc_map = self.db.custom_column_label_map + for cc in cc_map: + if cc_map[cc]['datatype'] == 'text': + self.category_labels.append(cc) + category_icons.append(cc_icon) + category_values.append(lambda col=cc: self.db.all_custom(label=col)) + category_names.append(cc_map[cc]['name']) + self.all_items = [] self.all_items_dict = {} for idx,label in enumerate(self.category_labels): diff --git a/src/calibre/gui2/library.py b/src/calibre/gui2/library.py index 9f209a0066..417734b691 100644 --- a/src/calibre/gui2/library.py +++ b/src/calibre/gui2/library.py @@ -724,7 +724,7 @@ class BooksModel(QAbstractTableModel): 'timestamp': functools.partial(datetime_type, idx=self.db.FIELD_MAP['timestamp']), 'pubdate' : functools.partial(datetime_type, idx=self.db.FIELD_MAP['pubdate']), 'rating' : functools.partial(rating_type, idx=self.db.FIELD_MAP['rating']), - 'publisher': functools.partial(text_type, idx=self.db.FIELD_MAP['title'], mult=False), + 'publisher': functools.partial(text_type, idx=self.db.FIELD_MAP['publisher'], mult=False), 'tags' : functools.partial(tags, idx=self.db.FIELD_MAP['tags']), 'series' : functools.partial(series, idx=self.db.FIELD_MAP['series'], siix=self.db.FIELD_MAP['series_index']), } diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index 5a4cf25966..4303881f02 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -279,9 +279,10 @@ class SavedSearchBox(QComboBox): idx = self.currentIndex if idx < 0: return + ss = self.saved_searches.lookup(unicode(self.currentText())) self.saved_searches.delete(unicode(self.currentText())) self.clear_to_help() - self.search_box.set_search_string('') + self.search_box.set_search_string(ss) self.emit(SIGNAL('changed()')) # SIGNALed from the main UI diff --git a/src/calibre/gui2/tag_view.py b/src/calibre/gui2/tag_view.py index 89e3c37e25..c3088ba468 100644 --- a/src/calibre/gui2/tag_view.py +++ b/src/calibre/gui2/tag_view.py @@ -184,7 +184,7 @@ class TagTreeItem(object): return QVariant('[%d] %s'%(self.tag.count, self.tag.name)) if role == Qt.DecorationRole: return self.icon_state_map[self.tag.state] - if role == Qt.ToolTipRole and self.tag.tooltip: + if role == Qt.ToolTipRole and self.tag.tooltip is not None: return QVariant(self.tag.tooltip) return NONE @@ -248,11 +248,17 @@ class TagsModel(QAbstractItemModel): self.categories.append(self.db.custom_column_label_map[c]['name']) self.cat_icon_map.append(self.custcol_icon) + # Now the rest of the normal tag categories + for i in range(self.tags_categories_start, len(self.row_map_orig)): + self.row_map.append(self.row_map_orig[i]) + self.categories.append(self.categories_orig[i]) + self.cat_icon_map.append(self.cat_icon_map_orig[i]) + # Now do the user-defined categories. There is a time/space tradeoff here. # By converting the tags into a map, we can do the verification in the category # loop much faster, at the cost of duplicating the categories lists. taglist = {} - for c in self.row_map_orig: + for c in self.row_map: taglist[c] = dict(map(lambda t:(t.name if c != 'author' else t.name.replace('|', ','), t), data[c])) for c in self.user_categories: @@ -269,11 +275,6 @@ class TagsModel(QAbstractItemModel): self.categories.append(c) self.cat_icon_map.append(self.usercat_icon) - # Now the rest of the normal tag categories - for i in range(self.tags_categories_start, len(self.row_map_orig)): - self.row_map.append(self.row_map_orig[i]) - self.categories.append(self.categories_orig[i]) - self.cat_icon_map.append(self.cat_icon_map_orig[i]) data['search'] = self.get_search_nodes(self.search_icon) # Add the search category self.row_map.append(self.search_keys[0]) self.categories.append(self.search_keys[1]) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 6e1ef9308e..623a29159f 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -648,9 +648,14 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): query += ' ORDER BY {0} ASC'.format(cn[1]) data = self.conn.get(query) category = cn[0] - icon = icon_map[category] if category in icon_map else icon_map['*custom'] + if category in icon_map: + icon = icon_map[category] + tooltip = '' + else: + icon = icon_map['*custom'] + tooltip = self.custom_column_label_map[category]['name'] if ids is None: # no filtering - categories[category] = [Tag(r[1], count=r[2], id=r[0], icon=icon) + categories[category] = [Tag(r[1], count=r[2], id=r[0], icon=icon, tooltip = tooltip) for r in data] else: # filter out zero-count tags categories[category] = [Tag(r[1], count=r[2], id=r[0], icon=icon)