9#include <QtDesigner/abstractformeditor.h>
10#include <QtDesigner/abstractformwindow.h>
11#include <QtDesigner/abstractformwindowmanager.h>
12#include <QtDesigner/abstractobjectinspector.h>
13#include <QtDesigner/abstractwidgetbox.h>
14#include <QtDesigner/abstractwidgetdatabase.h>
16#include <QtCore/qmap.h>
17#include <QtCore/qcoreapplication.h>
22using namespace Qt::StringLiterals;
26 const QSet<QString> &nonPromotableClasses() {
27 static const QSet<QString> rc = {
40 int promotedWidgetDataBaseIndex(
const QDesignerWidgetDataBaseInterface *widgetDataBase,
41 const QString &className,
42 QString *errorMessage) {
43 const int index = widgetDataBase->indexOfClassName(className);
44 if (index == -1 || !widgetDataBase->item(index)->isPromoted()) {
45 *errorMessage = QCoreApplication::tr(
"%1 is not a promoted class.").arg(className);
52 QDesignerWidgetDataBaseItemInterface *promotedWidgetDataBaseItem(
const QDesignerWidgetDataBaseInterface *widgetDataBase,
53 const QString &className,
54 QString *errorMessage) {
56 const int index = promotedWidgetDataBaseIndex(widgetDataBase, className, errorMessage);
59 return widgetDataBase->item(index);
63 QString classNameFromXml(QString xml)
65 constexpr auto tag =
"class=\""_L1;
66 const int pos = xml.indexOf(tag);
69 xml.remove(0, pos + tag.size());
70 const auto closingPos = xml.indexOf(u'"');
73 xml.remove(closingPos, xml.size() - closingPos);
78 QStringList getScratchPadClasses(
const QDesignerWidgetBoxInterface *wb) {
80 const int catCount = wb->categoryCount();
81 for (
int c = 0; c < catCount; c++) {
82 const QDesignerWidgetBoxInterface::Category category = wb->category(c);
83 if (category.type() == QDesignerWidgetBoxInterface::Category::Scratchpad) {
84 const int widgetCount = category.widgetCount();
85 for (
int w = 0; w < widgetCount; w++) {
86 const QString className = classNameFromXml( category.widget(w).domXml());
87 if (!className.isEmpty())
98 const QDesignerFormWindowManagerInterface *fwm = core->formWindowManager();
99 for (
int f = 0, count = fwm->formWindowCount(); f < count; ++f)
100 fwm->formWindow(f)->setDirty(
true);
152 for (
int i = 0;
i <
cnt;
i++) {
188 for (
int i = 0;
i <
cnt;
i++) {
279 <<
" extends " <<
className <<
", changing its base class to " <<
extends <<
'.';
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.