Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_size_group_p.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2013 Juan Palacios <jpalaciosdev@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef KISSIZEGROUPPRIVATE_H
8#define KISSIZEGROUPPRIVATE_H
9
10#include <QObject>
11#include <QWidgetItem>
12#include <QList>
13#include <QSize>
14
15#include "kis_size_group.h"
16
17class QWidget;
18class QEvent;
19class QTimer;
20
21class GroupItem;
22class KisSizeGroupPrivate : public QObject
23{
24 Q_OBJECT
25
26public:
27 KisSizeGroupPrivate(KisSizeGroup *q_ptr, KisSizeGroup::mode mode, bool ignoreHidden);
28
29 void addWidget(QWidget *widget);
30 void removeWidget(QWidget *widget);
31
33 void scheduleSizeUpdate();
34
36 const QSize getSizeHint() const { return m_sizeHint; }
37
38
39private Q_SLOTS:
40 void updateSize();
41
42public:
46
47private:
48 QTimer* m_updateTimer; // used to filter multiple calls to scheduleSizeUpdate() into one single updateSize()
51};
52
53
54class GroupItem : public QObject, public QWidgetItem
55{
56 Q_OBJECT
57
58public:
59 explicit GroupItem(QWidget* widget);
60 ~GroupItem() override {}
61
62 void setSize(const QSize &size) { m_size = size; }
63
64 int getWidth() const { return m_size.width(); }
65 void setWidth(int width) { m_size.setWidth(width); }
66
67 int getHeight() const { return m_size.height(); }
68 void setHeight(int height) { m_size.setHeight(height); }
69
70 bool hidden() const { return m_hidden; }
71
73 void setGroup(KisSizeGroupPrivate* group) { m_group = group; }
74
75 QSize sizeHint() const override;
76 QSize minimumSize() const override;
77
78 bool eventFilter(QObject*, QEvent *event) override;
79
80private:
81 bool m_hidden {false};
82 QSize m_size;
84};
85
86#endif // KISSIZEGROUPPRIVATE_H
bool hidden() const
KisSizeGroupPrivate * getGroup()
void setSize(const QSize &size)
QSize sizeHint() const override
QSize minimumSize() const override
KisSizeGroupPrivate * m_group
void setGroup(KisSizeGroupPrivate *group)
int getHeight() const
void setHeight(int height)
~GroupItem() override
GroupItem(QWidget *widget)
bool eventFilter(QObject *, QEvent *event) override
int getWidth() const
void setWidth(int width)
KisSizeGroup::mode m_mode
KisSizeGroupPrivate(KisSizeGroup *q_ptr, KisSizeGroup::mode mode, bool ignoreHidden)
QList< GroupItem * > m_groupItems
void addWidget(QWidget *widget)
const QSize getSizeHint() const
Returns the size hint for the widgets contained in the size group.
void scheduleSizeUpdate()
Schedules an update of all widgets size.
void removeWidget(QWidget *widget)