diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-12-29 16:34:39 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:12:51 -0300 |
commit | 87ae5790fa75114dbf335380ca7ab644b013a50b (patch) | |
tree | c4b502dcf425cb832d8ba1c577d790a1ba28ce1a /tests/libsample | |
parent | 4a25e3a3801cebfb90cf89fd1eb1faf05c4725a1 (diff) |
Add support to fix the bug#493 - "__eq__ and friends not implemented for QKeyEvent == QKeySequence"
Diffstat (limited to 'tests/libsample')
-rw-r--r-- | tests/libsample/objecttypeoperators.cpp | 22 | ||||
-rw-r--r-- | tests/libsample/objecttypeoperators.h | 8 |
2 files changed, 24 insertions, 6 deletions
diff --git a/tests/libsample/objecttypeoperators.cpp b/tests/libsample/objecttypeoperators.cpp index 08c49b1a4..43aedc5de 100644 --- a/tests/libsample/objecttypeoperators.cpp +++ b/tests/libsample/objecttypeoperators.cpp @@ -31,13 +31,27 @@ bool ObjectTypeOperators::operator==(const ObjectTypeOperators& other) const return m_key == other.m_key; } -bool ObjectTypeOperators::operator==(const std::string& other) const +const ObjectTypeOperators& ObjectTypeOperators::operator<(const ObjectTypeOperators& other) const { - return m_key == other; + return m_key < other.m_key ? *this : other; } -const ObjectTypeOperators& ObjectTypeOperators::operator<(const ObjectTypeOperators& other) const +bool operator==(const ObjectTypeOperators* obj, const std::string& str) { - return m_key < other.m_key ? *this : other; + return obj->key() == str; +} + +bool operator==(const std::string& str, const ObjectTypeOperators* obj) +{ + return str == obj->key(); +} + +std::string operator+(const ObjectTypeOperators* obj, const std::string& str) +{ + return obj->key() + str; } +std::string operator+(const std::string& str, const ObjectTypeOperators* obj) +{ + return str + obj->key(); +} diff --git a/tests/libsample/objecttypeoperators.h b/tests/libsample/objecttypeoperators.h index 1d65eb167..9c1a85dc7 100644 --- a/tests/libsample/objecttypeoperators.h +++ b/tests/libsample/objecttypeoperators.h @@ -29,10 +29,9 @@ class LIBSAMPLE_API ObjectTypeOperators { public: - ObjectTypeOperators(const std::string key); + explicit ObjectTypeOperators(const std::string key); bool operator==(const ObjectTypeOperators& other) const; - bool operator==(const std::string& other) const; const ObjectTypeOperators& operator<(const ObjectTypeOperators& other) const; // chaos! @@ -47,4 +46,9 @@ private: ObjectTypeOperators& operator=(ObjectTypeOperators&); }; +LIBSAMPLE_API bool operator==(const ObjectTypeOperators* obj, const std::string& str); +LIBSAMPLE_API bool operator==(const std::string& str, const ObjectTypeOperators* obj); +LIBSAMPLE_API std::string operator+(const ObjectTypeOperators* obj, const std::string& str); +LIBSAMPLE_API std::string operator+(const std::string& str, const ObjectTypeOperators* obj); + #endif // OBJECTTYPEOPERATORS_H |