Exemplo n.º 1
0
 def createEditor(self, parent, option, index):
     if self.db and hasattr(self.db, self.items_func_name):
         col = self.col
         if col is None:
             # We have not specified an explicit column, so we need
             # to lookup a column name. The calibre one will rely on stuff
             # on the model, we will rely on a callback function instead
             col = self.col_fn(index.column())
         editor = MultiCompleteComboBox(parent)
         editor.set_separator(self.sep)
         editor.set_space_before_sep(self.space_before_sep)
         if self.sep == '&':
             editor.set_add_separator(
                 tweaks['authors_completer_append_separator'])
         if col.startswith('#'):
             all_items = list(
                 self.db.all_custom(
                     label=self.db.field_metadata.key_to_label(col)))
         else:
             all_items = getattr(self.db, self.items_func_name)()
         editor.update_items_cache(all_items)
         for item in sorted(all_items, key=sort_key):
             editor.addItem(item)
         ct = index.data(Qt.DisplayRole).toString()
         editor.show_initial_value(ct)
     else:
         editor = EnLineEdit(parent)
     return editor
Exemplo n.º 2
0
 def createEditor(self, parent, option, index):
     if self.db and hasattr(self.db, self.items_func_name):
         col = self.col
         if col is None:
             # We have not specified an explicit column, so we need
             # to lookup a column name. The calibre one will rely on stuff
             # on the model, we will rely on a callback function instead
             col = self.col_fn(index.column())
         editor = MultiCompleteComboBox(parent)
         editor.set_separator(self.sep)
         editor.set_space_before_sep(self.space_before_sep)
         if self.sep == '&':
             editor.set_add_separator(tweaks['authors_completer_append_separator'])
         if col.startswith('#'):
             all_items = list(self.db.all_custom(
                 label=self.db.field_metadata.key_to_label(col)))
         else:
             all_items = getattr(self.db, self.items_func_name)()
         editor.update_items_cache(all_items)
         for item in sorted(all_items, key=sort_key):
             editor.addItem(item)
         ct = index.data(Qt.DisplayRole).toString()
         editor.show_initial_value(ct)
     else:
         editor = EnLineEdit(parent)
     return editor
Exemplo n.º 3
0
 def createEditor(self, parent, option, index):
     if self.db and hasattr(self.db, self.items_func_name):
         editor = MultiCompleteComboBox(parent)
         editor.set_separator(self.sep)
         editor.set_space_before_sep(self.space_before_sep)
         if self.sep == '&':
             editor.set_add_separator(tweaks['authors_completer_append_separator'])
         if self.col.startswith('#'):
             all_items = list(self.db.all_custom(
                 label=self.db.field_metadata.key_to_label(self.col)))
         else:
             all_items = getattr(self.db, self.items_func_name)()
         editor.update_items_cache(all_items)
         for item in sorted(all_items, key=sort_key):
             editor.addItem(item)
         ct = index.data(Qt.DisplayRole).toString()
         editor.show_initial_value(ct)
     else:
         editor = EnLineEdit(parent)
     return editor