aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergely Risko <gergely+context@risko.hu>2009-12-09 10:56:20 +0200
committerGergely Risko <gergely+context@risko.hu>2009-12-09 10:56:20 +0200
commitb8971ba7f8b8d4287060ebb91889f892396a10a0 (patch)
treeaccd6dfb79e8dba7b4a01ae3232fdc72c8ed49f5
parent8d6a43aa2470a746d613e87e953a673b399dba45 (diff)
New getBase("foobar") accessor in contexttypeinfo.
Used in the commander as getBase("string-enum") and getBase("integer"), to render the combobox and spinbox with good parameters.
-rw-r--r--libcontextsubscriber/src/contexttypeinfo.cpp14
-rw-r--r--libcontextsubscriber/src/contexttypeinfo.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/libcontextsubscriber/src/contexttypeinfo.cpp b/libcontextsubscriber/src/contexttypeinfo.cpp
index a5ed9f01..df72e22d 100644
--- a/libcontextsubscriber/src/contexttypeinfo.cpp
+++ b/libcontextsubscriber/src/contexttypeinfo.cpp
@@ -258,6 +258,20 @@ bool ContextTypeInfo::hasBase(QString wanted, int depth) const
return base().hasBase(wanted, depth-1);
}
+ContextTypeInfo ContextTypeInfo::getBase(QString wanted, int depth) const
+{
+ if (name() == wanted)
+ return *this;
+
+ if (base() == AssocTree())
+ return ContextTypeInfo();
+
+ if (depth == 0)
+ return ContextTypeInfo();
+
+ return base().getBase(wanted, depth-1);
+}
+
QVariantList ContextTypeInfo::parameters() const
{
return nodes();
diff --git a/libcontextsubscriber/src/contexttypeinfo.h b/libcontextsubscriber/src/contexttypeinfo.h
index 68d94575..1dba18b7 100644
--- a/libcontextsubscriber/src/contexttypeinfo.h
+++ b/libcontextsubscriber/src/contexttypeinfo.h
@@ -38,6 +38,7 @@ public:
bool typeCheck(const QVariant &value) const;
bool hasBase(QString wanted, int depth = 10) const;
+ ContextTypeInfo getBase(QString wanted, int depth = 10) const;
QVariantList parameters() const;
QVariant parameterValue(QString p) const;
AssocTree parameterNode(QString p) const;