Fixed FacebookLoginBrowser::destroyed() signal handling
[situare] / src / ui / locationlistitem.cpp
1 #include <QDebug>
2
3 #include "../common.h"
4 #include "listcommon.h"
5
6 #include "locationlistitem.h"
7
8 const int LOCATION_SUBITEM_TEXT_MAX_WIDTH = SUBITEM_TEXT_MAX_WIDTH + MARGIN + IMAGE_WIDTH;
9
10 LocationListItem::LocationListItem()
11 {
12     qDebug() << __PRETTY_FUNCTION__;
13
14     setSubitemTextWidth(LOCATION_SUBITEM_TEXT_MAX_WIDTH);
15 }
16
17 void LocationListItem::bounds(GeoCoordinate &swBound, GeoCoordinate &neBound)
18 {
19     qDebug() << __PRETTY_FUNCTION__;
20
21     m_location.viewport(swBound, neBound);
22 }
23
24 GeoCoordinate LocationListItem::coordinates() const
25 {
26     qDebug() << __PRETTY_FUNCTION__;
27
28     return m_location.coordinates();
29 }
30
31 void LocationListItem::setLocationData(const Location &location)
32 {
33     qDebug() << __PRETTY_FUNCTION__;
34
35     m_location = location;
36
37     QStringList addressComponents = m_location.addressComponents();
38
39     if (addressComponents.isEmpty())
40         return;
41
42     setTitle(shortenText(addressComponents.at(0), ITEM_WIDTH - 3 * MARGIN,
43                             ListItem::TEXT_SIZE_NORMAL));
44
45     addressComponents.removeFirst();
46
47     if (!addressComponents.isEmpty()) {
48         clearSubItems();
49         addSubItem(addressComponents.join(", "), QPixmap(":/res/images/compass.png"));
50     }
51
52 }
53
54 LocationListItem::~LocationListItem()
55 {
56     qDebug() << __PRETTY_FUNCTION__;
57 }