Added friend find button to FriendListItem.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 12 May 2010 09:33:29 +0000 (12:33 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 12 May 2010 09:33:29 +0000 (12:33 +0300)
src/map/mapengine.h
src/src.pro
src/ui/friendlistitem.cpp
src/ui/friendlistitem.h
src/ui/friendlistpanel.cpp
src/ui/friendlistpanel.h
src/ui/friendlistview.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/mapviewscreen.cpp
src/ui/mapviewscreen.h

index 450d22b..3608856 100644 (file)
@@ -99,14 +99,6 @@ public:
     void init();
 
     /**
-    * @brief Helper for setting view location based on latitude and longitude
-    * coordinates
-    *
-    * @param latLonCoordinate Latitude & longitude coordinates for location
-    */
-    void setViewLocation(QPointF latLonCoordinate);
-
-    /**
     * @brief Getter for scene
     *
     * @return QGraphicsScene
@@ -140,6 +132,14 @@ public slots:
     void setLocation(QPoint sceneCoordinate);
 
     /**
+    * @brief Helper for setting view location based on latitude and longitude
+    * coordinates
+    *
+    * @param latLonCoordinate Latitude & longitude coordinates for location
+    */
+    void setViewLocation(QPointF latLonCoordinate);
+
+    /**
     * @brief Slot for view resizing.
     *
     * @param size view size
index bf3e3e7..af28831 100644 (file)
@@ -81,7 +81,7 @@ HEADERS += ui/mainwindow.h \
     gps/gpspositioninterface.h
 QT += network \
     webkit
-DEFINES += QT_NO_DEBUG_OUTPUT
+#DEFINES += QT_NO_DEBUG_OUTPUT
 
 !maemo5 {
     SOURCES += gps/gpspositionmockup.cpp
index 032626f..f8cb015 100644 (file)
@@ -34,6 +34,7 @@
 #include "friendlistitem.h"
 #include "../user/user.h"
 #include "avatarimage.h"
+#include "imagebutton.h"
 
 FriendListItem::FriendListItem(QWidget *parent)
     : QWidget(parent)
@@ -82,9 +83,11 @@ FriendListItem::FriendListItem(QWidget *parent)
     m_distanceLabel = new QLabel();
     m_distanceLabel->setFixedHeight(IMAGE_HEIGHT);
 
-    QLabel *button = new QLabel();
-    button->setPixmap(QPixmap(":/res/images/show_position.png"));
-    button->setFixedSize(IMAGE_WIDTH, IMAGE_HEIGHT);
+//    QLabel *button = new QLabel();
+//    button->setPixmap(QPixmap(":/res/images/show_position.png"));
+//    button->setFixedSize(IMAGE_WIDTH, IMAGE_HEIGHT);
+    m_findButton = new ImageButton(this, ":/res/images/show_position.png",
+                                   ":/res/images/show_position_s.png");
 
     m_updatedLabel = new QLabel();
     m_updatedLabel->setWordWrap(true);
@@ -101,7 +104,7 @@ FriendListItem::FriendListItem(QWidget *parent)
     topLayout->addWidget(m_nameLabel, 1);
     topLayout->addWidget(m_distanceLabel);
 
-    bottomLayout->addWidget(button, 0, Qt::AlignTop);
+    bottomLayout->addWidget(m_findButton, 0, Qt::AlignTop);
     bottomLayout->addLayout(infoLayout);
 
     layout->addLayout(topLayout, 0);
@@ -122,6 +125,8 @@ FriendListItem::FriendListItem(QWidget *parent)
     m_backgroundTopImage.load(":/res/images/list_item_top.png");
     m_backgroundMiddleImage.load(":/res/images/list_item_middle.png");
     m_backgroundBottomImage.load(":/res/images/list_item_bottom.png");
+
+    connect(m_findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked()));
 }
 
 void FriendListItem::setData(User *user)
@@ -246,3 +251,8 @@ void FriendListItem::paintEvent(QPaintEvent *event)
     painter.drawPixmap(middleRect, m_backgroundMiddleImage);
     painter.drawPixmap(bottomRect, m_backgroundBottomImage);
 }
+
+void FriendListItem::findButtonClicked()
+{
+    emit findFriend(m_user->coordinates());
+}
index b2bcdb0..5f4758e 100644 (file)
@@ -29,6 +29,7 @@
 #include "../user/user.h"
 
 class QLabel;
+class ImageButton;
 
 /**
 * @brief FriendListItem shows friend data in expandable item.
@@ -101,11 +102,20 @@ private:
     */
     void setText(bool expanded);
 
+private slots:
+    /**
+    * @brief Slot for find button click
+    *
+    * @param coordinates friend's geo coordinates
+    */
+    void findButtonClicked();
+
 /******************************************************************************
 * SIGNALS
 ******************************************************************************/
 signals:
-    void locationButtonClicked(const QPointF &coordinates);
+
+    void findFriend(const QPointF &coordinates);
 
 /******************************************************************************
 * DATA MEMBERS
@@ -116,6 +126,7 @@ private:
     QPixmap m_backgroundBottomImage;   ///< Bottom background image
     bool m_expanded;                ///< Item expanded state
     QLabel *m_distanceLabel;        ///< Distance to friend label
+    ImageButton *m_findButton;      ///< Friend find button
     QLabel *m_imageLabel;           ///< Image label
     QLabel *m_locationLabel;        ///< Location label
     QPoint m_mousePosition;         ///< Current mouse press position
index 7378d12..47e4b8e 100644 (file)
@@ -83,6 +83,7 @@ void FriendListPanel::friendInfoReceived(QList<User *> &friendList)
     foreach (User *user, friendList) {
         FriendListItem *item = new FriendListItem(m_friendListView);
         item->setData(user);
+        connect(item, SIGNAL(findFriend(QPointF)), this, SIGNAL(findFriend(QPointF)));
         m_friendListView->addWidget(item);
     }
 }
index 4fc1d2e..53f3894 100644 (file)
@@ -66,6 +66,12 @@ public slots:
     void reDrawFriendsPanel(int width, int height);
 
 /*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
+    void findFriend(const QPointF &coordinates);
+
+/*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
 private:
index cf57111..18e870b 100644 (file)
@@ -56,6 +56,7 @@ void FriendListView::clear()
     foreach (QWidget *widget, widgets) {
         m_friendListLayout->removeWidget(widget);
         widgets.removeOne(widget);
+        disconnect(widget, 0, 0, 0);
         delete widget;
     }
 }
index a95dbd1..148e676 100644 (file)
@@ -56,10 +56,11 @@ MainWindow::MainWindow(QWidget *parent)
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             m_mapViewScreen, SIGNAL(friendsLocationsReady(QList<User*>&)));
 
-       connect(this, SIGNAL(enableAutoCentering(bool)),
+    connect(this, SIGNAL(enableAutoCentering(bool)),
             m_mapViewScreen, SLOT(enableAutoCentering(bool)));
     connect(this, SIGNAL(positionReceived(QPointF)),
             m_mapViewScreen, SLOT(positionReceived(QPointF)));
+    connect(m_mapViewScreen, SIGNAL(mapLocationChanged()), this, SLOT(mapLocationChanged()));
 
     this->toggleProgressIndicator(true);
 }
@@ -89,8 +90,8 @@ void MainWindow::createMenus()
     m_autoCenteringAct->setCheckable(true);
     m_autoCenteringAct->setChecked(true);
     connect(m_autoCenteringAct, SIGNAL(toggled(bool)), this, SLOT(autoCenteringToggled(bool)));    
-       
-       m_viewMenu = menuBar()->addMenu(tr("Main"));
+
+    m_viewMenu = menuBar()->addMenu(tr("Main"));
 
     m_viewMenu->addAction(m_toSettingsAct);
        m_viewMenu->addAction(m_gpsToggleAct);
@@ -144,6 +145,13 @@ void MainWindow::gpsError(const QString &message)
     showMaemoInformationBox(message);
 }
 
+void MainWindow::mapLocationChanged()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_autoCenteringAct->setChecked(false);
+}
+
 void MainWindow::autoCenteringToggled(bool checked)
 {
     qDebug() << __PRETTY_FUNCTION__ << " " << checked;
index f5ea600..24edd20 100644 (file)
@@ -58,7 +58,7 @@ public:
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
 public slots:
-       /**
+    /**
     * @brief Slot for auto centering enabling.
     *
     * @param checked true if button state is checked, false otherwise
@@ -66,6 +66,11 @@ public slots:
     void autoCenteringToggled(bool checked);
 
     /**
+    * @brief Slot for map location change.
+    */
+    void mapLocationChanged();
+
+    /**
     * @brief Public slot, which open settings dialog
     */
     void openSettingsDialog();
index e367a6c..c08cbae 100644 (file)
@@ -66,12 +66,16 @@ MapViewScreen::MapViewScreen(QWidget *parent)
 
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
+    connect(friendsListPanel, SIGNAL(findFriend(QPointF)),
+            mapEngine, SLOT(setViewLocation(QPointF)));
 
     connect(this, SIGNAL(userLocationReady(User*)),
             mapEngine, SLOT(receiveOwnLocation(User*)));
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
 
+    connect(mapView, SIGNAL(viewScrolled(QPoint)), this, SLOT(locationChanged()));
+
     QHBoxLayout *mapViewLayout = new QHBoxLayout;
 
     osmLicense = new QLabel(this);
@@ -105,6 +109,14 @@ void MapViewScreen::drawOsmLicense(int width, int height)
                      height - osmLicense->fontMetrics().height());
 }
 
+void MapViewScreen::locationChanged()
+{
+    qDebug() << __PRETTY_FUNCTION__ << " m_autoCentering: " << m_autoCenteringEnabled;
+
+    if (m_autoCenteringEnabled)
+        emit mapLocationChanged();
+}
+
 void MapViewScreen::positionReceived(QPointF position)
 {
     qDebug() << __PRETTY_FUNCTION__;
index f62cc54..c92d59e 100644 (file)
@@ -67,6 +67,11 @@ private slots:
     void drawOsmLicense(int width, int height);
 
     /**
+    * @brief Slot for map location change.
+    */
+    void locationChanged();
+
+    /**
     * @brief Slot for GPS position.
     *
     * @param position latitude and longitude values
@@ -85,6 +90,11 @@ signals:
     void userLocationReady(User *user);
 
     /**
+    * @brief Signal for map location change.
+    */
+    void mapLocationChanged();
+
+    /**
     * @brief Signal when friend list locations are fetched
     *
     * Forwarded to map engine and friends list panel