Libksieve

selectaddheaderpositioncombobox.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 "selectaddheaderpositioncombobox.h"
7#include "autocreatescripts/autocreatescriptutil_p.h"
8
9#include <KLocalizedString>
10
11using namespace KSieveUi;
12SelectAddHeaderPositionCombobox::SelectAddHeaderPositionCombobox(QWidget *parent)
13 : QComboBox(parent)
14{
15 initialize();
16 connect(this, &SelectAddHeaderPositionCombobox::activated, this, &SelectAddHeaderPositionCombobox::valueChanged);
17}
18
19SelectAddHeaderPositionCombobox::~SelectAddHeaderPositionCombobox() = default;
20
21void SelectAddHeaderPositionCombobox::initialize()
22{
23 addItem(i18n("Insert at the beginning"), QString());
24 addItem(i18n("Append at the end"), QStringLiteral(":last"));
25}
26
27QString SelectAddHeaderPositionCombobox::code() const
28{
29 return itemData(currentIndex()).toString();
30}
31
32void SelectAddHeaderPositionCombobox::setCode(const QString &code, const QString &name, QString &error)
33{
34 const int index = findData(code);
35 if (index != -1) {
36 setCurrentIndex(index);
37 } else {
38 AutoCreateScriptUtil::comboboxItemNotFound(code, name, error);
40 }
41}
42
43#include "moc_selectaddheaderpositioncombobox.cpp"
QString i18n(const char *text, const TYPE &arg...)
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
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QString toString() const const
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.