From 632b69b6ef1318fede89a0a3fd46a29bd6c27fe5 Mon Sep 17 00:00:00 2001
From: Jarek Kobus <jkobus@trolltech.com>
Date: Tue, 13 Apr 2010 15:25:16 +0200
Subject: Fix dealing with the default dynamic properties of string type.

Fixed showing, changing and resetting of default dynamic properties
of string and keysequence type.

Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Task-number: QTBUG-9603
(cherry picked from commit 2ff6df50fac75af2d1b9d49101d9b1d8af28535d)
---
 .../src/lib/shared/qdesigner_propertysheet.cpp     | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
index 4a93673..bf2f47f 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
@@ -719,10 +719,11 @@ int QDesignerPropertySheet::addDynamicProperty(const QString &propName, const QV
     else if (value.type() == QVariant::Pixmap)
         v = qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue());
     else if (value.type() == QVariant::String)
-        v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue());
-    else if (value.type() == QVariant::KeySequence)
-        v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue());
-
+        v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(value.toString()));
+    else if (value.type() == QVariant::KeySequence) {
+        const QKeySequence keySequence = qVariantValue<QKeySequence>(value);
+        v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence));
+    }
 
     if (d->m_addIndex.contains(propName)) {
         const int idx = d->m_addIndex.value(propName);
@@ -1127,7 +1128,7 @@ void QDesignerPropertySheet::setProperty(int index, const QVariant &value)
             }
         }
 
-        if (isDynamicProperty(index)) {
+        if (isDynamicProperty(index) || isDefaultDynamicProperty(index)) {
             if (d->isResourceProperty(index))
                 d->setResourceProperty(index, value);
             if (d->isStringProperty(index))
@@ -1197,10 +1198,17 @@ bool QDesignerPropertySheet::reset(int index)
     } else if (isDynamic(index)) {
         const QString propName = propertyName(index);
         const QVariant oldValue = d->m_addProperties.value(index);
-        const QVariant newValue = d->m_info.value(index).defaultValue;
+        const QVariant defaultValue = d->m_info.value(index).defaultValue;
+        QVariant newValue = defaultValue;
+        if (d->isStringProperty(index)) {
+            newValue = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(newValue.toString()));
+        } else if (d->isKeySequenceProperty(index)) {
+            const QKeySequence keySequence = qVariantValue<QKeySequence>(newValue);
+            newValue = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence));
+        }
         if (oldValue == newValue)
             return true;
-        d->m_object->setProperty(propName.toUtf8(), newValue);
+        d->m_object->setProperty(propName.toUtf8(), defaultValue);
         d->m_addProperties[index] = newValue;
         return true;
     } else if (!d->m_info.value(index).defaultValue.isNull()) {
-- 
cgit v0.12