-
Notifications
You must be signed in to change notification settings - Fork 0
/
datamanager.cpp
62 lines (56 loc) · 1.84 KB
/
datamanager.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
#include "datamanager.h"
#include <QFile>
#include <QFileInfo>
#include <QDateTime>
DataManager::DataManager() {
srcModel = new SrcModel();
bbModel = new BbModel();
}
SrcModel* DataManager::getSrcModel() {
return srcModel;
}
BbModel* DataManager::getBbModel() {
return bbModel;
}
bool DataManager::newFile(QString name) {
QFile file;
if(file.exists(name+".bbmodel") && file.exists(name+".lnmodel")) {
QFileInfo bbmodelFile, lnmodelFile, cFile;
bbmodelFile.setFile(name+".bbmodel");
lnmodelFile.setFile(name+".lnmodel");
cFile.setFile(name+".c");
if((bbmodelFile.lastModified() == cFile.lastModified()) && (lnmodelFile.lastModified() == cFile.lastModified())) {
file.setFileName(name+".bbmodel");
file.open(QIODevice::ReadOnly);
QString line = file.readLine().constData();
while(line.size() != 0) {
if(!line.startsWith("#") && !line.startsWith("\n")) {
bbModel->addBbData(line);
}
line = file.readLine().constData();
}
file.close();
if(bbModel->findBbLines(name)) {
file.setFileName(name+".lnmodel");
file.open(QIODevice::ReadOnly);
line = file.readLine().constData();
while(line.size() != 0) {
if(!line.startsWith("#") && !line.startsWith("\n")) {
srcModel->addSrcData(line);
}
line = file.readLine().constData();
}
file.close();
return true;
}
}
}
return false;
}
int* DataManager::bbLines(int line) {
int *result;
result = new int[2];
result[0] = bbModel->start(line);
result[1] = bbModel->end(line);
return result;
}