[Marble-commits] KDE/kdeedu/marble/src
Dennis Nienhüser
earthwings at gentoo.org
Wed Oct 13 20:45:50 CEST 2010
SVN commit 1185566 by nienhueser:
Move the RoutingProfilesModel::Profile struct to its own class.
M +11 -11 QtMainWindow.cpp
M +1 -0 lib/CMakeLists.txt
M +2 -2 lib/MarbleRunnerManager.cpp
M +3 -3 lib/routing/RouteRequest.cpp
M +2 -2 lib/routing/RouteRequest.h
A lib/routing/RoutingProfile.cpp [License: LGPL]
A lib/routing/RoutingProfile.h [License: LGPL]
M +4 -4 lib/routing/RoutingProfileSettingsDialog.cpp
M +8 -8 lib/routing/RoutingProfilesModel.cpp
M +4 -10 lib/routing/RoutingProfilesModel.h
M +1 -1 plugins/runner/openrouteservice/OpenRouteServiceRunner.cpp
M +1 -1 plugins/runner/routino/RoutinoRunner.cpp
--- trunk/KDE/kdeedu/marble/src/QtMainWindow.cpp #1185565:1185566
@@ -941,18 +941,18 @@
settings.beginGroup( "Routing Profile" );
if ( settings.contains( "Num" ) ) {
- QList<RoutingProfilesModel::Profile> profiles;
+ QList<RoutingProfile> profiles;
int numProfiles = settings.value( "Num", 0 ).toInt();
for ( int i = 0; i < numProfiles; ++i ) {
settings.beginGroup( QString( "Profile %0" ).arg(i) );
- RoutingProfilesModel::Profile profile;
- profile.name = settings.value( "Name", tr( "Unnamed" ) ).toString();
+ QString name = settings.value( "Name", tr( "Unnamed" ) ).toString();
+ RoutingProfile profile( name );
foreach ( const QString& pluginName, settings.childGroups() ) {
settings.beginGroup( pluginName );
- profile.pluginSettings.insert( pluginName, QHash<QString, QVariant>() );
+ profile.pluginSettings().insert( pluginName, QHash<QString, QVariant>() );
foreach ( const QString& key, settings.childKeys() ) {
if ( key != "Enabled" ) {
- profile.pluginSettings[ pluginName ].insert( key, settings.value( key ) );
+ profile.pluginSettings()[ pluginName ].insert( key, settings.value( key ) );
}
}
settings.endGroup();
@@ -1030,24 +1030,24 @@
settings.endGroup();
settings.beginGroup( "Routing Profile" );
- QList<RoutingProfilesModel::Profile> profiles = m_controlView->marbleWidget()
+ QList<RoutingProfile> profiles = m_controlView->marbleWidget()
->model()->routingManager()->profilesModel()->profiles();
settings.setValue( "Num", profiles.count() );
for ( int i = 0; i < profiles.count(); ++i ) {
settings.beginGroup( QString( "Profile %0" ).arg(i) );
- RoutingProfilesModel::Profile profile = profiles.at( i );
- settings.setValue( "Name", profile.name );
+ const RoutingProfile& profile = profiles.at( i );
+ settings.setValue( "Name", profile.name() );
foreach ( const QString& pluginName, settings.childGroups() ) {
settings.beginGroup( pluginName );
settings.remove( "" ); //remove all keys
settings.endGroup();
}
- foreach ( const QString &key, profile.pluginSettings.keys() ) {
+ foreach ( const QString &key, profile.pluginSettings().keys() ) {
settings.beginGroup( key );
settings.setValue( "Enabled", true );
- foreach ( const QString& settingKey, profile.pluginSettings[ key ].keys() ) {
+ foreach ( const QString& settingKey, profile.pluginSettings()[ key ].keys() ) {
Q_ASSERT( settingKey != "Enabled" );
- settings.setValue( settingKey, profile.pluginSettings[ key ][ settingKey ] );
+ settings.setValue( settingKey, profile.pluginSettings()[ key ][ settingKey ] );
}
settings.endGroup();
}
--- trunk/KDE/kdeedu/marble/src/lib/CMakeLists.txt #1185565:1185566
@@ -183,6 +183,7 @@
routing/RouteRequest.cpp
routing/RoutingModel.cpp
routing/RoutingProxyModel.cpp
+ routing/RoutingProfile.cpp
routing/RoutingManager.cpp
routing/RoutingLayer.cpp
routing/RoutingLineEdit.cpp
--- trunk/KDE/kdeedu/marble/src/lib/MarbleRunnerManager.cpp #1185565:1185566
@@ -193,13 +193,13 @@
void MarbleRunnerManager::retrieveRoute( RouteRequest *request )
{
- RoutingProfilesModel::Profile profile = request->routingProfile();
+ RoutingProfile profile = request->routingProfile();
d->m_routingResult.clear();
d->m_routeRequest = request;
QList<RunnerPlugin*> plugins = d->plugins( RunnerPlugin::Routing );
foreach( RunnerPlugin* plugin, plugins ) {
- if ( !profile.pluginSettings.contains( plugin->nameId() ) ) continue;
+ if ( !profile.pluginSettings().contains( plugin->nameId() ) ) continue;
MarbleAbstractRunner* runner = plugin->newRunner();
connect( runner, SIGNAL( routeCalculated( GeoDataDocument* ) ),
this, SLOT( addRoutingResult( GeoDataDocument* ) ) );
--- trunk/KDE/kdeedu/marble/src/lib/routing/RouteRequest.cpp #1185565:1185566
@@ -29,7 +29,7 @@
QMap<int, QPixmap> m_pixmapCache;
- RoutingProfilesModel::Profile m_routingProfile;
+ RoutingProfile m_routingProfile;
int m_fontSize;
@@ -284,12 +284,12 @@
}
}
-void RouteRequest::setRoutingProfile( const RoutingProfilesModel::Profile &index )
+void RouteRequest::setRoutingProfile( const RoutingProfile &index )
{
d->m_routingProfile = index;
}
-RoutingProfilesModel::Profile RouteRequest::routingProfile() const
+RoutingProfile RouteRequest::routingProfile() const
{
return d->m_routingProfile;
}
--- trunk/KDE/kdeedu/marble/src/lib/routing/RouteRequest.h #1185565:1185566
@@ -91,9 +91,9 @@
void reverse();
- void setRoutingProfile( const RoutingProfilesModel::Profile &profile );
+ void setRoutingProfile( const RoutingProfile &profile );
- RoutingProfilesModel::Profile routingProfile() const;
+ RoutingProfile routingProfile() const;
Q_SIGNALS:
/** The value of the n-th element was changed */
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingProfileSettingsDialog.cpp #1185565:1185566
@@ -79,16 +79,16 @@
void RoutingProfileSettingsDialog::editProfile( int profileIndex )
{
- QList<RoutingProfilesModel::Profile> profiles = m_profilesModel->profiles();
- m_ui->name->setText( profiles.at( profileIndex ).name );
+ QList<RoutingProfile> profiles = m_profilesModel->profiles();
+ m_ui->name->setText( profiles.at( profileIndex ).name() );
m_servicesModel->clear();
foreach( RunnerPlugin *plugin, m_plugins ) {
QStandardItem *item = new QStandardItem( plugin->name() );
item->setCheckable( true );
- if ( profiles[ profileIndex ].pluginSettings.contains( plugin->nameId() ) ) {
+ if ( profiles[ profileIndex ].pluginSettings().contains( plugin->nameId() ) ) {
item->setCheckState( Qt::Checked );
- QHash<QString, QVariant> settings = profiles[ profileIndex ].pluginSettings[ plugin->nameId() ];
+ QHash<QString, QVariant> settings = profiles[ profileIndex ].pluginSettings()[ plugin->nameId() ];
mDebug() << settings;
if ( m_configWidgets[plugin] ) {
m_configWidgets[plugin]->loadSettings( settings );
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingProfilesModel.cpp #1185565:1185566
@@ -27,7 +27,7 @@
if ( index.parent().isValid() ) { return QVariant(); }
if ( index.row() >= m_profiles.count() ) { return QVariant(); }
if ( ( role == Qt::DisplayRole || role == Qt::EditRole ) && index.column() == 0 ) {
- return m_profiles.at( index.row() ).name;
+ return m_profiles.at( index.row() ).name();
}
return QVariant();
}
@@ -50,14 +50,14 @@
return true;
}
-void RoutingProfilesModel::setProfiles( const QList<Profile>& profiles )
+void RoutingProfilesModel::setProfiles( const QList<RoutingProfile>& profiles )
{
beginResetModel();
m_profiles = profiles;
endResetModel();
}
-QList<RoutingProfilesModel::Profile> RoutingProfilesModel::profiles() const
+QList<RoutingProfile> RoutingProfilesModel::profiles() const
{
return m_profiles;
}
@@ -65,7 +65,7 @@
void RoutingProfilesModel::addProfile( const QString& name )
{
beginInsertRows( QModelIndex(), m_profiles.count(), m_profiles.count() );
- m_profiles << Profile( name );
+ m_profiles << RoutingProfile( name );
endInsertRows();
}
@@ -91,7 +91,7 @@
{
if ( row < 0 ) { return false; }
if ( row >= m_profiles.count() ) { return false; }
- m_profiles[row].name = name;
+ m_profiles[row].setName( name );
emit dataChanged( index( row, 0 ), index( row, 0 ) );
return true;
}
@@ -100,7 +100,7 @@
{
if ( row < 0 ) { return false; }
if ( row >= m_profiles.count() ) { return false; }
- m_profiles[row].pluginSettings = pluginSettings;
+ m_profiles[row].pluginSettings() = pluginSettings;
return true;
}
@@ -128,7 +128,7 @@
beginInsertRows( QModelIndex(), m_profiles.count(), m_profiles.count() + int( LastTemplate ) - 1 );
for ( int i=0; i < LastTemplate; ++i) {
ProfileTemplate tpl = static_cast<ProfileTemplate>( i );
- Profile profile( templateName( tpl ) );
+ RoutingProfile profile( templateName( tpl ) );
bool profileSupportedByAtLeastOnePlugin = false;
foreach( RunnerPlugin* plugin, m_pluginManager->runnerPlugins() ) {
if ( !plugin->supports( RunnerPlugin::Routing ) ) {
@@ -147,7 +147,7 @@
continue;
}
if ( plugin->supportsTemplate( tpl ) ) {
- profile.pluginSettings[plugin->nameId()] = plugin->templateSettings( tpl );
+ profile.pluginSettings()[plugin->nameId()] = plugin->templateSettings( tpl );
}
}
m_profiles << profile;
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingProfilesModel.h #1185565:1185566
@@ -13,6 +13,7 @@
#define MARBLE_ROUTINGPROFILESMODEL_H
#include "marble_export.h"
+#include "RoutingProfile.h"
#include <QAbstractListModel>
@@ -41,15 +42,8 @@
LastTemplate
};
- struct Profile {
- Profile( const QString &name_ ) : name( name_ ) {}
- Profile() {}
- QString name;
- //icon
- QHash<QString, QHash<QString, QVariant> > pluginSettings;
- };
- void setProfiles( const QList<Profile> &profiles );
- QList<Profile> profiles() const;
+ void setProfiles( const QList<RoutingProfile> &profiles );
+ QList<RoutingProfile> profiles() const;
void loadDefaultProfiles();
@@ -61,7 +55,7 @@
bool setProfilePluginSettings( int row, const QHash<QString, QHash<QString, QVariant> > &pluginSettings );
private:
- QList<Profile> m_profiles;
+ QList<RoutingProfile> m_profiles;
PluginManager* m_pluginManager;
};
--- trunk/KDE/kdeedu/marble/src/plugins/runner/openrouteservice/OpenRouteServiceRunner.cpp #1185565:1185566
@@ -62,7 +62,7 @@
GeoDataCoordinates source = route->source();
GeoDataCoordinates destination = route->destination();
- QHash<QString, QVariant> settings = route->routingProfile().pluginSettings["openrouteservice"];
+ QHash<QString, QVariant> settings = route->routingProfile().pluginSettings()["openrouteservice"];
QString request = xmlHeader();
QString unit = "KM";
--- trunk/KDE/kdeedu/marble/src/plugins/runner/routino/RoutinoRunner.cpp #1185565:1185566
@@ -243,7 +243,7 @@
params << QString("--lon%1=%2").arg(i+1).arg(fLon, 0, 'f', 8);
}
- QHash<QString, QVariant> settings = route->routingProfile().pluginSettings["routino"];
+ QHash<QString, QVariant> settings = route->routingProfile().pluginSettings()["routino"];
QString transport = settings["transport"].toString();
params << QString( "--transport=%0" ).arg( transport );
More information about the Marble-commits
mailing list