FreeDebks  1.0.3
 All Classes Files Functions Variables Friends Pages
FdItemResults.cpp
Go to the documentation of this file.
1 // --------------------------------------------------------------------
2 // Copyright © 2011-2013 Mathieu Schopfer
3 //
4 // This file is part of FreeDebks.
5 //
6 // FreeDebks is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // FreeDebks is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with FreeDebks. If not, see <http://www.gnu.org/licenses/>.
18 // --------------------------------------------------------------------
19 
20 #include "FdItemResults.hpp"
21 #include "FdItemCoa.hpp"
22 
23 FdItemResults::FdItemResults(QString id, QString label, QString calculation, double previousResult, double result) :
24  mId(id), mLabel(label), mCalculation(calculation), mPreviousResult(previousResult), mResult(result)
25 {
26 }
27 
31 FdItemResults_p FdItemResults::pointer(QDomElement &calculation)
32 {
33  return FdItemResults_p(new FdItemResults(calculation.attribute("Id"),
34  calculation.attribute("Label"),
35  calculation.attribute("Calculation"),
36  calculation.attribute("Previous").toDouble()));
37 }
38 
42 FdItemResults_p FdItemResults::pointer(FdItemResults_p model)
43 {
44  return FdItemResults_p(new FdItemResults(model->id(),
45  model->label(),
46  model->calculation(),
47  model->result()));
48 }
49 
50 QString FdItemResults::id() const
51 {
52  return mId;
53 }
54 
55 QString FdItemResults::label() const
56 {
57  return mLabel;
58 }
59 
60 QString FdItemResults::calculation() const
61 {
62  return mCalculation;
63 }
64 
65 double FdItemResults::result() const
66 {
67  return mResult;
68 }
69 
70 double FdItemResults::previousResult() const
71 {
72  return mPreviousResult;
73 }
74 
75 void FdItemResults::setId(QString id)
76 {
77  mId = id;
78 }
79 
80 void FdItemResults::setLabel(QString label)
81 {
82  mLabel = label;
83 }
84 
85 void FdItemResults::setCalculation(QString calculation)
86 {
88 }
89 
90 void FdItemResults::setResult(double result)
91 {
92  mResult = result;
93 }
94 
95 void FdItemResults::setPreviousResult(double result)
96 {
98 }
99 
103 bool FdItemResults::isEmpty() const
104 {
105  if(mLabel == "" && mCalculation == "")
106  return true;
107 
108  return false;
109 }
110 
111 QDomElement FdItemResults::toXml(QDomDocument &document) const
112 {
113  QDomElement calculation = document.createElement("Entry");
114  calculation.setAttribute("Id", mId);
115  calculation.setAttribute("Label", mLabel);
116  calculation.setAttribute("Calculation", mCalculation);
117  calculation.setAttribute("Previous", mPreviousResult);
118 
119  return calculation;
120 }