Merge branch 'friendlist' into integration
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 3 May 2010 12:20:40 +0000 (15:20 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 3 May 2010 12:20:40 +0000 (15:20 +0300)
Conflicts:
src/engine/engine.cpp
src/engine/engine.h
src/map/mapview.h
src/situareservice/situareservice.cpp
src/src.pro
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/mapviewscreen.cpp
src/ui/mapviewscreen.h

13 files changed:
1  2 
src/engine/engine.cpp
src/engine/engine.h
src/map/mapcommon.h
src/map/mapengine.cpp
src/map/mapengine.h
src/situareservice/situareservice.h
src/src.pro
src/ui/friendlistitem.cpp
src/ui/listviewscreen.cpp
src/ui/listviewscreen.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/updatelocation/texteditautoresizer.h

Simple merge
@@@ -69,22 -84,21 +69,21 @@@ public slots
      */
      void requestAddress();
  
--    /**
++/**
      * @brief Calls updateLocation from SituareService to send the location update to
      *        Situare server.
      *
      * @param status Status message
      * @param publish Publish on Facebook
      */
 -    void requestUpdateLocation(const QString &status, const bool &publish);
 -
 -    void refreshUserData();
 -
 -    void userDataReceived(User *user,QList<User*> &friends);
 +    void requestUpdateLocation(const QString &status, bool publish);
  
 -    void updateWasSuccessful();
 +    /**
 +    * @brief Slot to initiate update friends list function
 +    */
 +    void updateFriendsList();
  
 +    void userDataChanged(User *user, QList<User *> &friendList);
  /*******************************************************************************
   * SIGNALS
   ******************************************************************************/
@@@ -30,23 -30,9 +30,24 @@@ const int TILE_SIZE_Y = 256; ///< Tile 
  
  const int MIN_MAP_ZOOM_LEVEL = 0; ///< Minimum zoom level
  const int MAX_MAP_ZOOM_LEVEL = 18; ///< Maximum zoom level
+ const int MIN_VIEW_ZOOM_LEVEL = 2; ///< Minimum zoom level for MapView
  const int MIN_MAP_SCENE_NORMAL_LEVEL = MAX_MAP_ZOOM_LEVEL + 1;
  
 +/**
 +* \var FRIEND_LOCATION_ICON_Z_LEVEL
 +* \brief layer of friend location icon
 +*/
 +const int FRIEND_LOCATION_ICON_Z_LEVEL = MIN_MAP_SCENE_NORMAL_LEVEL + MAX_MAP_ZOOM_LEVEL + 1;
 +
 +/**
 +* \var OWN_LOCATION_ICON_Z_LEVEL
 +* \brief layer of own location icon
 +*/
 +const int OWN_LOCATION_ICON_Z_LEVEL = FRIEND_LOCATION_ICON_Z_LEVEL + 1;
 +
 +const int MAP_ZOOM_PANEL_LEVEL = OWN_LOCATION_ICON_Z_LEVEL + 1; ///< Zepth of zoom panel (Z-axis)
 +
 +
  const int ZOOM_FPS = 30; ///< FPS for the zoom effect
  const qreal ZOOM_TIME = 250; ///< Length of the zoom effect (ms)
  
Simple merge
@@@ -279,10 -268,10 +280,11 @@@ private
      QPoint m_centerTile; ///< Current center tile
      OwnLocationItem *m_ownLocation; ///< Item to show own location
      QPoint m_sceneCoordinate; ///< Current center coordinate
-     QRect m_viewGrid; ///< Current grid of tiles in view (includes margin)
+     QRect m_viewTilesGrid; ///< Current grid of tiles in view (includes margin)
      QSize m_viewSize; ///< Current view size
+     bool m_zoomedIn; ///< Flag for checking if zoomed in when zoom is finished
      int m_zoomLevel; ///< Current zoom level
 +    QList<FriendLocationItem *> m_friendsLocations; ///< Location of friends
  };
  
  #endif // MAPENGINE_H
