-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotedata.cpp
More file actions
108 lines (86 loc) · 1.84 KB
/
notedata.cpp
File metadata and controls
108 lines (86 loc) · 1.84 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
102
103
104
105
106
107
#include "notedata.h"
#include <QFile>
#include <QTextStream>
#include <QRect>
NoteData::NoteData(QObject *parent) :
QObject(parent)
{
clearData();
}
void NoteData::clearData()
{
station = QRect(0,0,0,0);
percent = 100;
text = QString::null;
fontSize = 0;
}
bool NoteData::writeDataToFile(QString filename)
{
QFile file(filename);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
QTextStream out(&file);
out<< this->station.x() << "\n"
<< this->station.y() << "\n"
<< this->station.width() << "\n"
<< this->station.height() << "\n"
<< this->percent << "\n"
<< this->fontSize << "\n"
<< this->text;
file.close();
return true;
}
bool NoteData::readDataFromFile(QString filename)
{
QFile file(filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
QTextStream in(&file);
station.setX( in.readLine().toInt() );
station.setY( in.readLine().toInt() );
station.setWidth( in.readLine().toInt() );
station.setHeight( in.readLine().toInt() );
percent = in.readLine().toInt();
fontSize = in.readLine().toInt();
text = QString::null;
while (!in.atEnd())
{
QString line = in.readLine();
text += line;
text += "\n";
}
file.close();
return true;
}
QString NoteData::getText() const
{
return text;
}
void NoteData::setText(const QString &value)
{
text = value;
}
int NoteData::getFontSize() const
{
return fontSize;
}
void NoteData::setFontSize(int value)
{
fontSize = value;
}
int NoteData::getPercent() const
{
return percent;
}
void NoteData::setPercent(int value)
{
percent = value;
}
QRect NoteData::getStation() const
{
return station;
}
void NoteData::setStation(const QRect &value)
{
station = value;
}