Libksieve

selectmimecombobox.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #include "selectmimecombobox.h"
7 #include "autocreatescripts/autocreatescriptutil_p.h"
8 
9 #include <KLocalizedString>
10 
11 using namespace KSieveUi;
12 
13 SelectMimeComboBox::SelectMimeComboBox(QWidget *parent)
14  : QComboBox(parent)
15 {
16  initialize();
17  connect(this, QOverload<int>::of(&SelectMimeComboBox::activated), this, &SelectMimeComboBox::valueChanged);
18 }
19 
20 SelectMimeComboBox::~SelectMimeComboBox()
21 {
22 }
23 
24 void SelectMimeComboBox::initialize()
25 {
26  addItem(i18n("Type"), QStringLiteral(":type"));
27  addItem(i18n("Subtype"), QStringLiteral(":subtype"));
28  addItem(i18n("Anychild"), QStringLiteral(":anychild"));
29  addItem(i18n("Parameters"), QStringLiteral(":param"));
30 }
31 
32 QString SelectMimeComboBox::code() const
33 {
34  return QStringLiteral(":mime \"%1\"").arg(itemData(currentIndex()).toString());
35 }
36 
37 QString SelectMimeComboBox::require() const
38 {
39  return QStringLiteral("mime");
40 }
41 
42 void SelectMimeComboBox::setCode(const QString &code, const QString &name, QString &error)
43 {
44  const int index = findData(code);
45  if (index != -1) {
46  setCurrentIndex(index);
47  } else {
48  AutoCreateScriptUtil::comboboxItemNotFound(code, name, error);
49  setCurrentIndex(0);
50  }
51 }
KCRASH_EXPORT void initialize()
QString i18n(const char *text, const TYPE &arg...)
char * toString(const T &value)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 11 2021 23:09:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.