[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kproperty] src: Make KProperty::hasOptions() look at parent property too, if possible
From: Jaroslaw Staniek <staniek () kde ! org>
Date: 2016-11-07 23:13:14
Message-ID: E1c3t6I-0005XI-6S () code ! kde ! org
[Download RAW message or body]
Git commit 6f90a8f16b22461235e69266ebbeba4e44d9e32e by Jaroslaw Staniek.
Committed on 07/11/2016 at 23:12.
Pushed by staniek into branch 'master'.
Make KProperty::hasOptions() look at parent property too, if possible
Since 3.1
M +1 -1 src/KProperty.cpp
M +6 -1 src/KProperty.h
http://commits.kde.org/kproperty/6f90a8f16b22461235e69266ebbeba4e44d9e32e
diff --git a/src/KProperty.cpp b/src/KProperty.cpp
index fcde96a..9726bd6 100644
--- a/src/KProperty.cpp
+++ b/src/KProperty.cpp
@@ -568,7 +568,7 @@ QVariant KProperty::option(const char* name, const QVariant& defaultValue) const
bool
KProperty::hasOptions() const
{
- return !d->options.isEmpty();
+ return !d->options.isEmpty() || (d->parent && d->parent->hasOptions());
}
/////////////////////////////////////////////////////////////////
diff --git a/src/KProperty.h b/src/KProperty.h
index a3b52b7..e48726d 100644
--- a/src/KProperty.h
+++ b/src/KProperty.h
@@ -446,7 +446,12 @@ public:
*/
QVariant option(const char* name, const QVariant& defaultValue = QVariant()) const;
- /*! \return true if at least one option is defined for this property. */
+ /*! @brief Returns @c true if at least one option is specified for this property
+ * If there are no options defined @c true can be still returned if parent property
+ * is present and it has at least one option specified.
+ * Looking at parent property is available since 3.1.
+ * @note The lookup is performed recursively, first in parent, then grand parent, etc.
+ */
bool hasOptions() const;
/*! Equivalent to setValue(const QVariant &) */
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic