Merge branch 'master' into locationlistview
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 28 Jul 2010 14:20:14 +0000 (17:20 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 28 Jul 2010 14:20:14 +0000 (17:20 +0300)
Conflicts:
src/ui/mainwindow.h

14 files changed:
1  2 
src/engine/engine.cpp
src/map/mapengine.cpp
src/map/mapengine.h
src/src.pro
src/ui/friendlistpanel.cpp
src/ui/friendlistpanel.h
src/ui/listview.cpp
src/ui/listview.h
src/ui/locationlistitem.cpp
src/ui/locationlistitem.h
src/ui/locationlistview.cpp
src/ui/locationlistview.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h

@@@ -644,6 -644,6 +644,9 @@@ void SituareEngine::signalsFromMainWind
  
      connect(m_ui, SIGNAL(searchForLocation(QString)),
              this, SLOT(locationSearch(QString)));
++
++    connect(m_ui, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
++            m_mapEngine, SLOT(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
  }
  
  void SituareEngine::signalsFromMapEngine()
@@@ -623,3 -623,3 +623,11 @@@ void MapEngine::zoomOut(
          zoomed();
      }
  }
++
++void MapEngine::locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound)
++{
++    qDebug() << __PRETTY_FUNCTION__;
++
++    centerAndZoomTo(QRect(SceneCoordinate(swBound).toPointF().toPoint(),
++                          SceneCoordinate(neBound).toPointF().toPoint()));
++}
@@@ -378,6 -378,6 +378,8 @@@ private slots
       */
      void zoomOut();
  
++    void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
++
  /*******************************************************************************
   * SIGNALS
   ******************************************************************************/
diff --cc src/src.pro
@@@ -66,11 -66,7 +66,12 @@@ SOURCES += main.cpp 
      ui/listitem.cpp \
      ui/listitemdelegate.cpp \
      ui/friendlistitemdelegate.cpp \
 -    ui/searchdialog.cpp
 +    ui/searchdialog.cpp \
 +    ui/locationlistitem.cpp \
 +    ui/extendedlistitem.cpp \
 +    ui/extendedlistitemstore.cpp \
-     ui/extendedlistitemdelegate.cpp
++    ui/extendedlistitemdelegate.cpp \
++    ui/locationlistview.cpp
  HEADERS += application.h \
      common.h \
      engine/engine.h \
      ui/listitemdelegate.h \
      ui/friendlistitemdelegate.h \
      ui/listcommon.h \
 -    ui/searchdialog.h
 +    ui/searchdialog.h \
 +    ui/locationlistitem.h \
 +    ui/extendedlistitem.h \
 +    ui/extendedlistitemstore.h \
-     ui/extendedlistitemdelegate.h
++    ui/extendedlistitemdelegate.h \
++    ui/locationlistview.h
  QT += network \
      webkit
  
  #include "friendlistitemdelegate.h"
  #include "panelcommon.h"
  #include "sidepanel.h"
 +#include "../routing/location.h"
 +#include "locationlistitem.h"
++#include "locationlistview.h"
 +#include "extendedlistitemdelegate.h"
  
  #include "friendlistpanel.h"
  
@@@ -63,16 -60,8 +64,16 @@@ FriendListPanel::FriendListPanel(QWidge
      m_friendListView->viewport()->setAutoFillBackground(false);
      m_friendListItemDelegate = new FriendListItemDelegate();
      m_friendListView->setItemDelegate(m_friendListItemDelegate);
 +    //REMOVE
 +    m_friendListView->hide();
  
-     m_locationListView = new ListView(this);
 -    friendListLayout->addWidget(m_friendListView);
++    m_locationListView = new LocationListView(this);
 +    m_locationListView->setAutoFillBackground(false);
 +    m_locationListView->viewport()->setAutoFillBackground(false);
 +    m_locationListView->setItemDelegate(new ExtendedListItemDelegate());
 +
 +    //friendListLayout->addWidget(m_friendListView);
 +    friendListLayout->addWidget(m_locationListView);
      m_panelVBox->addLayout(friendListLayout);
  
      connect(m_friendListView, SIGNAL(listItemClicked(GeoCoordinate)),
@@@ -82,6 -71,6 +83,9 @@@
              this, SLOT(clearFriendListFilter()));
      connect(this, SIGNAL(panelOpened()),
              this, SLOT(clearFriendListFilter()));
++
++    connect(m_locationListView, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
++            this, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
  }
  
  void FriendListPanel::friendImageReady(User *user)
@@@ -131,19 -120,6 +135,21 @@@ void FriendListPanel::clearFriendListFi
      m_friendListView->clearFilter();
  }
  
 +void FriendListPanel::locationDataReady(QList<Location> &result)
 +{
 +    qWarning() << __PRETTY_FUNCTION__;
 +
++    m_locationListView->clearList();
++
 +    for (int i = 0; i < result.size(); ++i) {
 +        LocationListItem *item = new LocationListItem();
 +        item->setLocationData(result.at(i));
 +        m_locationListView->addListItem(QString::number(i), item);
 +    }
 +
 +
 +}
 +
  void FriendListPanel::showFriendsInList(const QList<QString> &userIDs)
  {
      qDebug() << __PRETTY_FUNCTION__;
@@@ -34,7 -34,6 +34,8 @@@ class FriendListItemDelegate
  class GeoCoordinate;
  class ListView;
  class User;
 +class Location;
++class LocationListView;
  
  /**
  * @brief Class for sliding friends list panel
@@@ -104,6 -96,6 +105,8 @@@ signals
      */
      void findFriend(const GeoCoordinate &coordinates);
  
++    void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
++
  /*******************************************************************************
   * DATA MEMBERS
   ******************************************************************************/
@@@ -112,7 -104,6 +115,7 @@@ private
      QLabel *m_friendListLabel;          ///< Friend list label
      QPushButton *m_clearFilterButton;   ///< Button to clear list filtering
      ListView *m_friendListView;         ///< Friend list view
-     ListView *m_locationListView;
++    LocationListView *m_locationListView;
      FriendListItemDelegate *m_friendListItemDelegate;   ///< Friend list item delegate
  };
  
