Libksieve

selectaddheaderpositioncombobox.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #include "selectaddheaderpositioncombobox.h"
7 #include "autocreatescripts/autocreatescriptutil_p.h"
8 
9 #include <KLocalizedString>
10 
11 using namespace KSieveUi;
12 SelectAddHeaderPositionCombobox::SelectAddHeaderPositionCombobox(QWidget *parent)
13  : QComboBox(parent)
14 {
15  initialize();
16  connect(this, QOverload<int>::of(&SelectAddHeaderPositionCombobox::activated), this, &SelectAddHeaderPositionCombobox::valueChanged);
17 }
18 
19 SelectAddHeaderPositionCombobox::~SelectAddHeaderPositionCombobox()
20 {
21 }
22 
23 void SelectAddHeaderPositionCombobox::initialize()
24 {
25  addItem(i18n("Insert at the beginning"), QString());
26  addItem(i18n("Append at the end"), QStringLiteral(":last"));
27 }
28 
29 QString SelectAddHeaderPositionCombobox::code() const
30 {
31  return itemData(currentIndex()).toString();
32 }
33 
34 void SelectAddHeaderPositionCombobox::setCode(const QString &code, const QString &name, QString &error)
35 {
36  const int index = findData(code);
37  if (index != -1) {
38  setCurrentIndex(index);
39  } else {
40  AutoCreateScriptUtil::comboboxItemNotFound(code, name, error);
41  setCurrentIndex(0);
42  }
43 }
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:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.