diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-12-31 09:35:11 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-12-31 09:35:11 -0500 |
| commit | 541ed4742c6368cc36c35ca74dba09b9d108283b (patch) | |
| tree | 67e5d39723bcb7638eecaf0687baf16ed513ad00 /sigscript | |
| parent | 06387e2d3c6e4396560dfa7d6fe86d4854089858 (diff) | |
| download | sigen-541ed4742c6368cc36c35ca74dba09b9d108283b.tar.gz sigen-541ed4742c6368cc36c35ca74dba09b9d108283b.tar.xz sigen-541ed4742c6368cc36c35ca74dba09b9d108283b.zip | |
Changed Config to use Config as parents instead of plain QObject
Diffstat (limited to 'sigscript')
| -rw-r--r-- | sigscript/Config.cpp | 20 | ||||
| -rw-r--r-- | sigscript/Config.h | 3 |
2 files changed, 14 insertions, 9 deletions
diff --git a/sigscript/Config.cpp b/sigscript/Config.cpp index 54774720..70644be5 100644 --- a/sigscript/Config.cpp +++ b/sigscript/Config.cpp @@ -18,9 +18,13 @@ // Header include #include "Config.h" -Sigscript::Config::Config(QObject* parent) : +// Qt includes +#include <QtCore/QSet> + +Sigscript::Config::Config(Config* parent) : QObject(parent), - m_lock(QReadWriteLock::Recursive) + m_lock(QReadWriteLock::Recursive), + m_parent(parent) { } @@ -78,12 +82,12 @@ QVariant Sigscript::Config::value(const QString& name, const bool recursive) con } if (recursive) { - QObject* par = parent(); + Config* par = m_parent; while (par) { - if (qobject_cast<Config*>(par) && qobject_cast<Config*>(par)->hasValue(name)) - return qobject_cast<Config*>(par)->value(name); - par = par->parent(); + if (par->hasValue(name)) + return par->value(name); + par = par->m_parent; } } return QVariant(); @@ -94,8 +98,8 @@ bool Sigscript::Config::hasValue(const QString& name, const bool recursive) cons QReadLocker locker(&m_lock); if (m_values.contains(name)) return !(m_values[name].second & (Deleted | Hidden)); - if (recursive && qobject_cast<Config*>(parent())) - return qobject_cast<Config*>(parent())->hasValue(name, true); + if (recursive) + return m_parent->hasValue(name, true); return false; } diff --git a/sigscript/Config.h b/sigscript/Config.h index 309220c2..33fb4011 100644 --- a/sigscript/Config.h +++ b/sigscript/Config.h @@ -55,7 +55,7 @@ class SIGSCRIPT_EXPORT Config : public QObject typedef QPair<QVariant, Options> Value; - Config(QObject* parent); + Config(Config* parent); Q_SCRIPTABLE QVariant value(const QString& name, const bool recursive = true) const; template<typename T> T valueOfType(const QString& name, const bool recursive = true) const; @@ -78,6 +78,7 @@ class SIGSCRIPT_EXPORT Config : public QObject virtual void writeBack(); private: mutable QReadWriteLock m_lock; + Config* m_parent; QMap<QString, Value> m_values; }; |