@@@ -127,21 -126,20 +127,23 @@@ void ListView::listItemClicked(QListWid
              bool selected = currentItem->toggleSelection();
  
              if (selected)
--                emit listItemClicked(currentItem->coordinates());
++                ;//emit listItemClicked(currentItem->coordinates());
  
          } else {
 +            qWarning() << __PRETTY_FUNCTION__ << "previousItem != currentItem";
              if (m_previousItem)
                  m_previousItem->setSelected(false);
  
              currentItem->setSelected(true);
--            emit listItemClicked(currentItem->coordinates());
++            //emit listItemClicked(currentItem->coordinates());
          }
  
          m_previousItem = currentItem;
      }
  }
  
++
++
  ListItem *ListView::listItem(const QString &userID)
  {
      qDebug() << __PRETTY_FUNCTION__;
@@@ -122,13 -122,13 +122,13 @@@ public
      */
      ListItem *listItem(const QString &userID);
  
--private slots:
++protected slots:
      /**
      * @brief Slot for list item clicked.
      *
      * Toggles items selection state and emits listItemClicked signal.
      */
--    void listItemClicked(QListWidgetItem *item);
++    virtual void listItemClicked(QListWidgetItem *item);
  
  /******************************************************************************
  * SIGNALS
index b0112e3,0000000..fb8306b
mode 100644,000000..100644
--- /dev/null
@@@ -1,41 -1,0 +1,57 @@@
 +#include <QDebug>
 +
 +#include "../common.h"
 +#include "listcommon.h"
 +
 +#include "locationlistitem.h"
 +
 +const int LOCATION_SUBITEM_TEXT_MAX_WIDTH = SUBITEM_TEXT_MAX_WIDTH + MARGIN + IMAGE_WIDTH;
 +
 +LocationListItem::LocationListItem()
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    setSubitemTextWidth(LOCATION_SUBITEM_TEXT_MAX_WIDTH);
-     addSubItem(QString("Hei pitka teksti hep hep hep hep hep hep hep hep hep hep hep hep"),
-                QPixmap(":/res/images/clock.png"));
-     addSubItem(QString("Hep"));
-     addSubItem(QString("Jep"), QPixmap(":/res/images/compass.png"));
 +}
 +
 +GeoCoordinate LocationListItem::coordinates()
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    return m_location.coordinates();
 +}
 +
 +QString LocationListItem::id() const
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    return QString();
 +}
 +
 +void LocationListItem::setLocationData(const Location &location)
 +{
 +    m_location = location;
 +
-     setName(shortenText("blaah bavlsdfasdfhldsaf dsafldsaf ldsa lfadsl fl sadf",
-                         ITEM_WIDTH - 3*MARGIN, ListItem::TEXT_SIZE_NORMAL));
++    QStringList addressComponents = m_location.addressComponents();
++
++    if (addressComponents.count() > 0)
++        setName(shortenText(addressComponents.at(0), ITEM_WIDTH - 3*MARGIN,
++                            ListItem::TEXT_SIZE_NORMAL));
++
++    QString addressTail;
++
++    for (int i = 1; i < addressComponents.count(); ++i) {
++        addressTail.append(addressComponents.at(i));
++
++        if (i < (addressComponents.count() - 1))
++            addressTail.append(", ");
++    }
++
++    addSubItem(addressTail, QPixmap(":/res/images/compass.png"));
++
++}
++
++void LocationListItem::bounds(GeoCoordinate &swBound, GeoCoordinate &neBound)
++{
++    m_location.bounds(swBound, neBound);
 +}
index ae8453e,0000000..dc89fc1
mode 100644,000000..100644
--- /dev/null
@@@ -1,49 -1,0 +1,51 @@@
 +#ifndef LOCATIONLISTITEM_H
 +#define LOCATIONLISTITEM_H
 +
 +#include "extendedlistitem.h"
 +#include "../routing/location.h"
 +
 +class LocationListItem : public ExtendedListItem
 +{
 +public:
 +    LocationListItem();
 +
 +/*******************************************************************************
 + * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
 + ******************************************************************************/
 +public:
 +    /**
 +    * @brief Returns item's coordinates.
 +    *
 +    * @return item's coordinates
 +    */
 +    GeoCoordinate coordinates();
 +
 +    /**
 +    * @brief Returns item's ID.
 +    *
 +    * @return item's ID
 +    */
 +    QString id() const;
 +
++    void bounds(GeoCoordinate &swBound, GeoCoordinate &neBound);
++
 +/******************************************************************************
 +* MEMBER FUNCTIONS AND SLOTS
 +******************************************************************************/
 +public:
 +    /**
 +    * @brief Set user data for this item.
 +    *
 +    * @param user User pointer
 +    */
 +    void setLocationData(const Location &location);
 +
 +/******************************************************************************
 +* DATA MEMBERS
 +******************************************************************************/
 +private:
 +    Location m_location;
 +    bool m_selected;
 +};
 +
 +#endif // LOCATIONLISTITEM_H
