QWidget* CharactersViewDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { switch (index.column()) { case 0: { KLineEdit* lineEdit = new KLineEdit(parent); lineEdit->setFrame(false); lineEdit->setMaxLength(1); return lineEdit; } case 1: { KLineEdit* lineEdit = new KLineEdit(parent); lineEdit->setFrame(false); QStringList wordList; for (int i = 0; i < m_keyboardLayout->keyCount(); i++) { if (SpecialKey* key = qobject_cast<SpecialKey*>(m_keyboardLayout->key(i))) { wordList << key->modifierId(); } } QCompleter* completer = new QCompleter(wordList, lineEdit); lineEdit->setCompleter(completer); return lineEdit; } case 2: { KComboBox* comboBox = new KComboBox(parent); comboBox->setEditable(false); comboBox->addItem(i18n("Hidden"), KeyChar::Hidden); comboBox->addItem(i18n("Top left"), KeyChar::TopLeft); comboBox->addItem(i18n("Top right"), KeyChar::TopRight); comboBox->addItem(i18n("Bottom left"), KeyChar::BottomLeft); comboBox->addItem(i18n("Bottom right"), KeyChar::BottomRight); return comboBox; } default: return QStyledItemDelegate::createEditor(parent, option, index); } }
QWidget * KWQTableDelegate::createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const { Q_UNUSED(option); KLineEdit *editor = new KLineEdit(parent); editor->setFrame(false); editor->setFont(index.data(Qt::FontRole).value<QFont>()); //connect(editor, SIGNAL(returnPressed()), this, SLOT(commitAndCloseEditor())); return editor; }