Mailcommon

filteractionwithstringlist.cpp
1/*
2 * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <taferner@kde.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 *
6 */
7
8#include "filteractionwithstringlist.h"
9
10#include <QComboBox>
11
12using namespace MailCommon;
13
15 : FilterActionWithString(name, label, parent)
16{
17}
18
20{
21 auto comboBox = new QComboBox(parent);
22 comboBox->setMinimumWidth(50);
23 comboBox->setObjectName(QLatin1StringView("combobox"));
24 comboBox->setEditable(false);
25 comboBox->addItems(mParameterList);
26 setParamWidgetValue(comboBox);
28
29 return comboBox;
30}
31
33{
34 mParameter = static_cast<QComboBox *>(paramWidget)->currentText();
35}
36
38{
39 const int index = mParameterList.indexOf(mParameter);
40 static_cast<QComboBox *>(paramWidget)->setCurrentIndex(index >= 0 ? index : 0);
41}
42
44{
45 static_cast<QComboBox *>(paramWidget)->setCurrentIndex(0);
46}
47
49{
50 int index = mParameterList.indexOf(argsStr);
51 if (index < 0) {
52 mParameterList.append(argsStr);
53 index = mParameterList.count() - 1;
54 }
55
56 mParameter = mParameterList.at(index);
57}
58
59#include "moc_filteractionwithstringlist.cpp"
QWidget * createParamWidget(QWidget *parent) const override
Creates a widget for setting the filter action parameter.
void setParamWidgetValue(QWidget *paramWidget) const override
The filter action shall set it's widget's contents from it's parameter.
void applyParamWidgetValue(QWidget *paramWidget) override
The filter action shall set it's parameter from the widget's contents.
void clearParamWidget(QWidget *paramWidget) const override
The filter action shall clear it's parameter widget's contents.
FilterActionWithStringList(const QString &name, const QString &label, QObject *parent=nullptr)
Creates a new filter action.
void argsFromString(const QString &argsStr) override
Read extra arguments from given string.
Abstract base class for filter actions with a free-form string as parameter.
void filterActionModified()
Called to notify that the current FilterAction has had some value modification.
The filter dialog.
void currentIndexChanged(int index)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
qsizetype count() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
qsizetype indexOf(const QRegularExpression &re, qsizetype from) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.