[Marble-commits] KDE/kdeedu/marble/src/plugins/runner/localdatabase
Thibaut Gridel
tgridel at free.fr
Sat Jan 15 14:34:41 CET 2011
SVN commit 1214590 by tgridel:
LocalDatabase: use a QAbstractItemModel
M +6 -20 LocalDatabaseRunner.cpp
--- trunk/KDE/kdeedu/marble/src/plugins/runner/localdatabase/LocalDatabaseRunner.cpp #1214589:1214590
@@ -46,13 +46,12 @@
QVector<GeoDataPlacemark*> vector;
if (model()) {
- MarblePlacemarkModel * placemarkModel =
- qobject_cast<MarblePlacemarkModel*>( model()->placemarkModel() );
+ QAbstractItemModel * placemarkModel = model()->placemarkModel();
if (placemarkModel) {
QModelIndexList resultList;
QModelIndex firstIndex = placemarkModel->index( 0, 0 );
- resultList = placemarkModel->approxMatch( firstIndex,
+ resultList = placemarkModel->match( firstIndex,
Qt::DisplayRole, searchTerm, -1,
Qt::MatchStartsWith );
@@ -62,26 +61,13 @@
mDebug() << "invalid index!!!";
continue;
}
- QString name = index.data( Qt::DisplayRole ).toString();
- GeoDataPlacemark *placemark = new GeoDataPlacemark;
- placemark->setName( name );
- GeoDataCoordinates coordinates =
- qvariant_cast<GeoDataCoordinates>( index.data( MarblePlacemarkModel::CoordinateRole ) );
- placemark->setCoordinate( coordinates.longitude(),
- coordinates.latitude() );
-
- int visualCategory = qvariant_cast<int>(
- index.data( MarblePlacemarkModel::VisualCategoryRole ) );
- placemark->setVisualCategory( static_cast<GeoDataFeature::GeoDataVisualCategory>(visualCategory) );
-
- // FIXME: We don't always want to have it this prominent
- placemark->setPopularity( 1000000000 );
- placemark->setPopularityIndex( 18 );
-
- vector.append( placemark );
+ GeoDataPlacemark *placemark = dynamic_cast<GeoDataPlacemark*>(qvariant_cast<GeoDataObject*>( index.data( MarblePlacemarkModel::ObjectPointerRole )));
+ if ( placemark ) {
+ vector.append( new GeoDataPlacemark( *placemark ));
}
}
}
+ }
emit searchFinished( vector );
}
More information about the Marble-commits
mailing list