| 98 | } |
| 99 | |
| 100 | void 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 | |
| 128 | void CMakeCacheDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const |
| 129 | { |