KSane

labeledcombo.h
1/*
2 * SPDX-FileCopyrightText: 2007-2011 Kare Sars <kare.sars@iki .fi>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6
7#ifndef LABELED_COMBO_H
8#define LABELED_COMBO_H
9
10#include "ksaneoptionwidget.h"
11
12#include <QVariant>
13
14class QComboBox;
15
16namespace KSaneIface
17{
18
19/**
20 * A label and a combobox.
21 */
23{
25
26public:
27 /**
28 * create a label and combobox combination.
29 * \param parent parent widget
30 * \param label is the lext for the label
31 * \param list a stringlist with values the list should contain.
32 */
33 LabeledCombo(QWidget *parent, const QString &label, const QStringList &list = QStringList());
34
36
37 /** This function forwards the request to the QComboBox equivalent */
38 QVariant currentData(int role = Qt::UserRole) const;
39
40 /** This function forwards the request to the QComboBox equivalent */
41 void addItem(const QString &text, const QVariant &userData = QVariant());
42
43 /** This function forwards the request to the QComboBox equivalent */
44 int count() const;
45
46 /** This function forwards the request to the QComboBox equivalent */
47 int currentIndex() const;
48
49 /**
50 * This function is used to read the current string of the combobox
51 */
52 QString currentText() const;
53
54public Q_SLOTS:
55
56 /**
57 * Add string entries to the combobox
58 */
59 void addItems(const QStringList &list);
60
61 /**
62 * Remove all string entries
63 */
64 void clear();
65
66 /**
67 * If the given string can be found in the combobox, activate that entry.
68 * If not, the entry is not changed.
69 */
70 void setCurrentText(const QString &);
71
72 /**
73 * set the current item of the combobox.
74 */
75 void setCurrentIndex(int);
76
77 void setValue(const QVariant &val);
78
79private Q_SLOTS:
80
81 void emitChangedValue(int index);
82
84
85 void activated(int);
86
87 void valueChanged(const QVariant &value);
88
89private:
90 void initCombo(const QStringList &list);
91
92 QString getStringWithUnitForInteger(int iValue) const;
93
94 QString getStringWithUnitForFloat(float iValue) const;
95
96 QComboBox *m_combo;
97};
98
99} // NameSpace KSaneIface
100
101#endif // LABELED_COMBO_H
Base class for option widgets.
A label and a combobox.
void setCurrentText(const QString &)
If the given string can be found in the combobox, activate that entry.
QString currentText() const
This function is used to read the current string of the combobox.
void addItem(const QString &text, const QVariant &userData=QVariant())
This function forwards the request to the QComboBox equivalent.
void addItems(const QStringList &list)
Add string entries to the combobox.
int count() const
This function forwards the request to the QComboBox equivalent.
void setCurrentIndex(int)
set the current item of the combobox.
QVariant currentData(int role=Qt::UserRole) const
This function forwards the request to the QComboBox equivalent.
int currentIndex() const
This function forwards the request to the QComboBox equivalent.
LabeledCombo(QWidget *parent, const QString &label, const QStringList &list=QStringList())
create a label and combobox combination.
void clear()
Remove all string entries.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 12:00:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.