List classes reviewed and fixed review observations.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 11 Aug 2010 13:28:17 +0000 (16:28 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 11 Aug 2010 13:28:17 +0000 (16:28 +0300)
Reviewed by: Sami Rämö

28 files changed:
src/engine/engine.cpp
src/map/mapengine.cpp
src/map/mapengine.h
src/routing/geocodingservice.h
src/ui/extendedlistitemdelegate.cpp
src/ui/extendedlistitemstore.cpp
src/ui/extendedlistitemstore.h
src/ui/friendlistitem.cpp
src/ui/friendlistitem.h
src/ui/friendlistitemdelegate.cpp
src/ui/friendlistview.cpp
src/ui/listcommon.h
src/ui/listitem.cpp
src/ui/listitem.h
src/ui/listitemdelegate.cpp
src/ui/listitemdelegate.h
src/ui/listview.cpp
src/ui/locationlistitem.cpp
src/ui/locationlistitem.h
src/ui/locationlistview.cpp
src/ui/locationlistview.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/routingpanel.cpp
src/ui/routingpanel.h
tests/ui/friendlistitem/testfriendlistitem.cpp
tests/ui/listview/listview.pro [deleted file]
tests/ui/listview/testlistview.cpp [deleted file]

index a05ccfc..175f28d 100644 (file)
@@ -569,8 +569,8 @@ void SituareEngine::signalsFromGeocodingService()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    connect(m_geocodingService, SIGNAL(locationDataParsed(QList<Location>&)),
-            m_ui, SIGNAL(locationDataParsed(QList<Location>&)));
+    connect(m_geocodingService, SIGNAL(locationDataParsed(const QList<Location>&)),
+            m_ui, SIGNAL(locationDataParsed(const QList<Location>&)));
 }
 
 void SituareEngine::signalsFromGPS()
@@ -652,8 +652,10 @@ void SituareEngine::signalsFromMainWindow()
             m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
 
     // signals from routing tab
-    connect(m_ui, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
-            m_mapEngine, SLOT(showMapArea(GeoCoordinate&,GeoCoordinate&)));
+    connect(m_ui,
+            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
+            m_mapEngine,
+            SLOT(showMapArea(const GeoCoordinate&, const GeoCoordinate&)));
 
     // signals from distence indicator button
     connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
index 4c239be..6ec3f04 100644 (file)
@@ -484,7 +484,7 @@ void MapEngine::setTilesGridSize(const QSize &viewSize)
     m_tilesGridSize.setWidth(gridWidth);
 }
 
-void MapEngine::showMapArea(GeoCoordinate &swBound, GeoCoordinate &neBound)
+void MapEngine::showMapArea(const GeoCoordinate &swBound, const GeoCoordinate &neBound)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
index f60a9bf..fae035c 100644 (file)
@@ -322,7 +322,7 @@ private slots:
     * @param swBound south-west bound of location item
     * @param neBound north-east bound of location item
     */
