107 m_buddyMarkerRegexp(u"\\&[^&]"_s),
108 m_labelNameEdited(
false),
109 m_fieldNameEdited(
false),
110 m_buddyClicked(
false)
112 Q_ASSERT(m_buddyMarkerRegexp.isValid());
116 connect(m_ui.labelTextLineEdit, &QLineEdit::textEdited,
this, &FormLayoutRowDialog::labelTextEdited);
118 auto *nameValidator =
new QRegularExpressionValidator(QRegularExpression(u"^[a-zA-Z0-9_]+$"_s),
this);
119 Q_ASSERT(nameValidator->regularExpression().isValid());
121 m_ui.labelNameLineEdit->setValidator(nameValidator);
122 connect(m_ui.labelNameLineEdit, &QLineEdit::textEdited,
123 this, &FormLayoutRowDialog::labelNameEdited);
125 m_ui.fieldNameLineEdit->setValidator(nameValidator);
126 connect(m_ui.fieldNameLineEdit, &QLineEdit::textEdited,
127 this, &FormLayoutRowDialog::fieldNameEdited);
129 connect(m_ui.buddyCheckBox, &QAbstractButton::clicked,
this, &FormLayoutRowDialog::buddyClicked);
131 m_ui.fieldClassComboBox->addItems(fieldWidgetClasses(core));
132 m_ui.fieldClassComboBox->setCurrentIndex(0);
133 connect(m_ui.fieldClassComboBox,
134 &QComboBox::currentIndexChanged,
135 this, &FormLayoutRowDialog::fieldClassChanged);
269 bool lastWasAcceptable =
false;
270 for (
const QChar &c : prefix) {
271 const PrefixCharacterKind kind = prefixCharacterKind(c);
272 const bool acceptable = kind != PC_Invalid;
276 rc += kind == PC_UpperCaseLetter ? c.toLower() : c;
279 rc += !lastWasAcceptable && kind == PC_LowerCaseLetter ? c.toUpper() : c;
282 lastWasAcceptable = acceptable;
333 static QStringList rc;
336 QStringList baseClasses;
338 baseClasses.append(QLatin1StringView(fw));
342 QMultiHash<QString, QString> customClassMap;
343 if (qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core) ==
nullptr) {
344 const QDesignerWidgetDataBaseInterface *wdb = core->widgetDataBase();
345 const int wdbCount = wdb->count();
346 for (
int w = 0; w < wdbCount; ++w) {
349 const QDesignerWidgetDataBaseItemInterface *dbItem = wdb->item(w);
350 if (!dbItem->isPromoted() && !dbItem->isContainer() && dbItem->isCustom()) {
351 const int index = baseClasses.indexOf(dbItem->extends());
353 customClassMap.insert(baseClasses.at(index), dbItem->name());
359 for (
const auto &baseClass : baseClasses) {
360 rc.append(baseClass);
361 rc += customClassMap.values(baseClass);
381 QDesignerFormWindowInterface *formWindow)
383 QDesignerFormEditorInterface *core = formWindow->core();
384 QDesignerWidgetFactoryInterface *wf = core->widgetFactory();
387 wf->createWidget(row.fieldClassName, parent)};
389 const QString objectNameProperty = u"objectName"_s;
391 int nameIndex = labelSheet->indexOf(objectNameProperty);
392 labelSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.labelName)));
393 labelSheet->setChanged(nameIndex,
true);
394 formWindow->ensureUniqueObjectName(rc.first);
395 const int textIndex = labelSheet->indexOf(u"text"_s);
396 labelSheet->setProperty(textIndex, QVariant::fromValue(PropertySheetStringValue(row.labelText)));
397 labelSheet->setChanged(textIndex,
true);
400 nameIndex = controlSheet->indexOf(objectNameProperty);
401 controlSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.fieldName)));
402 controlSheet->setChanged(nameIndex,
true);
403 formWindow->ensureUniqueObjectName(rc.second);
410 QDesignerFormWindowInterface *formWindow)
412 QFormLayout *formLayout = managedFormLayout(formWindow->core(), w);
413 Q_ASSERT(formLayout);
414 QUndoStack *undoStack = formWindow->commandHistory();
415 const QString macroName = QCoreApplication::translate(
"Command",
"Add '%1' to '%2'").arg(formLayoutRow.labelText, formLayout->objectName());
416 undoStack->beginMacro(macroName);
419 const auto widgetPair = createWidgets(formLayoutRow, w, formWindow);
421 InsertWidgetCommand *labelCmd =
new InsertWidgetCommand(formWindow);
422 labelCmd->init(widgetPair.first,
false, row, 0);
423 undoStack->push(labelCmd);
424 InsertWidgetCommand *controlCmd =
new InsertWidgetCommand(formWindow);
425 controlCmd->init(widgetPair.second,
false, row, 1);
426 undoStack->push(controlCmd);
427 if (formLayoutRow
.buddy) {
428 SetPropertyCommand *buddyCommand =
new SetPropertyCommand(formWindow);
429 buddyCommand->init(widgetPair.first, buddyPropertyC, widgetPair.second->objectName());
430 undoStack->push(buddyCommand);
432 undoStack->endMacro();