Libksieve

selectvacationcombobox.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "selectvacationcombobox.h"
8#include "autocreatescripts/autocreatescriptutil_p.h"
9
10#include <KLocalizedString>
11
12using namespace KSieveUi;
13SelectVacationComboBox::SelectVacationComboBox(QWidget *parent)
14 : QComboBox(parent)
15{
16 initialize();
17 connect(this, &SelectVacationComboBox::activated, this, &SelectVacationComboBox::valueChanged);
18}
19
20SelectVacationComboBox::~SelectVacationComboBox() = default;
21
22void SelectVacationComboBox::initialize()
23{
24 addItem(i18n("days"), QStringLiteral(":days"));
25 addItem(i18n("seconds"), QStringLiteral(":seconds"));
26}
27
28QString SelectVacationComboBox::code() const
29{
30 return itemData(currentIndex()).toString();
31}
32
33void SelectVacationComboBox::setCode(const QString &code, const QString &name, QString &error)
34{
35 const int index = findData(code);
36 if (index != -1) {
37 setCurrentIndex(index);
38 } else {
39 AutoCreateScriptUtil::comboboxItemNotFound(code, name, error);
41 }
42}
43
44#include "moc_selectvacationcombobox.cpp"
QString i18n(const char *text, const TYPE &arg...)
void initialize(StandardShortcut id)
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 Tue Mar 26 2024 11:17:19 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.