Simple merge
diff --cc src/src.pro
Simple merge
index 0000000,cac8d4c..b1a236c
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,195 +1,195 @@@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+        Jussi Laitinen - jussi.laitinen@ixonos.com
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
+    Situare is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+ #include <QVBoxLayout>
+ #include <QPushButton>
+ #include <QPainter>
+ #include <QDebug>
+ #include <QPaintEvent>
+ #include <QLabel>
+ #include <QPixmap>
+ #include <QFormLayout>
+ #include <QSpacerItem>
+ #include "friendlistitem.h"
+ #include "../user/user.h"
+ const QString BACKGROUND_PATH = ":/res/images/list_item.png";   ///< Background image path
+ const QString CLOCK_PATH = ":/res/images/clock.png";        ///< Clock image path
+ const QString COMPASS_PATH = ":/res/images/compass.png";    ///< Compass image path
+ const QString ENVELOPE_PATH = ":/res/images/envelope.png";  ///< Envelope image path
+ const int ICON_MARGIN = 5;   ///< Icon margin
+ const int IMAGE_HEIGHT = 60; ///< Friend image height
+ const int IMAGE_WIDTH = 60;  ///< Friend image width
+ const int ITEM_MAX_HEIGHT = 240; ///< Maximum height for item
+ const int ITEM_MAX_WIDTH = 368;  ///< Maximum width for item
+ const int ITEM_MIN_HEIGHT = 141; ///< Minimum height for item
+ const int ITEM_MIN_WIDTH = 368;  ///< Minimum width for item
+ const int LABEL_MAX_WIDTH = 350;   ///< Label maximum width
+ FriendListItem::FriendListItem(QWidget *parent)
+     : QWidget(parent)
+     , m_expanded(false)
+     , m_user(0)
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     QVBoxLayout *layout = new QVBoxLayout(this);
+     this->setLayout(layout);
+     QHBoxLayout *topLayout = new QHBoxLayout();
+     topLayout->setMargin(0);
+     topLayout->setSpacing(0);
+     QHBoxLayout *bottomLayout = new QHBoxLayout();
+     bottomLayout->setMargin(0);
+     bottomLayout->setSpacing(0);
+     QFormLayout *infoLayout = new QFormLayout();
+     infoLayout->setMargin(0);
+     infoLayout->setSpacing(0);
+     QLabel *clockLabel = new QLabel();
+     clockLabel->setPixmap(QPixmap(CLOCK_PATH));
+     clockLabel->setContentsMargins(0, 0, ICON_MARGIN, 0);
+     QLabel *envelopeLabel = new QLabel();
+     envelopeLabel->setPixmap(QPixmap(ENVELOPE_PATH));
+     envelopeLabel->setContentsMargins(0, 0, ICON_MARGIN, 0);
+     QLabel *compassLabel = new QLabel();
+     compassLabel->setPixmap(QPixmap(COMPASS_PATH));
+     compassLabel->setContentsMargins(0, 0, ICON_MARGIN, 0);
+     m_imageLabel = new QLabel();
+     m_imageLabel->setFixedSize(IMAGE_WIDTH, IMAGE_HEIGHT);
+     m_nameLabel = new QLabel();
+     m_nameLabel->setFixedHeight(IMAGE_HEIGHT);
+     m_updatedLabel = new QLabel();
+     m_updatedLabel->setWordWrap(true);
+     m_statusTextLabel = new QLabel();
+     m_statusTextLabel->setWordWrap(true);
+     m_locationLabel = new QLabel();
+     m_locationLabel->setWordWrap(true);
+     infoLayout->addRow(clockLabel, m_updatedLabel);
+     infoLayout->addRow(envelopeLabel, m_statusTextLabel);
+     infoLayout->addRow(compassLabel, m_locationLabel);
+     topLayout->addWidget(m_imageLabel);
+     topLayout->addWidget(m_nameLabel);
+     bottomLayout->addSpacing(IMAGE_WIDTH);
+     bottomLayout->addLayout(infoLayout, 1);
+     layout->addLayout(topLayout, 0);
+     layout->addLayout(bottomLayout, 1);
+     setObjectName("listItem");
+     m_nameLabel->setObjectName("nameLabel");
+     setStyleSheet("#listItem { border-image: url(:/res/images/list_item.png) 20%; " \
+                         "border-width: 20px 14px 16px 14px; } " \
+                         "QLabel { font-size: 13pt; color: #989898; }" \
+                         "#nameLabel { font-size: 18pt; color: #ffffff }");
+     setMinimumSize(ITEM_MIN_WIDTH, ITEM_MIN_HEIGHT);
+     setMaximumSize(ITEM_MAX_WIDTH, ITEM_MAX_HEIGHT);
+ }
+ void FriendListItem::setData(User *user)
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     if (user) {
+         m_user = user;
+         shortenTexts();
+         m_imageLabel->setPixmap(m_user->profileImage());
+         setText(false);
+     }
+ }
+ void FriendListItem::shortenTexts()
+ {
 -    qDebug() << __PRETTY_FUNCTION__ << m_user->address().length();
++    qDebug() << __PRETTY_FUNCTION__;
+     m_shortenedName = m_nameLabel->fontMetrics()
+                       .elidedText(m_user->name(), Qt::ElideRight, LABEL_MAX_WIDTH);
+     m_shortenedUpdated = m_updatedLabel->fontMetrics()
+                          .elidedText(m_user->timestamp(), Qt::ElideRight, LABEL_MAX_WIDTH);
+     m_shortenedStatusText = m_statusTextLabel->fontMetrics()
+                             .elidedText(m_user->note(), Qt::ElideRight, LABEL_MAX_WIDTH);
+     m_shortenedLocation = m_locationLabel->fontMetrics()
+                           .elidedText(m_user->address(), Qt::ElideRight, LABEL_MAX_WIDTH);
+ }
+ void FriendListItem::setText(bool expanded)
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     if (expanded) {
+         m_nameLabel->setText(m_user->name());
+         m_updatedLabel->setText(m_user->timestamp());
+         m_statusTextLabel->setText(m_user->note());
+         m_locationLabel->setText(m_user->address());
+     }
+     else {
+         m_nameLabel->setText(m_shortenedName);
+         m_updatedLabel->setText(m_shortenedUpdated);
+         m_statusTextLabel->setText(m_shortenedStatusText);
+         m_locationLabel->setText(m_shortenedLocation);
+     }
+ }
+ void FriendListItem::mousePressEvent(QMouseEvent *event)
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     m_mousePosition = event->pos();
+ }
+ void FriendListItem::mouseReleaseEvent(QMouseEvent *event)
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     if (event->pos() == m_mousePosition) {
+         if (m_expanded) {
+             setText(false);
+             m_expanded = false;
+         }
+         else {
+             setText(true);
+             m_expanded = true;
+         }
+     }
+ }
+ void FriendListItem::paintEvent(QPaintEvent *)
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     QStyleOption option;
+     option.init(this);
+     QPainter painter(this);
+     style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this);
+ }
@@@ -130,38 -205,48 +205,55 @@@ ListViewScreen::ListViewScreen(QWidget 
  
  ListViewScreen::~ListViewScreen()
  {
-     if (m_personalInfo)
-         delete m_personalInfo;
-     if (m_leftSideBar)
-         delete m_leftSideBar;
-     if (m_slidingLeftSideBar)
-         delete m_slidingLeftSideBar;
-     if (m_trans1)
-         delete m_trans1;
-     if (m_trans2)
-         delete m_trans2;
-     if (m_anim1)
-         delete m_anim1;
-     if (m_anim2)
-         delete m_anim2;
-     if (m_anim3)
-         delete m_anim3;
-     if (m_anim4)
-         delete m_anim4;
-     if (m_anim5)
-         delete m_anim5;
-     if (m_anim6)
-         delete m_anim6;
-     if (m_anim7)
-         delete m_anim7;
-     if (m_anim8)
-         delete m_anim8;
-     if (m_vbox)
-         delete m_vbox;
+     delete m_personalInfo;
+     delete m_leftSideBar;
+     delete m_slidingLeftSideBar;
+     delete m_personalInfoBackGround;
+     delete m_arrowLeft;
+     delete m_arrowRight;
+     delete m_trans1;
+     delete m_trans2;
+     delete m_anim1;
+     delete m_anim2;
+     delete m_anim3;
+     delete m_anim4;
+     delete m_anim5;
+     delete m_anim6;
+     delete m_anim7;
+     delete m_anim8;
+     delete m_anim9;
+     delete m_anim10;
+     delete m_anim11;
+     delete m_anim12;
+     delete m_anim13;
+     delete m_anim14;
+     delete m_vbox;
  }
  
- void ListViewScreen::updateMessage()
 -void ListViewScreen::userDataChanged(User *user, QList<User *> &friends)
++void ListViewScreen::userDataReceived(User *user)
  {
-    qDebug() << __PRETTY_FUNCTION__;
- //   m_locationDialog->exec();
+     qDebug() << __PRETTY_FUNCTION__;
 -    emit toggleProgressIndicator(false);
 -
+     m_personalInfo->setUserName(user->name());
+     m_personalInfo->setAvatar(user->profileImage());
+     m_personalInfo->setMessageText(user->note());
+     m_personalInfo->setAddress(user->address());
+     m_personalInfo->setTime(user->timestamp());
++    emit toggleProgressIndicator(false);
++}
++
++void ListViewScreen::friendInfoReceived(QList<User *> &friendList)
++{
++    qDebug() << __PRETTY_FUNCTION__;
++
+     m_friendListView->clear();
 -    foreach (User *user, friends) {
++    foreach (User *user, friendList) {
+         FriendListItem *item = new FriendListItem(m_friendListView);
+         item->setData(user);
+         m_friendListView->addWidget(item);
+     }
++
++    emit toggleProgressIndicator(false);
  }
@@@ -54,10 -57,29 +57,25 @@@ public
   * MEMBER FUNCTIONS AND SLOTS
   ******************************************************************************/
  public slots:
 -    /**
 -    * @brief Slot for new user and friend data.
 -    *
 -    * @param user User object
 -    * @param friends list of User objects
 -    */
 -    void userDataChanged(User* user,QList<User*>& friends);
++    void userDataReceived(User *user);
++
++    void friendInfoReceived(QList<User *> &friendList);
+ signals:
+     /**
+     * @brief Signal for progress bar indicator toggling.
+     *
+     * @param state true if progress bar should be shown, false otherwise
+     */
+     void toggleProgressIndicator(bool state);
+     /**
+     * @brief Forwarding signal from InfoTab to parent to open update dialog
+     */
+     void launchUpdateDialog();
      /**
-     * @brief Slot to open Location update dialog
+     * @brief  Forwarding signal from InfoTab to parent to update friends list data
      */
-     void updateMessage();
+     void updateFriendsData();
  
  /*******************************************************************************
   * DATA MEMBERS
@@@ -47,10 -48,16 +48,21 @@@ MainWindow::MainWindow(QWidget *parent
      connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
              SIGNAL(statusUpdate(QString,bool)));
  
 -    connect(this, SIGNAL(userDataChanged(User*,QList<User*>&)), m_listViewScreen,
 -            SLOT(userDataChanged(User*,QList<User*>&)));
 -
 +    connect(this, SIGNAL(userLocationReady(User*)),
 +            m_mapViewScreen, SLOT(userLocationReady(User*)));
 +    connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
 +            m_mapViewScreen, SLOT(friendsLocationsReady(QList<User*>&)));
++
++    connect(this, SIGNAL(userLocationReady(User*)), m_listViewScreen,
++            SLOT(userDataReceived(User*)));
++    connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)), m_listViewScreen,
++            SLOT(friendInfoReceived(QList<User*>&)));
+     connect(m_listViewScreen, SIGNAL(updateFriendsData()),
+             this, SIGNAL(refreshUserData()));
 -
+     connect(m_listViewScreen, SIGNAL(toggleProgressIndicator(bool)), this,
+             SLOT(toggleProgressIndicator(bool)));
+     this->toggleProgressIndicator(true);
  }
  
  MainWindow::~MainWindow()
@@@ -133,17 -132,17 +133,19 @@@ private slots
      */
      void statusUpdate(const QString &status, const bool &publish);
  
 +    void userLocationReady(User *user);
 +    void friendsLocationsReady(QList<User *> &friendsList);
+     void refreshUserData();
+     void userDataChanged(User*,QList<User*>&);
  
  /*******************************************************************************
   * DATA MEMBERS
   ******************************************************************************/
  private:
 -    ListViewScreen *m_listViewScreen;
 +    ListViewScreen *m_listViewScreen; ///< Instance of the list view
      UpdateLocationDialog *m_locationDialog; ///< Message dialog
 -    MapViewScreen *m_mapViewScreen;
 +    MapViewScreen *m_mapViewScreen; ///< Instance of the map view
      QStackedWidget *m_situareViews; ///< Stacked widget that hold both view widgets
      QAction *m_toListViewAct; ///< Action to trigger switch to list view
      QAction *m_toMapViewAct; ///< Action to trigger switch to map view