-    void showMapArea(GeoCoordinate &swBound, GeoCoordinate &neBound);
+    void showMapArea(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
 
     /**
      * @brief Slot for actions after view zoom is finished
index c982fa2..c851734 100644 (file)
@@ -103,7 +103,7 @@ signals:
     *
     * @param result List of Location items
     */
-    void locationDataParsed(QList<Location> &result);
+    void locationDataParsed(const QList<Location> &result);
 
 /*******************************************************************************
  * DATA MEMBERS
index cf4015c..50bc9d6 100644 (file)
@@ -70,8 +70,8 @@ void ExtendedListItemDelegate::paint(QPainter *painter, const QStyleOptionViewIt
             }
 
             QRect iconRect = QRect(itemRect.left() + MARGIN * 3,
-                                       previousSubItemTextRectBottom + ICON_MARGIN,
-                                       ICON_WIDTH, ICON_HEIGHT);
+                                   previousSubItemTextRectBottom + ICON_MARGIN,
+                                   ICON_WIDTH, ICON_HEIGHT);
 
             if (itemHasImage)
                 iconRect.translate(IMAGE_WIDTH, 0);
index 603ca8d..dcab599 100644 (file)
@@ -32,39 +32,39 @@ ExtendedListItemStore::ExtendedListItemStore(const QString &text)
     qDebug() << __PRETTY_FUNCTION__;
 }
 
-void ExtendedListItemStore::setIcon(const QPixmap &icon)
+QPixmap ExtendedListItemStore::icon() const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_icon = icon;
+    return m_icon;
 }
 
-void ExtendedListItemStore::setShortenedText(const QString &shortenedText)
+void ExtendedListItemStore::setIcon(const QPixmap &icon)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_shortenedText = shortenedText;
+    m_icon = icon;
 }
 
-void ExtendedListItemStore::setTextRect(const QRect &textRect)
+void ExtendedListItemStore::setShortenedText(const QString &shortenedText)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_textRect = textRect;
+    m_shortenedText = shortenedText;
 }
 
-QPixmap ExtendedListItemStore::icon() const
+QString ExtendedListItemStore::shortenedText() const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    return m_icon;
+    return m_shortenedText;
 }
 
-QString ExtendedListItemStore::shortenedText() const
+void ExtendedListItemStore::setTextRect(const QRect &textRect)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    return m_shortenedText;
+    m_textRect = textRect;
 }
 
 QString ExtendedListItemStore::text() const
index 9b37760..e5ebd63 100644 (file)
@@ -48,11 +48,11 @@ public:
 ******************************************************************************/
 public:
     /**
-    * @brief Sets shortended text.
+    * @brief Returns icon.
     *
-    * @param shortenedText shortened text
+    * @return QPixmap
     */
-    void setShortenedText(const QString &shortenedText);
+    QPixmap icon() const;
 
     /**
     * @brief Sets icon.
@@ -62,25 +62,25 @@ public:
     void setIcon(const QPixmap &icon);
 
     /**
-    * @brief Sets text rect.
+    * @brief Sets shortended text.
     *
-    * @param textRect text rect
+    * @param shortenedText shortened text
     */
-    void setTextRect(const QRect &textRect);
+    void setShortenedText(const QString &shortenedText);
 
     /**
-    * @brief Returns icon.
+    * @brief Returns shortened text.
     *
-    * @return QPixmap
+    * @return QString
     */
-    QPixmap icon() const;
+    QString shortenedText() const;
 
     /**
-    * @brief Returns text rect.
+    * @brief Sets text rect.
     *
-    * @return QRect
+    * @param textRect text rect
     */
-    QRect textRect() const;
+    void setTextRect(const QRect &textRect);
 
     /**
     * @brief Returns text
@@ -90,11 +90,11 @@ public:
     QString text() const;
 
     /**
-    * @brief Returns shortened text.
+    * @brief Returns text rect.
     *
-    * @return QString
+    * @return QRect
     */
-    QString shortenedText() const;
+    QRect textRect() const;
 
 /******************************************************************************
 * DATA MEMBERS
index f2e4e05..c4491f2 100644 (file)
 
 #include "friendlistitem.h"
 
-const int AEROPLANE_DISTANCE = 5000;///< Aeroplane distance limit for distance icon
-const int CAR_DISTANCE = 500;       ///< Car distance limit for distance icon
-const int WALK_DISTANCE = 5;        ///< Walk distance limit for distance icon
-
 FriendListItem::FriendListItem()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -40,7 +36,7 @@ FriendListItem::FriendListItem()
     setSubitemTextWidth(SUBITEM_TEXT_MAX_WIDTH);
 }
 
-GeoCoordinate FriendListItem::coordinates()
+GeoCoordinate FriendListItem::coordinates() const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -51,36 +47,33 @@ void FriendListItem::setUserData(User *user)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if(user) {
-
-        QString unit;
-        double value;
-        user->distance(value, unit);
-        QString distanceText = QString::number(value) + " " + unit;
-        setData(DISTANCE_TEXT_DISPLAY_INDEX, distanceText);
-        setDistanceIcon(value, unit);
-
-        //Dummy value to get painter font metrics.
-        QPixmap p = QPixmap(ICON_WIDTH, ICON_HEIGHT);
-        QPainter painter(&p);
-        painter.setFont(NOKIA_FONT_SMALL);
-        QFontMetrics distanceTextFontMetrics = painter.fontMetrics();
-        QRect distanceRect = distanceTextFontMetrics.boundingRect(distanceText);
-
-        setData(DISTANCE_SIZE_HINT_INDEX, distanceRect);
-        setName(shortenText(user->name(), NAME_TEXT_MAX_WIDTH - distanceRect.width() + MARGIN,
-                            ListItem::TEXT_SIZE_NORMAL));
-        setCoordinates(user->coordinates());
-
-        if (!user->profileImage().isNull())
-            setImage(user->profileImage());
-
-        clearSubItems();
-
-        addSubItem(user->note(), QPixmap(":/res/images/envelope.png"));
-        addSubItem(user->address(), QPixmap(":/res/images/compass.png"));
-        addSubItem(user->timestamp(), QPixmap(":/res/images/clock.png"));
-    }
+    QString unit;
+    double value;
+    user->distance(value, unit);
+    QString distanceText = QString::number(value) + " " + unit;
+    setData(DISTANCE_TEXT_DISPLAY_INDEX, distanceText);
+    setDistanceIcon(value, unit);
+
+    //Dummy value to get painter font metrics.
+    QPixmap p = QPixmap(ICON_WIDTH, ICON_HEIGHT);
+    QPainter painter(&p);
+    painter.setFont(NOKIA_FONT_SMALL);
+    QFontMetrics distanceTextFontMetrics = painter.fontMetrics();
+    QRect distanceRect = distanceTextFontMetrics.boundingRect(distanceText);
+
+    setData(DISTANCE_SIZE_HINT_INDEX, distanceRect);
+    setTitle(shortenText(user->name(), NAME_TEXT_MAX_WIDTH - distanceRect.width() + MARGIN,
+                        ListItem::TEXT_SIZE_NORMAL));
+    setCoordinates(user->coordinates());
+
+    if (!user->profileImage().isNull())
+        setImage(user->profileImage());
+
+    clearSubItems();
+
+    addSubItem(user->note(), QPixmap(":/res/images/envelope.png"));
+    addSubItem(user->address(), QPixmap(":/res/images/compass.png"));
+    addSubItem(user->timestamp(), QPixmap(":/res/images/clock.png"));
 }
 
 void FriendListItem::setAvatarImage(const QPixmap &image)
@@ -102,6 +95,10 @@ void FriendListItem::setDistanceIcon(double value, const QString &unit)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    const int AEROPLANE_DISTANCE = 5000;///< Aeroplane distance limit for distance icon
+    const int CAR_DISTANCE = 500;       ///< Car distance limit for distance icon
+    const int WALK_DISTANCE = 5;        ///< Walk distance limit for distance icon
+
     QPixmap distanceImage;
 
     if ((unit == "m") || (value < WALK_DISTANCE))
index ee39146..07ded37 100644 (file)
@@ -57,7 +57,7 @@ public:
     *
     * @return item's coordinates
     */
-    GeoCoordinate coordinates();
+    GeoCoordinate coordinates() const;
 
     /**
     * @brief Sets item's coordinates.
index 174a830..06cd57d 100644 (file)
@@ -47,10 +47,12 @@ void FriendListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
 
     QRect itemRect = option.rect;
 
-    QPoint distanceIconPoint = QPoint(ITEM_WIDTH - ICON_WIDTH - 3*MARGIN, itemRect.top() + MARGIN);
+    QPoint distanceIconPoint = QPoint(ITEM_WIDTH - ICON_WIDTH - 3 * MARGIN,
+                                      itemRect.top() + MARGIN);
+
     QRect distanceRect = index.data(DISTANCE_SIZE_HINT_INDEX).toRect();
-    distanceRect.translate(ITEM_WIDTH - distanceRect.width() - 2*MARGIN,
-                           itemRect.top() + ICON_HEIGHT + 3*MARGIN);
+    distanceRect.translate(ITEM_WIDTH - distanceRect.width() - 2 * MARGIN,
+                           itemRect.top() + ICON_HEIGHT + 3 * MARGIN);
 
     painter->drawPixmap(distanceIconPoint, distanceIcon);
     painter->drawText(distanceRect, Qt::TextSingleLine, distance);
index 0f4a840..a0ef305 100644 (file)
@@ -2,9 +2,7 @@
    Situare - A location system for Facebook
    Copyright (C) 2010  Ixonos Plc. Authors:
 
-       Kaj Wallin - kaj.wallin@ixonos.com
-       Henri Lampela - henri.lampela@ixonos.com
-       Pekka Nissinen - pekka.nissinen@ixonos.com
+       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
index a7f3fff..1b01d34 100644 (file)
@@ -48,7 +48,7 @@ const int NAME_TEXT_MAX_WIDTH = ITEM_WIDTH - 3 * MARGIN - IMAGE_WIDTH;
 const int SUBITEM_TEXT_MAX_WIDTH = ITEM_WIDTH - 3 * MARGIN - IMAGE_WIDTH - MARGIN - ICON_WIDTH
                                    - MARGIN * 2;
 
-const int NAME_DISPLAY_INDEX = Qt::DisplayRole;
+const int TITLE_DISPLAY_INDEX = Qt::DisplayRole;
 const int AVATAR_IMAGE_INDEX = Qt::DecorationRole;
 
 const int ITEM_SIZE_HINT_INDEX = Qt::SizeHintRole;
index 71cdccc..a2f08d5 100644 (file)
@@ -34,11 +34,11 @@ ListItem::ListItem()
     setSize(QSize(ITEM_WIDTH, ITEM_MIN_HEIGHT));
 }
 
-QString ListItem::name() const
+QString ListItem::title() const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    return data(NAME_DISPLAY_INDEX).toString();
+    return data(TITLE_DISPLAY_INDEX).toString();
 }
 
 void ListItem::setImage(const QPixmap &image)
@@ -50,11 +50,11 @@ void ListItem::setImage(const QPixmap &image)
 
 }
 
-void ListItem::setName(const QString &name)
+void ListItem::setTitle(const QString &title)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    setData(NAME_DISPLAY_INDEX, name);
+    setData(TITLE_DISPLAY_INDEX, title);
 }
 
 void ListItem::setSize(const QSize &size)
index 60bfdd7..7c6e320 100644 (file)
@@ -49,11 +49,11 @@ public:
 * MEMBER FUNCTIONS AND SLOTS
 ******************************************************************************/
     /**
-    * @brief Returns item's name.
+    * @brief Returns item's title.
     *
-    * @return item's name
+    * @return item's title
     */
-    QString name() const;
+    QString title() const;
 
     /**
     * @brief Sets item's image.
@@ -63,11 +63,11 @@ public:
     void setImage(const QPixmap &image);
 
     /**
-    * @brief Sets item's name.
+    * @brief Sets item's title.
     *
-    * @param name item's name
+    * @param name item's title
     */
-    void setName(const QString &name);
+    void setTitle(const QString &name);
 
     /**
     * @brief Sets item selected.
index c1d3094..c6ed37d 100644 (file)
@@ -49,7 +49,7 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
     qDebug() << __PRETTY_FUNCTION__;
 
     QPixmap image = QPixmap(qvariant_cast<QPixmap>(index.data(AVATAR_IMAGE_INDEX)));
-    QString name = index.data(NAME_DISPLAY_INDEX).toString();
+    QString name = index.data(TITLE_DISPLAY_INDEX).toString();
     QSize size = index.data(ITEM_SIZE_HINT_INDEX).toSize();
 
     QRect itemRect = option.rect;
index 524b26a..b10118b 100644 (file)
@@ -72,7 +72,7 @@ public:
 private:
     QPixmap m_backgroundBottomImage;   ///< Bottom background image
     QPixmap m_backgroundMiddleImage;   ///< Middle background image
-    QPixmap m_backgroundTopImage;       ///< Top background image
+    QPixmap m_backgroundTopImage;      ///< Top background image
 };
 
 #endif // LISTITEMDELEGATE_H
index cc3be74..c070361 100644 (file)
@@ -115,7 +115,7 @@ void ListView::filter(const QString &pattern)
     qDebug() << __PRETTY_FUNCTION__;
 
     foreach (ListItem *item, m_listItems) {
-        if (item->name().contains(pattern, Qt::CaseInsensitive))
+        if (item->title().contains(pattern, Qt::CaseInsensitive))
             setItemHidden(item, false);
         else
             setItemHidden(item, true);
index 20accca..8329411 100644 (file)
@@ -14,18 +14,18 @@ LocationListItem::LocationListItem()
     setSubitemTextWidth(LOCATION_SUBITEM_TEXT_MAX_WIDTH);
 }
 
-GeoCoordinate LocationListItem::coordinates()
+void LocationListItem::bounds(GeoCoordinate &swBound, GeoCoordinate &neBound)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    return m_location.coordinates();
+    m_location.viewport(swBound, neBound);
 }
 
-QString LocationListItem::id() const
+GeoCoordinate LocationListItem::coordinates() const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    return QString();
+    return m_location.coordinates();
 }
 
 void LocationListItem::setLocationData(const Location &location)
@@ -36,29 +36,19 @@ void LocationListItem::setLocationData(const Location &location)
 
     QStringList addressComponents = m_location.addressComponents();
 
-    if (addressComponents.count() > 0)
-        setName(shortenText(addressComponents.at(0), ITEM_WIDTH - 3*MARGIN,
-                            ListItem::TEXT_SIZE_NORMAL));
+    if (addressComponents.isEmpty())
+        return;
 
-    QString addressTail;
+    setTitle(shortenText(addressComponents.at(0), ITEM_WIDTH - 3 * MARGIN,
+                            ListItem::TEXT_SIZE_NORMAL));
 
-    for (int i = 1; i < addressComponents.count(); ++i) {
-        addressTail.append(addressComponents.at(i));
+    addressComponents.removeFirst();
 
-        if (i < (addressComponents.count() - 1))
-            addressTail.append(", ");
+    if (!addressComponents.isEmpty()) {
+        clearSubItems();
+        addSubItem(addressComponents.join(", "), QPixmap(":/res/images/compass.png"));
     }
 
-    clearSubItems();
-    addSubItem(addressTail, QPixmap(":/res/images/compass.png"));
-
-}
-
-void LocationListItem::bounds(GeoCoordinate &swBound, GeoCoordinate &neBound)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_location.viewport(swBound, neBound);
 }
 
 LocationListItem::~LocationListItem()
index b4661bd..19b4f3a 100644 (file)
@@ -62,14 +62,7 @@ public:
     *
     * @return item's coordinates
     */
-    GeoCoordinate coordinates();
-
-    /**
-    * @brief Returns item's ID.
-    *
-    * @return item's ID
-    */
-    QString id() const;
+    GeoCoordinate coordinates() const;
 
 /******************************************************************************
 * MEMBER FUNCTIONS AND SLOTS
index eacfcc9..9a3a52b 100644 (file)
@@ -1,3 +1,24 @@
+/*
+   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 "locationlistitem.h"
 
 #include "locationlistview.h"
index c26934e..eb8970c 100644 (file)
@@ -56,7 +56,7 @@ signals:
     * @param swBound south-west bound in GeoCoorinate
     * @param neBound north-east bound in GeoCoordinate
     */
-    void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
+    void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
 };
 
 #endif // LOCATIONLISTVIEW_H
