Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-10-22 16:54:50 +0300
committerHannah von Reth <vonreth@kde.org>2021-10-27 16:25:02 +0300
commit29cae9bfff37dd3292ea2ce8343e1a34512d2f46 (patch)
treeff28ae9802d1609efc17882a165133ae8814d39e /src/common
parent15fc9d017fcdcc4cc95728c16a2dd171d0395b85 (diff)
Add Utility::stringToEnum
Diffstat (limited to 'src/common')
-rw-r--r--src/common/utility.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/common/utility.h b/src/common/utility.h
index 3d2e77bd7..bc0f07258 100644
--- a/src/common/utility.h
+++ b/src/common/utility.h
@@ -269,12 +269,24 @@ OCSYNC_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcUtility)
#endif
template <class E>
- QString enumName(E value)
+ E stringToEnum(const char *key)
+ {
+ return static_cast<E>(QMetaEnum::fromType<E>().keyToValue(key));
+ }
+
+ template <class E>
+ E stringToEnum(const QString &key)
+ {
+ return stringToEnum<E>(key.toUtf8().constData());
+ }
+
+ template <class E>
+ QString enumToString(E value)
{
return QMetaEnum::fromType<E>().valueToKeys(value);
}
template <class E = void>
- QString enumDisplayName(E)
+ QString enumToDisplayName(E)
{
static_assert(std::is_same<E, void>::value, "Not implemented");
Q_UNREACHABLE();