1 #include "stationlistproxymodel.h"
2 #include "stationlistmodel.h"
5 #include <QGeoCoordinate>
9 Q_DECLARE_METATYPE(QGeoCoordinate)
11 StationListProxyModel::StationListProxyModel(QObject *parent) :
12 QSortFilterProxyModel(parent),
17 bool StationListProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
19 int role = sortRole();
21 qDebug() << "lessThan called";
23 if (role == StationListModel::PositionRole) {
24 QGeoCoordinate first = left.data(role).value<QGeoCoordinate>();
25 QGeoCoordinate second = right.data(role).value<QGeoCoordinate>();
26 qDebug() << "PositionRole" << left.data(Qt::DisplayRole) << first << right.data(Qt::DisplayRole) << second << "Here" << m_here;
27 return first.distanceTo(m_here) < second.distanceTo(m_here);
29 qDebug() << "OtherRole";
30 return QString::compare(left.data(role).toString(),
31 right.data(role).toString(),
32 sortCaseSensitivity()) < 0;
36 void StationListProxyModel::setUserPosition(const QtMobility::QGeoCoordinate &pos)