index f30bdca..137a783 100644 (file)
@@ -320,11 +320,13 @@ void MainWindow::buildRoutingPanel()
 
     m_routingPanel = new RoutingPanel(this);
 
-    connect(this, SIGNAL(locationDataParsed(QList<Location>&)),
-            m_routingPanel, SLOT(populateLocationListView(QList<Location>&)));
+    connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
+            m_routingPanel, SLOT(populateLocationListView(const QList<Location>&)));
 
-    connect(m_routingPanel, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
-            this, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
+    connect(m_routingPanel,
+            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
+            this,
+            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
 }
 
 void MainWindow::buildUserInfoPanel()
index 32cf580..a053cd8 100644 (file)
@@ -497,7 +497,7 @@ signals:
     *
     * @param result List of Location items
     */
-    void locationDataParsed(QList<Location> &result);
+    void locationDataParsed(const QList<Location> &result);
 
     /**
      * @brief Signal is emitted when location item is clicked on map.
@@ -512,7 +512,7 @@ signals:
      * @param swBound south-west bound in GeoCoorinate
      * @param neBound north-east bound in GeoCoordinate
      */
-    void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
+    void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
 
     /**
      * @brief Signals when Login/Logout action is pressed
index 6479f5f..fa7c09c 100644 (file)
@@ -44,11 +44,13 @@ RoutingPanel::RoutingPanel(QWidget *parent)
     routingLayout->addWidget(m_locationListHeaderWidget);
     routingLayout->addLayout(listViewLayout);
 
-    connect(m_locationListView, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
-            this, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
+    connect(m_locationListView,
+            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
+            this,
+            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
 }
 
-void RoutingPanel::populateLocationListView(QList<Location> &locations)
+void RoutingPanel::populateLocationListView(const QList<Location> &locations)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -65,8 +67,11 @@ void RoutingPanel::populateLocationListView(QList<Location> &locations)
 
     //openPanel();
 
-    if (locations.size() == 1) {
-        ListItem *item = m_locationListView->listItemAt(0);
+    const int FIRST_LOCATION_ITEM_INDEX = 0;
+    const int ONE_LOCATION_ITEM = 1;
+
+    if (locations.size() == ONE_LOCATION_ITEM) {
+        ListItem *item = m_locationListView->listItemAt(FIRST_LOCATION_ITEM_INDEX);
 
         if (item)
             m_locationListView->listItemClicked(item);
index 66bbcfa..1877c6e 100644 (file)
@@ -53,9 +53,9 @@ private slots:
     /**
     * @brief Populates location list view.
     *
-    * @param result list of Location objects
+    * @param locations list of Location objects
     */
-    void populateLocationListView(QList<Location> &locations);
+    void populateLocationListView(const QList<Location> &locations);
 
 /*******************************************************************************
  * SIGNALS
@@ -67,7 +67,7 @@ signals:
     * @param swBound south-west bound GeoCoordinate
     * @param neBound north-east bound GeoCoordinate
     */
-    void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
+    void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
 
 /*******************************************************************************
  * DATA MEMBERS
index 9167ed5..7fc2713 100644 (file)
@@ -108,7 +108,7 @@ void TestFriendListItem::toggleSelection()
     QCOMPARE(subItems->at(2)->textRect(), QRect(0, 0, 250, 48));
 
     friendListItem->toggleSelection();
-    QCOMPARE(friendListItem->data(ITEM_SIZE_HINT_INDEX).toSize(), QSize(368, 142 + 3*24));
+    QCOMPARE(friendListItem->data(ITEM_SIZE_HINT_INDEX).toSize(), QSize(368, 142 + 3 * 24));
     QCOMPARE(friendListItem->data(ITEM_EXPANDED_INDEX).toBool(), true);
 
     friendListItem->toggleSelection();
diff --git a/tests/ui/listview/listview.pro b/tests/ui/listview/listview.pro
deleted file mode 100644 (file)
index bcd62da..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-CONFIG += qtestlib
-DEFINES += QT_NO_DEBUG_OUTPUT
-INCLUDEPATH += . \
-    ../../../src/
-HEADERS += ../../../src/ui/listview.h \
-    ../../../src/ui/listitem.h \
-    ../../../src/ui/extendedlistitem.h \
-    ../../../src/ui/extendedlistitemstore.h \
-    ../../../src/ui/friendlistitem.h \
-    ../../../src/user/user.h \
-    ../../../src/coordinates/scenecoordinate.h \
-    ../../../src/coordinates/geocoordinate.h \
-    ../../../src/ui/friendlistview.h
-SOURCES += ../../../src/ui/listview.cpp \
-    ../../../src/ui/listitem.cpp \
-    ../../../src/ui/extendedlistitem.cpp \
-    ../../../src/ui/extendedlistitemstore.cpp \
-    ../../../src/ui/friendlistitem.cpp \
-    ../../../src/user/user.cpp \
-    testlistview.cpp \
-    ../../../src/coordinates/scenecoordinate.cpp \
-    ../../../src/coordinates/geocoordinate.cpp \
-    ../../../src/ui/friendlistview.cpp
-RESOURCES += ../../../images.qrc
diff --git a/tests/ui/listview/testlistview.cpp b/tests/ui/listview/testlistview.cpp
deleted file mode 100644 (file)
index fb22d35..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
-   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 <QtTest>
-#include <QtGui>
-
-#include "../../../src/ui/friendlistitem.h"
-#include "../../../src/ui/friendlistview.h"
-#include "../../../src/user/user.h"
-
-class TestListView: public QObject
-{
-    Q_OBJECT
-
-private slots:
-    void cleanupTestCase();
-    void initTestCase();
-    void addListItem();
-    void addItemToView();
-    void clearUnused();
-    void filterListByID();
-    void filterListByName();
-    void takeListItemFromView();
-
-private:
-    int hiddenItemCount();
-
-private:
-    FriendListView *friendListView;
-    User *user1;
-    User *user2;
-    User *user3;
-    User *user4;
-};
-
-void TestListView::cleanupTestCase()
-{
-    delete friendListView;
-    delete user1;
-    delete user2;
-    delete user3;
-    delete user4;
-}
-
-void TestListView::initTestCase()
-{
-    friendListView = new FriendListView();
-    QVERIFY(friendListView != 0);
-
-    user1 = new User(QString("Address address address address address"),
-                           GeoCoordinate(12.22, 23.33), QString("John Doe"),
-                           QString("Note note note note note note note note"),
-                           QUrl("http://image.url"), QString("Timestamp timestamp timestamp tim"),
-                           true, QString("key1"), QString("km"), 44.12);
-    user1->setProfileImage(QPixmap(":/res/images/profile_pic_border.png"));
-    user2 = new User(QString("Address address"),
-                           GeoCoordinate(12.1, 44.33), QString("Jane Doe"),
-                           QString("Note note note note note note note note"),
-                           QUrl("http://image.url"), QString("Timestamp timestamp timestamp tim"),
-                           true, QString("key2"), QString("km"), 144.12);
-    user2->setProfileImage(QPixmap(":/res/images/profile_pic_border.png"));
-    user3 = new User(QString("Address address address address address"),
-                           GeoCoordinate(12.22, 23.33), QString("Kate Nameless"),
-                           QString("Note note note note note note note note"),
-                           QUrl("http://image.url"), QString("Timestamp timestamp timestamp tim"),
-                           true, QString("key3"), QString("km"), 44.12);
-    user3->setProfileImage(QPixmap(":/res/images/profile_pic_border.png"));
-    user4 = new User(QString("Address address"),
-                           GeoCoordinate(12.1, 44.33), QString("Jay Nameless"),
-                           QString("Note note note note note note note note"),
-                           QUrl("http://image.url"), QString("Timestamp timestamp timestamp tim"),
-                           true, QString("key4"), QString("km"), 144.12);
-    user4->setProfileImage(QPixmap(":/res/images/profile_pic_border.png"));
-
-    QVERIFY(user1 != 0);
-    QVERIFY(user2 != 0);
-    QVERIFY(user3 != 0);
-    QVERIFY(user4 != 0);
-}
-
-void TestListView::addListItem()
-{
-    friendListView->addListItem("key1", new FriendListItem());
-    QCOMPARE(friendListView->count(), 1);
-
-    friendListView->addListItem("key1", new FriendListItem());
-    QCOMPARE(friendListView->count(), 1);
-
-    friendListView->addListItem("key2", new FriendListItem());
-    QCOMPARE(friendListView->count(), 2);
-}
-
-void TestListView::addItemToView()
-{
-    friendListView->addListItemToView(new FriendListItem());
-    QCOMPARE(friendListView->count(), 3);
-
-    friendListView->addListItemToView(new FriendListItem());
-    QCOMPARE(friendListView->count(), 4);
-
-    friendListView->clearList();
-    QCOMPARE(friendListView->count(), 0);
-}
-
-void TestListView::clearUnused()
-{
-    friendListView->addListItem("key1", new FriendListItem());
-    friendListView->addListItem("key2", new FriendListItem());
-    friendListView->addListItem("key3", new FriendListItem());
-    friendListView->addListItem("key4", new FriendListItem());
-    QCOMPARE(friendListView->count(), 4);
-
-    QStringList newUserIDs;
-    newUserIDs.append("key2");
-    newUserIDs.append("key3");
-    friendListView->clearUnused(newUserIDs);
-    QCOMPARE(friendListView->count(), 2);
-    QVERIFY(friendListView->listItem("key1") == 0);
-    QVERIFY(friendListView->listItem("key2") != 0);
-    QVERIFY(friendListView->listItem("key3") != 0);
-    QVERIFY(friendListView->listItem("key4") == 0);
-}
-
-void TestListView::filterListByID()
-{
-    friendListView->clearList();
-    QCOMPARE(friendListView->count(), 0);
-
-    FriendListItem *item1 = new FriendListItem();
-    FriendListItem *item2 = new FriendListItem();
-    FriendListItem *item3 = new FriendListItem();;
-    FriendListItem *item4 = new FriendListItem();
-
-    item1->setUserData(user1);
-    item2->setUserData(user2);
-    item3->setUserData(user3);
-    item4->setUserData(user4);
-
-    friendListView->addListItem("key1", item1);
-    friendListView->addListItem("key2", item2);
-    friendListView->addListItem("key3", item3);
-    friendListView->addListItem("key4", item4);
-    QCOMPARE(friendListView->count(), 4);
-
-    QList<QString> userIDs;
-    userIDs.append("key1");
-    friendListView->filter(userIDs);
-    QCOMPARE(friendListView->count(), 4);
-    QCOMPARE(hiddenItemCount(), 3);
-
-    userIDs.append("key2");
-    friendListView->filter(userIDs);
-    QCOMPARE(friendListView->count(), 4);
-    QCOMPARE(hiddenItemCount(), 2);
-
-    friendListView->clearFilter();
-    QCOMPARE(hiddenItemCount(), 0);
-}
-
-void TestListView::filterListByName()
-{
-    friendListView->clearList();
-    QCOMPARE(friendListView->count(), 0);
-
-    FriendListItem *item1 = new FriendListItem();
-    FriendListItem *item2 = new FriendListItem();
-    FriendListItem *item3 = new FriendListItem();;
-    FriendListItem *item4 = new FriendListItem();
-
-    item1->setUserData(user1);
-    item2->setUserData(user2);
-    item3->setUserData(user3);
-    item4->setUserData(user4);
-
-    friendListView->addListItem("key1", item1);
-    friendListView->addListItem("key2", item2);
-    friendListView->addListItem("key3", item3);
-    friendListView->addListItem("key4", item4);
-    QCOMPARE(friendListView->count(), 4);
-
-    friendListView->filter("doe");
-    QCOMPARE(hiddenItemCount(), 2);
-
-    friendListView->filter("j");
-    QCOMPARE(hiddenItemCount(), 1);
-
-    friendListView->filter("john");
-    QCOMPARE(hiddenItemCount(), 3);
-
-    friendListView->clearFilter();
-    QCOMPARE(hiddenItemCount(), 0);
-}
-
-void TestListView::takeListItemFromView()
-{
-    QCOMPARE(friendListView->count(), 4);
-
-    ListItem *item = friendListView->takeListItemFromView("key3");
-    QVERIFY(item != 0);
-    QCOMPARE(friendListView->count(), 3);
-
-    friendListView->addListItemToView(item);
-    QCOMPARE(friendListView->count(), 4);
-}
-
-int TestListView::hiddenItemCount()
-{
-    int hiddenCounter = 0;
-
-    for (int i = 0; i < friendListView->count(); ++i) {
-        if (friendListView->item(i)->isHidden())
-            hiddenCounter++;
-    }
-
-    return hiddenCounter;
-}
-
-QTEST_MAIN(TestListView)
-#include "testlistview.moc"