diff options
author | Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com> | 2013-03-20 17:14:38 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-27 19:58:19 +0200 |
commit | 7ed15da3c1b9e2bb26f414a10bfc6e6d79d7cc7b (patch) | |
tree | c315f3b0e09bb745822d2b310559e8c3b2672cc9 /src/corelib/kernel/qvariant.h | |
parent | 63354e0d097116138e7d998a01194f5ee502117a (diff) |
Core: QDebug and comparison operator support metatypes.
This patch adds a way to enable operator<, operator== and operator<<
into QDebug for QVariants with custom types.
Change-Id: I3d12d891bd7252ad2b8f1de69bced354800a1f29
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/corelib/kernel/qvariant.h')
-rw-r--r-- | src/corelib/kernel/qvariant.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 4832a633f8..d5ea491288 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -433,6 +433,14 @@ class Q_CORE_EXPORT QVariant { return cmp(v); } inline bool operator!=(const QVariant &v) const { return !cmp(v); } + inline bool operator<(const QVariant &v) const + { return compare(v) < 0; } + inline bool operator<=(const QVariant &v) const + { return compare(v) <= 0; } + inline bool operator>(const QVariant &v) const + { return compare(v) > 0; } + inline bool operator>=(const QVariant &v) const + { return compare(v) >= 0; } protected: friend inline bool operator==(const QVariant &, const QVariantComparisonHelper &); @@ -450,6 +458,7 @@ public: Private d; void create(int type, const void *copy); bool cmp(const QVariant &other) const; + int compare(const QVariant &other) const; bool convert(const int t, void *ptr) const; private: |