Add Longitude and Latitude to StationListModel
authorLuciano Montanaro <mikelima@cirulla.net>
Sat, 16 Nov 2013 09:47:45 +0000 (10:47 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Sat, 16 Nov 2013 09:47:45 +0000 (10:47 +0100)
This is in preparation to allow the QML to bring up a map of the station
surroundings

application/icons/sailfish/86x86/quandoparte.png [deleted file]
application/icons/sailfish/90x90/quandoparte.png [new file with mode: 0644]
application/stationlistmodel.cpp
application/stationlistmodel.h

diff --git a/application/icons/sailfish/86x86/quandoparte.png b/application/icons/sailfish/86x86/quandoparte.png
deleted file mode 100644 (file)
index f97601a..0000000
Binary files a/application/icons/sailfish/86x86/quandoparte.png and /dev/null differ
diff --git a/application/icons/sailfish/90x90/quandoparte.png b/application/icons/sailfish/90x90/quandoparte.png
new file mode 100644 (file)
index 0000000..f97601a
Binary files /dev/null and b/application/icons/sailfish/90x90/quandoparte.png differ
index 2ee009d..47a87c6 100644 (file)
@@ -87,6 +87,8 @@ QHash<int, QByteArray> StationListModel::roleNames() const
     roles[Qt::DisplayRole] = "name";
     roles[StationListModel::PositionRole] = "position";
     roles[StationListModel::StationCodeRole] = "code";
+    roles[StationListModel::LongitudeRole] = "longitude";
+    roles[StationListModel::LatitudeRole] = "latitude";
     return roles;
 }
 
@@ -145,6 +147,8 @@ void StationListModel::readPosElement(QStandardItem *item)
     QStringList coordinates = m_reader.readElementText().split(",");
     QGeoCoordinate pos = QGeoCoordinate(coordinates[0].toDouble(), coordinates[1].toDouble());
     item->setData(QVariant::fromValue(pos), PositionRole);
+    item->setData(QVariant::fromValue(pos.longitude()), LongitudeRole);
+    item->setData(QVariant::fromValue(pos.latitude()), LatitudeRole);
     m_reader.readElementText();
     if (m_reader.isEndElement()) {
         m_reader.readNext();
index d59f99b..ee5e8f8 100644 (file)
@@ -38,7 +38,9 @@ public:
     enum StationListRole {
         PositionRole = Qt::UserRole + 1, //< QGeoCoordinate - Station coordinate
         StationCodeRole, //< QString - Station Code (Precise name if the Display name is known to fail)
-        RecentIndicatorRole //<bool - If the station has been recently looked up
+        RecentIndicatorRole, //<bool - If the station has been recently looked up
+        LongitudeRole, //< double - Longitude of the station
+        LatitudeRole, //< double - Latitude of the station
     };
 
     explicit StationListModel(QObject *parent = 0);