Libksieve

selectvacationcombobox.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
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 
12 using namespace KSieveUi;
13 SelectVacationComboBox::SelectVacationComboBox(QWidget *parent)
14  : QComboBox(parent)
15 {
16  initialize();
17  connect(this, QOverload<int>::of(&SelectVacationComboBox::activated), this, &SelectVacationComboBox::valueChanged);
18 }
19 
20 SelectVacationComboBox::~SelectVacationComboBox()
21 {
22 }
23 
24 void SelectVacationComboBox::initialize()
25 {
26  addItem(i18n("days"), QStringLiteral(":days"));
27  addItem(i18n("seconds"), QStringLiteral(":seconds"));
28 }
29 
30 QString SelectVacationComboBox::code() const
31 {
32  return itemData(currentIndex()).toString();
33 }
34 
35 void SelectVacationComboBox::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);
42  setCurrentIndex(0);
43  }
44 }
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.