1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QOPTIONSWIDGET_H
5#define QOPTIONSWIDGET_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of the help generator tools. This header file may change from version
13// to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qhash.h>
19#include <QtWidgets/qwidget.h>
20
21QT_BEGIN_NAMESPACE
22
23class QListWidget;
24class QListWidgetItem;
25
26class QOptionsWidget : public QWidget
27{
28 Q_OBJECT
29public:
30 QOptionsWidget(QWidget *parent = nullptr);
31
32 void clear() { setOptions(validOptions: {}, selectedOptions: {}); }
33 void setOptions(const QStringList &validOptions, const QStringList &selectedOptions);
34 QStringList validOptions() const { return m_validOptions; }
35 QStringList selectedOptions() const { return m_selectedOptions; }
36
37 void setNoOptionText(const QString &text);
38 void setInvalidOptionText(const QString &text);
39
40signals:
41 void optionSelectionChanged(const QStringList &options);
42
43private:
44 QString optionText(const QString &optionName, bool valid) const;
45 QListWidgetItem *appendItem(const QString &optionName, bool valid, bool selected);
46 void appendSeparator();
47 void itemChanged(QListWidgetItem *item);
48
49 QListWidget *m_listWidget = nullptr;
50 QString m_noOptionText;
51 QString m_invalidOptionText;
52 QStringList m_validOptions;
53 QStringList m_invalidOptions;
54 QStringList m_selectedOptions;
55 QHash<QString, QListWidgetItem *> m_optionToItem;
56 QHash<QListWidgetItem *, QString> m_itemToOption;
57};
58
59QT_END_NAMESPACE
60
61#endif // QOPTIONSWIDGET_H
62

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qttools/src/assistant/help/qoptionswidget_p.h