Commit 76738c21 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Add hasKey method to find out whether a envvar exists

Reviewed-by: dt
parent ee8caa5b
...@@ -291,6 +291,11 @@ void Environment::modify(const QList<EnvironmentItem> & list) ...@@ -291,6 +291,11 @@ void Environment::modify(const QList<EnvironmentItem> & list)
*this = resultEnvironment; *this = resultEnvironment;
} }
bool Environment::hasKey(const QString &key)
{
return m_values.contains(key);
}
bool Environment::operator!=(const Environment &other) const bool Environment::operator!=(const Environment &other) const
{ {
return !(*this == other); return !(*this == other);
......
...@@ -71,6 +71,7 @@ public: ...@@ -71,6 +71,7 @@ public:
void set(const QString &key, const QString &value); void set(const QString &key, const QString &value);
void unset(const QString &key); void unset(const QString &key);
void modify(const QList<EnvironmentItem> & list); void modify(const QList<EnvironmentItem> & list);
bool hasKey(const QString &key);
void appendOrSet(const QString &key, const QString &value, const QString &sep = QString()); void appendOrSet(const QString &key, const QString &value, const QString &sep = QString());
void prependOrSet(const QString &key, const QString &value, const QString &sep = QString()); void prependOrSet(const QString &key, const QString &value, const QString &sep = QString());
......
...@@ -271,7 +271,7 @@ QModelIndex EnvironmentModel::addVariable() ...@@ -271,7 +271,7 @@ QModelIndex EnvironmentModel::addVariable()
QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item) QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
{ {
bool existsInBaseEnvironment = (m_baseEnvironment.find(item.name) != m_baseEnvironment.constEnd()); bool existsInBaseEnvironment = m_baseEnvironment.hasKey(item.name);
int rowInResult; int rowInResult;
if (existsInBaseEnvironment) if (existsInBaseEnvironment)
rowInResult = findInResult(item.name); rowInResult = findInResult(item.name);
...@@ -301,7 +301,7 @@ void EnvironmentModel::removeVariable(const QString &name) ...@@ -301,7 +301,7 @@ void EnvironmentModel::removeVariable(const QString &name)
{ {
int rowInResult = findInResult(name); int rowInResult = findInResult(name);
int rowInChanges = findInChanges(name); int rowInChanges = findInChanges(name);
bool existsInBaseEnvironment = m_baseEnvironment.find(name) != m_baseEnvironment.constEnd(); bool existsInBaseEnvironment = m_baseEnvironment.hasKey(name);
if (existsInBaseEnvironment) { if (existsInBaseEnvironment) {
m_items.removeAt(rowInChanges); m_items.removeAt(rowInChanges);
updateResultEnvironment(); updateResultEnvironment();
...@@ -347,7 +347,7 @@ bool EnvironmentModel::isUnset(const QString &name) ...@@ -347,7 +347,7 @@ bool EnvironmentModel::isUnset(const QString &name)
bool EnvironmentModel::isInBaseEnvironment(const QString &name) bool EnvironmentModel::isInBaseEnvironment(const QString &name)
{ {
return m_baseEnvironment.find(name) != m_baseEnvironment.constEnd(); return m_baseEnvironment.hasKey(name);
} }
QList<EnvironmentItem> EnvironmentModel::userChanges() const QList<EnvironmentItem> EnvironmentModel::userChanges() const
......
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