Replaced message Text item with TextEdit item in profile view.
authorSami Rämö <sami.ramo@ixonos.com>
Thu, 18 Nov 2010 09:16:32 +0000 (11:16 +0200)
committerSami Rämö <sami.ramo@ixonos.com>
Thu, 18 Nov 2010 09:16:32 +0000 (11:16 +0200)
src/qmlui/DetailEditorRow.qml [new file with mode: 0644]
src/qmlui/ProfileView.qml
src/qmlui/res.qrc
src/src.pro

diff --git a/src/qmlui/DetailEditorRow.qml b/src/qmlui/DetailEditorRow.qml
new file mode 100644 (file)
index 0000000..380f4f5
--- /dev/null
@@ -0,0 +1,79 @@
+import Qt 4.7
+
+Item {
+    property alias image: image.source
+    property alias text: text.text
+
+    property int textSingleLineHeight: 0
+
+    anchors.left: parent.left
+    anchors.right: parent.right
+    width: childrenRect.width
+    height: text.height > image.height ? text.height : image.height
+
+    state: parent.state
+
+    Image {
+        id: image
+        anchors { left: parent.left; top: parent.top }
+    }
+
+    TextEdit {
+        id: text
+        anchors { leftMargin: 5; left: image.right; right: parent.right; top: parent.top }
+        focus: true
+        selectByMouse: true
+        font.pixelSize: image.height * 0.7
+        clip: true;
+//        elide: Text.ElideRight
+        state: parent.state
+        Behavior on height {
+            id: textHeightBehavior
+            NumberAnimation { duration: 150 }
+        }
+    }
+
+    Component.onCompleted: {
+        textSingleLineHeight = text.height
+    }
+
+    states: [
+        State {
+            name: "expanded"
+                PropertyChanges {
+                    target: text
+                    height: paintedHeight
+                }
+        },
+        State {
+            name: ""
+            PropertyChanges {
+                target: text
+                explicit: true
+                height: textSingleLineHeight
+            }
+        }
+    ]
+
+    transitions: [
+        Transition {
+            from: ""
+            to: "expanded"
+            SequentialAnimation {
+                PropertyAction { target: textHeightBehavior; property: "enabled"; value: true }
+                PropertyAction { target: text; property: "wrapMode"; value: Text.Wrap }
+                PropertyAction { target: text; property: "elide"; value: Text.ElideNone }
+            }
+        },
+        Transition {
+            from: "expanded"
+            to: ""
+            SequentialAnimation {
+                PropertyAction { target: textHeightBehavior; property: "enabled"; value: false }
+                NumberAnimation { target: text; properties: "height"; duration: 150 }
+                PropertyAction { target: text; property: "wrapMode"; value: Text.NoWrap }
+                PropertyAction { target: text; property: "elide"; value: Text.ElideRight }
+            }
+        }
+    ]
+}
index 732f21d..936f4a2 100644 (file)
@@ -67,6 +67,7 @@ Item {
 
     Loader {
         id: details
+        z: 1
         sourceComponent: detailsComponent
         state: parent.state
         anchors { left: primaryText.left; right: primaryText.right; top: primaryText.bottom }
@@ -87,7 +88,7 @@ Item {
             state: delegate.state
             height: messageRow.height + addressRow.height + timeRow.height
             width: parent.width
-            DetailRow { id: messageRow; image: "qrc:/res/images/envelope.png"; text: userProfile.message }
+            DetailEditorRow { id: messageRow; image: "qrc:/res/images/envelope.png"; text: userProfile.message }
             DetailRow { id: addressRow; anchors.top: messageRow.bottom; image: "qrc:/res/images/compass.png"; text: userProfile.address }
             DetailRow { id: timeRow; anchors.top: addressRow.bottom; image: "qrc:/res/images/clock.png"; text: userProfile.time }
         }
index d37f106..25c9e1f 100644 (file)
@@ -30,5 +30,6 @@
         <file>RoutingView.qml</file>
         <file>LocationsView.qml</file>
         <file>ListBase.qml</file>
+        <file>DetailEditorRow.qml</file>
     </qresource>
 </RCC>
index f387e6a..828304b 100644 (file)
@@ -204,7 +204,8 @@ OTHER_FILES += qmlui/Main.qml \
     qmlui/Panel.qml \
     qmlui/ProfileView.qml \
     qmlui/FriendsView.qml \
-    qmlui/LocationsView.qml
+    qmlui/LocationsView.qml \
+    qmlui/DetailEditorRow.qml
 
 QT += network \
     webkit  \