Warning, file /utilities/kdebugsettings/src/categorytypecombobox.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2015-2022 Laurent Montel <montel@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 
0006 */
0007 
0008 #include "categorytypecombobox.h"
0009 
0010 #include <KLocalizedString>
0011 
0012 CategoryTypeComboBox::CategoryTypeComboBox(bool customType, QWidget *parent)
0013     : QComboBox(parent)
0014 {
0015     addItem(i18n("Full Debug"), QVariant::fromValue(LoggingCategory::All));
0016     addItem(i18n("Info"), QVariant::fromValue(LoggingCategory::Info));
0017     addItem(i18n("Warning"), QVariant::fromValue(LoggingCategory::Warning));
0018     addItem(i18n("Critical"), QVariant::fromValue(LoggingCategory::Critical));
0019     if (!customType) {
0020         addItem(i18n("Off"), QVariant::fromValue(LoggingCategory::Off));
0021     }
0022 }
0023 
0024 CategoryTypeComboBox::~CategoryTypeComboBox() = default;
0025 
0026 void CategoryTypeComboBox::restoreToDefault()
0027 {
0028     setType(mDefaultCategories);
0029 }
0030 
0031 void CategoryTypeComboBox::setType(LoggingCategory::LoggingType type)
0032 {
0033     const int pos = findData(QVariant::fromValue(type));
0034     if (pos != -1) {
0035         setCurrentIndex(pos);
0036     } else {
0037         // Default;
0038         setCurrentIndex(0);
0039     }
0040 }
0041 
0042 LoggingCategory::LoggingType CategoryTypeComboBox::type() const
0043 {
0044     return currentData().value<LoggingCategory::LoggingType>();
0045 }
0046 
0047 bool CategoryTypeComboBox::loggingCategoryIsNotDefault() const
0048 {
0049     return type() != mDefaultCategories;
0050 }
0051 
0052 void CategoryTypeComboBox::setDefaultCategories(LoggingCategory::LoggingType defaultCategories)
0053 {
0054     mDefaultCategories = defaultCategories;
0055 }
0056 
0057 LoggingCategory::LoggingType CategoryTypeComboBox::defaultCategories() const
0058 {
0059     return mDefaultCategories;
0060 }