Libksieve

selectvariablemodifiercombobox.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #include "selectvariablemodifiercombobox.h"
7 #include "autocreatescripts/autocreatescriptutil_p.h"
8 
9 #include <KLocalizedString>
10 
11 using namespace KSieveUi;
12 
13 SelectVariableModifierComboBox::SelectVariableModifierComboBox(QWidget *parent)
14  : QComboBox(parent)
15 {
16  initialize();
17  connect(this, QOverload<int>::of(&SelectVariableModifierComboBox::activated), this, &SelectVariableModifierComboBox::valueChanged);
18 }
19 
20 SelectVariableModifierComboBox::~SelectVariableModifierComboBox()
21 {
22 }
23 
24 void SelectVariableModifierComboBox::initialize()
25 {
26  addItem(i18n("None"), QString());
27  addItem(i18n("Lower"), QStringLiteral(":lower"));
28  addItem(i18n("Upper"), QStringLiteral(":upper"));
29  addItem(i18n("Lower first letter"), QStringLiteral(":lowerfirst"));
30  addItem(i18n("Upper first letter"), QStringLiteral(":upperfirst"));
31  addItem(i18n("Quote wildcard"), QStringLiteral(":quotewildcard"));
32  addItem(i18n("Length"), QStringLiteral(":length"));
33 }
34 
35 QString SelectVariableModifierComboBox::code() const
36 {
37  return itemData(currentIndex()).toString();
38 }
39 
40 void SelectVariableModifierComboBox::setCode(const QString &code, const QString &name, QString &error)
41 {
42  const int index = findData(code);
43  if (index != -1) {
44  setCurrentIndex(index);
45  } else {
46  AutoCreateScriptUtil::comboboxItemNotFound(code, name, error);
47  setCurrentIndex(0);
48  }
49 }
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.