return roles;
}
+int StationListModel::rowCount(const QModelIndex &parent) const
+{
+ return QStandardItemModel::rowCount(parent);
+
+}
+
void StationListModel::readStationsElement()
{
m_reader.readNext();
if (m_reader.name() == "station") {
readStationElement();
} else {
- skipUnknownElement();
+ skipUnknownElement(m_reader.name().toString());
}
} else {
m_reader.readNext();
} else if (m_reader.name() == "code") {
readCodeElement(item);
} else {
- skipUnknownElement();
+ skipUnknownElement(m_reader.name().toString());
}
} else {
m_reader.readNext();
}
}
-void StationListModel::skipUnknownElement()
+void StationListModel::skipUnknownElement(const QString &name)
{
- qDebug() << "skipping unknown element";
+ qDebug() << "skipping unknown element" << name << "at line" << m_reader.lineNumber();
m_reader.readNext();
while (!m_reader.atEnd()) {
m_reader.readNext();
break;
} else if (!m_reader.isStartElement()) {
- skipUnknownElement();
+ skipUnknownElement(m_reader.name().toString());
} else {
m_reader.readNext();
}
{
Q_OBJECT
Q_ENUMS(StationListRole)
+ Q_PROPERTY(int count READ rowCount)
+
public:
enum StationListRole {
PositionRole = Qt::UserRole + 1, //< QGeoCoordinate - Station coordinate
QHash<int, QByteArray> roleNames() const;
+ // Needed to make SectionScroller happy.
+ Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const;
+
+
signals:
public slots:
void readPosElement(QStandardItem *item);
void readNameElement(QStandardItem *item);
void readCodeElement(QStandardItem *item);
- void skipUnknownElement();
+ void skipUnknownElement(const QString &name = QString());
QXmlStreamReader m_reader;
};