-
Notifications
You must be signed in to change notification settings - Fork 0
/
projectfile.cpp
83 lines (76 loc) · 2.14 KB
/
projectfile.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
78
79
80
81
82
83
#include "projectfile.h"
ProjectFile::ProjectFile(QString name, QString filePath,QObject *parent) :
QObject(parent), mName(name), mPath(filePath)
{
int slash = filePath.lastIndexOf("/");
mPath = filePath.section("",0,slash+1);
if(mName == "")
mName = filePath.remove(slash,filePath.size());
}
void ProjectFile::addFile(FileInfo * file)
{
mFiles.append(file);
}
void ProjectFile::addFilter(QString filter)
{
mFilters.append(filter);
}
void ProjectFile::loadProject(QString project_location)
{
}
void ProjectFile::saveProject()
{
QString data_out;
QXmlStreamWriter writer(&data_out);
writer.setAutoFormatting(true);
writer.writeStartDocument();
writer.writeStartElement("Project");
writer.writeTextElement("Name",this->mName);
writer.writeStartElement("Filters");
foreach( QString filter, mFilters)
{
writer.writeTextElement("Filter",filter);
foreach( FileInfo * file, mFiles)
{
if(file->mType == filter)
{
writer.writeStartElement("File");
writer.writeTextElement("Name", file->mFilename);
writer.writeTextElement("Path", file->mPath);
writer.writeTextElement("Type", file->mType);
if(file->mBreakpoints.size() > 0)
{
writer.writeStartElement("Breakpoints");
foreach(int line_count, file->mBreakpoints)
{
writer.writeTextElement("BP",QString::number(line_count));
}
writer.writeEndElement();
}
writer.writeEndElement();
}
}
}
writer.writeEndElement();
writer.writeEndElement();
writer.writeEndDocument();
QString filepath = (mPath + mName);
QFile out(filepath);
out.open(QIODevice::WriteOnly);
out.write(data_out.toAscii());
out.flush();
out.close();
}
ProjectFile::~ProjectFile()
{
mName.clear();
mPath.clear();
mFilters.clear();
int count = mFiles.count();
for (int index = 0; index < count; index ++)
{
FileInfo * ptr = mFiles.at(index);
delete ptr;
}
mFiles.clear();
}