diff --git a/projectmanagers/custom-buildsystem/CMakeLists.txt b/projectmanagers/custom-buildsystem/CMakeLists.txt --- a/projectmanagers/custom-buildsystem/CMakeLists.txt +++ b/projectmanagers/custom-buildsystem/CMakeLists.txt @@ -8,6 +8,7 @@ custombuildsystemconfig.cpp custombuildsystemplugin.cpp custombuildjob.cpp + configconstants.cpp configwidget.cpp custombuildsystemconfigwidget.cpp kcm_custombuildsystem.cpp diff --git a/projectmanagers/custom-buildsystem/configconstants.h b/projectmanagers/custom-buildsystem/configconstants.h --- a/projectmanagers/custom-buildsystem/configconstants.h +++ b/projectmanagers/custom-buildsystem/configconstants.h @@ -20,23 +20,23 @@ #ifndef CONFIGCONSTANTS_H #define CONFIGCONSTANTS_H -#include +class QString; namespace ConfigConstants { - const QString buildConfigPrefix("BuildConfig"); - const QString buildDirKey("BuildDir"); - const QString currentConfigKey("CurrentConfiguration"); - const QString toolGroupPrefix("Tool"); - const QString toolArguments("Arguments"); - const QString toolExecutable("Executable"); - const QString toolEnvironment("Environment"); - const QString toolType("Type"); - const QString toolEnabled("Enabled"); - const QString projectPathPrefix("ProjectPath"); - const QString projectPathKey("Path"); - const QString customBuildSystemGroup("CustomBuildSystem"); - const QString configTitleKey("Title"); + QString buildConfigPrefix(); + QString buildDirKey(); + QString currentConfigKey(); + QString toolGroupPrefix(); + QString toolArguments(); + QString toolExecutable(); + QString toolEnvironment(); + QString toolType(); + QString toolEnabled(); + QString projectPathPrefix(); + QString projectPathKey(); + QString customBuildSystemGroup(); + QString configTitleKey(); } #endif diff --git a/projectmanagers/custom-buildsystem/configconstants.h b/projectmanagers/custom-buildsystem/configconstants.cpp copy from projectmanagers/custom-buildsystem/configconstants.h copy to projectmanagers/custom-buildsystem/configconstants.cpp --- a/projectmanagers/custom-buildsystem/configconstants.h +++ b/projectmanagers/custom-buildsystem/configconstants.cpp @@ -17,26 +17,23 @@ * along with this program; if not, see . * ************************************************************************/ -#ifndef CONFIGCONSTANTS_H -#define CONFIGCONSTANTS_H +#include "configconstants.h" #include namespace ConfigConstants { - const QString buildConfigPrefix("BuildConfig"); - const QString buildDirKey("BuildDir"); - const QString currentConfigKey("CurrentConfiguration"); - const QString toolGroupPrefix("Tool"); - const QString toolArguments("Arguments"); - const QString toolExecutable("Executable"); - const QString toolEnvironment("Environment"); - const QString toolType("Type"); - const QString toolEnabled("Enabled"); - const QString projectPathPrefix("ProjectPath"); - const QString projectPathKey("Path"); - const QString customBuildSystemGroup("CustomBuildSystem"); - const QString configTitleKey("Title"); + QString buildConfigPrefix() { return QStringLiteral("BuildConfig"); } + QString buildDirKey() { return QStringLiteral("BuildDir"); } + QString currentConfigKey() { return QStringLiteral("CurrentConfiguration"); } + QString toolGroupPrefix() { return QStringLiteral("Tool"); } + QString toolArguments() { return QStringLiteral("Arguments"); } + QString toolExecutable() { return QStringLiteral("Executable"); } + QString toolEnvironment() { return QStringLiteral("Environment"); } + QString toolType() { return QStringLiteral("Type"); } + QString toolEnabled() { return QStringLiteral("Enabled"); } + QString projectPathPrefix() { return QStringLiteral("ProjectPath"); } + QString projectPathKey() { return QStringLiteral("Path"); } + QString customBuildSystemGroup() { return QStringLiteral("CustomBuildSystem"); } + QString configTitleKey() { return QStringLiteral("Title"); } } - -#endif diff --git a/projectmanagers/custom-buildsystem/custombuildjob.cpp b/projectmanagers/custom-buildsystem/custombuildjob.cpp --- a/projectmanagers/custom-buildsystem/custombuildjob.cpp +++ b/projectmanagers/custom-buildsystem/custombuildjob.cpp @@ -47,19 +47,19 @@ QString subgrpname; switch( type ) { case CustomBuildSystemTool::Build: - subgrpname = QString( "%1Build" ).arg( ConfigConstants::toolGroupPrefix ); + subgrpname = ConfigConstants::toolGroupPrefix() + QLatin1String("Build"); break; case CustomBuildSystemTool::Clean: - subgrpname = QString( "%1Clean" ).arg( ConfigConstants::toolGroupPrefix ); + subgrpname = ConfigConstants::toolGroupPrefix() + QLatin1String("Clean"); break; case CustomBuildSystemTool::Install: - subgrpname = QString( "%1Install" ).arg( ConfigConstants::toolGroupPrefix ); + subgrpname = ConfigConstants::toolGroupPrefix() + QLatin1String("Install"); break; case CustomBuildSystemTool::Configure: - subgrpname = QString( "%1Configure" ).arg( ConfigConstants::toolGroupPrefix ); + subgrpname = ConfigConstants::toolGroupPrefix() + QLatin1String("Configure"); break; case CustomBuildSystemTool::Prune: - subgrpname = QString( "%1Prune" ).arg( ConfigConstants::toolGroupPrefix ); + subgrpname = ConfigConstants::toolGroupPrefix() + QLatin1String("Prune"); break; case CustomBuildSystemTool::Undefined: return; @@ -69,10 +69,10 @@ KConfigGroup g = plugin->configuration( item->project() ); if(g.isValid()) { KConfigGroup grp = g.group( subgrpname ); - enabled = grp.readEntry( ConfigConstants::toolEnabled, false ); - cmd = grp.readEntry( ConfigConstants::toolExecutable, QUrl() ).toLocalFile(); - environment = grp.readEntry( ConfigConstants::toolEnvironment, "" ); - arguments = grp.readEntry( ConfigConstants::toolArguments, "" ); + enabled = grp.readEntry(ConfigConstants::toolEnabled(), false); + cmd = grp.readEntry(ConfigConstants::toolExecutable(), QUrl()).toLocalFile(); + environment = grp.readEntry(ConfigConstants::toolEnvironment(), QString()); + arguments = grp.readEntry(ConfigConstants::toolArguments(), QString()); } QString title; diff --git a/projectmanagers/custom-buildsystem/custombuildsystemconfigwidget.cpp b/projectmanagers/custom-buildsystem/custombuildsystemconfigwidget.cpp --- a/projectmanagers/custom-buildsystem/custombuildsystemconfigwidget.cpp +++ b/projectmanagers/custom-buildsystem/custombuildsystemconfigwidget.cpp @@ -44,7 +44,7 @@ Q_ASSERT( type >= 0 && type < toolTypeCount ); Q_UNUSED( toolTypeCount ); - return ConfigConstants::toolGroupPrefix + toolTypes[type]; + return ConfigConstants::toolGroupPrefix() + toolTypes[type]; } } @@ -79,31 +79,31 @@ { ui->currentConfig->clear(); QStringList groupNameList; - KConfigGroup grp = cfg->group( ConfigConstants::customBuildSystemGroup ); + KConfigGroup grp = cfg->group(ConfigConstants::customBuildSystemGroup()); foreach( const QString& grpName, grp.groupList() ) { KConfigGroup subgrp = grp.group( grpName ); CustomBuildSystemConfig config; - config.title = subgrp.readEntry( ConfigConstants::configTitleKey, QString() ); - config.buildDir = subgrp.readEntry( ConfigConstants::buildDirKey, QUrl() ); + config.title = subgrp.readEntry(ConfigConstants::configTitleKey(), QString()); + config.buildDir = subgrp.readEntry(ConfigConstants::buildDirKey(), QUrl()); foreach( const QString& subgrpName, subgrp.groupList() ) { - if( subgrpName.startsWith( ConfigConstants::toolGroupPrefix ) ) { + if (subgrpName.startsWith(ConfigConstants::toolGroupPrefix())) { KConfigGroup toolgrp = subgrp.group( subgrpName ); CustomBuildSystemTool tool; - tool.arguments = toolgrp.readEntry( ConfigConstants::toolArguments, "" ); - tool.executable = toolgrp.readEntry( ConfigConstants::toolExecutable, QUrl() ); - tool.envGrp = toolgrp.readEntry( ConfigConstants::toolEnvironment, QString() ); - tool.enabled = toolgrp.readEntry( ConfigConstants::toolEnabled, false ); - tool.type = CustomBuildSystemTool::ActionType( toolgrp.readEntry( ConfigConstants::toolType, 0 ) ); + tool.arguments = toolgrp.readEntry(ConfigConstants::toolArguments(), QString()); + tool.executable = toolgrp.readEntry(ConfigConstants::toolExecutable(), QUrl()); + tool.envGrp = toolgrp.readEntry(ConfigConstants::toolEnvironment(), QString()); + tool.enabled = toolgrp.readEntry(ConfigConstants::toolEnabled(), false); + tool.type = CustomBuildSystemTool::ActionType(toolgrp.readEntry(ConfigConstants::toolType(), 0)); config.tools[tool.type] = tool; } } configs << config; ui->currentConfig->addItem( config.title ); groupNameList << grpName; } - int idx = groupNameList.indexOf( grp.readEntry( ConfigConstants::currentConfigKey, "" ) ); + int idx = groupNameList.indexOf(grp.readEntry(ConfigConstants::currentConfigKey(), QString())); if( !groupNameList.isEmpty() && idx < 0 ) idx = 0; @@ -114,28 +114,28 @@ void CustomBuildSystemConfigWidget::saveConfig( KConfigGroup& grp, CustomBuildSystemConfig& c, int index ) { // Generate group name, access and clear it - KConfigGroup subgrp = grp.group( ConfigConstants::buildConfigPrefix + QString::number(index) ); + KConfigGroup subgrp = grp.group(ConfigConstants::buildConfigPrefix() + QString::number(index)); subgrp.deleteGroup(); // Write current configuration key, if our group is current if( ui->currentConfig->currentIndex() == index ) - grp.writeEntry( ConfigConstants::currentConfigKey, subgrp.name() ); + grp.writeEntry(ConfigConstants::currentConfigKey(), subgrp.name()); - subgrp.writeEntry( ConfigConstants::configTitleKey, c.title ); - subgrp.writeEntry( ConfigConstants::buildDirKey, c.buildDir ); + subgrp.writeEntry(ConfigConstants::configTitleKey(), c.title); + subgrp.writeEntry(ConfigConstants::buildDirKey(), c.buildDir); foreach( const CustomBuildSystemTool& tool, c.tools ) { KConfigGroup toolgrp = subgrp.group( generateToolGroupName( tool.type ) ); - toolgrp.writeEntry( ConfigConstants::toolType, int(tool.type) ); - toolgrp.writeEntry( ConfigConstants::toolEnvironment , tool.envGrp ); - toolgrp.writeEntry( ConfigConstants::toolEnabled, tool.enabled ); - toolgrp.writeEntry( ConfigConstants::toolExecutable, tool.executable ); - toolgrp.writeEntry( ConfigConstants::toolArguments, tool.arguments ); + toolgrp.writeEntry(ConfigConstants::toolType(), int(tool.type)); + toolgrp.writeEntry(ConfigConstants::toolEnvironment(), tool.envGrp); + toolgrp.writeEntry(ConfigConstants::toolEnabled(), tool.enabled); + toolgrp.writeEntry(ConfigConstants::toolExecutable(), tool.executable); + toolgrp.writeEntry(ConfigConstants::toolArguments(), tool.arguments); } } void CustomBuildSystemConfigWidget::saveTo( KConfig* cfg, KDevelop::IProject* /*project*/ ) { - KConfigGroup subgrp = cfg->group( ConfigConstants::customBuildSystemGroup ); + KConfigGroup subgrp = cfg->group(ConfigConstants::customBuildSystemGroup()); subgrp.deleteGroup(); for( int i = 0; i < ui->currentConfig->count(); i++ ) { configs[i].title = ui->currentConfig->itemText(i); diff --git a/projectmanagers/custom-buildsystem/custombuildsystemplugin.cpp b/projectmanagers/custom-buildsystem/custombuildsystemplugin.cpp --- a/projectmanagers/custom-buildsystem/custombuildsystemplugin.cpp +++ b/projectmanagers/custom-buildsystem/custombuildsystemplugin.cpp @@ -91,7 +91,7 @@ return Path(); } - Path builddir(grp.readEntry( ConfigConstants::buildDirKey, QUrl() )); + Path builddir(grp.readEntry(ConfigConstants::buildDirKey(), QUrl())); if(!builddir.isValid() ) // set builddir to default if project contains a buildDirKey that does not have a value { builddir = item->project()->path(); @@ -175,9 +175,9 @@ KConfigGroup CustomBuildSystem::configuration( IProject* project ) const { - KConfigGroup grp = project->projectConfiguration()->group( ConfigConstants::customBuildSystemGroup ); - if(grp.isValid() && grp.hasKey(ConfigConstants::currentConfigKey)) - return grp.group( grp.readEntry( ConfigConstants::currentConfigKey ) ); + KConfigGroup grp = project->projectConfiguration()->group(ConfigConstants::customBuildSystemGroup()); + if (grp.isValid() && grp.hasKey(ConfigConstants::currentConfigKey())) + return grp.group(grp.readEntry(ConfigConstants::currentConfigKey())); else return KConfigGroup(); } diff --git a/projectmanagers/custom-buildsystem/tests/CMakeLists.txt b/projectmanagers/custom-buildsystem/tests/CMakeLists.txt --- a/projectmanagers/custom-buildsystem/tests/CMakeLists.txt +++ b/projectmanagers/custom-buildsystem/tests/CMakeLists.txt @@ -8,6 +8,7 @@ # Useful for testing UI ideas quickly set( kcm_uitest_SRCS kcmuitestmain.cpp ../custombuildsystemconfigwidget.cpp + ../configconstants.cpp ../configwidget.cpp ../debugarea.cpp )