-
Notifications
You must be signed in to change notification settings - Fork 1
/
qDFProjReportCollection.cpp
128 lines (102 loc) · 3.28 KB
/
qDFProjReportCollection.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <iostream>
#include <QDataStream>
#include "qDFProjReport.hpp"
#include "qDFProjReportCollection.hpp"
qDFProjReportCollection::qDFProjReportCollection()
: DFLib::ReportCollection()
{
}
qDFProjReportCollection::~qDFProjReportCollection()
{
}
void qDFProjReportCollection::deleteReports()
{
DFLib::ReportCollection::deleteReports();
reportMap_.clear();
emit collectionCleared();
}
int qDFProjReportCollection::addReport(qDFProjReport * aReport)
{
int returnValue=DFLib::ReportCollection::addReport(dynamic_cast<DFLib::Abstract::Report *>(aReport));
// Add the report to our name/pointer map:
reportMap_.insert(QString::fromStdString(aReport->getReportName()),aReport);
// This makes sure that whenever any report in our collection emits a signal
// that it's changed, we emit a signal that the collection has changed.
connect(aReport,SIGNAL(reportChanged(qDFProjReport *)),this,SLOT(reportChanged(qDFProjReport *)));
emit collectionChanged();
emit collectionChanged(returnValue); // for those customers who care which
// is the new report index
return (returnValue);
}
void qDFProjReportCollection::newReport(qDFProjReport * aReport)
{
addReport(aReport);
// cout << "newReport slot called, added report number "<< i << endl;
}
void qDFProjReportCollection::reportChanged(qDFProjReport *theChangedReport)
{
int index=getReportIndex(theChangedReport);
emit collectionChanged(index); // for those who care which
emit collectionChanged(); // for those who don't
}
QString qDFProjReportCollection::getReportName(int reportIndex)
{
return (dynamic_cast<const qDFProjReport *>(getReport(reportIndex))->getReportNameQS());
}
qDFProjReport * qDFProjReportCollection::getReportPointer(const QString &rN)
{
return reportMap_[rN];
// will return 0 if report doesn't exist. Let the caller figure that out.
}
QString qDFProjReportCollection::getReportSummary(const QString &reportName,
const std::vector<std::string> & projArgs) const
{
return (reportMap_[reportName]->getReportSummary(projArgs));
}
QDataStream & operator<<(QDataStream &out, const qDFProjReportCollection &tC)
{
out << quint32(tC.size());
for (int i=0; i<tC.size(); i++)
{
out << *(dynamic_cast<const qDFProjReport *> (tC.getReport(i)));
}
return out;
}
QDataStream & operator>>(QDataStream &in, qDFProjReportCollection &tC)
{
quint32 nrep;
in >> nrep;
for (unsigned int i=0; i<nrep; i++)
{
QString reportName;
std::vector<double> coords(2);
double bearing;
double sigma;
bool validity;
QString csName;
quint32 zone;
QString equipType;
QString quality;
CoordSysBuilder csB;
in >> reportName;
in >> coords[0] >> coords[1];
in >> bearing >> sigma;
in >> validity;
in >> csName;
in >> zone;
in >> equipType;
in >> quality;
CoordSys CS=csB.getCoordSys(csName.toStdString());
if (CS.isZoneRequired())
CS.setZone(zone);
qDFProjReport *nR = new qDFProjReport(coords,bearing,sigma,reportName.
toStdString(),CS, equipType,
quality);
if (validity)
nR->setValid();
else
nR->setInvalid();
tC.addReport(nR);
}
return in;
}