<station>
<pos>45.0609728,7.6778693</pos>
<name>Torino Porta Nuova</name>
+ <code>S00219Torino P.Nuova</code>
</station>
<station>
<pos>44.3513022,9.2313884</pos>
readPosElement(item);
} else if (m_reader.name() == "name") {
readNameElement(item);
+ } else if (m_reader.name() == "code") {
+ readCodeElement(item);
} else {
skipUnknownElement();
}
}
}
+void StationListModel::readCodeElement(QStandardItem *item)
+{
+ const QString code = m_reader.readElementText();
+ qDebug() << "reading code element" << code;
+
+ item->setData(QVariant::fromValue(code), StationCodeRole);
+ if (m_reader.isEndElement()) {
+ m_reader.readNext();
+ }
+}
+
void StationListModel::skipUnknownElement()
{
qDebug() << "skipping unknown element";
public:
enum StationListRole {
PositionRole = Qt::UserRole + 1, //< QGeoCoordinate - Station coordinate
- StationIdRole, //< QString - Station Id (Precise name if the Display name is known to fail)
+ StationCodeRole, //< QString - Station Code (Precise name if the Display name is known to fail)
RecentIndicatorRole //<bool - If the station has been recently looked up
};
void readStationElement();
void readPosElement(QStandardItem *item);
void readNameElement(QStandardItem *item);
+ void readCodeElement(QStandardItem *item);
void skipUnknownElement();
QXmlStreamReader m_reader;