[Marble-commits] KDE/kdeedu/marble/src/plugins/render/geodata
Thibaut Gridel
tgridel at free.fr
Fri Jul 16 23:10:26 CEST 2010
SVN commit 1150820 by tgridel:
GeoRenderer: use the GeoDataTreeModel
M +3 -3 GeoRendererPlugin.cpp
M +17 -16 GeoRendererView.cpp
M +1 -1 GeoRendererView.h
--- trunk/KDE/kdeedu/marble/src/plugins/render/geodata/GeoRendererPlugin.cpp #1150819:1150820
@@ -21,7 +21,7 @@
#include "MarbleDirs.h"
#include "MarbleDataFacade.h"
#include "MarbleGeoDataModel.h"
-#include "MarbleGeometryModel.h"
+#include "GeoDataTreeModel.h"
#include "GeoPainter.h"
#include "GeoDataCoordinates.h"
@@ -114,10 +114,10 @@
return true;
}
- if( !dataFacade() || !dataFacade()->geometryModel() )
+ if( !dataFacade() || !dataFacade()->treeModel() )
return false;
- if( !m_view->model() ) m_view->setModel( dataFacade()->geometryModel() );
+ if( !m_view->model() ) m_view->setModel( dataFacade()->treeModel() );
m_view->setGeoPainter( painter );
return true;
}
--- trunk/KDE/kdeedu/marble/src/plugins/render/geodata/GeoRendererView.cpp #1150819:1150820
@@ -24,6 +24,7 @@
#include "GeoDataStyle.h"
#include "GeoDataStyleMap.h"
#include "MarbleDebug.h"
+#include "GeoDataTypes.h"
#include "GeoPainter.h"
@@ -102,25 +103,28 @@
* then call the real render function. For the rest iterate through the
* children and recurse.
*/
- QVariant indexObjectVariant = model()->data( rootIndex(), Qt::UserRole + 11 );
- GeoDataObject* indexObject = indexObjectVariant.value<Marble::GeoDataObject*>();
- if( !( dynamic_cast<GeoDataFeature*>( indexObject )
- && dynamic_cast<GeoDataFeature*>( indexObject )->isVisible() ) ) {
+ if (index.isValid())
+ {
+ GeoDataObject* indexObject = static_cast<GeoDataObject*>(index.internalPointer());
+ if (indexObject->nodeType() == GeoDataTypes::GeoDataDocumentType) {
+ m_root = static_cast<GeoDataDocument*>(indexObject);
+ if (!m_root->isVisible())
+ {
return;
}
+ }
+ }
int rowCount = model()->rowCount( index );
for ( int row = 0; row < rowCount; ++row )
{
QModelIndex childIndex = model()->index( row, 0, index );
- QString output = model()->data( childIndex ).toString();
- QVariant objectVariant = model()->data( childIndex, Qt::UserRole + 11 );
- GeoDataObject* object = objectVariant.value<Marble::GeoDataObject*>();
+ GeoDataObject* object = static_cast<GeoDataObject*>(childIndex.internalPointer());
if( dynamic_cast<GeoDataGeometry*>( object ) ) {
if( static_cast<GeoDataGeometry*>( object )->geometryId() != GeoDataMultiGeometryId ) {
- renderGeoDataGeometry( reinterpret_cast<GeoDataGeometry*>( object ), styleUrl );
+ renderGeoDataGeometry( static_cast<GeoDataGeometry*>( object ), m_styleUrl );
} else {
if( childIndex.isValid() && model()->rowCount( childIndex ) > 0 ) {
renderIndex( childIndex );
@@ -129,8 +133,8 @@
}
else if( dynamic_cast<GeoDataFeature*>( object ) ) {
if( dynamic_cast<GeoDataFeature*>( object )->featureId() == GeoDataPlacemarkId ) {
- GeoDataPlacemark placemark( *static_cast<GeoDataFeature*>( object ) );
- styleUrl = placemark.styleUrl();
+ GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>( object );
+ m_styleUrl = placemark->styleUrl();
}
if( childIndex.isValid() && model()->rowCount( childIndex ) > 0 ) {
@@ -208,9 +212,6 @@
m_painter->save();
m_painter->autoMapQuality();
- m_root = dynamic_cast<GeoDataDocument*>( model()->data( rootIndex(),
- Qt::UserRole + 11 ).value<Marble::GeoDataObject*>() );
-
if( !m_root ) {
qWarning() << "root seems to be 0!!!";
return false;
@@ -230,18 +231,18 @@
setBrushStyle( mapped );
setPenStyle( mapped );
// geometries are implicitly shared, this shouldn't hurt
- GeoDataPolygon polygon( *static_cast<GeoDataPolygon*>( object ) );
+ GeoDataPolygon polygon( *object );
m_painter->drawPolygon( polygon );
}
if( object->geometryId() == GeoDataLinearRingId ) {
m_painter->setBrush( QColor( 0, 0, 0, 0 ) );
setPenStyle( mapped );
- GeoDataLinearRing linearRing( *static_cast<GeoDataLinearRing*>( object ) );
+ GeoDataLinearRing linearRing( *object );
m_painter->drawPolygon( linearRing );
}
if( object->geometryId() == GeoDataLineStringId ) {
setPenStyle( mapped );
- GeoDataLineString lineString( *static_cast<GeoDataLineString*>( object ) );
+ GeoDataLineString lineString( *object );
m_painter->drawPolyline( lineString );
}
/* Note: GeoDataMultiGeometry is handled within the model */
--- trunk/KDE/kdeedu/marble/src/plugins/render/geodata/GeoRendererView.h #1150819:1150820
@@ -60,7 +60,7 @@
private:
GeoPainter *m_painter;
GeoDataDocument *m_root;
- QString styleUrl;
+ QString m_styleUrl;
void setBrushStyle( QString styleId );
void setPenStyle( QString styleId );
More information about the Marble-commits
mailing list