Cleaned up code and moved the new ZoomButtonPanel into master branch.
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Fri, 14 May 2010 12:01:34 +0000 (15:01 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Fri, 14 May 2010 12:01:34 +0000 (15:01 +0300)
Reviewed by: Kaj Wallin

src/engine/engine.cpp
src/engine/engine.h
src/facebookservice/facebookauthentication.cpp
src/ui/imagebutton.cpp
src/ui/imagebutton.h
src/ui/mainwindow.cpp
src/ui/zoombuttonpanel.cpp
src/ui/zoombuttonpanel.h

index 2587f0d..39c56e4 100644 (file)
@@ -33,7 +33,9 @@
 #endif
 
 SituareEngine::SituareEngine(QMainWindow *parent)
-    : QObject(parent)
+    : QObject(parent),
+      m_autoCenteringEnabled(false),
+      m_gpsEnabled(false)
 {
     qDebug() << __PRETTY_FUNCTION__;
     m_ui = new MainWindow;
@@ -109,6 +111,12 @@ SituareEngine::~SituareEngine()
     qDebug() << __PRETTY_FUNCTION__;
 
     delete m_ui;
+
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+    qDebug() << __PRETTY_FUNCTION__ << m_gpsEnabled;
+    qDebug() << __PRETTY_FUNCTION__ << m_autoCenteringEnabled;
+    settings.setValue(GPS_ENABLED, m_gpsEnabled);
+    settings.setValue(AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
 }
 
 void SituareEngine::loginProcessCancelled()
@@ -182,6 +190,8 @@ void SituareEngine::enableGPS(bool enabled)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    m_gpsEnabled = enabled;
+
     if (enabled) {
         m_gps->lastPosition();
         m_gps->start();
@@ -197,6 +207,8 @@ void SituareEngine::enableAutoCentering(bool enabled)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    m_autoCenteringEnabled = enabled;
+
     if (enabled) {
         m_ui->setAutoCenteringButton(true);
         m_ui->autoCenteringEnabled(true);
index 3b51cea..8aa2595 100644 (file)
@@ -152,6 +152,8 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
+    bool m_autoCenteringEnabled;    ///< Auto centering enabled
+    bool m_gpsEnabled;              ///< GPS enabled
     FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
     GPSPositionInterface *m_gps;   ///< Instance of the gps position
     MainWindow *m_ui; ///< Instance of the MainWindow UI
index 687470e..6e65072 100644 (file)
@@ -103,8 +103,14 @@ bool FacebookAuthentication::updateCredentials(const QUrl &url)
                         qDebug() << "Session Key" << result[SESSION_KEY].toString();
                         m_loginCredentials.setSessionKey(result[SESSION_KEY].toString());
 
-                        qDebug() << "userID" << result[USER_ID].toString();
-                        m_loginCredentials.setUserID(result[USER_ID].toString());
+//                        // commeted out until qjson parser can handle 64-bit integers
+//                        qDebug() << "userID" << result[USER_ID].toString();
+//                        m_loginCredentials.setUserID(result[USER_ID].toString().toAscii());
+
+                        // dirty fix, get user id from session_key
+                        QStringList list = result[SESSION_KEY].toString().split("-");
+                        m_loginCredentials.setUserID(list.at(1));
+                        qDebug() << m_loginCredentials.userID();
 
                         qDebug() << "Expires" << result[EXPIRES].toString();
                         m_loginCredentials.setExpires(result[EXPIRES].toString());
index 4edd5ac..0c3bf40 100644 (file)
@@ -52,8 +52,7 @@ void ImageButton::mousePressEvent(QMouseEvent *event)
 
     if(m_buttonMode != QIcon::Disabled) {
         QAbstractButton::mousePressEvent(event);
-        m_buttonMode = QIcon::Selected;
-        update();
+        setMode(QIcon::Selected);
     }
 }
 
@@ -63,8 +62,7 @@ void ImageButton::mouseReleaseEvent(QMouseEvent *event)
 
     if(m_buttonMode != QIcon::Disabled) {
         QAbstractButton::mouseReleaseEvent(event);
-        m_buttonMode = QIcon::Normal;
-        update();
+        setMode(QIcon::Normal);
     }
 }
 
@@ -75,18 +73,12 @@ void ImageButton::paintEvent(QPaintEvent *event)
     Q_UNUSED(event);
 
     QPainter painter(this);
-
-    // Temporary border
-    painter.setPen(Qt::white);
-    painter.drawRect(this->rect().x(), this->rect().y(),
-                     this->rect().width() - 1, this->rect().height() - 1);
-
     icon().paint(&painter, this->rect(), NULL, m_buttonMode);
 }
 
 void ImageButton::setMode(QIcon::Mode mode)
 {
-    qDebug() << __PRETTY_FUNCTION__;
+    qDebug() << __PRETTY_FUNCTION__ << "Button icon mode:" << mode;
 
     m_buttonMode = mode;
     update();
index a6bb9cb..be7852e 100644 (file)
 #include <QPaintEvent>
 
 /**
-* @brief A simple class for icon button
-*
-* @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
-*/
+ * @brief A simple class for icon button
+ *
+ * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
+ */
 class ImageButton : public QPushButton
 {
     Q_OBJECT
 
 public:
     /**
-    * @brief Constructor
-    *
-    * @param parent Parent
-    * @param normalIconPictureFileName Normal state Icon image file name
-    * @param selectedIconPictureFileName Selected state Icon image file name (optional)
-    */
+     * @brief Constructor
+     *
+     * @param parent Parent
+     * @param normalIconPictureFileName Normal state Icon image file name
+     * @param selectedIconPictureFileName Selected state Icon image file name (optional)
+     */
     ImageButton(QWidget *parent = 0, QString normalIconPictureFileName = "",
                 QString selectedIconPictureFileName = "");
 
@@ -54,31 +54,36 @@ public:
  ******************************************************************************/
 protected:
     /**
-    * @brief Event handler for mouse press events
-    *
-    * @param event Mouse event
-    */
+     * @brief Event handler for mouse press events
+     *
+     * @param event Mouse event
+     */
     void mousePressEvent(QMouseEvent *event);
 
     /**
-    * @brief Event handler for mouse release events
-    *
-    * @param event Mouse event
-    */
+     * @brief Event handler for mouse release events
+     *
+     * @param event Mouse event
+     */
     void mouseReleaseEvent(QMouseEvent *event);
 
     /**
-    * @brief Event handler for paint events
-    *
-    * Paints the button and its icon
-    * @param event Paint event
-    */
+     * @brief Event handler for paint events
+     *
+     * Paints the button and its icon
+     * @param event Paint event
+     */
     void paintEvent(QPaintEvent *event);
 
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
 public:
+    /**
+     * @brief Sets the button icon mode
+     *
+     * @param mode Button icon mode
+     */
     void setMode(QIcon::Mode mode);
 
 /*******************************************************************************
index 6fd9bbb..46c04d5 100644 (file)
@@ -373,6 +373,8 @@ void MainWindow::grabZoomKeys(bool grab)
                      PropModeReplace,
                      reinterpret_cast<unsigned char *>(&val),
                      1);
+#else
+    Q_UNUSED(grab);
 #endif // Q_WS_MAEMO_5
 }
 
index 5f357ea..59b0327 100644 (file)
@@ -46,27 +46,3 @@ ZoomButtonPanel::ZoomButtonPanel(QWidget *parent, int x, int y)
 
     move(m_x, m_y);
 }
-
-ZoomButtonPanel::~ZoomButtonPanel()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    delete m_zoomInBtn;
-    delete m_zoomOutBtn;
-    m_zoomInBtn = 0;
-    m_zoomOutBtn = 0;
-}
-
-void ZoomButtonPanel ::paintEvent(QPaintEvent *event)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    Q_UNUSED(event);
-
-    QPainter painter(this);
-
-    // Temporary border
-    painter.setPen(Qt::red);
-    painter.drawRect(this->rect().x(), this->rect().y(),
-                     this->rect().width() - 1, this->rect().height() - 1);
-}
index a28c5a9..c55d593 100644 (file)
@@ -48,17 +48,6 @@ public:
     */
     ZoomButtonPanel(QWidget *parent = 0, int x = 0, int y = 0);
 
-    /**
-    * @brief Destructor
-    */
-    ~ZoomButtonPanel();
-
-/*******************************************************************************
- * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
- ******************************************************************************/
-protected:
-    void paintEvent(QPaintEvent *event);
-
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/