MCPcopy Create free account
hub / github.com/baldurk/renderdoc / createEditor

Method createEditor

qrenderdoc/Windows/Dialogs/ConfigEditor.cpp:477–622  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475}
476
477QWidget *SettingDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
478 const QModelIndex &index) const
479{
480 QWidget *ret = NULL;
481
482 SDObject *o = (SDObject *)index.data(Qt::UserRole).toULongLong();
483 SDObject *val = o->FindChild("value");
484 if(val)
485 {
486 // bools should have checkboxes
487 if(val->type.basetype == SDBasic::Boolean)
488 {
489 qWarning() << "Unexpected createEditor for boolean " << QString(o->name);
490 return ret;
491 }
492
493 QString settingName;
494
495 SDObject *key = o->FindChild("key");
496 if(key)
497 settingName = key->AsString();
498 else
499 settingName = tr("Unknown Setting %1").arg(o->name);
500
501 // for numbers, provide a spinbox
502 if(val->type.basetype == SDBasic::UnsignedInteger || val->type.basetype == SDBasic::SignedInteger)
503 {
504 QSpinBox *spin = new QSpinBox(parent);
505 ret = spin;
506 if(val->type.basetype == SDBasic::UnsignedInteger)
507 spin->setMinimum(0);
508 else
509 spin->setMinimum(INT_MIN);
510 spin->setMaximum(INT_MAX);
511 }
512 else if(val->type.basetype == SDBasic::Float)
513 {
514 QDoubleSpinBox *spin = new QDoubleSpinBox(parent);
515 ret = spin;
516 spin->setSingleStep(0.1);
517 spin->setMinimum(-FLT_MAX);
518 spin->setMaximum(FLT_MAX);
519 }
520 else if(val->type.basetype == SDBasic::String)
521 {
522 if(QString(o->name).contains(lit("DirPath"), Qt::CaseSensitive))
523 {
524 QString dir = RDDialog::getExistingDirectory(m_Editor, tr("Browse for %1").arg(settingName));
525
526 if(!dir.isEmpty())
527 {
528 val->data.str = dir;
529
530 // we've handled the edit synchronously, don't create an edit widget
531 ret = NULL;
532
533 // call setData() to emit the dataChanged for this element and all parents
534 m_View->model()->setData(index, QVariant(), Qt::UserRole);

Callers

nothing calls this directly

Calls 15

connectFunction · 0.85
makeSDStringFunction · 0.85
setMinimumMethod · 0.80
setMaximumMethod · 0.80
setSingleStepMethod · 0.80
setWindowTitleMethod · 0.80
windowFlagsMethod · 0.80
getItemsMethod · 0.80
DeleteChildrenMethod · 0.80
QStringFunction · 0.50
trFunction · 0.50
QVariantClass · 0.50

Tested by

no test coverage detected