+/*
+
+Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
+*/
+
#include "stationlistmodel.h"
#include <QFile>
+#include <QFileInfo>
#include <QDebug>
#include <QStandardItem>
#include <QGeoCoordinate>
StationListModel::StationListModel(QObject *parent) :
QStandardItemModel(parent)
-
{
setRowCount(0);
}
bool StationListModel::load(const QString &filename)
{
QFile file(filename);
+ QFileInfo fi(file);
- qDebug() << "loading filename:" << filename;
+ qDebug() << "loading file:" << fi.absoluteFilePath();
+ emit layoutAboutToBeChanged();
+ beginResetModel();
if (!file.open(QFile::ReadOnly | QFile::Text)) {
qDebug() << "cannot open file:" << filename;
return false;
qDebug() << "file error for:" << filename;
return false;
}
- /*
- QModelIndex first = index(0, 0);
- QModelIndex last = index(rowCount(), columnCount());
- emit dataChanged(first, last);
- */
+ endResetModel();
emit layoutChanged();
return true;
}
QStringList coordinates = m_reader.readElementText().split(",");
QGeoCoordinate pos = QGeoCoordinate(coordinates[0].toDouble(), coordinates[1].toDouble());
item->setData(QVariant::fromValue(pos), PositionRole);
- qDebug() << "pos:" << pos;
m_reader.readElementText();
if (m_reader.isEndElement()) {
m_reader.readNext();
void StationListModel::readNameElement(QStandardItem *item)
{
item->setText(m_reader.readElementText());
- qDebug() << "name:" << item->text();
if (m_reader.isEndElement()) {
m_reader.readNext();
}