This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgallery.cpp
83 lines (70 loc) · 2.09 KB
/
gallery.cpp
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
78
79
80
81
82
83
#include "gallery.h"
#include "QDebug"
Gallery::Gallery(){}
Gallery::~Gallery()
{
delete[] thumbnails;
}
void Gallery::arrangeThumbnails()
{
//creating a pen for generating the thumbnail border
QPen thumbnailBorderPen;
thumbnailBorderPen.setColor(Qt::black);
thumbnailBorderPen.setWidth(1);
//variables for storing thumbnail width and height
int witdh;
int height;
int xPosAdjustment;
int yPosAdjustment;
//moving thumbnails to appropiate positions in the graphicView;
for(int i = 0,j = 0; i < thumbnailsCount; i++)
{
thumbnails[i].setPos(-490 + 245*(i%3),10 + 180*j);
galleryScene->addRect(-490 + 245*(i%3),10 + 180*j, 220, 165, thumbnailBorderPen);
witdh = thumbnails[i].getThumbnailWidth();
height = thumbnails[i].getThumbnailHeight();
if(witdh < 220)
{
xPosAdjustment = (220 - witdh)/2;
thumbnails[i].setThumbnailPointX(xPosAdjustment);
}
if(height < 165)
{
yPosAdjustment = (165 - height)/2;
thumbnails[i].setThumbnailPointY(yPosAdjustment);
}
if(i%3 == 2)
j++;
}
}
void Gallery::load()
{
galleryScene = new QGraphicsScene;
thumbnailsCount = 11;
thumbnails = new GalleryThumbnail[thumbnailsCount];
QString imagePath;
int i = 0;
for(; i < thumbnailsCount; i++)
{
//setting paths for full scale images
imagePath.append("Images/");
imagePath.append(QString::number(i));
imagePath.append(".jpg");
thumbnails[i].setFullResImagePath(imagePath);
imagePath.clear();
//loading thumbnails
imagePath.append("Images/thumbnails/");
imagePath.append(QString::number(i));
imagePath.append(".jpg");
thumbnails[i].setThumbnailImage(imagePath);
imagePath.clear();
galleryScene->addItem(&thumbnails[i]);
//setting image indexes
thumbnails[i].setImageIndex(i);
thumbnails[i].setTotalImageCount(thumbnailsCount);
}
}
QGraphicsScene* Gallery::getScene()
{
return galleryScene;
}