summaryrefslogtreecommitdiffstats
path: root/tools/designer/src/lib/shared
diff options
context:
space:
mode:
authorJarek Kobus <jkobus@trolltech.com>2010-03-04 08:23:53 (GMT)
committerJarek Kobus <jkobus@trolltech.com>2010-03-04 08:34:33 (GMT)
commit8d6b5483e34d27f1ee45af9d9fadb87525c9f915 (patch)
tree18b1a474335a3a3f44a73ec89aa4e910c2f4079d /tools/designer/src/lib/shared
parenta3e7f41b085605b6856686b5dfd29818308bd820 (diff)
downloadQt-8d6b5483e34d27f1ee45af9d9fadb87525c9f915.zip
Qt-8d6b5483e34d27f1ee45af9d9fadb87525c9f915.tar.gz
Qt-8d6b5483e34d27f1ee45af9d9fadb87525c9f915.tar.bz2
Make QLabel::text a reloadable property
In this way we can correctly load / reload a label in case it contains a rich text with a reference to the image taken from resources. Since QLabel::setText() ignores the call in case we try to set the same text, we force the reload by setting the empty string in between. For performance reasons we do it only in cases when the text value contains :/ (only in this case it might have a reference to the resources). Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Task-number: QTBUG-8347
Diffstat (limited to 'tools/designer/src/lib/shared')
-rw-r--r--tools/designer/src/lib/shared/formwindowbase.cpp12
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertysheet.cpp2
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertysheet_p.h3
3 files changed, 15 insertions, 2 deletions
diff --git a/tools/designer/src/lib/shared/formwindowbase.cpp b/tools/designer/src/lib/shared/formwindowbase.cpp
index 2c5efbf..b57e9d7 100644
--- a/tools/designer/src/lib/shared/formwindowbase.cpp
+++ b/tools/designer/src/lib/shared/formwindowbase.cpp
@@ -181,7 +181,17 @@ void FormWindowBase::reloadProperties()
QMapIterator<int, bool> itIndex(itSheet.value());
while (itIndex.hasNext()) {
const int index = itIndex.next().key();
- sheet->setProperty(index, sheet->property(index));
+ const QVariant newValue = sheet->property(index);
+ if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == QLatin1String("text")) {
+ const PropertySheetStringValue newString = qVariantValue<PropertySheetStringValue>(newValue);
+ // optimize a bit, reset only if the text value might contain a reference to qt resources
+ // (however reloading of icons other than taken from resources might not work here)
+ if (newString.value().contains(QLatin1String(":/"))) {
+ const QVariant resetValue = qVariantFromValue(PropertySheetStringValue());
+ sheet->setProperty(index, resetValue);
+ }
+ }
+ sheet->setProperty(index, newValue);
}
if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(sheet->object())) {
const int count = tabWidget->count();
diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
index 13bb1d7..77ab2a6 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
@@ -271,6 +271,7 @@ bool QDesignerPropertySheetPrivate::isReloadableProperty(int index) const
{
return isResourceProperty(index)
|| propertyType(index) == QDesignerPropertySheet::PropertyStyleSheet
+ || propertyType(index) == QDesignerPropertySheet::PropertyText
|| q->property(index).type() == QVariant::Url;
}
@@ -549,6 +550,7 @@ QDesignerPropertySheet::PropertyType QDesignerPropertySheet::propertyTypeFromNam
propertyTypeHash.insert(QLatin1String("windowModality"), PropertyWindowModality);
propertyTypeHash.insert(QLatin1String("windowModified"), PropertyWindowModified);
propertyTypeHash.insert(QLatin1String("styleSheet"), PropertyStyleSheet);
+ propertyTypeHash.insert(QLatin1String("text"), PropertyText);
}
return propertyTypeHash.value(name, PropertyNone);
}
diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h b/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h
index 9db7367..0105eac 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h
@@ -176,7 +176,8 @@ public:
PropertyWindowIconText,
PropertyWindowModality,
PropertyWindowModified,
- PropertyStyleSheet
+ PropertyStyleSheet,
+ PropertyText
};
enum ObjectType { ObjectNone, ObjectLabel, ObjectLayout, ObjectLayoutWidget, ObjectQ3GroupBox };