Add favorite role in StationListModel class
authorLuciano Montanaro <mikelima@cirulla.net>
Sun, 17 Nov 2013 22:16:01 +0000 (23:16 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Sun, 17 Nov 2013 22:16:01 +0000 (23:16 +0100)
application/stationlistmodel.cpp
application/stationlistmodel.h

index 47a87c6..f739b02 100644 (file)
@@ -86,9 +86,12 @@ QHash<int, QByteArray> StationListModel::roleNames() const
     QHash<int, QByteArray> roles;
     roles[Qt::DisplayRole] = "name";
     roles[StationListModel::PositionRole] = "position";
+    roles[StationListModel::RecentIndicatorRole] = "recent";
+    roles[StationListModel::FavoriteIndicatorRole] = "favorite";
     roles[StationListModel::StationCodeRole] = "code";
     roles[StationListModel::LongitudeRole] = "longitude";
     roles[StationListModel::LatitudeRole] = "latitude";
+    roles[StationListModel::SectionRole] = "section";
     return roles;
 }
 
@@ -136,6 +139,7 @@ void StationListModel::readStationElement()
             } else {
                 skipUnknownElement(m_reader.name().toString());
             }
+            item->setData(QVariant::fromValue(false), FavoriteIndicatorRole);
         } else {
             m_reader.readNext();
         }
index ee5e8f8..785122b 100644 (file)
@@ -39,8 +39,10 @@ public:
         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
+        FavoriteIndicatorRole, //<bool - If the station has been marked as favorite
         LongitudeRole, //< double - Longitude of the station
         LatitudeRole, //< double - Latitude of the station
+        SectionRole //< Qstring - The section the station belongs to (depends on the sorting mode)
     };
 
     explicit StationListModel(QObject *parent = 0);