1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
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 <QtWidgets/QWidget>
19#include <QtCore/QMap>
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();
33 void setOptions(const QStringList &validOptions,
34 const QStringList &selectedOptions);
35 QStringList validOptions() const;
36 QStringList selectedOptions() const;
37
38 void setNoOptionText(const QString &text);
39 void setInvalidOptionText(const QString &text);
40
41signals:
42 void optionSelectionChanged(const QStringList &options);
43
44private:
45 QString optionText(const QString &optionName, bool valid) const;
46 QListWidgetItem *appendItem(const QString &optionName, bool valid, bool selected);
47 void appendSeparator();
48 void itemChanged(QListWidgetItem *item);
49
50 QListWidget *m_listWidget = nullptr;
51 QString m_noOptionText;
52 QString m_invalidOptionText;
53 QStringList m_validOptions;
54 QStringList m_invalidOptions;
55 QStringList m_selectedOptions;
56 QMap<QString, QListWidgetItem *> m_optionToItem;
57 QMap<QListWidgetItem *, QString> m_itemToOption;
58};
59
60QT_END_NAMESPACE
61
62#endif // OPTIONSWIDGET_H
63

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