15#ifndef QDESIGNER_UTILS_H
16#define QDESIGNER_UTILS_H
20#include <QtDesigner/abstractformwindow.h>
22#include <QtCore/qcompare.h>
23#include <QtCore/qhash.h>
24#include <QtCore/qvariant.h>
25#include <QtCore/qshareddata.h>
26#include <QtWidgets/qmainwindow.h>
27#include <QtGui/qicon.h>
28#include <QtGui/qpixmap.h>
37class QDesignerFormWindowCommand;
38class DesignerIconCache;
51
52
53
54
55
56
59
60
62template <
class IntType>
71 MetaEnum(
const QString &enumName,
const QString &scope,
const QString &separator);
73 void addKey(IntType value,
const QString &name);
75 QString
valueToKey(IntType value,
bool *ok =
nullptr)
const;
77 IntType
keyToValue(QStringView key,
bool *ok =
nullptr)
const;
79 const QString &
enumName()
const {
return m_enumName; }
80 const QString &
scope()
const {
return m_scope; }
81 const QString &
separator()
const {
return m_separator; }
93 KeyToValueMap m_keyToValueMap;
97template <
class IntType>
98MetaEnum<IntType>::
MetaEnum(
const QString &enumName,
const QString &scope,
const QString &separator) :
105template <
class IntType>
108 m_keyToValueMap.insert({name, value});
112template <
class IntType>
116 for (
auto it = m_keyToValueMap.begin(), end = m_keyToValueMap.end(); it != end; ++it) {
117 if (it->second == value) {
127template <
class IntType>
130 const auto lastSep = key.lastIndexOf(m_separator);
132 key = key.sliced(lastSep + m_separator.size());
133 const auto it = m_keyToValueMap.find(key);
134 const bool found = it != m_keyToValueMap.end();
137 return found ? it->second : IntType(0);
140template <
class IntType>
142 QString &target)
const
144 if (!m_scope.isEmpty()) {
146 target += m_separator;
148 if (sm == FullyQualified)
149 target += m_enumName + m_separator;
448Q_DECLARE_METATYPE(qdesigner_internal::PropertySheetEnumValue)
449Q_DECLARE_METATYPE(qdesigner_internal::PropertySheetFlagValue)
450Q_DECLARE_METATYPE(qdesigner_internal::PropertySheetPixmapValue)
451Q_DECLARE_METATYPE(qdesigner_internal::PropertySheetIconValue)
452Q_DECLARE_METATYPE(qdesigner_internal::PropertySheetStringValue)
453Q_DECLARE_METATYPE(qdesigner_internal::PropertySheetStringListValue)
454Q_DECLARE_METATYPE(qdesigner_internal::PropertySheetKeySequenceValue)
476 QByteArray& ba, QString &errorMessage);
482
483
494 const bool m_enabled;
499 QPalette::ColorRole colorRole);
505inline int valueOf(
const QVariant &value,
bool *ok =
nullptr)
507 if (value.canConvert<PropertySheetEnumValue>()) {
510 return qvariant_cast<PropertySheetEnumValue>(value).value;
512 if (value.canConvert<PropertySheetFlagValue>()) {
515 return qvariant_cast<PropertySheetFlagValue>(value).value;
517 return value.toInt(ok);
522 QObject *obj = child;
523 while (obj !=
nullptr) {
533 if (! fw || ! widget)
536 if (widget == fw->mainContainer())
540 if (QMainWindow *mw = qobject_cast<QMainWindow*>(fw->mainContainer())) {
541 return mw->centralWidget() == widget;
static bool canBeBuddy(QWidget *w, QDesignerFormWindowInterface *form)
static QString buddy(QLabel *label, QDesignerFormEditorInterface *core)
static constexpr auto buddyPropertyC
#define QT_BUDDYEDITOR_EXPORT
void init(QWidget *parentWidget, QAction *action, QAction *beforeAction=nullptr, bool update=true)
ActionInsertionCommand(const QString &text, QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
AddMenuActionCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void redo() override
Applies a change to the document.
AddStackedWidgetPageCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void init(QStackedWidget *stackedWidget)
void init(QStackedWidget *stackedWidget, InsertionMode mode)
~AddStackedWidgetPageCommand() override
void redo() override
Applies a change to the document.
void undo() override
Reverts a change to the document.
~AddTabPageCommand() override
void init(QTabWidget *tabWidget, InsertionMode mode)
void init(QTabWidget *tabWidget)
AddTabPageCommand(QDesignerFormWindowInterface *formWindow)
AddToolBoxPageCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void init(QToolBox *toolBox, InsertionMode mode)
~AddToolBoxPageCommand() override
void init(QToolBox *toolBox)
void undo() override
Reverts a change to the document.
void setBackground(QWidget *background) override
QDesignerFormWindowInterface * formWindow() const
void endConnection(QWidget *target, const QPoint &pos) override
void widgetRemoved(QWidget *w) override
QWidget * widgetAt(const QPoint &pos) const override
Connection * createConnection(QWidget *source, QWidget *destination) override
void createContextMenu(QMenu &menu) override
void deleteSelected() override
CreateMenuBarCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void init(QMainWindow *mainWindow)
void undo() override
Reverts a change to the document.
void redo() override
Applies a change to the document.
void undo() override
Reverts a change to the document.
void init(QMainWindow *mainWindow)
CreateStatusBarCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void init(QDesignerMenu *menu, QAction *action, QObject *m_objectToSelect=nullptr)
CreateSubmenuCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void restore(QDesignerFormWindowInterface *formWindow) const
void save(const QDesignerFormWindowInterface *formWindow)
void init(QMenuBar *menuBar)
void redo() override
Applies a change to the document.
void undo() override
Reverts a change to the document.
DeleteMenuBarCommand(QDesignerFormWindowInterface *formWindow)
DeleteStackedWidgetPageCommand(QDesignerFormWindowInterface *formWindow)
void init(QStackedWidget *stackedWidget)
void redo() override
Applies a change to the document.
~DeleteStackedWidgetPageCommand() override
void undo() override
Reverts a change to the document.
void init(QTabWidget *tabWidget)
void redo() override
Applies a change to the document.
~DeleteTabPageCommand() override
void undo() override
Reverts a change to the document.
DeleteTabPageCommand(QDesignerFormWindowInterface *formWindow)
void init(QToolBox *toolBox)
DeleteToolBoxPageCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void undo() override
Reverts a change to the document.
~DeleteToolBoxPageCommand() override
void undo() override
Reverts a change to the document.
InsertActionIntoCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void init(QAction *action, QAction *actionBefore, QWidget *associatedWidget, QWidget *objectToSelect)
MenuActionCommand(const QString &text, QDesignerFormWindowInterface *formWindow)
~MoveTabPageCommand() override
void undo() override
Reverts a change to the document.
MoveTabPageCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void init(QTabWidget *tabWidget, QWidget *page, const QIcon &icon, const QString &label, int index, int newIndex)
MoveToolBoxPageCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void init(QToolBox *toolBox, QWidget *page, int newIndex)
void undo() override
Reverts a change to the document.
~MoveToolBoxPageCommand() override
RemoveActionFromCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void redo() override
Applies a change to the document.
RemoveMenuActionCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void redo() override
Applies a change to the document.
Combined button and popup list for selecting options.
int valueOf(const QVariant &value, bool *ok=nullptr)
bool isObjectAncestorOf(QObject *ancestor, QObject *child)
bool isCentralWidget(QDesignerFormWindowInterface *fw, QWidget *widget)
Auxiliary methods to store/retrieve settings.
QDESIGNER_SHARED_EXPORT void getFormLayoutItemPosition(const QFormLayout *formLayout, int index, int *rowPtr, int *columnPtr=nullptr, int *rowspanPtr=nullptr, int *colspanPtr=nullptr)
QDESIGNER_SHARED_EXPORT QDebug operator<<(QDebug, const PropertySheetIconValue &)
static QUndoCommand * createBuddyCommand(QDesignerFormWindowInterface *fw, QLabel *label, QWidget *buddy)
QDESIGNER_SHARED_EXPORT void formLayoutAddWidget(QFormLayout *formLayout, QWidget *w, const QRect &r, bool insert)
QDESIGNER_SHARED_EXPORT void designerWarning(const QString &message)
QDESIGNER_SHARED_EXPORT void reloadIconResources(DesignerIconCache *iconCache, QObject *object)
QDESIGNER_SHARED_EXPORT bool runUIC(const QString &fileName, UicLanguage language, QByteArray &ba, QString &errorMessage)
#define QDESIGNER_SHARED_EXPORT