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()
zoomed();
}
}
++
++void MapEngine::locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound)
++{
++ qDebug() << __PRETTY_FUNCTION__;
++
++ centerAndZoomTo(QRect(SceneCoordinate(swBound).toPointF().toPoint(),
++ SceneCoordinate(neBound).toPointF().toPoint()));
++}
*/
void zoomOut();
++ void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
++
/*******************************************************************************
* SIGNALS
******************************************************************************/
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"
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)),
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)
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__;
class GeoCoordinate;
class ListView;
class User;
+class Location;
++class LocationListView;
/**
* @brief Class for sliding friends list panel
*/
void findFriend(const GeoCoordinate &coordinates);
++ void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
++
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
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
};
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__;
*/
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
--- /dev/null
+#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);
+}
--- /dev/null
+#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
--- /dev/null
--- /dev/null
++#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);
++ }
++}
--- /dev/null
--- /dev/null
++#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
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()
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();
/**