| 72 | } |
| 73 | |
| 74 | void CMakeCacheDelegate::setEditorData(QWidget * editor, const QModelIndex & index) const |
| 75 | { |
| 76 | if(index.column()==2) |
| 77 | { |
| 78 | QModelIndex typeIdx=index.sibling(index.row(), 1); |
| 79 | QString type=index.model()->data(typeIdx, Qt::DisplayRole).toString(); |
| 80 | QString value=index.model()->data(index, Qt::DisplayRole).toString(); |
| 81 | if(type==QLatin1String("BOOL")) |
| 82 | { |
| 83 | auto *boolean=qobject_cast<QCheckBox*>(editor); |
| 84 | boolean->setCheckState(value==QLatin1String("ON") ? Qt::Checked : Qt::Unchecked); |
| 85 | } |
| 86 | else if(type==QLatin1String("PATH") || type==QLatin1String("FILEPATH")) |
| 87 | { |
| 88 | auto *url=qobject_cast<KUrlRequester*>(editor); |
| 89 | url->setUrl(QUrl(value)); |
| 90 | } |
| 91 | else |
| 92 | { |
| 93 | QItemDelegate::setEditorData(editor, index); |
| 94 | } |
| 95 | } |
| 96 | else |
| 97 | qCDebug(CMAKE) << "Error. trying to edit a read-only field"; |
| 98 | } |
| 99 | |
| 100 | void CMakeCacheDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const |
| 101 | { |