Libksieve

selectimportancecombobox.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 "selectimportancecombobox.h"
7#include "autocreatescripts/autocreatescriptutil_p.h"
8
9#include <KLocalizedString>
10
11using namespace KSieveUi;
12
13SelectImportanceCombobox::SelectImportanceCombobox(QWidget *parent)
14 : QComboBox(parent)
15{
16 initialize();
17 connect(this, &SelectImportanceCombobox::activated, this, &SelectImportanceCombobox::valueChanged);
18}
19
20SelectImportanceCombobox::~SelectImportanceCombobox() = default;
21
22void SelectImportanceCombobox::initialize()
23{
25 addItem(i18n("high importance"), QStringLiteral("1"));
26 addItem(i18n("normal importance"), QStringLiteral("2"));
27 addItem(i18n("low importance"), QStringLiteral("3"));
28}
29
30QString SelectImportanceCombobox::code() const
31{
32 return itemData(currentIndex()).toString();
33}
34
35void SelectImportanceCombobox::setCode(const QString &code, const QString &name, QString &error)
36{
37 const int index = findData(code);
38 if (index != -1) {
39 setCurrentIndex(index);
40 } else {
41 AutoCreateScriptUtil::comboboxItemNotFound(code, name, error);
43 }
44}
45
46#include "moc_selectimportancecombobox.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.