Commit a06039a5 authored by Tobias Koenig's avatar Tobias Koenig
Browse files

Renamed PlaceMark::population[Index] to PlaceMark::popularity[Index],

as this attribute is not only used for holding the population of
a place mark.

svn path=/trunk/KDE/kdeedu/marble/; revision=717236
parent 9c2f346e
......@@ -18,17 +18,17 @@
#include "PlaceMark.h"
PlaceMark::PlaceMark()
: m_population( 0 ),
: m_popularity( 0 ),
m_symbolIndex( 0 ),
m_populationIndex( 0 )
m_popularityIndex( 0 )
{
}
PlaceMark::PlaceMark( const QString& name )
: KMLFeature( name ),
m_population( 0 ),
m_popularity( 0 ),
m_symbolIndex( 0 ),
m_populationIndex( 0 )
m_popularityIndex( 0 )
{
}
......@@ -77,24 +77,24 @@ void PlaceMark::setSymbolIndex( int index )
m_symbolIndex = index;
}
const int PlaceMark::populationIndex() const
const int PlaceMark::popularityIndex() const
{
return m_populationIndex;
return m_popularityIndex;
}
void PlaceMark::setPopulationIndex( int populationIndex )
void PlaceMark::setPopularityIndex( int popularityIndex )
{
m_populationIndex = populationIndex;
m_popularityIndex = popularityIndex;
}
const int PlaceMark::population() const
const int PlaceMark::popularity() const
{
return m_population;
return m_popularity;
}
void PlaceMark::setPopulation( int population )
void PlaceMark::setPopularity( int popularity )
{
m_population = population;
m_popularity = popularity;
}
const QSize PlaceMark::symbolSize() const
......@@ -176,9 +176,9 @@ void PlaceMark::pack( QDataStream& stream ) const
{
KMLFeature::pack( stream );
stream << m_population;
stream << m_popularity;
stream << m_symbolIndex;
stream << m_populationIndex;
stream << m_popularityIndex;
stream << m_role;
stream << m_countrycode;
......@@ -198,9 +198,9 @@ void PlaceMark::unpack( QDataStream& stream )
{
KMLFeature::unpack( stream );
stream >> m_population;
stream >> m_popularity;
stream >> m_symbolIndex;
stream >> m_populationIndex;
stream >> m_popularityIndex;
stream >> m_role;
stream >> m_countrycode;
......
......@@ -90,27 +90,27 @@ class PlaceMark : public KMLFeature
void setSymbolIndex( int index );
/**
* Returns the population index of the place mark.
* Returns the popularity index of the place mark.
*
* The population index is a value which describes
* The popularity index is a value which describes
* at which zoom level the place mark will be shown.
*/
const int populationIndex() const;
const int popularityIndex() const;
/**
* Sets the population @p index of the place mark.
* Sets the popularity @p index of the place mark.
*/
void setPopulationIndex( int index );
void setPopularityIndex( int index );
/**
* Returns the population of the place mark.
* Returns the popularity of the place mark.
*/
const int population() const;
const int popularity() const;
/**
* Sets the @p population of the place mark.
* Sets the @p popularity of the place mark.
*/
void setPopulation( int population );
void setPopularity( int popularity );
/**
* Returns the symbol size of the place mark.
......@@ -133,11 +133,11 @@ class PlaceMark : public KMLFeature
GeoPoint m_coordinate;
QChar m_role;
QString m_countrycode;
int m_population;
int m_popularity;
// View specific data
int m_symbolIndex;
int m_populationIndex;
int m_popularityIndex;
};
#endif // PLACEMARK_H
......@@ -27,7 +27,7 @@ inline bool populationLessThan( PlaceMark* mark1, PlaceMark* mark2 )
{
// If compared items do not differ in terms of being selected,
// compare them based on population numbers.
return (mark1->population() > mark2->population());
return (mark1->popularity() > mark2->popularity());
}
......
......@@ -71,7 +71,7 @@ void PlaceMarkInfoDialog::showContent()
rolestring = tr("Location");
break;
case 'H':
if ( m_index.data( PlaceMarkModel::PopulationRole ).toInt() > 0 )
if ( m_index.data( PlaceMarkModel::PopularityRole ).toInt() > 0 )
rolestring = tr("Mountain");
else
rolestring = tr("Elevation extreme");
......@@ -97,13 +97,13 @@ void PlaceMarkInfoDialog::showContent()
coordinates_val_lbl->setText( m_index.data( PlaceMarkModel::CoordinateRole ).value<GeoPoint>().toString() );
country_val_lbl->setText( m_index.data( PlaceMarkModel::CountryCodeRole ).toString() );
const int population = m_index.data( PlaceMarkModel::PopulationRole ).toInt();
const int popularity = m_index.data( PlaceMarkModel::PopularityRole ).toInt();
const QChar role = m_index.data( PlaceMarkModel::GeoTypeRole ).toChar();
if ( role == 'H' || role == 'V' ) {
population_val_lbl->setVisible( false );
population_lbl->setVisible( false );
elevation_val_lbl->setText( tr("%1 m").arg( QLocale::system().toString( population / 1000 ) ) );
elevation_val_lbl->setText( tr("%1 m").arg( QLocale::system().toString( popularity / 1000 ) ) );
}
else if ( role == 'P' || role == 'M' ) {
population_val_lbl->setVisible( false );
......@@ -112,7 +112,7 @@ void PlaceMarkInfoDialog::showContent()
elevation_lbl->setVisible( false );
}
else{
population_val_lbl->setText( tr("%1 inh.").arg( QLocale::system().toString( population ) ) );
population_val_lbl->setText( tr("%1 inh.").arg( QLocale::system().toString( popularity ) ) );
elevation_val_lbl->setText( tr("-") );
}
......
......@@ -245,9 +245,9 @@ void PlaceMarkLayout::paintPlaceFolder(QPainter* painter,
* Now handle all other place marks...
*/
const QModelIndex firstIndex = model->index( 0, 0 );
const int firstPopulation = firstIndex.data( PlaceMarkModel::PopulationRole ).toInt();
const bool noFilter = ( firstPopulation == 0
|| ( firstPopulation != 0
const int firstPopularity = firstIndex.data( PlaceMarkModel::PopularityRole ).toInt();
const bool noFilter = ( firstPopularity == 0
|| ( firstPopularity != 0
&& firstIndex.data( PlaceMarkModel::GeoTypeRole ).toChar().isNull() ) )
? true : false;
const QItemSelection selection = selectionModel->selection();
......@@ -256,14 +256,14 @@ void PlaceMarkLayout::paintPlaceFolder(QPainter* painter,
{
QModelIndex index = model->index( i, 0 );
int populationIndex = index.data( PlaceMarkModel::PopulationIndexRole ).toInt();
int popularityIndex = index.data( PlaceMarkModel::PopularityIndexRole ).toInt();
// Skip the places that are too small.
if ( noFilter == false ) {
if ( m_weightfilter.at( populationIndex ) > viewParams->m_radius )
if ( m_weightfilter.at( popularityIndex ) > viewParams->m_radius )
{
// qDebug() << QString("Filter: %1 Radius: %2")
// .arg(m_weightfilter.at( populationIndex )).arg(viewParams->m_radius);
// .arg(m_weightfilter.at( popularityIndex )).arg(viewParams->m_radius);
break;
}
}
......
......@@ -245,9 +245,9 @@ void PlaceMarkManager::saveFile( const QString& filename,
out << QString( (*it) -> role() );
out << QString( (*it) -> description() );
out << QString( (*it) -> countryCode() );
out << (qint32)(*it) -> populationIndex();
out << (qint32)(*it) -> popularityIndex();
out << (qint32)(*it) -> symbolIndex();
out << (qint32)(*it) -> population();
out << (qint32)(*it) -> popularity();
}
}
......@@ -304,11 +304,11 @@ bool PlaceMarkManager::loadFile( const QString& filename,
in >> tmpstr;
mark -> setCountryCode( tmpstr );
in >> a;
mark -> setPopulationIndex( a );
mark -> setPopularityIndex( a );
in >> a;
mark -> setSymbolIndex( a );
in >> a;
mark -> setPopulation( a );
mark -> setPopularity( a );
placeMarkContainer -> append( mark );
}
......
......@@ -87,8 +87,8 @@ QVariant PlaceMarkModel::data( const QModelIndex &index, int role ) const
return d->m_placeMarkContainer.at( index.row() )->symbolPixmap();
} else if ( role == GeoTypeRole ) {
return d->m_placeMarkContainer.at( index.row() )->role();
} else if ( role == PopulationIndexRole ) {
return d->m_placeMarkContainer.at( index.row() )->populationIndex();
} else if ( role == PopularityIndexRole ) {
return d->m_placeMarkContainer.at( index.row() )->popularityIndex();
} else if ( role == CoordinateRole ) {
QVariant v;
v.setValue( d->m_placeMarkContainer.at( index.row() )->coordinate() );
......@@ -99,8 +99,8 @@ QVariant PlaceMarkModel::data( const QModelIndex &index, int role ) const
return d->m_placeMarkContainer.at( index.row() )->symbolIndex();
} else if ( role == SymbolSizeRole ) {
return d->m_placeMarkContainer.at( index.row() )->symbolSize();
} else if ( role == PopulationRole ) {
return d->m_placeMarkContainer.at( index.row() )->population();
} else if ( role == PopularityRole ) {
return d->m_placeMarkContainer.at( index.row() )->popularity();
} else if ( role == DescriptionRole ) {
return d->m_placeMarkContainer.at( index.row() )->description();
} else
......
......@@ -47,8 +47,8 @@ class MARBLE_EXPORT PlaceMarkModel : public QAbstractListModel
CountryCodeRole, ///< The country code
SymbolIndexRole, ///< The symbol index
SymbolSizeRole, ///< The symbol size
PopulationIndexRole, ///< The population index
PopulationRole ///< The population
PopularityIndexRole, ///< The popularity index
PopularityRole ///< The popularity
};
/**
......
......@@ -124,10 +124,10 @@ bool XmlHandler::endElement( const QString&, const QString&,
else if ( m_placemark->role() == 'H' ) m_placemark->setSymbolIndex(18);
else if ( m_placemark->role() == 'V' ) m_placemark->setSymbolIndex(19);
else if ( m_placemark->role() == 'F' ) m_placemark->setSymbolIndex(20);
else if ( m_placemark->role() == 'N' ) m_placemark->setSymbolIndex( ( m_placemark->populationIndex() -1 ) / 4 * 4 );
else if ( m_placemark->role() == 'R' ) m_placemark->setSymbolIndex( ( m_placemark->populationIndex() -1 ) / 4 * 4 + 2);
else if ( m_placemark->role() == 'N' ) m_placemark->setSymbolIndex( ( m_placemark->popularityIndex() -1 ) / 4 * 4 );
else if ( m_placemark->role() == 'R' ) m_placemark->setSymbolIndex( ( m_placemark->popularityIndex() -1 ) / 4 * 4 + 2);
else if ( m_placemark->role() == 'C' || m_placemark->role() == 'B' )
m_placemark->setSymbolIndex( ( m_placemark->populationIndex() -1 ) / 4 * 4 + 3 );
m_placemark->setSymbolIndex( ( m_placemark->popularityIndex() -1 ) / 4 * 4 + 3 );
else if ( m_placemark->role().isNull() && !m_hasPopulation )
m_placemark->setSymbolIndex(21);
......@@ -160,11 +160,11 @@ bool XmlHandler::endElement( const QString&, const QString&,
else
population = m_currentText.toInt();
m_placemark->setPopulation( population );
m_placemark->setPopularity( population );
// else if(population < 7500000) popidx=15;
m_placemark->setPopulationIndex( popIdx( population ) );
m_placemark->setPopularityIndex( popIdx( population ) );
}
if ( m_inKml && nameLower == "point" ) {
......@@ -183,8 +183,8 @@ bool XmlHandler::endElement( const QString&, const QString&,
if ( splitline.size() == 3 ) {
int elevation = splitline[2].toInt();
m_placemark->setPopulation( elevation*1000 );
m_placemark->setPopulationIndex( popIdx( abs(elevation*1000) ) );
m_placemark->setPopularity( elevation*1000 );
m_placemark->setPopularityIndex( popIdx( abs(elevation*1000) ) );
}
m_coordsset = true;
......
......@@ -179,8 +179,8 @@ bool KMLPlaceMarkParser::characters( const QString& str )
switch ( m_phase ) {
case WAIT_POP:
population = str.toInt();
placemark.setPopulation( population );
placemark.setPopulationIndex( popIdx( population ) );
placemark.setPopularity( population );
placemark.setPopularityIndex( popIdx( population ) );
result = true;
break;
case WAIT_ROLE:
......@@ -207,10 +207,10 @@ void KMLPlaceMarkParser::setPlaceMarkSymbol()
else if ( placemark.role() == 'H' ) placemark.setSymbolIndex(18);
else if ( placemark.role() == 'V' ) placemark.setSymbolIndex(19);
else if ( placemark.role() == 'F' ) placemark.setSymbolIndex(20);
else if ( placemark.role() == 'N' ) placemark.setSymbolIndex( ( placemark.populationIndex() -1 ) / 4 * 4 );
else if ( placemark.role() == 'R' ) placemark.setSymbolIndex( ( placemark.populationIndex() -1 ) / 4 * 4 + 2);
else if ( placemark.role() == 'N' ) placemark.setSymbolIndex( ( placemark.popularityIndex() -1 ) / 4 * 4 );
else if ( placemark.role() == 'R' ) placemark.setSymbolIndex( ( placemark.popularityIndex() -1 ) / 4 * 4 + 2);
else if ( placemark.role() == 'C' || placemark.role() == 'B' )
placemark.setSymbolIndex( ( placemark.populationIndex() -1 ) / 4 * 4 + 3 );
placemark.setSymbolIndex( ( placemark.popularityIndex() -1 ) / 4 * 4 + 3 );
}
int KMLPlaceMarkParser::popIdx( int population )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment