Libksieve

selectvariablemodifiercombobox.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
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
11using namespace KSieveUi;
12
13SelectVariableModifierComboBox::SelectVariableModifierComboBox(QWidget *parent)
14 : QComboBox(parent)
15{
16 initialize();
17 connect(this, &SelectVariableModifierComboBox::activated, this, &SelectVariableModifierComboBox::valueChanged);
18}
19
20SelectVariableModifierComboBox::~SelectVariableModifierComboBox() = default;
21
22void SelectVariableModifierComboBox::initialize()
23{
24 addItem(i18n("None"), QString());
25 addItem(i18n("Lower"), QStringLiteral(":lower"));
26 addItem(i18n("Upper"), QStringLiteral(":upper"));
27 addItem(i18n("Lower first letter"), QStringLiteral(":lowerfirst"));
28 addItem(i18n("Upper first letter"), QStringLiteral(":upperfirst"));
29 addItem(i18n("Quote wildcard"), QStringLiteral(":quotewildcard"));
30 addItem(i18n("Length"), QStringLiteral(":length"));
31}
32
33QString SelectVariableModifierComboBox::code() const
34{
35 return itemData(currentIndex()).toString();
36}
37
38void SelectVariableModifierComboBox::setCode(const QString &code, const QString &name, QString &error)
39{
40 const int index = findData(code);
41 if (index != -1) {
42 setCurrentIndex(index);
43 } else {
44 AutoCreateScriptUtil::comboboxItemNotFound(code, name, error);
46 }
47}
48
49#include "moc_selectvariablemodifiercombobox.cpp"
QString i18n(const char *text, const TYPE &arg...)
KCRASH_EXPORT void initialize()
void addItem(const QIcon &icon, const QString &text, const QVariant &userData)
int findData(const QVariant &data, int role, Qt::MatchFlags flags) const const
QVariant itemData(int index, int role) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:56:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.