1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef ENVIRONMENTWIDGET_H |
6 | #define ENVIRONMENTWIDGET_H |
7 | |
8 | #include "configutil.h" |
9 | |
10 | #include <QAbstractTableModel> |
11 | #include <QWidget> |
12 | |
13 | class EnvironmentModelPrivate; |
14 | class EnvironmentModel : public QAbstractTableModel |
15 | { |
16 | Q_OBJECT |
17 | public: |
18 | enum ColumnType |
19 | { |
20 | kVaribale, |
21 | kValue, |
22 | kColumnCount |
23 | }; |
24 | |
25 | explicit EnvironmentModel(QObject *parent = nullptr); |
26 | ~EnvironmentModel() override; |
27 | |
28 | int rowCount(const QModelIndex &) const override; |
29 | int columnCount(const QModelIndex &) const override; |
30 | QVariant data(const QModelIndex &index, int role) const override; |
31 | QVariant headerData(int section, Qt::Orientation orientation, int role) const override; |
32 | |
33 | void append(const QString &key, const QString &value); |
34 | void update(const QMap<QString, QString> &data); |
35 | const QMap<QString, QString> getEnvironment() const; |
36 | |
37 | private: |
38 | EnvironmentModelPrivate *const d; |
39 | }; |
40 | |
41 | class EnvironmentWidgetPrivate; |
42 | class EnvironmentWidget : public QWidget |
43 | { |
44 | Q_OBJECT |
45 | |
46 | public: |
47 | explicit EnvironmentWidget(QWidget *parent = nullptr); |
48 | virtual ~EnvironmentWidget(); |
49 | |
50 | void getValues(config::EnvironmentItem &env); |
51 | void setValues(const config::EnvironmentItem &env); |
52 | void bindValues(config::EnvironmentItem *env); |
53 | |
54 | private: |
55 | EnvironmentWidgetPrivate *const d; |
56 | }; |
57 | |
58 | #endif // ENVIRONMENTWIDGET_H |
59 |