Mailcommon

filteractionwithstringlist.cpp
1 /*
2  * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <[email protected]>
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  *
6  */
7 
8 #include "filteractionwithstringlist.h"
9 
10 #include <QComboBox>
11 
12 using 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(QStringLiteral("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 }
void append(const T &value)
int count(const T &value) const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
FilterActionWithStringList(const QString &name, const QString &label, QObject *parent=nullptr)
Creates a new filter action.
void filterActionModified()
Called to notify that the current FilterAction has had some value modification.
const T & at(int i) const const
void setParamWidgetValue(QWidget *paramWidget) const override
The filter action shall set it's widget's contents from it's parameter.
int indexOf(QStringView str, int from) const const
void argsFromString(const QString &argsStr) override
Read extra arguments from given string.
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.
QWidget * createParamWidget(QWidget *parent) const override
Creates a widget for setting the filter action parameter.
void currentIndexChanged(int index)
QObject * parent() const const
Abstract base class for filter actions with a free-form string as parameter.
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Sep 24 2022 03:58:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.