-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimagegridlayout.cpp
More file actions
77 lines (61 loc) · 1.51 KB
/
imagegridlayout.cpp
File metadata and controls
77 lines (61 loc) · 1.51 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "imagegridlayout.h"
#include <QDebug>
#include "imageview.h"
ImageGridLayout::ImageGridLayout() {
x = y = GAP;
}
void ImageGridLayout::update() {
x = y = GAP;
bool first = true;
foreach(QObject* qO, parent()->children()) {
ImageView* view = qobject_cast<ImageView*>(qO);
if(!view)
continue;
if(!first)
if((y += (view->size().height() + GAP)) + view->size().height() >= geometry().height()) {
x += (view->size().width() + GAP);
y = GAP;
}
view->moveAnimated(x, y);
first = false;
}
}
void ImageGridLayout::setGeometry(const QRect & r) {
QLayout::setGeometry(r);
update();
}
void ImageGridLayout::addItem(QLayoutItem *) {
update();
}
int ImageGridLayout::count() const {
return parent()->children().count() - 1;
}
Qt::Orientations ImageGridLayout::expandingDirections() const {
return Qt::Horizontal | Qt::Vertical;
}
bool ImageGridLayout::hasHeightForWidth() const {
return true;
}
int ImageGridLayout::heightForWidth ( int ) const {
return 0;
}
void ImageGridLayout::invalidate () {
}
QLayoutItem * ImageGridLayout::itemAt ( int ) const {
return 0;
}
QSize ImageGridLayout::maximumSize () const {
return QSize(x + DEFAULT_SIZE_X + GAP, y + GAP);
}
int ImageGridLayout::minimumHeightForWidth ( int ) const {
return 0;
}
QSize ImageGridLayout::minimumSize () const {
return QSize(x + DEFAULT_SIZE_X + GAP, y + GAP);
}
QSize ImageGridLayout::sizeHint() const {
return QSize(x + DEFAULT_SIZE_X + GAP, y + GAP);
}
QLayoutItem * ImageGridLayout::takeAt ( int ) {
return 0;
}