File indexing completed on 2024-12-01 04:36:37
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #pragma once 0007 #include "libruqolawidgets_export.h" 0008 #include <QLayout> 0009 #include <QVector> 0010 0011 class LIBRUQOLAWIDGETS_EXPORT FlowLayout : public QLayout 0012 { 0013 Q_OBJECT 0014 0015 public: 0016 explicit FlowLayout(QWidget *parent = nullptr); 0017 ~FlowLayout() override; 0018 0019 [[nodiscard]] int horizontalSpacing() const; 0020 void setHorizontalSpacing(int horizontalSpacing); 0021 0022 [[nodiscard]] int verticalSpacing() const; 0023 void setVerticalSpacing(int verticalSpacing); 0024 0025 QSize sizeHint() const override; 0026 QSize minimumSize() const override; 0027 0028 void addItem(QLayoutItem *item) override; 0029 QLayoutItem *itemAt(int index) const override; 0030 QLayoutItem *takeAt(int index) override; 0031 [[nodiscard]] int count() const override; 0032 0033 [[nodiscard]] Qt::Orientations expandingDirections() const override; 0034 [[nodiscard]] bool hasHeightForWidth() const override; 0035 [[nodiscard]] int heightForWidth(int width) const override; 0036 0037 void setGeometry(const QRect &rect) override; 0038 0039 void clear(); 0040 void clearAndDeleteWidgets(); 0041 0042 private: 0043 LIBRUQOLAWIDGETS_NO_EXPORT int doFlow(QRect rect, bool effective) const; 0044 QVector<QLayoutItem *> mItems; 0045 int mHorizontalSpacing = -1; 0046 int mVerticalSpacing = -1; 0047 };