Subversion Repositories OpenInventory

Rev

Rev 197 | Rev 199 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 197 Rev 198
Line 1... Line 1...
1
#include "fileform.h"
1
#include "fileform.h"
2
#include "ui_fileform.h"
2
#include "ui_fileform.h"
-
 
3
#include "mainwindow.h"
3
4
4
FileForm::FileForm(QWidget *parent) :
5
FileForm::FileForm(QWidget *parent) :
5
    QWidget(parent),
6
    QWidget(parent),
6
    ui(new Ui::FileForm)
7
    ui(new Ui::FileForm)
7
{
8
{
Line 25... Line 26...
25
    }
26
    }
26
}
27
}
27
28
28
29
29
30
30
void FileForm::on_pushButton_clicked(){          // îáðàáîò÷èê íàæàòèÿ êíîïêè "Ïîìåíÿòü èêîíêó"
31
void FileForm::on_pushButton_clicked(){          // îáðàáîò÷èê íàæàòèÿ êíîïêè "Îòêðûòü ôàéë"
-
 
32
    QString  fileName;
-
 
33
    QFile file;
-
 
34
    QByteArray data_tmp;
-
 
35
-
 
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)
-
 
38
-
 
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();
31
49
32
50
33
}
51
}
34
52
35
void FileForm::on_pushButton_2_clicked(){          // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü èêîíêó"
53
void FileForm::on_pushButton_2_clicked(){          // îáðàáîò÷èê íàæàòèÿ êíîïêè "Óäàëèòü ôàéë"
-
 
54
Data.clear();
-
 
55
-
 
56
}
-
 
57
-
 
58
void FileForm::on_pushButton_3_clicked(){          // îáðàáîò÷èê íàæàòèÿ êíîïêè "Ñîõðàíèòü ôàéë"
-
 
59
-
 
60
    QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
-
 
61
                                                     "",
-
 
62
                                                     tr("All Files (*.*);;Image Files (*.png *.jpg *.bmp);;Text files (*.txt);;XML files (*.xml)"));
-
 
63
-
 
64
    QByteArray data_tmp;
-
 
65
    QFile file;
-
 
66
    int i;
-
 
67
    i++;
-
 
68
    if (fileName.isEmpty()) return;
-
 
69
    if (Data.isEmpty()) return;
-
 
70
-
 
71
        file.setFileName(fileName);
-
 
72
        if (!file.open(QIODevice::WriteOnly)) return;
-
 
73
-
 
74
-
 
75
    // Data = file.readAll();
-
 
76
    QDataStream out(&Data,QIODevice::ReadOnly);
-
 
77
  //  out.device()->reset();
-
 
78
    out >> fileName;
-
 
79
-
 
80
    file.setFileName(fileName);
-
 
81
    if (!file.open(QIODevice::ReadWrite)) return;
-
 
82
    data_tmp.clear();
-
 
83
    out >> data_tmp;
-
 
84
    int count;
-
 
85
    count = file.write(data_tmp);
-
 
86
-
 
87
    file.close();
-
 
88
36
89
37
90
38
}
91
}