MCPcopy Create free account
hub / github.com/KDE/kdevelop / createEditor

Method createEditor

plugins/cmake/settings/cmakecachedelegate.cpp:27–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27QWidget * CMakeCacheDelegate::createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const
28{
29 QWidget *ret=nullptr;
30 if(index.column()==2)
31 {
32 QModelIndex typeIdx=index.sibling(index.row(), 1);
33 QString type=typeIdx.model()->data(typeIdx, Qt::DisplayRole).toString();
34 if(type==QLatin1String("BOOL"))
35 {
36 auto* box=new QCheckBox(parent);
37 connect(box, &QCheckBox::toggled, this, &CMakeCacheDelegate::checkboxToggled);
38 ret = box;
39 }
40 else if(type==QLatin1String("STRING"))
41 {
42 QModelIndex stringsIdx=index.sibling(index.row(), 5);
43 QString strings=typeIdx.model()->data(stringsIdx, Qt::DisplayRole).toString();
44 if (!strings.isEmpty()) {
45 auto* comboBox = new QComboBox(parent);
46 comboBox->setEditable(true);
47 comboBox->addItems(strings.split(QLatin1Char(';')));
48 ret = comboBox;
49 } else {
50 ret=QItemDelegate::createEditor(parent, option, index);
51 }
52 }
53 else if(type==QLatin1String("PATH") || type==QLatin1String("FILEPATH"))
54 {
55 auto *r=new KUrlRequester(parent);
56 if(type==QLatin1String("FILEPATH"))
57 r->setMode(KFile::File);
58 else
59 r->setMode(KFile::Directory | KFile::ExistingOnly);
60 emit const_cast<CMakeCacheDelegate*>(this)->sizeHintChanged ( index );
61 qCDebug(CMAKE) << "EMITINT!" << index;
62 ret=r;
63 }
64 else
65 {
66 ret=QItemDelegate::createEditor(parent, option, index);
67 }
68
69 if(!ret) qCDebug(CMAKE) << "Did not recognize type " << type;
70 }
71 return ret;
72}
73
74void CMakeCacheDelegate::setEditorData(QWidget * editor, const QModelIndex & index) const
75{

Callers

nothing calls this directly

Calls 11

siblingMethod · 0.80
columnMethod · 0.45
rowMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45
modelMethod · 0.45
isEmptyMethod · 0.45
setEditableMethod · 0.45
addItemsMethod · 0.45
splitMethod · 0.45
setModeMethod · 0.45

Tested by

no test coverage detected