Debian Codegraph @

kysdk-qtwidgets/src/kflowlayout.h

raw
1 /*
2 *
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: Sisheng He <[email protected]>
20 *
21 */
22 #ifndef KFLOWLAYOUT_H
23 #define KFLOWLAYOUT_H
24
25 #include <QLayout>
26 #include <QRect>
27 #include <QWidget>
28
29 namespace kdk
30 {
31
32 /**
33 * @defgroup LayoutModule
34 * @brief 存在水平间距、垂直间距的布局
35 * @since 3.0.1.0
36 * {
37 */
38 class KFlowLayoutPrivate;
39
40 class KFlowLayout : public QLayout
41 {
42 Q_OBJECT
43 public:
44 /**
45 * @brief 创建一个父对象为parent,边距为margin,水平间距为hSpacing,垂直间距为vSpacing的布局。
46 *
47 * @param home 是否首页布局
48 * @param margin 边距
49 * @param hSpacing 水平间距
50 * @param vSpacing 垂直间距
51 * @param parent
52 */
53 explicit KFlowLayout(QWidget *parent, bool home = false, int margin = -1, int hSpacing = -1, int vSpacing = -1);
54
55 /**
56 * @brief 创建一个边距为margin,水平间距为hSpacing,垂直间距为vSpacing的布局。
57 *
58 * @param margin 边距
59 * @param hSpacing 水平间距
60 * @param vSpacing 垂直间距
61 */
62 explicit KFlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1);
63
64 ~KFlowLayout();
65
66 public:
67 /**
68 * @brief 水平间距
69 *
70 * @param 无
71 */
72 int horizontalSpacing() const;
73
74 /**
75 * @brief 垂直间距
76 *
77 * @param 无
78 */
79 int verticalSpacing() const;
80
81 protected:
82 void addItem(QLayoutItem *item) Q_DECL_OVERRIDE;
83
84 Qt::Orientations expandingDirections() const Q_DECL_OVERRIDE;
85
86 bool hasHeightForWidth() const Q_DECL_OVERRIDE;
87
88 int heightForWidth(int) const Q_DECL_OVERRIDE;
89
90 int count() const Q_DECL_OVERRIDE;
91
92 QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE;
93
94 QSize minimumSize() const Q_DECL_OVERRIDE;
95
96 void setGeometry(const QRect &rect) Q_DECL_OVERRIDE;
97
98 QSize sizeHint() const Q_DECL_OVERRIDE;
99
100 QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE;
101
102 private:
103 Q_DECLARE_PRIVATE(KFlowLayout)
104 KFlowLayoutPrivate *const d_ptr;
105 };
106 }
107
108 #endif // KFLOWLAYOUT_H