Merge branch 'new_panels' into locationlistview
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 17 Aug 2010 08:48:20 +0000 (11:48 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 17 Aug 2010 08:48:20 +0000 (11:48 +0300)
Conflicts:
src/ui/friendlistpanel.cpp

1  2 
src/ui/friendlistpanel.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/routingpanel.cpp

Simple merge
Simple merge
Simple merge
index a87c310,0000000..ebd75c6
mode 100644,000000..100644
--- /dev/null
@@@ -1,147 -1,0 +1,147 @@@
 +#include "coordinates/geocoordinate.h"
 +#include "locationlistitem.h"
 +#include "locationlistview.h"
 +#include "extendedlistitemdelegate.h"
 +#include "routing/location.h"
 +#include "routing/route.h"
 +#include "routewaypointlistview.h"
 +#include "routewaypointlistitem.h"
 +#include "panelcommon.h"
 +
 +#include "routingpanel.h"
 +
 +RoutingPanel::RoutingPanel(QWidget *parent)
 +    : QWidget(parent)
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    QVBoxLayout *routingLayout = new QVBoxLayout;
 +    routingLayout->setMargin(0);
 +    routingLayout->setSpacing(0);
 +    setLayout(routingLayout);
 +
 +    QHBoxLayout *headerLayout = new QHBoxLayout();
-     headerLayout->setContentsMargins(FRIENDPANEL_FILTER_MARGIN_LEFT, 0,
-                                      FRIENDPANEL_FILTER_MARGIN_RIGHT, 0);
++    headerLayout->setContentsMargins(PANEL_MARGIN_LEFT, 0,
++                                     PANEL_MARGIN_RIGHT, 0);
 +
 +    QVBoxLayout *listViewLayout = new QVBoxLayout;
 +    listViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, 0, PANEL_MARGIN_RIGHT, 0);
 +
 +    m_searchLocationButton = new QPushButton(tr("Search location"));
 +
 +    m_routeButton = new QPushButton(tr("Route to location"));
 +    m_routeButton->hide();
 +
 +    m_locationListHeaderWidget = new QWidget();
 +    m_locationListHeaderWidget->setLayout(headerLayout);
 +    m_locationListHeaderWidget->setAutoFillBackground(true);
 +    QPalette labelPalette = m_locationListHeaderWidget->palette();
 +    labelPalette.setColor(QPalette::Background, Qt::black);
 +    m_locationListHeaderWidget->setPalette(labelPalette);
 +    m_locationListHeaderWidget->hide();
 +
 +    m_locationListLabel = new QLabel(this);
 +
 +    m_locationListView = new LocationListView(this);
 +    m_locationListView->setItemDelegate(new ExtendedListItemDelegate(this));
 +    m_locationListView->hide();
 +
 +    m_routeWaypointListView = new RouteWaypointListView(this);
 +    m_routeWaypointListView->setItemDelegate(new ExtendedListItemDelegate(this));
 +    m_routeWaypointListView->hide();
 +
 +    headerLayout->addWidget(m_locationListLabel, 0, Qt::AlignCenter);
 +
 +    listViewLayout->addWidget(m_locationListView);
 +    listViewLayout->addWidget(m_routeWaypointListView);
 +
 +    routingLayout->addWidget(m_searchLocationButton);
 +    routingLayout->addWidget(m_routeButton);
 +    routingLayout->addWidget(m_locationListHeaderWidget);
 +    routingLayout->addLayout(listViewLayout);
 +
 +    connect(m_locationListView,
 +            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
 +            this,
 +            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
 +
 +    connect(m_routeButton, SIGNAL(clicked()),
 +            this, SLOT(routeToSelectedLocation()));
 +
 +    connect(m_routeWaypointListView, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
 +            this, SIGNAL(routeWaypointItemClicked(GeoCoordinate)));
 +
 +    connect(m_searchLocationButton, SIGNAL(clicked()),
 +            this, SIGNAL(requestSearchLocation()));
 +}
 +
 +void RoutingPanel::populateLocationListView(const QList<Location> &locations)
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    m_routeButton->show();
 +
 +    m_locationListHeaderWidget->show();
 +    m_locationListLabel->setText(tr("Search results: %1").arg(locations.count()));
 +
 +    m_routeWaypointListView->hide();
 +    m_locationListView->show();
 +    m_locationListView->clearList();
 +
 +    for (int i = 0; i < locations.size(); ++i) {
 +        LocationListItem *item = new LocationListItem();
 +        item->setLocationData(locations.at(i));
 +        m_locationListView->addListItem(QString::number(i), item);
 +    }
 +
 +    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->setSelectedItem(item);
 +    }
 +
 +    m_locationListView->scrollToTop();
 +}
 +
 +void RoutingPanel::routeToSelectedLocation()
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    LocationListItem *item = dynamic_cast<LocationListItem *>
 +                             (m_locationListView->selectedItem());
 +
 +    if (item)
 +        emit routeToLocation(item->coordinates());
 +}
 +
 +void RoutingPanel::setRoute(Route &route)
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    m_routeButton->hide();
 +
 +    m_locationListHeaderWidget->hide();
 +    m_locationListView->hide();
 +    m_routeWaypointListView->show();
 +    m_routeWaypointListView->clearList();
 +
 +    QList<RouteSegment> segments = route.segments();
 +    QList<GeoCoordinate> geometryPoints = route.geometryPoints();
 +
 +    for (int i = 0; i < segments.size(); ++i) {
 +        RouteWaypointListItem *item = new RouteWaypointListItem();
 +        RouteSegment routeSegment = segments.at(i);
 +        item->setRouteWaypointData(routeSegment,
 +                                   geometryPoints.at(routeSegment.positionIndex()));
 +
 +        m_routeWaypointListView->addListItem(QString::number(i), item);
 +    }
 +
 +    m_routeWaypointListView->scrollToTop();
 +
 +    emit showPanelRequested(this);
 +}