forked from madtreat/qt-dynamic-layout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayoutmanager.h
43 lines (30 loc) · 1 KB
/
layoutmanager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* File: layoutmanager.h
* Author: madtreat
*
* Created on July 13, 2015, 11:23 AM
*/
#ifndef LAYOUTMANAGER_H
#define LAYOUTMANAGER_H
#include <QWidget>
#include <QList>
#include <QGridLayout>
#include "layoutitem.h"
class LayoutManager : public QWidget {
Q_OBJECT;
public:
LayoutManager(QWidget* _parent=0);
LayoutManager(const LayoutManager& orig) = delete;
virtual ~LayoutManager();
void addWidget(QWidget* widget, int row, int col, int rowSpan=1, int colSpan=1, bool visible=true);
void addWidget(LayoutItem* item);
void replaceItem(LayoutItem* item, QWidget* widget);
void replaceItem(LayoutItem* item1, LayoutItem* item2);
void swapItems(LayoutItem* item1, LayoutItem* item2);
QSize gridSize() const { return QSize(layout->columnCount(), layout->rowCount()); }
private:
QGridLayout* layout;
ItemList items; // list of visible items
ItemList invisibleItems; // list of invisible items that can be swapped later
};
#endif /* LAYOUTGRID_H */