Profile view: Send and cancel buttons, connected LocationUpdate controller.
authorSami Rämö <sami.ramo@ixonos.com>
Thu, 18 Nov 2010 11:28:51 +0000 (13:28 +0200)
committerSami Rämö <sami.ramo@ixonos.com>
Thu, 18 Nov 2010 11:28:51 +0000 (13:28 +0200)
src/engine/engine.cpp
src/qmlui/DetailEditorRow.qml
src/ui/mainwindow.cpp
src/ui/mainwindow.h

index cf3cc0c..fd33453 100644 (file)
@@ -54,6 +54,7 @@
 #include "user/friendmodel.h"
 #include "user/profile.h"
 #include "qmlui/userimageprovider.h"
+#include "updatelocation.h"
 
 const QString SETTINGS_GPS_ENABLED = "GPS_ENABLED"; ///< GPS setting
 const QString SETTINGS_AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";///< Auto centering setting
@@ -72,6 +73,7 @@ public:
     FriendModel friendModel;
     RouteModel routeModel;
     Profile profile;
+    UpdateLocation updateLocation;
 
     QDeclarativeView* ui;
 
@@ -201,6 +203,7 @@ SituareEngine::SituareEngine()
     d->ui->rootContext()->setContextProperty("routingModel", &d->routeModel);
     d->ui->rootContext()->setContextProperty("friendModel", &d->friendProxyModel);
     d->ui->rootContext()->setContextProperty("userProfile", &d->profile);
+    d->ui->rootContext()->setContextProperty("locationUpdate", &d->updateLocation);
     d->ui->rootContext()->setContextProperty("engine", this);
 
     d->ui->setSource(QUrl("qrc:/Main.qml"));
@@ -233,6 +236,9 @@ SituareEngine::SituareEngine()
     m_contactManager->requestContactGuids();
 
     m_facebookAuthenticator->login();
+
+    connect(&d->updateLocation, SIGNAL(locationUpdate(QString,bool)),
+            this, SLOT(requestUpdateLocation(QString,bool)));
 }
 
 SituareEngine::~SituareEngine()
@@ -730,9 +736,6 @@ void SituareEngine::signalsFromMainWindow()
     connect(m_ui, SIGNAL(requestReverseGeo()),
             this, SLOT(requestAddress()));
 
-    connect(m_ui, SIGNAL(locationUpdate(QString,bool)),
-            this, SLOT(requestUpdateLocation(QString,bool)));
-
     connect(m_ui, SIGNAL(enableAutomaticLocationUpdate(bool, int)),
             this, SLOT(enableAutomaticLocationUpdate(bool, int)));
 
@@ -847,8 +850,8 @@ void SituareEngine::signalsFromSituareService()
     connect(m_situareService, SIGNAL(updateWasSuccessful()),
             this, SLOT(updateWasSuccessful()));
 
-    connect(m_situareService, SIGNAL(updateWasSuccessful()),
-            m_ui, SIGNAL(updateWasSuccessful()));
+    Q_D(SituareEngine);
+    connect(m_situareService, SIGNAL(updateWasSuccessful()), &d->updateLocation, SLOT(clear()));
 }
 
 void SituareEngine::startAutomaticUpdate()
index 380f4f5..82da8a1 100644 (file)
@@ -20,7 +20,7 @@ Item {
 
     TextEdit {
         id: text
-        anchors { leftMargin: 5; left: image.right; right: parent.right; top: parent.top }
+        anchors { leftMargin: 5; left: image.right; right: sendButton.left; top: parent.top }
         focus: true
         selectByMouse: true
         font.pixelSize: image.height * 0.7
@@ -31,6 +31,39 @@ Item {
             id: textHeightBehavior
             NumberAnimation { duration: 150 }
         }
+        onActiveFocusChanged: {
+            if (activeFocus)
+                parent.state = "edit"
+        }
+    }
+
+    Button {
+        id: sendButton
+        text: "Send"
+        anchors { right: parent.right; rightMargin: 5; top: text.top }
+        height: 25
+        width: 0
+        visible: false
+        onButtonClicked: {
+            locationUpdate.setMessage(text.text)
+            locationUpdate.send()
+            parent.state = ""
+        }
+    }
+
+    Button {
+        id: cancelButton
+        text: "Cancel"
+        anchors { left: sendButton.left; right: sendButton.right; top: sendButton.bottom; topMargin: 5 }
+        height: 25
+        visible: false
+        onButtonClicked: {
+            parent.state = ""
+        }
+    }
+
+    onStateChanged: {
+        console.log("onStateChanged, state: " + state)
     }
 
     Component.onCompleted: {
@@ -52,7 +85,19 @@ Item {
                 explicit: true
                 height: textSingleLineHeight
             }
+        },
+        State {
+            name: "edit"
+            PropertyChanges {
+                target: text
+                text: locationUpdate.message
+            }
+            PropertyChanges {
+                target: sendButton
+                width: 60
+            }
         }
+
     ]
 
     transitions: [
@@ -74,6 +119,25 @@ Item {
                 PropertyAction { target: text; property: "wrapMode"; value: Text.NoWrap }
                 PropertyAction { target: text; property: "elide"; value: Text.ElideRight }
             }
+        },
+        Transition {
+            from: ""
+            to: "edit"
+            SequentialAnimation {
+                PropertyAction { target: sendButton; property: "visible"; value: true }
+                PropertyAction { target: cancelButton; property: "visible"; value: true }
+                NumberAnimation { target: sendButton; properties: "width"; duration: 1500 }
+            }
+        },
+        Transition {
+            from: "edit"
+            to: ""
+            SequentialAnimation {
+                NumberAnimation { target: sendButton; properties: "width"; duration: 1500 }
+                PropertyAction { target: sendButton; property: "visible"; value: false }
+                PropertyAction { target: cancelButton; property: "visible"; value: false }
+                PropertyAction { target: text; property: "visible"; value: text }
+            }
         }
     ]
 }
index 8a0ea5a..1f42b57 100644 (file)
@@ -113,12 +113,6 @@ MainWindow::MainWindow(QWidget *parent)
 #ifdef Q_WS_MAEMO_5
     setAttribute(Qt::WA_Maemo5StackedWindow);
 #endif
-
-    m_updateLocationController = new UpdateLocation(this);
-
-    connect(this, SIGNAL(updateWasSuccessful()), m_updateLocationController, SLOT(clear()));
-    connect(m_updateLocationController, SIGNAL(locationUpdate(QString,bool)),
-            this, SIGNAL(locationUpdate(QString,bool)));
 }
 
 MainWindow::~MainWindow()
index ea5683a..37265f6 100644 (file)
@@ -472,14 +472,6 @@ signals:
     void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
 
     /**
-    * @brief Send location update
-    *
-    * @param status Status message
-    * @param publish Publish on Facebook?
-    */
-    void locationUpdate(const QString &status, bool publish);
-
-    /**
      * @brief Signals when Login/Logout action is pressed
      *
      */
@@ -584,11 +576,6 @@ signals:
     void viewZoomFinished();
 
     /**
-    * @brief Signals when updateLocation request finished successfully
-    */
-    void updateWasSuccessful();
-
-    /**
      * @brief Signal for use location ready.
      *
      * @param user User object