109 m_buddyMarkerRegexp(u"\\&[^&]"_s),
110 m_labelNameEdited(
false),
111 m_fieldNameEdited(
false),
112 m_buddyClicked(
false)
114 Q_ASSERT(m_buddyMarkerRegexp.isValid());
118 connect(m_ui.labelTextLineEdit, &QLineEdit::textEdited,
this, &FormLayoutRowDialog::labelTextEdited);
120 auto *nameValidator =
new QRegularExpressionValidator(QRegularExpression(u"^[a-zA-Z0-9_]+$"_s),
this);
121 Q_ASSERT(nameValidator->regularExpression().isValid());
123 m_ui.labelNameLineEdit->setValidator(nameValidator);
124 connect(m_ui.labelNameLineEdit, &QLineEdit::textEdited,
127 m_ui.fieldNameLineEdit->setValidator(nameValidator);
128 connect(m_ui.fieldNameLineEdit, &QLineEdit::textEdited,
131 connect(m_ui.buddyCheckBox, &QAbstractButton::clicked,
this, &
FormLayoutRowDialog::buddyClicked);
133 m_ui.fieldClassComboBox->addItems(fieldWidgetClasses(core));
134 m_ui.fieldClassComboBox->setCurrentIndex(0);
135 connect(m_ui.fieldClassComboBox,
136 &QComboBox::currentIndexChanged,
271 bool lastWasAcceptable =
false;
272 for (
const QChar &c : prefix) {
273 const PrefixCharacterKind kind = prefixCharacterKind(c);
274 const bool acceptable = kind != PC_Invalid;
278 rc += kind == PC_UpperCaseLetter ? c.toLower() : c;
281 rc += !lastWasAcceptable && kind == PC_LowerCaseLetter ? c.toUpper() : c;
284 lastWasAcceptable = acceptable;
335 static QStringList rc;
338 QStringList baseClasses;
340 baseClasses.append(QLatin1StringView(fw));
344 QMultiHash<QString, QString> customClassMap;
345 if (qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core) ==
nullptr) {
346 const QDesignerWidgetDataBaseInterface *wdb = core->widgetDataBase();
347 const int wdbCount = wdb->count();
348 for (
int w = 0; w < wdbCount; ++w) {
351 const QDesignerWidgetDataBaseItemInterface *dbItem = wdb->item(w);
352 if (!dbItem->isPromoted() && !dbItem->isContainer() && dbItem->isCustom()) {
353 const int index = baseClasses.indexOf(dbItem->extends());
355 customClassMap.insert(baseClasses.at(index), dbItem->name());
361 for (
const auto &baseClass : std::as_const(baseClasses)) {
362 rc.append(baseClass);
363 rc += customClassMap.values(baseClass);
383 QDesignerFormWindowInterface *formWindow)
385 QDesignerFormEditorInterface *core = formWindow->core();
386 QDesignerWidgetFactoryInterface *wf = core->widgetFactory();
389 wf->createWidget(row.fieldClassName, parent)};
391 const QString objectNameProperty = u"objectName"_s;
393 int nameIndex = labelSheet->indexOf(objectNameProperty);
394 labelSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.labelName)));
395 labelSheet->setChanged(nameIndex,
true);
396 formWindow->ensureUniqueObjectName(rc.first);
397 const int textIndex = labelSheet->indexOf(u"text"_s);
398 labelSheet->setProperty(textIndex, QVariant::fromValue(PropertySheetStringValue(row.labelText)));
399 labelSheet->setChanged(textIndex,
true);
402 nameIndex = controlSheet->indexOf(objectNameProperty);
403 controlSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.fieldName)));
404 controlSheet->setChanged(nameIndex,
true);
405 formWindow->ensureUniqueObjectName(rc.second);
412 QDesignerFormWindowInterface *formWindow)
414 QFormLayout *formLayout = managedFormLayout(formWindow->core(), w);
415 Q_ASSERT(formLayout);
416 QUndoStack *undoStack = formWindow->commandHistory();
417 const QString macroName = QCoreApplication::translate(
"Command",
"Add '%1' to '%2'").arg(formLayoutRow.labelText, formLayout->objectName());
418 undoStack->beginMacro(macroName);
421 const auto widgetPair = createWidgets(formLayoutRow, w, formWindow);
423 InsertWidgetCommand *labelCmd =
new InsertWidgetCommand(formWindow);
424 labelCmd->init(widgetPair.first,
false, row, 0);
425 undoStack->push(labelCmd);
426 InsertWidgetCommand *controlCmd =
new InsertWidgetCommand(formWindow);
427 controlCmd->init(widgetPair.second,
false, row, 1);
428 undoStack->push(controlCmd);
429 if (formLayoutRow
.buddy) {
430 SetPropertyCommand *buddyCommand =
new SetPropertyCommand(formWindow);
431 buddyCommand->init(widgetPair.first, buddyPropertyC, widgetPair.second->objectName());
432 undoStack->push(buddyCommand);
434 undoStack->endMacro();