summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-07-23 06:00:05 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-07-23 10:07:01 (GMT)
commit93f97f5c3a20a54fe2ad4ec7eee994060c7bd2e3 (patch)
treee93c76eb1336d47815d7a862c2164792e05d23cd
parent4f54177f83d4847bbfb1e5ff34df59fe2b5973ef (diff)
Report additional role names
-rw-r--r--src/lib/marble/GeoDataTreeModel.cpp29
-rw-r--r--src/lib/marble/GeoDataTreeModel.h2
2 files changed, 30 insertions, 1 deletions
diff --git a/src/lib/marble/GeoDataTreeModel.cpp b/src/lib/marble/GeoDataTreeModel.cpp
index 4f4c953..8ece7fc 100644
--- a/src/lib/marble/GeoDataTreeModel.cpp
+++ b/src/lib/marble/GeoDataTreeModel.cpp
@@ -49,6 +49,7 @@ class Q_DECL_HIDDEN GeoDataTreeModel::Private {
GeoDataDocument* m_rootDocument;
bool m_ownsRootDocument;
QItemSelectionModel m_selectionModel;
+ QHash<int, QByteArray> m_roleNames;
};
GeoDataTreeModel::Private::Private( QAbstractItemModel *model ) :
@@ -56,7 +57,24 @@ GeoDataTreeModel::Private::Private( QAbstractItemModel *model ) :
m_ownsRootDocument( true ),
m_selectionModel( model )
{
- // nothing to do
+ m_roleNames[MarblePlacemarkModel::DescriptionRole] = "description";
+ m_roleNames[MarblePlacemarkModel::IconPathRole] = "iconPath";
+ m_roleNames[MarblePlacemarkModel::PopularityIndexRole] = "zoomLevel";
+ m_roleNames[MarblePlacemarkModel::VisualCategoryRole] = "visualCategory";
+ m_roleNames[MarblePlacemarkModel::AreaRole] = "area";
+ m_roleNames[MarblePlacemarkModel::PopulationRole] = "population";
+ m_roleNames[MarblePlacemarkModel::CountryCodeRole] = "countryCode";
+ m_roleNames[MarblePlacemarkModel::StateRole] = "state";
+ m_roleNames[MarblePlacemarkModel::PopularityRole] = "popularity";
+ m_roleNames[MarblePlacemarkModel::GeoTypeRole] = "role";
+ m_roleNames[MarblePlacemarkModel::CoordinateRole] = "coordinate";
+ m_roleNames[MarblePlacemarkModel::StyleRole] = "style";
+ m_roleNames[MarblePlacemarkModel::GmtRole] = "gmt";
+ m_roleNames[MarblePlacemarkModel::DstRole] = "dst";
+ m_roleNames[MarblePlacemarkModel::GeometryRole] = "geometry";
+ m_roleNames[MarblePlacemarkModel::ObjectPointerRole] = "objectPointer";
+ m_roleNames[MarblePlacemarkModel::LongitudeRole] = "longitude";
+ m_roleNames[MarblePlacemarkModel::LatitudeRole] = "latitude";
}
GeoDataTreeModel::Private::~Private()
@@ -84,6 +102,10 @@ GeoDataTreeModel::GeoDataTreeModel( QObject *parent )
: QAbstractItemModel( parent ),
d( new Private( this ) )
{
+ auto const roleNames = QAbstractItemModel::roleNames();
+ for(auto iter = roleNames.constBegin(); iter != roleNames.constEnd(); ++iter) {
+ d->m_roleNames[iter.key()] = iter.value();
+ }
}
GeoDataTreeModel::~GeoDataTreeModel()
@@ -225,6 +247,11 @@ QVariant GeoDataTreeModel::headerData(int section, Qt::Orientation orientation,
return QVariant();
}
+QHash<int, QByteArray> GeoDataTreeModel::roleNames() const
+{
+ return d->m_roleNames;
+}
+
QVariant GeoDataTreeModel::data( const QModelIndex &index, int role ) const
{
// mDebug() << "data";
diff --git a/src/lib/marble/GeoDataTreeModel.h b/src/lib/marble/GeoDataTreeModel.h
index 8a39f8a..b7a9ee5 100644
--- a/src/lib/marble/GeoDataTreeModel.h
+++ b/src/lib/marble/GeoDataTreeModel.h
@@ -58,6 +58,8 @@ class MARBLE_EXPORT GeoDataTreeModel : public QAbstractItemModel
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
+ QHash<int, QByteArray> roleNames() const override;
+
QVariant data( const QModelIndex &index, int role ) const;
QModelIndex index( int row, int column,