Subversion Repositories OpenInventory

Rev

Rev 199 | Rev 201 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
197 pingvin 1
#include "fileform.h"
2
#include "ui_fileform.h"
198 pingvin 3
#include "mainwindow.h"
197 pingvin 4
 
5
FileForm::FileForm(QWidget *parent) :
6
    QWidget(parent),
7
    ui(new Ui::FileForm)
8
{
9
    ui->setupUi(this);
10
}
11
 
12
FileForm::~FileForm()
13
{
14
    delete ui;
15
}
16
 
17
void FileForm::changeEvent(QEvent *e)
18
{
19
    QWidget::changeEvent(e);
20
    switch (e->type()) {
21
    case QEvent::LanguageChange:
22
        ui->retranslateUi(this);
23
        break;
24
    default:
25
        break;
26
    }
27
}
28
 
29
 
30
 
198 pingvin 31
void FileForm::on_pushButton_clicked(){          //    " "
32
    QString  fileName;
33
    QFile file;
34
    QByteArray data_tmp;
197 pingvin 35
 
198 pingvin 36
        fileName = QFileDialog::getOpenFileName(this,
37
         tr("Open Image"), "", tr("All Files (*.*);;Image Files (*.png *.jpg *.bmp);;Text files (*.txt);;XML files (*.xml)")); //Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)
197 pingvin 38
 
198 pingvin 39
    if (fileName.isEmpty()) return;
40
    file.setFileName(fileName);
41
    if (!file.open(QIODevice::ReadOnly)) return;
42
    Data.clear();
43
    // Data = file.readAll();
44
    QDataStream out(&Data,QIODevice::ReadWrite);
45
    out << fileName;
46
    data_tmp = file.readAll();
47
    out << data_tmp;
48
    file.close();
49
 
50
 
197 pingvin 51
}
52
 
198 pingvin 53
void FileForm::on_pushButton_2_clicked(){          //    " "
54
Data.clear();
197 pingvin 55
 
198 pingvin 56
}
197 pingvin 57
 
198 pingvin 58
void FileForm::on_pushButton_3_clicked(){          //    " "
59
 
199 pingvin 60
    QByteArray data_tmp;
61
    QFile file;
62
    QDataStream out(&Data,QIODevice::ReadOnly);
63
    QString fileName;
200 pingvin 64
    if (Data.isEmpty()) return;
199 pingvin 65
    out >> fileName;
66
    fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
67
                                                     fileName,
198 pingvin 68
                                                     tr("All Files (*.*);;Image Files (*.png *.jpg *.bmp);;Text files (*.txt);;XML files (*.xml)"));
69
 
199 pingvin 70
 
198 pingvin 71
    if (fileName.isEmpty()) return;
72
 
200 pingvin 73
 
198 pingvin 74
        file.setFileName(fileName);
75
        if (!file.open(QIODevice::WriteOnly)) return;
76
 
77
 
78
    // Data = file.readAll();
199 pingvin 79
 
198 pingvin 80
  //  out.device()->reset();
81
 
199 pingvin 82
 
83
 
198 pingvin 84
    data_tmp.clear();
85
    out >> data_tmp;
86
    int count;
87
    count = file.write(data_tmp);
199 pingvin 88
    int size;
89
    size = file.size();
198 pingvin 90
    file.close();
91
 
92
 
93
 
197 pingvin 94
}