summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess.cpp
diff options
context:
space:
mode:
authorThomas Sondergaard <ts@medical-insight.com>2011-04-04 09:40:46 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-04-04 10:21:50 (GMT)
commit0cf75b4dd1cc25694de8ece4c25ecb97a3969a54 (patch)
tree0724f3cb6b84f5fcbec493860c084e2d5442bb2d /src/corelib/io/qprocess.cpp
parent0c291498c3cf1aa254df41ce99f249e2116da025 (diff)
downloadQt-0cf75b4dd1cc25694de8ece4c25ecb97a3969a54.zip
Qt-0cf75b4dd1cc25694de8ece4c25ecb97a3969a54.tar.gz
Qt-0cf75b4dd1cc25694de8ece4c25ecb97a3969a54.tar.bz2
Add methods for traversing and combining QProcessEnvironment.
New methods that make QProcessEnvironment more friendly. With these two new functions developers no longer have to resort to using QStringList and use the deprecated QProcess::setEnvironment() method. New methods: - QStringList QProcessEnvironment::keys() - void QProcessEnvironment::insert(const QProcessEnvironment &). Merge-request: 1152 Reviewed-by: ossi Reviewed-by: thiago
Diffstat (limited to 'src/corelib/io/qprocess.cpp')
-rw-r--r--src/corelib/io/qprocess.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index e11cef9..db41a55 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -221,6 +221,24 @@ QProcessEnvironment QProcessEnvironmentPrivate::fromList(const QStringList &list
return env;
}
+QStringList QProcessEnvironmentPrivate::keys() const
+{
+ QStringList result;
+ QHash<Unit, Unit>::ConstIterator it = hash.constBegin(),
+ end = hash.constEnd();
+ for ( ; it != end; ++it)
+ result << nameToString(it.key());
+ return result;
+}
+
+void QProcessEnvironmentPrivate::insert(const Hash &h)
+{
+ QHash<Unit, Unit>::ConstIterator it = h.constBegin(),
+ end = h.constEnd();
+ for ( ; it != end; ++it)
+ hash.insert(it.key(), it.value());
+}
+
/*!
Creates a new QProcessEnvironment object. This constructor creates an
empty environment. If set on a QProcess, this will cause the current
@@ -396,6 +414,33 @@ QStringList QProcessEnvironment::toStringList() const
return d ? d->toList() : QStringList();
}
+/*!
+ \since 4.8
+
+ Returns a list containing all the variable names in this QProcessEnvironment
+ object.
+*/
+QStringList QProcessEnvironment::keys() const
+{
+ return d ? d->keys() : QStringList();
+}
+
+/*!
+ \overload
+ \since 4.8
+
+ Inserts the contents of \a e in this QProcessEnvironment object. Variables in
+ this object that also exist in \a e will be overwritten.
+*/
+void QProcessEnvironment::insert(const QProcessEnvironment &e)
+{
+ if (!e.d)
+ return;
+
+ // d detaches from null
+ d->insert(e.d->hash);
+}
+
void QProcessPrivate::Channel::clear()
{
switch (type) {