| 445 | } |
| 446 | |
| 447 | bool SettingDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, |
| 448 | const QStyleOptionViewItem &option, const QModelIndex &index) |
| 449 | { |
| 450 | if(event->type() == QEvent::MouseButtonRelease && index.column() == SettingModel::Column_ResetButton) |
| 451 | { |
| 452 | SDObject *o = (SDObject *)index.data(Qt::UserRole).toULongLong(); |
| 453 | |
| 454 | SDObject *def = o->FindChild("default"); |
| 455 | SDObject *val = o->FindChild("value"); |
| 456 | |
| 457 | if(def && val) |
| 458 | { |
| 459 | val->data.str = def->data.str; |
| 460 | memcpy(&val->data.basic, &def->data.basic, sizeof(val->data.basic)); |
| 461 | |
| 462 | val->DeleteChildren(); |
| 463 | |
| 464 | for(size_t c = 0; c < def->NumChildren(); c++) |
| 465 | val->DuplicateAndAddChild(def->GetChild(c)); |
| 466 | |
| 467 | // call setData() to emit the dataChanged for this element and all parents |
| 468 | model->setData(index, QVariant(), Qt::UserRole); |
| 469 | |
| 470 | return true; |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | return QStyledItemDelegate::editorEvent(event, model, option, index); |
| 475 | } |
| 476 | |
| 477 | QWidget *SettingDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
| 478 | const QModelIndex &index) const |
nothing calls this directly
no test coverage detected