-
Notifications
You must be signed in to change notification settings - Fork 0
/
qfileinfoandsettings.h
59 lines (48 loc) · 1.49 KB
/
qfileinfoandsettings.h
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
#ifndef QFILEINFOANDSETTINGS_H
#define QFILEINFOANDSETTINGS_H
#include <QFileInfo>
#include <QRectF>
#include <QTransform>
#include <QDataStream>
class QFileInfoAndSettings : public QFileInfo
{
public:
~QFileInfoAndSettings();
QFileInfoAndSettings();
QFileInfoAndSettings(const QString &file);
const QTransform& getTransform();
const QRectF& getCropRegion();
void setTransform(const QTransform& transform);
void setCropRegion(const QRectF& cropRegion);
void setRotationAngle(int rotationAngle);
int getRotationAngle();
// I/O support
friend inline QDataStream& operator<<(QDataStream& out, const QFileInfoAndSettings& f);
friend inline QDataStream& operator>>(QDataStream& in, QFileInfoAndSettings& f);
private:
QTransform transform; // matriz identidad
QRectF cropRegion;
int rotationAngle;
};
inline QDataStream& operator<<(QDataStream &out, const QFileInfoAndSettings &f)
{
QString path = f.absoluteFilePath();
QRectF cropRect = f.cropRegion;
qint32 angle = qint32(f.rotationAngle);
QTransform trans = f.transform;
return out<<path<<cropRect<<angle<<trans;
}
inline QDataStream& operator>>(QDataStream& in, QFileInfoAndSettings& f)
{
QString path;
QRectF cropRect;
qint32 angle;
QTransform trans;
in>>path>>cropRect>>angle>>trans;
f.setFile(path);
f.setCropRegion(cropRect);
f.setRotationAngle(static_cast<int>(angle));
f.setTransform(trans);
return in;
}
#endif // QFILEINFOANDSETTINGS_H