1 /*=========================================================================
2 
3   Library:   CTK
4 
5   Copyright (c) Kitware Inc.
6 
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10 
11       http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18 
19 =========================================================================*/
20 
21 #include "ctkErrorLogLevel.h"
22 
23 // Qt includes
24 #include <QMetaEnum>
25 
26 // --------------------------------------------------------------------------
ctkErrorLogLevel()27 ctkErrorLogLevel::ctkErrorLogLevel()
28 {
29   qRegisterMetaType<ctkErrorLogLevel::LogLevel>("ctkErrorLogLevel::LogLevel");
30 }
31 
32 // --------------------------------------------------------------------------
operator ()(ctkErrorLogLevel::LogLevel logLevel)33 QString ctkErrorLogLevel::operator()(ctkErrorLogLevel::LogLevel logLevel)
34 {
35   return ctkErrorLogLevel::logLevelAsString(logLevel);
36 }
37 
38 // --------------------------------------------------------------------------
logLevelAsString(ctkErrorLogLevel::LogLevel logLevel)39 QString ctkErrorLogLevel::logLevelAsString(ctkErrorLogLevel::LogLevel logLevel)
40 {
41   QMetaEnum logLevelEnum = ctkErrorLogLevel::staticMetaObject.enumerator(0);
42   Q_ASSERT(QString("LogLevel").compare(logLevelEnum.name()) == 0);
43   return QLatin1String(logLevelEnum.valueToKey(logLevel));
44 }
45