diff options
author | Mikhail Svetkin <mikhail.svetkin@gmail.com> | 2019-11-08 20:24:24 +0100 |
---|---|---|
committer | Mikhail Svetkin <mikhail.svetkin@gmail.com> | 2019-11-10 22:41:25 +0100 |
commit | 7dc185f1010067de6082276dbc009a04473bc27c (patch) | |
tree | 6b1ea4df7a61932de16876bb094f8102c0a78332 /tests | |
parent | dba675ed617592a25b7ca17420c77e92640a3f12 (diff) |
Refactor access to QMetaEnum for QHttpServerRequest::Method
Replace QHttpServerRequest::staticMetaObject.indexOfEnumerator("Method")
with QMetaEnum::fromType<QHttpServerRequest::Method>.
Change-Id: Idda142fd065e9ce216e2d76c09a5b19d384df1b3
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qhttpserver/tst_qhttpserver.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/tests/auto/qhttpserver/tst_qhttpserver.cpp b/tests/auto/qhttpserver/tst_qhttpserver.cpp index ec4fad3..3919528 100644 --- a/tests/auto/qhttpserver/tst_qhttpserver.cpp +++ b/tests/auto/qhttpserver/tst_qhttpserver.cpp @@ -185,12 +185,8 @@ void tst_QHttpServer::initTestCase() }); httpserver.route("/any", "All", [] (const QHttpServerRequest &request) { - static const int index = QHttpServerRequest::staticMetaObject.indexOfEnumerator("Method"); - if (index == -1) - return "Error: Could not find enum Method"; - - static const QMetaEnum en = QHttpServerRequest::staticMetaObject.enumerator(index); - return en.valueToKey(static_cast<int>(request.method())); + static const auto metaEnum = QMetaEnum::fromType<QHttpServerRequest::Method>(); + return metaEnum.valueToKey(static_cast<int>(request.method())); }); httpserver.route("/page/", [] (const qint32 number) { |