mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 12:23:58 -07:00
* Fix local variable double declaration. Took 44 seconds * Mark functions as [[nodiscard]] Took 31 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
/**
|
|
* @file overlap_layout.h
|
|
* @ingroup UI
|
|
* @brief TODO: Document this.
|
|
*/
|
|
|
|
#ifndef OVERLAP_LAYOUT_H
|
|
#define OVERLAP_LAYOUT_H
|
|
|
|
#include <QLayout>
|
|
#include <QList>
|
|
#include <QLoggingCategory>
|
|
#include <QWidget>
|
|
|
|
inline Q_LOGGING_CATEGORY(OverlapLayoutLog, "overlap_layout");
|
|
|
|
class OverlapLayout : public QLayout
|
|
{
|
|
public:
|
|
OverlapLayout(QWidget *parent = nullptr,
|
|
int overlapPercentage = 10,
|
|
int maxColumns = 2,
|
|
int maxRows = 2,
|
|
Qt::Orientation overlapDirection = Qt::Vertical,
|
|
Qt::Orientation flowDirection = Qt::Horizontal);
|
|
~OverlapLayout();
|
|
void insertWidgetAtIndex(QWidget *toInsert, int index);
|
|
|
|
void addItem(QLayoutItem *item) override;
|
|
[[nodiscard]] int count() const override;
|
|
[[nodiscard]] QLayoutItem *itemAt(int index) const override;
|
|
QLayoutItem *takeAt(int index) override;
|
|
void setGeometry(const QRect &rect) override;
|
|
[[nodiscard]] QSize minimumSize() const override;
|
|
[[nodiscard]] QSize sizeHint() const override;
|
|
void setMaxColumns(int _maxColumns);
|
|
void setMaxRows(int _maxRows);
|
|
[[nodiscard]] int calculateMaxColumns() const;
|
|
[[nodiscard]] int calculateRowsForColumns(int columns) const;
|
|
[[nodiscard]] int calculateMaxRows() const;
|
|
[[nodiscard]] int calculateColumnsForRows(int rows) const;
|
|
void setDirection(Qt::Orientation _direction);
|
|
|
|
private:
|
|
QList<QLayoutItem *> itemList;
|
|
int overlapPercentage;
|
|
int maxColumns;
|
|
int maxRows;
|
|
Qt::Orientation overlapDirection;
|
|
Qt::Orientation flowDirection;
|
|
|
|
// Calculate the preferred size of the layout
|
|
[[nodiscard]] QSize calculatePreferredSize() const;
|
|
};
|
|
|
|
#endif // OVERLAP_LAYOUT_H
|