-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimageview.cpp
More file actions
54 lines (46 loc) · 1.13 KB
/
imageview.cpp
File metadata and controls
54 lines (46 loc) · 1.13 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
#include "imageview.h"
#include "ui_imageview.h"
ImageView::ImageView(const std::vector<Photo *> & _photos, int _index, QWidget *parent) :
QDialog(parent),
m_currentIndex(_index),
p_photos(&_photos),
ui(new Ui::ImageView)
{
ui->setupUi(this);
ShowPhoto();
}
void ImageView::ShowPhoto() {
Photo * _photo = p_photos->at(m_currentIndex);
QByteArray _barr = _photo->GetImageBytes();
QPixmap outPixmap = QPixmap();
outPixmap.loadFromData(_barr);
ui->label->setPixmap(outPixmap.scaled(ui->label->width(),
ui->label->height(),
Qt::KeepAspectRatio));
}
void ImageView::Next() {
if (m_currentIndex == p_photos->size() - 1)
m_currentIndex = 0;
else
++m_currentIndex;
}
void ImageView::Previous() {
if (m_currentIndex == 0)
m_currentIndex = p_photos->size() - 1;
else
--m_currentIndex;
}
ImageView::~ImageView()
{
delete ui;
}
void ImageView::on_pushButton_clicked()
{
Previous();
ShowPhoto();
}
void ImageView::on_pushButton_2_clicked()
{
Next();
ShowPhoto();
}