-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdlgimgpopup.cpp
More file actions
101 lines (79 loc) · 2.48 KB
/
dlgimgpopup.cpp
File metadata and controls
101 lines (79 loc) · 2.48 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "dlgimgpopup.h"
#include "ui_dlgimgpopup.h"
DlgImgPopup::DlgImgPopup(QWidget *parent, QPoint locationCoord) :
QDialog(parent),
locationPoint(locationCoord),
ui(new Ui::DlgImgPopup)
{
ui->setupUi(this);
mapFrame = qobject_cast<MapTilesFrame *>(this->parentWidget()->parentWidget());
assert(mapFrame != NULL);
//connect(&mapFrame->provider(), SIGNAL(readyImage(QString)), this, SLOT(update()));
imgIndex = 0;
//ui->imgPopupLabel->setStyleSheet("border-image: url(:/images/qPictur.jpg);");
QSqlQuery query;
QString queryString("SELECT name, ImageName FROM interestNode WHERE CoordinateX=" +
QString().setNum(locationPoint.x()) + " AND CoordinateY=" + QString().setNum(locationPoint.y()));
query.exec(queryString);
query.next();
assert(query.isValid());
QString spotName = query.value(0).toString();
QString imageNames = query.value(1).toString();
ui->spotNameLabel->setText(spotName);
if(imageNames == "none" || imageNames.isEmpty())
{
ui->imgPopupLabel->setPixmap(QPixmap(":/images/notile.bmp"));
}
else
{
imgNameList = imageNames.split("#");
// QString imgName;
// foreach(imgName, imgNameList)
// {
// mapFrame->provider().getTile(QString("/SpotImages/" + imgName));
// }
autoChangeImg();
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(autoChangeImg()));
timer->start(2500);
}
// QString imgName;
// foreach(imgName, imgNameList)
// {
// if(imgName == "none")
// {
// break;
// }
// imgList.append();
// }
}
DlgImgPopup::~DlgImgPopup()
{
delete ui;
}
void DlgImgPopup::mousePressEvent(QMouseEvent *)
{
close();
}
void DlgImgPopup::autoChangeImg()
{
QString imgName = imgNameList[imgIndex];
QImage* img = mapFrame->provider().getTile(QString("/SpotImages/" + imgName), true);
// while(!img)
// {
// img = mapFrame->provider().getTile(QString("/SpotImages/" + imgName), true);
// QCoreApplication::processEvents();
// }
if(img)
{
QPixmap pixmap(QPixmap::fromImage(*img));
ui->imgPopupLabel->setPixmap(pixmap);
delete img;
img = NULL;
imgIndex++;
if(imgIndex >= imgNameList.length())
{
imgIndex = 0;
}
}
}