Libksieve

selectsizetypecombobox.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 "selectsizetypecombobox.h"
7#include "autocreatescripts/autocreatescriptutil_p.h"
8
9#include <KLocalizedString>
10
11using namespace KSieveUi;
12
13SelectSizeTypeComboBox::SelectSizeTypeComboBox(QWidget *parent)
14 : QComboBox(parent)
15{
16 initialize();
17 connect(this, &SelectSizeTypeComboBox::activated, this, &SelectSizeTypeComboBox::valueChanged);
18}
19
20SelectSizeTypeComboBox::~SelectSizeTypeComboBox() = default;
21
22void SelectSizeTypeComboBox::initialize()
23{
24 addItem(i18n("Bytes"), QString());
25 addItem(i18n("KiB"), QStringLiteral("K"));
26 addItem(i18n("MiB"), QStringLiteral("M"));
27 addItem(i18n("GiB"), QStringLiteral("G"));
28}
29
30QString SelectSizeTypeComboBox::code() const
31{
32 return itemData(currentIndex()).toString();
33}
34
35void SelectSizeTypeComboBox::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_selectsizetypecombobox.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 Sat Dec 21 2024 16:57:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.