Exemple #1
0
 def createEditor(self, parent, option, index):
     if self.db and hasattr(self.db, self.items_func_name):
         m = index.model()
         col = m.column_map[index.column()]
         # If shifted, bring up the tag editor instead of the line editor.
         if check_key_modifier(
                 Qt.KeyboardModifier.ShiftModifier) and col != 'authors':
             key = col if m.is_custom_column(col) else None
             d = TagEditor(parent, self.db, m.id(index.row()), key=key)
             if d.exec() == QDialog.DialogCode.Accepted:
                 m.setData(index, self.sep.join(d.tags),
                           Qt.ItemDataRole.EditRole)
             return None
         editor = EditWithComplete(parent)
         if col == 'tags':
             editor.set_elide_mode(Qt.TextElideMode.ElideMiddle)
         editor.set_separator(self.sep)
         editor.set_clear_button_enabled(False)
         editor.set_space_before_sep(self.space_before_sep)
         if self.sep == '&':
             editor.set_add_separator(
                 tweaks['authors_completer_append_separator'])
         if not m.is_custom_column(col):
             all_items = getattr(self.db, self.items_func_name)()
         else:
             all_items = list(
                 self.db.all_custom(
                     label=self.db.field_metadata.key_to_label(col)))
         editor.update_items_cache(all_items)
     else:
         editor = EnLineEdit(parent)
     return editor
Exemple #2
0
 def createEditor(self, parent, option, index):
     if self.auto_complete_function:
         editor = EditWithComplete(parent)
         editor.set_separator(None)
         editor.set_clear_button_enabled(False)
         complete_items = [i[1] for i in self.auto_complete_function()]
         editor.update_items_cache(complete_items)
     else:
         editor = EnLineEdit(parent)
     return editor
Exemple #3
0
 def createEditor(self, parent, option, index):
     m = index.model()
     col = m.column_map[index.column()]
     key = m.db.field_metadata.key_to_label(col)
     if m.db.field_metadata[col]['datatype'] != 'comments':
         editor = EditWithComplete(parent)
         editor.set_separator(None)
         editor.set_clear_button_enabled(False)
         complete_items = sorted(list(m.db.all_custom(label=key)), key=sort_key)
         editor.update_items_cache(complete_items)
     else:
         editor = QLineEdit(parent)
         text = index.data(Qt.ItemDataRole.DisplayRole)
         if text:
             editor.setText(text)
             editor.selectAll()
     return editor