20#include "sizepolicyedit.h"
21#include "KPropertyCoreUtils_p.h"
22#include "KPropertyListData.h"
29 SizePolicyListData() : KPropertyListData(keysInternal(), stringsInternal())
34 const int index =
keys().indexOf(
static_cast<int>(p));
36 return names()[0].toString();
37 return names()[index].toString();
41 static QList<QVariant> keysInternal() {
54 static QStringList stringsInternal() {
68Q_GLOBAL_STATIC(SizePolicyListData, s_sizePolicyListData)
72KPropertySizePolicyDelegate::KPropertySizePolicyDelegate()
78 const QSizePolicy sp(value.
value<QSizePolicy>());
81 .
arg(KPropertyUtils::keyForEnumValue(
"SizePolicy", sp.horizontalPolicy()))
82 .
arg(KPropertyUtils::keyForEnumValue(
"SizePolicy", sp.verticalPolicy()))
83 .
arg(sp.horizontalStretch())
84 .
arg(sp.verticalStretch());
87 .
arg(s_sizePolicyListData->nameForPolicy(sp.horizontalPolicy()))
88 .
arg(s_sizePolicyListData->nameForPolicy(sp.verticalPolicy()))
96 return *s_sizePolicyListData;
101KSizePolicyComposedProperty::KSizePolicyComposedProperty(
KProperty *property)
104 (void)
new KProperty(
"hor_policy",
new SizePolicyListData(),
107 (void)
new KProperty(
"vert_policy",
new SizePolicyListData(),
112 KProperty::UInt, property);
115 KProperty::UInt, property);
118void KSizePolicyComposedProperty::setValue(
KProperty *property,
119 const QVariant &value, KProperty::ValueOptions valueOptions)
121 const QSizePolicy sp( value.
value<QSizePolicy>() );
122 property->child(
"hor_policy")->setValue(sp.horizontalPolicy(), valueOptions);
123 property->child(
"vert_policy")->setValue(sp.verticalPolicy(), valueOptions);
124 property->child(
"hor_stretch")->setValue(sp.horizontalStretch(), valueOptions);
125 property->child(
"vert_stretch")->setValue(sp.verticalStretch(), valueOptions);
128void KSizePolicyComposedProperty::childValueChanged(
KProperty *child,
129 const QVariant &value, KProperty::ValueOptions valueOptions)
132 if (child->
name() ==
"hor_policy")
134 else if (child->
name() ==
"vert_policy")
136 else if (child->
name() ==
"hor_stretch")
137 sp.setHorizontalStretch(value.
toInt());
138 else if (child->
name() ==
"vert_stretch")
139 sp.setVerticalStretch(value.
toInt());
144bool KSizePolicyComposedProperty::valuesEqual(
const QVariant &first,
const QVariant &second)
146 return first.
value<QSizePolicy>() == second.
value<QSizePolicy>();
An interface for for composed property handlers.
A data container for properties of list type.
QVariantList keys() const
A list containing all possible keys for a property.
QVariantList names() const
The list of user-visible translated name elements.
The base class representing a single property.
bool setValue(const QVariant &value, ValueOptions options=ValueOptions())
Sets value of the property.
@ ValueFromList
string value from a list
KProperty * parent() const
Language language() const const
QString toString(QDate date, FormatType format) const const
QString tr(const char *sourceText, const char *disambiguation, int n)
QString arg(Args &&... args) const const
QString fromLatin1(QByteArrayView str)
int toInt(bool *ok) const const