Libksieve

selectmimetypecombobox.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
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
11using namespace KSieveUi;
12
13SelectMimeTypeComboBox::SelectMimeTypeComboBox(QWidget *parent)
14 : QComboBox(parent)
15{
16 initialize();
17 connect(this, &SelectMimeTypeComboBox::activated, this, &SelectMimeTypeComboBox::valueChanged);
18}
19
20SelectMimeTypeComboBox::~SelectMimeTypeComboBox() = default;
21
22void SelectMimeTypeComboBox::initialize()
23{
24 // TODO verify
25 addItem(i18n("JPEG"), QStringLiteral("image/jpeg"));
26 addItem(i18n("TIFF"), QStringLiteral("image/tiff"));
27 addItem(i18n("PNG"), QStringLiteral("image/png"));
28 addItem(i18n("BMP"), QStringLiteral("image/bmp"));
29}
30
31QString SelectMimeTypeComboBox::code() const
32{
33 return QStringLiteral("\"%1\"").arg(itemData(currentIndex()).toString());
34}
35
36void SelectMimeTypeComboBox::setCode(const QString &code, const QString &name, QString &error)
37{
38 const int index = findData(code);
39 if (index != -1) {
40 setCurrentIndex(index);
41 } else {
42 AutoCreateScriptUtil::comboboxItemNotFound(code, name, error);
44 }
45}
46
47#include "moc_selectmimetypecombobox.cpp"
QString i18n(const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
KCRASH_EXPORT void initialize()
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
QString arg(Args &&... args) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.