Libksieve

selectimportancecombobox.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #include "selectimportancecombobox.h"
7 #include "autocreatescripts/autocreatescriptutil_p.h"
8 
9 #include <KLocalizedString>
10 
11 using namespace KSieveUi;
12 
13 SelectImportanceCombobox::SelectImportanceCombobox(QWidget *parent)
14  : QComboBox(parent)
15 {
16  initialize();
17  connect(this, QOverload<int>::of(&SelectImportanceCombobox::activated), this, &SelectImportanceCombobox::valueChanged);
18 }
19 
20 SelectImportanceCombobox::~SelectImportanceCombobox()
21 {
22 }
23 
24 void SelectImportanceCombobox::initialize()
25 {
26  addItem(QString(), QString());
27  addItem(i18n("high importance"), QStringLiteral("1"));
28  addItem(i18n("normal importance"), QStringLiteral("2"));
29  addItem(i18n("low importance"), QStringLiteral("3"));
30 }
31 
32 QString SelectImportanceCombobox::code() const
33 {
34  return itemData(currentIndex()).toString();
35 }
36 
37 void SelectImportanceCombobox::setCode(const QString &code, const QString &name, QString &error)
38 {
39  const int index = findData(code);
40  if (index != -1) {
41  setCurrentIndex(index);
42  } else {
43  AutoCreateScriptUtil::comboboxItemNotFound(code, name, error);
44  setCurrentIndex(0);
45  }
46 }
KCRASH_EXPORT void initialize()
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 16 2021 23:09:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.