[Marble-commits] KDE/kdeedu/marble/src/lib
Thibaut Gridel
tgridel at free.fr
Sun Dec 12 12:28:27 CET 2010
SVN commit 1205739 by tgridel:
PlacemarkInfoDialog: use GeoDataPlacemark instead of model::data roles
M +17 -13 PlacemarkInfoDialog.cpp
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkInfoDialog.cpp #1205738:1205739
@@ -23,6 +23,7 @@
#include "DeferredFlag.h"
#include "GeoDataCoordinates.h"
+#include "GeoDataExtendedData.h"
#include "MarbleDirs.h"
#include "MarblePlacemarkModel.h"
@@ -59,6 +60,9 @@
void PlacemarkInfoDialog::showContent()
{
+ GeoDataPlacemark *placemark
+ = static_cast<GeoDataPlacemark*>(qVariantValue<GeoDataObject*>( m_index.model()->data(m_index, MarblePlacemarkModel::ObjectPointerRole ) ) );
+
elevation_lbl->setVisible( true );
elevation_val_lbl->setVisible( true );
population_lbl->setText( tr("Population:") );
@@ -67,7 +71,7 @@
name_val_lbl->setText( "<H1><b>" + m_index.data().toString() + "</b></H1>" );
altername_val_lbl->setText( "" );
QString rolestring;
- const QString role = m_index.data( MarblePlacemarkModel::GeoTypeRole ).toString();
+ const QString role = placemark->role();
if(role=="PPLC")
rolestring = tr("National Capital");
else if(role=="PPL")
@@ -84,7 +88,7 @@
rolestring = tr("Location");
else if(role=="H")
{
- if ( m_index.data( MarblePlacemarkModel::PopularityRole ).toInt() > 0 )
+ if ( placemark->popularity() > 0 )
rolestring = tr("Mountain");
else
rolestring = tr("Elevation extreme");
@@ -113,10 +117,10 @@
role_val_lbl->setText( rolestring );
m_flagcreator = new DeferredFlag( this );
- requestFlag( m_index.data( MarblePlacemarkModel::CountryCodeRole ).toString() );
+ requestFlag( placemark->countryCode() );
- const QString description = m_index.data( MarblePlacemarkModel::DescriptionRole ).toString();
+ const QString description = placemark->description();
description_val_browser->setEnabled( false );
if ( !description.isEmpty() )
@@ -124,16 +128,16 @@
description_val_browser->setEnabled( true );
description_val_browser->setHtml( description );
}
- coordinates_val_lbl->setText( m_index.data( MarblePlacemarkModel::CoordinateRole ).value<GeoDataCoordinates>().toString() );
- country_val_lbl->setText( m_index.data( MarblePlacemarkModel::CountryCodeRole ).toString() );
- QString gmt = QString( "%1" ).arg( m_index.data( MarblePlacemarkModel::GmtRole ).toInt()/( double ) 100, 0, 'f', 1 );
- QString dst = QString( "%1" ).arg( ( m_index.data( MarblePlacemarkModel::GmtRole ).toInt() + m_index.data( MarblePlacemarkModel::DstRole ).toInt() )/( double ) 100, 0, 'f', 1 );
+ coordinates_val_lbl->setText( placemark->coordinate().toString() );
+ country_val_lbl->setText( placemark->countryCode() );
+ QString gmt = QString( "%1" ).arg( placemark->extendedData().value("gmt").value().toInt()/( double ) 100, 0, 'f', 1 );
+ QString dst = QString( "%1" ).arg( ( placemark->extendedData().value("gmt").value().toInt() + placemark->extendedData().value("dst").value().toInt() )/( double ) 100, 0, 'f', 1 );
gmtdst_val_lbl->setText( gmt + " / " + dst );
- state_val_lbl->setText( m_index.data( MarblePlacemarkModel::StateRole ).toString() );
+ state_val_lbl->setText( placemark->state() );
- const qint64 population = m_index.data( MarblePlacemarkModel::PopulationRole ).toLongLong();
- const qreal area = m_index.data( MarblePlacemarkModel::AreaRole ).toDouble();
- const qreal altitude = m_index.data( MarblePlacemarkModel::CoordinateRole ).value<GeoDataCoordinates>().altitude();
+ const qint64 population = placemark->population();
+ const qreal area = placemark->area();
+ const qreal altitude = placemark->coordinate().altitude();
area_lbl->setText( tr("Area:") );
if ( area < 10000000 )
@@ -203,7 +207,7 @@
state_lbl->setVisible( false );
state_val_lbl->setVisible( false );
}
- if ( (role == "a" || role == "c" || role == "m") && m_index.data( MarblePlacemarkModel::PopularityRole ).toInt() > 0) {
+ if ( (role == "a" || role == "c" || role == "m") && placemark->popularity() > 0) {
diameter_lbl->setVisible( true );
diameter_val_lbl->setVisible( true );
gmtdst_lbl->setVisible( false );
More information about the Marble-commits
mailing list