index 0000000,0000000..5233f56
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,26 @@@
++#include "locationlistitem.h"
++
++#include "locationlistview.h"
++
++LocationListView::LocationListView(QWidget *parent)
++    : ListView(parent)
++{
++    qWarning() << __PRETTY_FUNCTION__;
++}
++
++void LocationListView::listItemClicked(QListWidgetItem *item)
++{
++    qWarning() << __PRETTY_FUNCTION__;
++
++    ListView::listItemClicked(item);
++
++    LocationListItem *locationItem = static_cast<LocationListItem*>(item);
++
++    if (locationItem) {
++        qWarning() << __PRETTY_FUNCTION__ << "locationItem != null";
++        GeoCoordinate swBound;
++        GeoCoordinate neBound;
++        locationItem->bounds(swBound, neBound);
++        emit locationItemClicked(swBound, neBound);
++    }
++}
index 0000000,0000000..f779b0f
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,20 @@@
++#ifndef LOCATIONLISTVIEW_H
++#define LOCATIONLISTVIEW_H
++
++#include "listview.h"
++
++class LocationListView : public ListView
++{
++    Q_OBJECT
++
++public:
++    LocationListView(QWidget *parent = 0);
++
++private slots:
++    void listItemClicked(QListWidgetItem *item);
++
++signals:
++    void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
++};
++
++#endif // LOCATIONLISTVIEW_H
@@@ -176,9 -176,6 +176,12 @@@ void MainWindow::buildFriendListPanel(
  
      connect(this, SIGNAL(friendImageReady(User*)),
              m_friendsListPanel, SLOT(friendImageReady(User*)));
 +
 +    connect(this, SIGNAL(locationDataParsed(QList<Location>&)),
 +            m_friendsListPanel, SLOT(locationDataReady(QList<Location>&)));
++
++    connect(m_friendsListPanel, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
++            this, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
  }
  
  void MainWindow::buildIndicatorButton()
@@@ -497,23 -489,16 +490,25 @@@ signals
      void friendsLocationsReady(QList<User *> &friendsList);
  
      /**
 +    * @brief Emited when location request is parsed and is ready for further processing
 +    *
 +    * @param result List of Location items
 +    */
 +    void locationDataParsed(QList<Location> &result);
 +
 +    /**
-     * @brief Signal is emitted when location item is clicked.
-     *
-     * @param userIDs list of friends user IDs in the group
-     */
+      * @brief Signal is emitted when location item is clicked.
+      *
+      * @param userIDs list of friends user IDs in the group
+      */
      void locationItemClicked(const QList<QString> &userIDs);
  
++    void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
++
      /**
-     * @brief Signals when Login/Logout action is pressed
-     *
-     */
+      * @brief Signals when Login/Logout action is pressed
+      *
+      */
      void loginActionPressed();
  
      /**