-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshoworsetdata.cpp
78 lines (67 loc) · 1.98 KB
/
showorsetdata.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
#include <QFileDialog>
#include "showorsetdata.h"
#include "ui_showorsetdata.h"
ShowOrSetData::ShowOrSetData(QWidget *parent) :
QDialog(parent),
ui(new Ui::ShowOrSetData)
{
SaveIsCliked = false;
mydata = new Data;
ui->setupUi(this);
if (!image.isNull())
ui->img->setVisible(false);
QObject::connect(this->ui->choseButton,SIGNAL(clicked()),this,SLOT(chose()));
QObject::connect(this->ui->saveButton,SIGNAL(clicked()),this,SLOT(save()));
setWindowTitle(QApplication::translate("toplevel", "Set Data"));
}
ShowOrSetData::ShowOrSetData(QString name, QString code, QString description, QString quantity,QString imgPath):ShowOrSetData()
{
ui->nameLine->setText(name);
ui->barcodeLine->setText(code);
ui->descriptionLine->setText(description);
ui->qantityLine->setText(quantity);
Pathimg=imgPath;
this->image.load(imgPath);
ui->img->setPixmap(QPixmap::fromImage(this->image));
}
void ShowOrSetData::chose()
{
QString fileName = QFileDialog::getOpenFileName(this,tr("chose"),"",tr("Images(*.png *.jpg *jpeg *bmp *gif)"));
ChoseImgPath = fileName;
if(QString::compare(fileName,QString())!=0){
QImage image ;
bool valid = image.load(fileName);
if(valid){
ui->img->setVisible(true);
ui->img->setPixmap(QPixmap::fromImage(image).scaled(311,101));
}
}
}
void ShowOrSetData::save()
{
mydata->quantity = ui->qantityLine->text().toInt();
mydata->code = ui->barcodeLine->text().toInt();
mydata->description = ui->descriptionLine->text();
mydata->name = ui->nameLine->text();
if(!QFileInfo::exists(ChoseImgPath)){
mydata->pathImg = Pathimg;
}else{
mydata->pathImg = ChoseImgPath;
}
emit SendStatusSave(true);
emit saveBtn_signal(mydata);
this->close();
}
ShowOrSetData::~ShowOrSetData()
{
delete mydata;
delete ui;
}
QString ShowOrSetData::getImage()
{
return Pathimg;
}
Data *ShowOrSetData::getData()
{
return mydata;
}