Libksieve

selectmimetypecombobox.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #include "selectmimetypecombobox.h"
7 #include "autocreatescripts/autocreatescriptutil_p.h"
8 
9 #include <KLocalizedString>
10 
11 using namespace KSieveUi;
12 
13 SelectMimeTypeComboBox::SelectMimeTypeComboBox(QWidget *parent)
14  : QComboBox(parent)
15 {
16  initialize();
17  connect(this, QOverload<int>::of(&SelectMimeTypeComboBox::activated), this, &SelectMimeTypeComboBox::valueChanged);
18 }
19 
20 SelectMimeTypeComboBox::~SelectMimeTypeComboBox()
21 {
22 }
23 
24 void SelectMimeTypeComboBox::initialize()
25 {
26  // TODO verify
27  addItem(i18n("JPEG"), QStringLiteral("image/jpeg"));
28  addItem(i18n("TIFF"), QStringLiteral("image/tiff"));
29  addItem(i18n("PNG"), QStringLiteral("image/png"));
30  addItem(i18n("BMP"), QStringLiteral("image/bmp"));
31 }
32 
33 QString SelectMimeTypeComboBox::code() const
34 {
35  return QStringLiteral("\"%1\"").arg(itemData(currentIndex()).toString());
36 }
37 
38 void SelectMimeTypeComboBox::setCode(const QString &code, const QString &name, QString &error)
39 {
40  const int index = findData(code);
41  if (index != -1) {
42  setCurrentIndex(index);
43  } else {
44  AutoCreateScriptUtil::comboboxItemNotFound(code, name, error);
45  setCurrentIndex(0);
46  }
47 }
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 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.