diff --git a/outputview/outputexecutejob.cpp b/outputview/outputexecutejob.cpp --- a/outputview/outputexecutejob.cpp +++ b/outputview/outputexecutejob.cpp @@ -21,7 +21,7 @@ #include "outputmodel.h" #include "outputdelegate.h" #include "debug.h" -#include +#include #include #include #include @@ -483,13 +483,13 @@ QProcessEnvironment OutputExecuteJobPrivate::effectiveEnvironment(const QUrl& workingDirectory) const { - const EnvironmentGroupList environmentGroup( KSharedConfig::openConfig() ); + const EnvironmentProfileList environmentProfiles(KSharedConfig::openConfig()); QString environmentProfile = m_owner->environmentProfile(); if( environmentProfile.isEmpty() ) { - environmentProfile = environmentGroup.defaultGroup(); + environmentProfile = environmentProfiles.defaultProfileName(); } QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); - auto userEnv = environmentGroup.variables(environmentProfile); + auto userEnv = environmentProfiles.variables(environmentProfile); expandVariables(userEnv, environment); OutputExecuteJobPrivate::mergeEnvironment( environment, userEnv ); diff --git a/plugins/execute/executeplugin.h b/plugins/execute/executeplugin.h --- a/plugins/execute/executeplugin.h +++ b/plugins/execute/executeplugin.h @@ -47,7 +47,7 @@ static QString argumentsEntry; static QString isExecutableEntry; static QString dependencyEntry; - static QString environmentGroupEntry; + static QString environmentProfileEntry; static QString useTerminalEntry; static QString terminalEntry; static QString userIdToRunEntry; @@ -60,7 +60,7 @@ QStringList arguments( KDevelop::ILaunchConfiguration*, QString& err ) const override; QUrl workingDirectory( KDevelop::ILaunchConfiguration* ) const override; KJob* dependencyJob( KDevelop::ILaunchConfiguration* ) const override; - QString environmentGroup( KDevelop::ILaunchConfiguration* ) const override; + QString environmentProfileName(KDevelop::ILaunchConfiguration*) const override; bool useTerminal( KDevelop::ILaunchConfiguration* ) const override; QString terminal( KDevelop::ILaunchConfiguration* ) const override; QString nativeAppConfigTypeId() const override; diff --git a/plugins/execute/executeplugin.cpp b/plugins/execute/executeplugin.cpp --- a/plugins/execute/executeplugin.cpp +++ b/plugins/execute/executeplugin.cpp @@ -49,7 +49,8 @@ QString ExecutePlugin::argumentsEntry = QStringLiteral("Arguments"); QString ExecutePlugin::isExecutableEntry = QStringLiteral("isExecutable"); QString ExecutePlugin::dependencyEntry = QStringLiteral("Dependencies"); -QString ExecutePlugin::environmentGroupEntry = QStringLiteral("EnvironmentGroup"); +// TODO: migrate to more consistent key term "EnvironmentProfile" +QString ExecutePlugin::environmentProfileEntry = QStringLiteral("EnvironmentGroup"); QString ExecutePlugin::useTerminalEntry = QStringLiteral("Use External Terminal"); QString ExecutePlugin::terminalEntry = QStringLiteral("External Terminal"); QString ExecutePlugin::userIdToRunEntry = QStringLiteral("User Id to Run"); @@ -147,14 +148,14 @@ } -QString ExecutePlugin::environmentGroup( KDevelop::ILaunchConfiguration* cfg ) const +QString ExecutePlugin::environmentProfileName(KDevelop::ILaunchConfiguration* cfg) const { if( !cfg ) { return QLatin1String(""); } - return cfg->config().readEntry( ExecutePlugin::environmentGroupEntry, "" ); + return cfg->config().readEntry(ExecutePlugin::environmentProfileEntry, QString()); } diff --git a/plugins/execute/iexecuteplugin.h b/plugins/execute/iexecuteplugin.h --- a/plugins/execute/iexecuteplugin.h +++ b/plugins/execute/iexecuteplugin.h @@ -45,7 +45,7 @@ virtual QStringList arguments( KDevelop::ILaunchConfiguration* config, QString& error) const = 0; virtual QUrl workingDirectory( KDevelop::ILaunchConfiguration* config) const = 0; virtual KJob* dependencyJob( KDevelop::ILaunchConfiguration* config) const = 0; - virtual QString environmentGroup( KDevelop::ILaunchConfiguration* config) const = 0; + virtual QString environmentProfileName(KDevelop::ILaunchConfiguration* config) const = 0; virtual bool useTerminal( KDevelop::ILaunchConfiguration* config) const = 0; virtual QString terminal( KDevelop::ILaunchConfiguration* config) const = 0; virtual QString nativeAppConfigTypeId() const = 0; diff --git a/plugins/execute/nativeappconfig.cpp b/plugins/execute/nativeappconfig.cpp --- a/plugins/execute/nativeappconfig.cpp +++ b/plugins/execute/nativeappconfig.cpp @@ -93,7 +93,7 @@ arguments->setClearButtonEnabled( true ); arguments->setText( cfg.readEntry( ExecutePlugin::argumentsEntry, "" ) ); workingDirectory->setUrl( cfg.readEntry( ExecutePlugin::workingDirEntry, QUrl() ) ); - environment->setCurrentProfile( cfg.readEntry( ExecutePlugin::environmentGroupEntry, QString() ) ); + environment->setCurrentProfile(cfg.readEntry(ExecutePlugin::environmentProfileEntry, QString())); runInTerminal->setChecked( cfg.readEntry( ExecutePlugin::useTerminalEntry, false ) ); terminal->setEditText( cfg.readEntry( ExecutePlugin::terminalEntry, terminal->itemText(0) ) ); dependencies->setDependencies(KDevelop::stringToQVariant( cfg.readEntry( ExecutePlugin::dependencyEntry, QString() ) ).toList()); @@ -147,7 +147,7 @@ cfg.writeEntry( ExecutePlugin::projectTargetEntry, projectTarget->currentItemPath() ); cfg.writeEntry( ExecutePlugin::argumentsEntry, arguments->text() ); cfg.writeEntry( ExecutePlugin::workingDirEntry, workingDirectory->url() ); - cfg.writeEntry( ExecutePlugin::environmentGroupEntry, environment->currentProfile() ); + cfg.writeEntry( ExecutePlugin::environmentProfileEntry, environment->currentProfile() ); cfg.writeEntry( ExecutePlugin::useTerminalEntry, runInTerminal->isChecked() ); cfg.writeEntry( ExecutePlugin::terminalEntry, terminal->currentText() ); cfg.writeEntry( ExecutePlugin::dependencyActionEntry, dependencyAction->itemData( dependencyAction->currentIndex() ).toString() ); diff --git a/plugins/execute/nativeappjob.cpp b/plugins/execute/nativeappjob.cpp --- a/plugins/execute/nativeappjob.cpp +++ b/plugins/execute/nativeappjob.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -50,8 +50,8 @@ IExecutePlugin* iface = KDevelop::ICore::self()->pluginController()->pluginForExtension(QStringLiteral("org.kdevelop.IExecutePlugin"), QStringLiteral("kdevexecute"))->extension(); Q_ASSERT(iface); - KDevelop::EnvironmentGroupList l(KSharedConfig::openConfig()); - QString envgrp = iface->environmentGroup(cfg); + const KDevelop::EnvironmentProfileList environmentProfiles(KSharedConfig::openConfig()); + QString envProfileName = iface->environmentProfileName(cfg); QString err; QUrl executable = iface->executable( cfg, err ); @@ -63,14 +63,13 @@ return; } - if( envgrp.isEmpty() ) - { - qWarning() << "Launch Configuration:" << cfg->name() << i18n("No environment group specified, looks like a broken " + if (envProfileName.isEmpty()) { + qWarning() << "Launch Configuration:" << cfg->name() << i18n("No environment profile specified, looks like a broken " "configuration, please check run configuration '%1'. " - "Using default environment group.", cfg->name() ); - envgrp = l.defaultGroup(); + "Using default environment profile.", cfg->name() ); + envProfileName = environmentProfiles.defaultProfileName(); } - setEnvironmentProfile(envgrp); + setEnvironmentProfile(envProfileName); QStringList arguments = iface->arguments( cfg, err ); if( !err.isEmpty() ) diff --git a/plugins/executescript/executescriptplugin.h b/plugins/executescript/executescriptplugin.h --- a/plugins/executescript/executescriptplugin.h +++ b/plugins/executescript/executescriptplugin.h @@ -50,7 +50,7 @@ static QString runCurrentFileEntry; static QString argumentsEntry; static QString isExecutableEntry; - static QString environmentGroupEntry; + static QString environmentProfileEntry; //static QString useTerminalEntry; static QString userIdToRunEntry; static QString projectTargetEntry; @@ -63,7 +63,7 @@ QString remoteHost(KDevelop::ILaunchConfiguration* , QString& err) const override; QStringList arguments( KDevelop::ILaunchConfiguration*, QString& err ) const override; QUrl workingDirectory( KDevelop::ILaunchConfiguration* ) const override; - QString environmentGroup( KDevelop::ILaunchConfiguration* ) const override; + QString environmentProfileName(KDevelop::ILaunchConfiguration*) const override; //bool useTerminal( KDevelop::ILaunchConfiguration* ) const; QString scriptAppConfigTypeId() const override; int outputFilterModeId( KDevelop::ILaunchConfiguration* ) const override; diff --git a/plugins/executescript/executescriptplugin.cpp b/plugins/executescript/executescriptplugin.cpp --- a/plugins/executescript/executescriptplugin.cpp +++ b/plugins/executescript/executescriptplugin.cpp @@ -47,7 +47,8 @@ QString ExecuteScriptPlugin::remoteHostEntry = QStringLiteral("Remote Host"); QString ExecuteScriptPlugin::argumentsEntry = QStringLiteral("Arguments"); QString ExecuteScriptPlugin::isExecutableEntry = QStringLiteral("isExecutable"); -QString ExecuteScriptPlugin::environmentGroupEntry = QStringLiteral("EnvironmentGroup"); +// TODO: migrate to more consistent key term "EnvironmentProfile" +QString ExecuteScriptPlugin::environmentProfileEntry = QStringLiteral("EnvironmentGroup"); //QString ExecuteScriptPlugin::useTerminalEntry = "Use External Terminal"; QString ExecuteScriptPlugin::userIdToRunEntry = QStringLiteral("User Id to Run"); QString ExecuteScriptPlugin::projectTargetEntry = QStringLiteral("Project Target"); @@ -161,14 +162,14 @@ return args; } -QString ExecuteScriptPlugin::environmentGroup( KDevelop::ILaunchConfiguration* cfg ) const +QString ExecuteScriptPlugin::environmentProfileName(KDevelop::ILaunchConfiguration* cfg) const { if( !cfg ) { return QString(); } - return cfg->config().readEntry( ExecuteScriptPlugin::environmentGroupEntry, "" ); + return cfg->config().readEntry(ExecuteScriptPlugin::environmentProfileEntry, QString()); } int ExecuteScriptPlugin::outputFilterModeId( KDevelop::ILaunchConfiguration* cfg ) const diff --git a/plugins/executescript/iexecutescriptplugin.h b/plugins/executescript/iexecutescriptplugin.h --- a/plugins/executescript/iexecutescriptplugin.h +++ b/plugins/executescript/iexecutescriptplugin.h @@ -49,7 +49,7 @@ virtual QString remoteHost( KDevelop::ILaunchConfiguration*, QString& ) const = 0; virtual QStringList arguments( KDevelop::ILaunchConfiguration*, QString& ) const = 0; virtual QUrl workingDirectory( KDevelop::ILaunchConfiguration* ) const = 0; - virtual QString environmentGroup( KDevelop::ILaunchConfiguration* ) const = 0; + virtual QString environmentProfileName(KDevelop::ILaunchConfiguration*) const = 0; //virtual bool useTerminal( KDevelop::ILaunchConfiguration* ) const = 0; virtual QString scriptAppConfigTypeId() const = 0; virtual int outputFilterModeId( KDevelop::ILaunchConfiguration* ) const = 0; diff --git a/plugins/executescript/scriptappconfig.cpp b/plugins/executescript/scriptappconfig.cpp --- a/plugins/executescript/scriptappconfig.cpp +++ b/plugins/executescript/scriptappconfig.cpp @@ -90,7 +90,7 @@ } arguments->setText( cfg.readEntry( ExecuteScriptPlugin::argumentsEntry, "" ) ); workingDirectory->setUrl( cfg.readEntry( ExecuteScriptPlugin::workingDirEntry, QUrl() ) ); - environment->setCurrentProfile( cfg.readEntry( ExecuteScriptPlugin::environmentGroupEntry, QString() ) ); + environment->setCurrentProfile(cfg.readEntry(ExecuteScriptPlugin::environmentProfileEntry, QString())); outputFilteringMode->setCurrentIndex( cfg.readEntry( ExecuteScriptPlugin::outputFilteringEntry, 2u )); //runInTerminal->setChecked( cfg.readEntry( ExecuteScriptPlugin::useTerminalEntry, false ) ); } @@ -125,7 +125,7 @@ cfg.writeEntry( ExecuteScriptPlugin::runCurrentFileEntry, runCurrentFile->isChecked() ); cfg.writeEntry( ExecuteScriptPlugin::argumentsEntry, arguments->text() ); cfg.writeEntry( ExecuteScriptPlugin::workingDirEntry, workingDirectory->url() ); - cfg.writeEntry( ExecuteScriptPlugin::environmentGroupEntry, environment->currentProfile() ); + cfg.writeEntry( ExecuteScriptPlugin::environmentProfileEntry, environment->currentProfile() ); cfg.writeEntry( ExecuteScriptPlugin::outputFilteringEntry, outputFilteringMode->currentIndex() ); //cfg.writeEntry( ExecuteScriptPlugin::useTerminalEntry, runInTerminal->isChecked() ); } diff --git a/plugins/executescript/scriptappjob.cpp b/plugins/executescript/scriptappjob.cpp --- a/plugins/executescript/scriptappjob.cpp +++ b/plugins/executescript/scriptappjob.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -55,8 +55,8 @@ IExecuteScriptPlugin* iface = KDevelop::ICore::self()->pluginController()->pluginForExtension(QStringLiteral("org.kdevelop.IExecuteScriptPlugin"))->extension(); Q_ASSERT(iface); - KDevelop::EnvironmentGroupList l(KSharedConfig::openConfig()); - QString envgrp = iface->environmentGroup(cfg); + const KDevelop::EnvironmentProfileList environmentProfiles(KSharedConfig::openConfig()); + QString envProfileName = iface->environmentProfileName(cfg); QString err; QString interpreterString = iface->interpreter( cfg, err ); @@ -106,12 +106,11 @@ return; } - if( envgrp.isEmpty() ) - { - qWarning() << "Launch Configuration:" << cfg->name() << i18n("No environment group specified, looks like a broken " + if (envProfileName.isEmpty()) { + qWarning() << "Launch Configuration:" << cfg->name() << i18n("No environment profile specified, looks like a broken " "configuration, please check run configuration '%1'. " - "Using default environment group.", cfg->name() ); - envgrp = l.defaultGroup(); + "Using default environment profile.", cfg->name() ); + envProfileName = environmentProfiles.defaultProfileName(); } QStringList arguments = iface->arguments( cfg, err ); @@ -142,7 +141,7 @@ // Now setup the process parameters - proc->setEnvironment( l.createEnvironment( envgrp, proc->systemEnvironment()) ); + proc->setEnvironment(environmentProfiles.createEnvironment(envProfileName, proc->systemEnvironment())); QUrl wc = iface->workingDirectory( cfg ); if( !wc.isValid() || wc.isEmpty() ) { diff --git a/shell/environmentconfigurebutton.cpp b/shell/environmentconfigurebutton.cpp --- a/shell/environmentconfigurebutton.cpp +++ b/shell/environmentconfigurebutton.cpp @@ -21,7 +21,6 @@ #include "environmentconfigurebutton.h" #include -#include #include "settings/environmentpreferences.h" #include diff --git a/shell/settings/environmentprofilelistmodel.h b/shell/settings/environmentprofilelistmodel.h --- a/shell/settings/environmentprofilelistmodel.h +++ b/shell/settings/environmentprofilelistmodel.h @@ -22,15 +22,15 @@ #define KDEVPLATFORM_ENVIRONMENTPROFILELISTMODEL_H #include -#include "util/environmentgrouplist.h" +#include "util/environmentprofilelist.h" class QStringList; namespace KDevelop { -// Subclassing EnvironmentGroupList instead of having as a member, to have access to protected API -class EnvironmentProfileListModel : public QAbstractItemModel, protected EnvironmentGroupList +// Subclassing EnvironmentProfileList instead of having as a member, to have access to protected API +class EnvironmentProfileListModel : public QAbstractItemModel, protected EnvironmentProfileList { Q_OBJECT diff --git a/shell/settings/environmentprofilelistmodel.cpp b/shell/settings/environmentprofilelistmodel.cpp --- a/shell/settings/environmentprofilelistmodel.cpp +++ b/shell/settings/environmentprofilelistmodel.cpp @@ -35,7 +35,7 @@ return 0; } - return groups().count(); + return profileNames().count(); } int EnvironmentProfileListModel::columnCount(const QModelIndex& parent) const @@ -56,8 +56,8 @@ } if (role == Qt::DisplayRole) { - auto profileName = groups().at(index.row()); - if (profileName == defaultGroup()) { + auto profileName = profileNames().at(index.row()); + if (profileName == defaultProfileName()) { profileName = i18n("%1 (default profile)", profileName); } return profileName; @@ -82,32 +82,32 @@ int EnvironmentProfileListModel::defaultProfileIndex() const { - return groups().indexOf(defaultGroup()); + return profileNames().indexOf(defaultProfileName()); } QString EnvironmentProfileListModel::profileName(int profileIndex) const { - return groups().value(profileIndex); + return profileNames().value(profileIndex); } int EnvironmentProfileListModel::profileIndex(const QString& profileName) const { - return groups().indexOf(profileName); + return profileNames().indexOf(profileName); } bool EnvironmentProfileListModel::hasProfile(const QString& profileName) const { - return groups().contains(profileName); + return profileNames().contains(profileName); } QMap& EnvironmentProfileListModel::variables(const QString& profileName) { - return EnvironmentGroupList::variables(profileName); + return EnvironmentProfileList::variables(profileName); } int EnvironmentProfileListModel::addProfile(const QString& newProfileName) { - const auto profileNames = groups(); + const auto profileNames = this->profileNames(); if (newProfileName.isEmpty() || profileNames.contains(newProfileName)) { return -1; @@ -130,27 +130,27 @@ void EnvironmentProfileListModel::removeProfile(int profileIndex) { - const auto profileNames = groups(); + const auto profileNames = this->profileNames(); if (profileIndex < 0 || profileIndex >= profileNames.size()) { return; } const auto profileName = profileNames.at(profileIndex); - if (defaultGroup() == profileName) { + if (defaultProfileName() == profileName) { return; } emit profileAboutToBeRemoved(profileName); beginRemoveRows(QModelIndex(), profileIndex, profileIndex); - EnvironmentGroupList::removeGroup(profileName); + EnvironmentProfileList::removeProfile(profileName); endRemoveRows(); } int EnvironmentProfileListModel::cloneProfile(const QString& newProfileName, const QString& sourceProfileName) { - const auto profileNames = groups(); + const auto profileNames = this->profileNames(); if (newProfileName.isEmpty() || profileNames.contains(newProfileName) || !profileNames.contains(sourceProfileName)) { @@ -175,8 +175,8 @@ void EnvironmentProfileListModel::setDefaultProfile(int profileIndex) { - const auto profileNames = groups(); - const auto oldDefaultProfileName = defaultGroup(); + const auto profileNames = this->profileNames(); + const auto oldDefaultProfileName = defaultProfileName(); const int oldDefaultProfileIndex = profileNames.indexOf(oldDefaultProfileName); if (profileIndex < 0 || profileIndex >= profileNames.size() || @@ -187,7 +187,7 @@ const auto oldIndex = index(oldDefaultProfileIndex, 0); const auto profileName = profileNames.at(profileIndex); - setDefaultGroup(profileName); + EnvironmentProfileList::setDefaultProfile(profileName); const int newDefaultProfileIndex = profileNames.indexOf(profileName); const auto newIndex = index(newDefaultProfileIndex, 0); diff --git a/shell/settings/environmentprofilemodel.h b/shell/settings/environmentprofilemodel.h --- a/shell/settings/environmentprofilemodel.h +++ b/shell/settings/environmentprofilemodel.h @@ -23,7 +23,6 @@ #include #include -#include "util/environmentgrouplist.h" namespace KDevelop { diff --git a/shell/settings/environmentwidget.h b/shell/settings/environmentwidget.h --- a/shell/settings/environmentwidget.h +++ b/shell/settings/environmentwidget.h @@ -37,7 +37,7 @@ /** * @short Environment variable setting widget. - * This class manages a EnvironmentGroupList and allows one to change the variables and add/remove groups + * This class manages a EnvironmentProfileList and allows one to change the variables and add/remove groups * * @sa EnvPreferences */ diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -13,7 +13,7 @@ commandexecutor.cpp environmentselectionwidget.cpp environmentselectionmodel.cpp - environmentgrouplist.cpp + environmentprofilelist.cpp jobstatus.cpp activetooltip.cpp executecompositejob.cpp @@ -76,7 +76,7 @@ processlinemaker.h commandexecutor.h environmentselectionwidget.h - environmentgrouplist.h + environmentprofilelist.h jobstatus.h pushvalue.h kdevvarlengtharray.h diff --git a/util/environmentgrouplist.h b/util/environmentprofilelist.h rename from util/environmentgrouplist.h rename to util/environmentprofilelist.h --- a/util/environmentgrouplist.h +++ b/util/environmentprofilelist.h @@ -17,8 +17,8 @@ Boston, MA 02110-1301, USA. */ -#ifndef KDEVPLATFORM_ENVIRONMENTGROUPLIST_H -#define KDEVPLATFORM_ENVIRONMENTGROUPLIST_H +#ifndef KDEVPLATFORM_ENVIRONMENTPROFILELIST_H +#define KDEVPLATFORM_ENVIRONMENTPROFILELIST_H #include "utilexport.h" @@ -34,7 +34,7 @@ { /** - * This class manages a list of environment groups, each group containing a number + * This class manages a list of environment profiles, each profile containing a number * of environment variables and their values. * * The class is constructed from a KConfig object for easy usage in the plugins. @@ -45,19 +45,19 @@ * Example Usage * \code * KSharedConfigPtr config = KSharedConfig::openConfig(); - * EnvironmentGroupList env(config); + * EnvironmentProfileList env(config); * KConfigGroup cfg(config, "QMake Builder"); * QMap myenvVars = env.variables( cfg.readEntry("QMake Environment") ); * \endcode * * Two entries are used by this class: * "Default Environment Group" and "Environment Variables". * - * "Default Environment Variables" stores the default group that should be used if the - * user didn't select a group via a plugins configuration dialog. + * "Default Environment Variables" stores the default profile that should be used if the + * user didn't select a profile via a plugins configuration dialog. * * "Environment Variables" entry stores the actual list of - * . The groupname can't contain '%' or '='. + * . The profilename can't contain '%' or '='. * For example, suppose that two configuration, say "release" and "debug" exist. * Then the actual contents of .kdev4 project file will be * @@ -68,76 +68,77 @@ * \endcode * */ -class KDEVPLATFORMUTIL_EXPORT EnvironmentGroupList +class KDEVPLATFORMUTIL_EXPORT EnvironmentProfileList { public: - EnvironmentGroupList( const EnvironmentGroupList& rhs ); - EnvironmentGroupList& operator=( const EnvironmentGroupList& rhs ); + EnvironmentProfileList(const EnvironmentProfileList& rhs); + EnvironmentProfileList& operator=(const EnvironmentProfileList& rhs); /** - * Creates an a list of EnvironmentGroups from a KConfig object - * @param config the KConfig object to read the environment groups from + * Creates an a list of environment profiles from a KConfig object + * @param config the KConfig object to read the environment profiles from */ - explicit EnvironmentGroupList( KSharedConfigPtr config ); - explicit EnvironmentGroupList( KConfig* config ); - ~EnvironmentGroupList(); + explicit EnvironmentProfileList(KSharedConfigPtr config); + explicit EnvironmentProfileList(KConfig* config ); + ~EnvironmentProfileList(); /** * Creates a merged environment between the defaults specified by - * \a defaultEnvironment and those saved in \a group + * \a defaultEnvironment and those saved in \a profileName */ - QStringList createEnvironment(const QString& group, const QStringList& defaultEnvironment ) const; + QStringList createEnvironment(const QString& profileName, const QStringList& defaultEnvironment) const; /** - * returns the variables that are set for a given group. + * returns the variables that are set for a given profile. * This function provides read-only access to the environment - * @param group the name of the group for which the environment should be returned - * @return a map containing the environment variables for this group, or an empty map if the group doesn't exist in this list + * @param profileName the name of the profile for which the environment should be returned + * @return a map containing the environment variables for this profile, or an empty map if the profile doesn't exist in this list */ - const QMap variables( const QString& group ) const; + QMap variables(const QString& profileName) const; /** - * returns the default group - * The default group should be used by plugins unless the user chooses a different group - * @return the name of the default group, defaults to "default" + * returns the name of the default profile + * The default profile should be used by plugins unless the user chooses a different profile + * @return the name of the default profile, defaults to "default" */ - QString defaultGroup() const; + QString defaultProfileName() const; /** - * Fetch the list of known groups from the list - * @return the list of groups + * Fetch the list of names of known profiles from the list + * @return the list of profile names */ - QStringList groups() const; + QStringList profileNames() const; protected: - EnvironmentGroupList(); + EnvironmentProfileList(); /** - * returns the variables that are set for a given group. + * returns the variables that are set for a given profile. * This function provides write access to the environment, so new variables can be inserted, existing ones changed or deleted * - * If a non-existing group is specified this returns a new empty map and that way this function can be used to add a new group - * to the list of environment groups - * @param group the name of the group for which the environment should be returned - * @return a map containing the environment variables for this group, or an empty map if the group doesn't exist in this list + * If a non-existing profile is specified this returns a new empty map and that way this function can be used to add a new profile + * to the list of environment profiles + * @param profileName the name of the profile for which the environment should be returned + * @return a map containing the environment variables for this profile, or an empty map if the profile doesn't exist in this list */ - QMap& variables( const QString& group ); + QMap& variables(const QString& profileName); /** - * Changes the default group. - * @param group a new groupname, if a group of this name doesn't exist the default group is not changed + * Changes the default profile. + * @param profileName the name of the new default profile, if a profile of this name doesn't exist the default profile is not changed */ - void setDefaultGroup( const QString& group ); + void setDefaultProfile(const QString& profileName); /** - * Stores the environment groups in this list to the given KConfig object + * Stores the environment profiles in this list to the given KConfig object * @param config a KConfig object to which the environment settings should be stored */ void saveSettings( KConfig* config ) const; void loadSettings( KConfig* config ); - void removeGroup( const QString& group ); + void removeProfile(const QString& profileName); + private: - class EnvironmentGroupListPrivate* const d; + class EnvironmentProfileListPrivate* const d; }; diff --git a/util/environmentgrouplist.cpp b/util/environmentprofilelist.cpp rename from util/environmentgrouplist.cpp rename to util/environmentprofilelist.cpp --- a/util/environmentgrouplist.cpp +++ b/util/environmentprofilelist.cpp @@ -17,7 +17,7 @@ Boston, MA 02110-1301, USA. */ -#include "environmentgrouplist.h" +#include "environmentprofilelist.h" #include #include @@ -29,56 +29,55 @@ #include namespace KDevelop { -class EnvironmentGroupListPrivate +class EnvironmentProfileListPrivate { public: - QMap > m_groups; - QString m_defaultGroup; + QMap > m_profiles; + QString m_defaultProfileName; }; } using namespace KDevelop; namespace { namespace Strings { -inline QString defaultEnvGroupKey() { return QStringLiteral("Default Environment Group"); } +// TODO: migrate to more consistent key term "Default Environment Profile" +inline QString defaultEnvProfileKey() { return QStringLiteral("Default Environment Group"); } inline QString envGroup() { return QStringLiteral("Environment Settings"); } -inline QString groupListKey() { return QStringLiteral("Group List"); } -inline QString defaultGroup() { return QStringLiteral("default"); } +// TODO: migrate to more consistent key term "Profile List" +inline QString profileListKey() { return QStringLiteral("Group List"); } +inline QString defaultProfileName() { return QStringLiteral("default"); } } -void decode( KConfig* config, EnvironmentGroupListPrivate* d ) +void decode(KConfig* config, EnvironmentProfileListPrivate* d) { KConfigGroup cfg( config, Strings::envGroup() ); - d->m_defaultGroup = cfg.readEntry( Strings::defaultEnvGroupKey(), Strings::defaultGroup() ); - QStringList grouplist = cfg.readEntry( Strings::groupListKey(), QStringList{Strings::defaultGroup()} ); - foreach( const QString &envgrpname, grouplist ) - { - KConfigGroup envgrp( &cfg, envgrpname ); + d->m_defaultProfileName = cfg.readEntry(Strings::defaultEnvProfileKey(), Strings::defaultProfileName()); + const QStringList profileNames = cfg.readEntry(Strings::profileListKey(), QStringList{Strings::defaultProfileName()}); + for (const auto& profileName : profileNames) { + KConfigGroup envgrp(&cfg, profileName); QMap variables; foreach( const QString &varname, envgrp.keyList() ) { variables[varname] = envgrp.readEntry( varname, QString() ); } - d->m_groups.insert( envgrpname, variables ); + d->m_profiles.insert(profileName, variables); } } -void encode( KConfig* config, EnvironmentGroupListPrivate* d ) +void encode(KConfig* config, EnvironmentProfileListPrivate* d) { KConfigGroup cfg( config, Strings::envGroup() ); - cfg.writeEntry( Strings::defaultEnvGroupKey(), d->m_defaultGroup ); - cfg.writeEntry( Strings::groupListKey(), d->m_groups.keys() ); + cfg.writeEntry(Strings::defaultEnvProfileKey(), d->m_defaultProfileName); + cfg.writeEntry(Strings::profileListKey(), d->m_profiles.keys()); foreach( const QString &group, cfg.groupList() ) { - if( !d->m_groups.contains( group ) ) - { + if (!d->m_profiles.contains(group)) { cfg.deleteGroup( group ); } } - for(auto it = d->m_groups.cbegin(), itEnd = d->m_groups.cend(); it!=itEnd; ++it) - { + for (auto it = d->m_profiles.cbegin(), itEnd = d->m_profiles.cend(); it!=itEnd; ++it) { KConfigGroup envgrp( &cfg, it.key() ); envgrp.deleteGroup(); @@ -93,90 +92,88 @@ } -EnvironmentGroupList::EnvironmentGroupList( const EnvironmentGroupList& rhs ) - : d( new EnvironmentGroupListPrivate( *rhs.d ) ) +EnvironmentProfileList::EnvironmentProfileList(const EnvironmentProfileList& rhs) + : d(new EnvironmentProfileListPrivate(*rhs.d)) { } -EnvironmentGroupList& EnvironmentGroupList::operator=( const EnvironmentGroupList& rhs ) +EnvironmentProfileList& EnvironmentProfileList::operator=(const EnvironmentProfileList& rhs) { *d = *rhs.d; return *this; } -EnvironmentGroupList::EnvironmentGroupList( KSharedConfigPtr config ) - : d( new EnvironmentGroupListPrivate ) +EnvironmentProfileList::EnvironmentProfileList(KSharedConfigPtr config) + : d( new EnvironmentProfileListPrivate ) { decode( config.data(), d ); } -EnvironmentGroupList::EnvironmentGroupList( KConfig* config ) - : d( new EnvironmentGroupListPrivate ) +EnvironmentProfileList::EnvironmentProfileList(KConfig* config) + : d(new EnvironmentProfileListPrivate) { decode( config, d ); } -EnvironmentGroupList::~EnvironmentGroupList() +EnvironmentProfileList::~EnvironmentProfileList() { delete d; } -const QMap EnvironmentGroupList::variables( const QString& group ) const +QMap EnvironmentProfileList::variables(const QString& profileName) const { - return d->m_groups[group.isEmpty() ? d->m_defaultGroup : group]; + return d->m_profiles[profileName.isEmpty() ? d->m_defaultProfileName : profileName]; } -QMap& EnvironmentGroupList::variables( const QString& group ) +QMap& EnvironmentProfileList::variables(const QString& profileName) { - return d->m_groups[group.isEmpty() ? d->m_defaultGroup : group]; + return d->m_profiles[profileName.isEmpty() ? d->m_defaultProfileName : profileName]; } -QString EnvironmentGroupList::defaultGroup() const +QString EnvironmentProfileList::defaultProfileName() const { - return d->m_defaultGroup; + return d->m_defaultProfileName; } -void EnvironmentGroupList::setDefaultGroup( const QString& group ) +void EnvironmentProfileList::setDefaultProfile(const QString& profileName) { - if( group.isEmpty() ) { + if (profileName.isEmpty() || + !d->m_profiles.contains(profileName)) { return; } - if( d->m_groups.contains( group ) ) - { - d->m_defaultGroup = group; - } + d->m_defaultProfileName = profileName; } -void EnvironmentGroupList::saveSettings( KConfig* config ) const +void EnvironmentProfileList::saveSettings(KConfig* config) const { encode( config, d ); config->sync(); } -void EnvironmentGroupList::loadSettings( KConfig* config ) +void EnvironmentProfileList::loadSettings(KConfig* config) { - d->m_groups.clear(); + d->m_profiles.clear(); decode( config, d ); } -QStringList EnvironmentGroupList::groups() const +QStringList EnvironmentProfileList::profileNames() const { - return d->m_groups.keys(); + return d->m_profiles.keys(); } -void EnvironmentGroupList::removeGroup( const QString& group ) +void EnvironmentProfileList::removeProfile(const QString& profileName) { - d->m_groups.remove( group ); + d->m_profiles.remove(profileName); } -EnvironmentGroupList::EnvironmentGroupList() - : d( new EnvironmentGroupListPrivate ) +EnvironmentProfileList::EnvironmentProfileList() + : d(new EnvironmentProfileListPrivate) { } -QStringList EnvironmentGroupList::createEnvironment( const QString & group, const QStringList & defaultEnvironment ) const +QStringList EnvironmentProfileList::createEnvironment(const QString& profileName, const QStringList& defaultEnvironment) const { QMap retMap; foreach( const QString &line, defaultEnvironment ) @@ -186,8 +183,8 @@ retMap.insert( varName, varValue ); } - if( !group.isEmpty() ) { - QMap userMap = variables(group); + if (!profileName.isEmpty()) { + const auto userMap = variables(profileName); for( QMap::const_iterator it = userMap.constBegin(); it != userMap.constEnd(); ++it ) diff --git a/util/environmentselectionmodel.h b/util/environmentselectionmodel.h --- a/util/environmentselectionmodel.h +++ b/util/environmentselectionmodel.h @@ -20,11 +20,10 @@ #ifndef ENVIRONMENTSELECTIONMODEL_H #define ENVIRONMENTSELECTIONMODEL_H -#include "environmentgrouplist.h" +#include "environmentprofilelist.h" #include - -#include +#include namespace KDevelop { @@ -47,10 +46,10 @@ bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override; /** - * @returns The @ref EnvironmentGroupList which has bee used to populate this + * @returns The @ref EnvironmentProfileList which has been used to populate this * model. */ - EnvironmentGroupList environment() const; + EnvironmentProfileList environmentProfiles() const; /** * Reloads the model from the global config. @@ -66,8 +65,8 @@ QString reloadSelectedItem( const QString& currentProfile ); private: - EnvironmentGroupList m_env; - QSet m_groupsLookupTable; + EnvironmentProfileList m_env; + QSet m_profilesLookupTable; }; } // namespace KDevelop diff --git a/util/environmentselectionmodel.cpp b/util/environmentselectionmodel.cpp --- a/util/environmentselectionmodel.cpp +++ b/util/environmentselectionmodel.cpp @@ -19,13 +19,15 @@ #include "environmentselectionmodel.h" +#include + namespace { -QStringList entriesFromEnv( const KDevelop::EnvironmentGroupList& env ) +QStringList entriesFromEnv(const KDevelop::EnvironmentProfileList& env) { // We add an empty (i. e. default profile) entry to the front of the model's list. - return QStringList( QString() ) + env.groups(); + return QStringList(QString()) + env.profileNames(); } } @@ -38,7 +40,7 @@ m_env( KSharedConfig::openConfig() ) { setStringList( entriesFromEnv( m_env ) ); - m_groupsLookupTable = stringList().toSet(); + m_profilesLookupTable = stringList().toSet(); } QVariant EnvironmentSelectionModel::headerData( int section, Qt::Orientation orientation, int role ) const @@ -60,18 +62,18 @@ switch( role ) { case Qt::DisplayRole: if( profileName.isEmpty() ) { - return i18nc( "@item:inlistbox", "Use default profile (currently: %1)", m_env.defaultGroup() ); + return i18nc("@item:inlistbox", "Use default profile (currently: %1)", m_env.defaultProfileName()); } - if( !m_groupsLookupTable.contains( profileName ) ) { + if (!m_profilesLookupTable.contains(profileName)) { return i18nc( "@item:inlistbox", "%1 (does not exist)", profileName ); } return nativeData; case EffectiveNameRole: if( profileName.isEmpty() ) { - return m_env.defaultGroup(); + return m_env.defaultProfileName(); } return nativeData; @@ -86,22 +88,22 @@ return false; } -EnvironmentGroupList EnvironmentSelectionModel::environment() const +EnvironmentProfileList EnvironmentSelectionModel::environmentProfiles() const { return m_env; } void EnvironmentSelectionModel::reload() { - m_env = EnvironmentGroupList( KSharedConfig::openConfig() ); + m_env = EnvironmentProfileList(KSharedConfig::openConfig()); setStringList( entriesFromEnv( m_env ) ); - m_groupsLookupTable = stringList().toSet(); + m_profilesLookupTable = stringList().toSet(); } QString EnvironmentSelectionModel::reloadSelectedItem( const QString& currentProfile ) { - if( m_groupsLookupTable.contains( currentProfile ) ) { + if (m_profilesLookupTable.contains(currentProfile)) { return currentProfile; } else { return QString(); diff --git a/util/environmentselectionwidget.h b/util/environmentselectionwidget.h --- a/util/environmentselectionwidget.h +++ b/util/environmentselectionwidget.h @@ -22,10 +22,10 @@ #include #include "utilexport.h" -#include "environmentgrouplist.h" namespace KDevelop { +class EnvironmentProfileList; /** * Simple combobox which allows each plugin to decide which environment @@ -65,10 +65,10 @@ QString effectiveProfileName() const; /** - * @returns The @ref EnvironmentGroupList which has been used to populate this + * @returns The @ref EnvironmentProfileList which has been used to populate this * widget. */ - EnvironmentGroupList environment() const; + EnvironmentProfileList environmentProfiles() const; public slots: /** diff --git a/util/environmentselectionwidget.cpp b/util/environmentselectionwidget.cpp --- a/util/environmentselectionwidget.cpp +++ b/util/environmentselectionwidget.cpp @@ -17,7 +17,7 @@ Boston, MA 02110-1301, USA. */ #include "environmentselectionwidget.h" -#include "environmentgrouplist.h" +#include "environmentprofilelist.h" #include "environmentselectionmodel.h" #include @@ -89,9 +89,9 @@ return d->model->index( d->comboBox->currentIndex(), 0 ).data( EnvironmentSelectionModel::EffectiveNameRole ).toString(); } -EnvironmentGroupList EnvironmentSelectionWidget::environment() const +EnvironmentProfileList EnvironmentSelectionWidget::environmentProfiles() const { - return d->model->environment(); + return d->model->environmentProfiles(); } } diff --git a/util/tests/test_environment.cpp b/util/tests/test_environment.cpp --- a/util/tests/test_environment.cpp +++ b/util/tests/test_environment.cpp @@ -21,7 +21,7 @@ #include "test_environment.h" -#include "util/environmentgrouplist.h" +#include "util/environmentprofilelist.h" #include