Messagelib

dkimmanagerulescombobox.cpp
1 /*
2  SPDX-FileCopyrightText: 2019-2023 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "dkimmanagerulescombobox.h"
8 #include <KLocalizedString>
9 using namespace MessageViewer;
10 DKIMManageRulesComboBox::DKIMManageRulesComboBox(QWidget *parent)
11  : QComboBox(parent)
12 {
13  init();
14 }
15 
16 DKIMManageRulesComboBox::~DKIMManageRulesComboBox() = default;
17 
18 void DKIMManageRulesComboBox::init()
19 {
20  addItem(i18n("Must be signed"), QVariant::fromValue(MessageViewer::DKIMRule::RuleType::MustBeSigned));
21  addItem(i18n("Can be signed"), QVariant::fromValue(MessageViewer::DKIMRule::RuleType::CanBeSigned));
22  addItem(i18n("Ignore if not signed"), QVariant::fromValue(MessageViewer::DKIMRule::RuleType::IgnoreEmailNotSigned));
23 }
24 
25 MessageViewer::DKIMRule::RuleType DKIMManageRulesComboBox::ruleType() const
26 {
27  return currentData().value<MessageViewer::DKIMRule::RuleType>();
28 }
29 
30 void DKIMManageRulesComboBox::setRuleType(MessageViewer::DKIMRule::RuleType type)
31 {
32  const int index = findData(QVariant::fromValue(type));
33  if (index != -1) {
34  setCurrentIndex(index);
35  }
36 }
QVariant fromValue(const T &value)
QString i18n(const char *text, const TYPE &arg...)
void init(KXmlGuiWindow *window, KgDifficulty *difficulty=nullptr)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Apr 1 2023 04:01:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.