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

Method setModelData

plugins/cmake/settings/cmakecachedelegate.cpp:100–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100void CMakeCacheDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
101{
102 if(index.column()==2)
103 {
104 QModelIndex typeIdx=index.sibling(index.row(), 1);
105 QString type=model->data(typeIdx, Qt::DisplayRole).toString();
106 QString value;
107 if(type==QLatin1String("BOOL"))
108 {
109 auto *boolean=qobject_cast<QCheckBox*>(editor);
110 value = boolean->isChecked() ? QStringLiteral("ON") : QStringLiteral("OFF");
111 }
112 else if(type==QLatin1String("PATH") || type==QLatin1String("FILEPATH"))
113 {
114 auto *urlreq=qobject_cast<KUrlRequester*>(editor);
115 value = urlreq->url().toDisplayString(QUrl::StripTrailingSlash | QUrl::PreferLocalFile); //CMake usually don't put it
116 }
117 else
118 {
119 QItemDelegate::setModelData(editor, model, index);
120 return;
121 }
122 model->setData(index, value, Qt::DisplayRole);
123 }
124 else
125 qCDebug(CMAKE) << "Error. trying to edit a read-only field";
126}
127
128void CMakeCacheDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
129{

Callers

nothing calls this directly

Calls 7

siblingMethod · 0.80
columnMethod · 0.45
rowMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45
urlMethod · 0.45
setDataMethod · 0.45

Tested by

no test coverage detected