Debian Codegraph @

kysdk-qtwidgets/src/knavigationbar.h

raw
1 /*
2 * libkysdk-qtwidgets's Library
3 *
4 * Copyright (C) 2023, KylinSoft Co., Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this library. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Authors: Zhen Sun <[email protected]>
20 *
21 */
22
23 #ifndef KNAVIGATIONBAR_H
24 #define KNAVIGATIONBAR_H
25
26 #include "gui_g.h"
27 #include <QListView>
28 #include <QModelIndex>
29 #include <QMouseEvent>
30 #include <QScrollArea>
31 #include <QStandardItem>
32 #include <QStandardItemModel>
33
34 namespace kdk
35 {
36
37 /** @defgroup BarModule
38 * @{
39 */
40
41 class KNavigationBarPrivate;
42 class ListView;
43
44 /**
45 * @brief 导航栏控件
46 * @since 1.0.0
47 */
48 class GUI_EXPORT KNavigationBar : public QScrollArea
49 {
50 Q_OBJECT
51
52 public:
53 enum NavigationBarDataType {
54 ValueRole = Qt::UserRole + 1,
55 StringRole = Qt::UserRole + 2,
56 boolRole = Qt::UserRole + 3
57 };
58
59 KNavigationBar(QWidget *parent);
60
61 /**
62 * @brief 增加常规Item
63 * @param item
64 */
65 void addItem(QStandardItem *item);
66
67 /**
68 * @brief 增加次级Item
69 * @param subItem
70 */
71 void addSubItem(QStandardItem *subItem);
72
73 /**
74 * @brief 成组增加Item,在导航栏中会显示tag
75 * @param items
76 * @param tag
77 */
78 void addGroupItems(QList<QStandardItem *> items, const QString &tag);
79
80 /**
81 * @brief 在指定tag组中指定位置row插入item
82 * @param tag
83 * @param row
84 * @param item
85 * @since 3.0.1.0
86 */
87 void insertGroupItems(QString tag, int row, QStandardItem *item);
88
89 /**
90 * @brief 在指定组中删除item
91 * @param tag
92 * @param item
93 * @since 3.0.1.0
94 */
95 void removeGroupItem(QString tag, QStandardItem *item);
96 /**
97 * @brief 添加tag
98 * @param tag
99 */
100 void addTag(const QString &tag);
101
102 /**
103 * @brief 获取model
104 * @return
105 */
106 QStandardItemModel *model();
107
108 /**
109 * @brief 获取view
110 * @return
111 */
112 QListView *listview();
113
114 /**
115 * @brief 设置tabvalue
116 * @param item
117 * @param value
118 * @since 3.0.1.0
119 */
120 void setTabValue(QStandardItem *item, QString value); // item
121
122 /**
123 * @brief 设置tabvalue是否可见
124 * @param visible
125 * @since 3.0.1.0
126 */
127 void setTabValueVisible(bool visible);
128
129 /**
130 * @brief tag 添加add图标
131 * @param tag
132 * @param icon
133 * @since 3.0.1.0
134 */
135 void setAddIcon(QString tag, QIcon icon);
136
137 /**
138 * @brief 设置tag add图标是否可见
139 * @param tag
140 * @param visible
141 * @since 3.0.1.0
142 */
143 void setAddTagVisible(QString tag, bool visible);
144
145 /**
146 * @brief 设置折叠图标是否可见
147 * @param tag
148 * @param visible
149 * @since 3.0.1.0
150 */
151 void setExtendTagVisible(QString tag, bool visible);
152
153 Q_SIGNALS:
154 void addTagClicked(QString str);
155
156 private:
157 Q_DECLARE_PRIVATE(KNavigationBar)
158 KNavigationBarPrivate *const d_ptr;
159 };
160
161 }
162 /**
163 * @example testnavigationbar/widget.h
164 * @example testnavigationbar/widget.cpp
165 * @}
166 */
167 #endif // KNAVIGATIONBAR_H