Libksieve

selectmimecombobox.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 "selectmimecombobox.h"
7#include "autocreatescripts/autocreatescriptutil_p.h"
8
9#include <KLocalizedString>
10
11using namespace KSieveUi;
12
13SelectMimeComboBox::SelectMimeComboBox(QWidget *parent)
14 : QComboBox(parent)
15{
16 initialize();
17 connect(this, &SelectMimeComboBox::activated, this, &SelectMimeComboBox::valueChanged);
18}
19
20SelectMimeComboBox::~SelectMimeComboBox() = default;
21
22void SelectMimeComboBox::initialize()
23{
24 addItem(i18n("Type"), QStringLiteral(":type"));
25 addItem(i18n("Subtype"), QStringLiteral(":subtype"));
26 addItem(i18n("Anychild"), QStringLiteral(":anychild"));
27 addItem(i18n("Parameters"), QStringLiteral(":param"));
28}
29
30QString SelectMimeComboBox::code() const
31{
32 return QStringLiteral(":mime \"%1\"").arg(itemData(currentIndex()).toString());
33}
34
35QString SelectMimeComboBox::require() const
36{
37 return QStringLiteral("mime");
38}
39
40void SelectMimeComboBox::setCode(const QString &code, const QString &name, QString &error)
41{
42 const int index = findData(code);
43 if (index != -1) {
44 setCurrentIndex(index);
45 } else {
46 AutoCreateScriptUtil::comboboxItemNotFound(code, name, error);
48 }
49}
50
51#include "moc_selectmimecombobox.cpp"
QString i18n(const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
void initialize(StandardShortcut id)
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 Mon Nov 18 2024 12:14:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.