53 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_QDESIGNER_UTILS_P_H
54 #define BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_QDESIGNER_UTILS_P_H
58 #include <QtDesigner/QDesignerFormWindowInterface>
60 #include <QMainWindow>
61 #include <QtCore/QMap>
62 #include <QtCore/QSharedDataPointer>
63 #include <QtCore/QVariant>
64 #include <QtGui/QIcon>
65 #include <QtGui/QPixmap>
72 class QDesignerFormWindowCommand;
73 class DesignerIconCache;
121 template <
class IntType>
123 : m_name(
name), m_scope(scope), m_separator(separator)
129 m_keyToValueMap.insert(
name, value);
135 const QString rc = m_keyToValueMap.key(value);
143 if (!m_scope.isEmpty() && key.startsWith(m_scope))
144 key.remove(0, m_scope.size() + m_separator.size());
145 const typename KeyToValueMap::const_iterator it = m_keyToValueMap.find(key);
146 const bool found = it != m_keyToValueMap.constEnd();
149 return found ? it.value() : IntType(0);
152 template <
class IntType>
155 if (!m_scope.isEmpty()) {
157 target += m_separator;
176 int parseEnum(
const QString& s,
bool* ok = 0)
const {
return keyToValue(s, ok); }
228 enum PixmapSource { LanguageResourcePixmap, ResourcePixmap, FilePixmap };
233 return getPixmapSource(core, m_path);
247 class PropertySheetIconValueData;
286 QSharedDataPointer<PropertySheetIconValueData>
m_data;
301 mutable QMap<PropertySheetPixmapValue, QPixmap>
m_cache;
315 mutable QMap<PropertySheetIconValue, QIcon>
m_cache;
324 const QString& comment =
"");
333 void setComment(
const QString& comment) { m_comment = comment; }
345 const QString& disambiguation =
"",
const QString& comment =
"");
363 const QString& disambiguation =
"",
const QString& comment =
"");
381 const QString& disambiguation =
"",
const QString& comment =
"");
383 bool translatable =
true,
const QString& disambiguation =
"",
384 const QString& comment =
"");
423 QDesignerFormWindowInterface* fw);
427 QWidget* managedWidget);
453 inline int valueOf(
const QVariant& value,
bool* ok = 0)
458 return qvariant_cast<PropertySheetEnumValue>(value).value;
462 return qvariant_cast<PropertySheetFlagValue>(value).value;
464 return value.toInt(ok);
469 QObject* obj = child;
483 if (widget == fw->mainContainer())
487 if (QMainWindow* mw = qobject_cast<QMainWindow*>(fw->mainContainer())) {
488 return mw->centralWidget() == widget;
DesignerIconCache(DesignerPixmapCache *pixmapCache, QObject *parent=0)
QIcon icon(const PropertySheetIconValue &value) const
QMap< PropertySheetIconValue, QIcon > m_cache
DesignerPixmapCache * m_pixmapCache
QPixmap pixmap(const PropertySheetPixmapValue &value) const
QMap< PropertySheetPixmapValue, QPixmap > m_cache
DesignerPixmapCache(QObject *parent=0)
void assign(const PropertySheetIconValue &other, uint mask)
~PropertySheetIconValue()
const ModeStateToPixmapMap & paths() const
bool operator==(const PropertySheetIconValue &other) const
QMap< ModeStateKey, PropertySheetPixmapValue > ModeStateToPixmapMap
PropertySheetPixmapValue pixmap(QIcon::Mode mode, QIcon::State state) const
PropertySheetIconValue & operator=(const PropertySheetIconValue &)
void setTheme(const QString &)
void setPixmap(QIcon::Mode mode, QIcon::State state, const PropertySheetPixmapValue &path)
uint compare(const PropertySheetIconValue &other) const
QPair< QIcon::Mode, QIcon::State > ModeStateKey
bool operator<(const PropertySheetIconValue &other) const
PropertySheetIconValue unthemed() const
bool operator!=(const PropertySheetIconValue &other) const
PropertySheetIconValue(const PropertySheetPixmapValue &pixmap)
PropertySheetIconValue(const PropertySheetIconValue &)
PropertySheetIconValue themed() const
QSharedDataPointer< PropertySheetIconValueData > m_data
bool equals(const PropertySheetIconValue &rhs) const
bool isStandardKey() const
bool operator==(const PropertySheetKeySequenceValue &other) const
bool operator!=(const PropertySheetKeySequenceValue &other) const
QKeySequence value() const
QKeySequence::StandardKey standardKey() const
PropertySheetKeySequenceValue(const QKeySequence::StandardKey &standardKey, bool translatable=true, const QString &disambiguation="", const QString &comment="")
PropertySheetKeySequenceValue(const QKeySequence &value={}, bool translatable=true, const QString &disambiguation="", const QString &comment="")
bool equals(const PropertySheetKeySequenceValue &rhs) const
QKeySequence::StandardKey m_standardKey
void setValue(const QKeySequence &value)
void setStandardKey(const QKeySequence::StandardKey &standardKey)
bool operator==(const PropertySheetPixmapValue &other) const
static PixmapSource getPixmapSource(QDesignerFormEditorInterface *core, const QString &path)
int compare(const PropertySheetPixmapValue &other) const
PixmapSource pixmapSource(QDesignerFormEditorInterface *core) const
PropertySheetPixmapValue(const QString &path)
void setPath(const QString &path)
bool operator!=(const PropertySheetPixmapValue &other) const
PropertySheetPixmapValue()
bool operator<(const PropertySheetPixmapValue &other) const
PropertySheetStringListValue(const QStringList &value={}, bool translatable=true, const QString &disambiguation="", const QString &comment="")
bool equals(const PropertySheetStringListValue &rhs) const
bool operator==(const PropertySheetStringListValue &other) const
bool operator!=(const PropertySheetStringListValue &other) const
void setValue(const QStringList &value)
QStringList value() const
bool equals(const PropertySheetStringValue &rhs) const
PropertySheetStringValue(const QString &value="", bool translatable=true, const QString &disambiguation="", const QString &comment="")
void setValue(const QString &value)
bool operator!=(const PropertySheetStringValue &other) const
bool operator==(const PropertySheetStringValue &other) const
void setComment(const QString &comment)
bool translatable() const
PropertySheetTranslatableData(bool translatable=true, const QString &disambiguation="", const QString &comment="")
void setTranslatable(bool translatable)
QString disambiguation() const
void setDisambiguation(const QString &d)
bool equals(const PropertySheetTranslatableData &rhs) const
UpdateBlocker(QWidget *w)
const SessionItem * ancestor(const SessionItem *item, const QString &requiredModelType)
Returns ancestor of given modelType for given item.
QString const & name(EShape k)
int valueOf(const QVariant &value, bool *ok=0)
bool isObjectAncestorOf(QObject *ancestor, QObject *child)
bool isCentralWidget(QDesignerFormWindowInterface *fw, QWidget *widget)
QDESIGNER_SHARED_EXPORT QDebug operator<<(QDebug, const PropertySheetIconValue &)
QDESIGNER_SHARED_EXPORT bool runUIC(const QString &fileName, QByteArray &ba, QString &errorMessage)
QDESIGNER_SHARED_EXPORT QDesignerFormWindowCommand * createTextPropertyCommand(const QString &propertyName, const QString &text, QObject *object, QDesignerFormWindowInterface *fw)
QDESIGNER_SHARED_EXPORT QString qtify(const QString &name)
QDESIGNER_SHARED_EXPORT void designerWarning(const QString &message)
QDESIGNER_SHARED_EXPORT void reloadIconResources(DesignerIconCache *iconCache, QObject *object)
QDESIGNER_SHARED_EXPORT QAction * preferredEditAction(QDesignerFormEditorInterface *core, QWidget *managedWidget)
#define QDESIGNER_SHARED_EXPORT
PropertySheetEnumValue(int v, const DesignerMetaEnum &me)
DesignerMetaEnum metaEnum
DesignerMetaFlags metaFlags
PropertySheetFlagValue(int v, const DesignerMetaFlags &mf)