Diffstat (limited to 'noncore/apps/checkbook/graphinfo.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/graphinfo.cpp | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/noncore/apps/checkbook/graphinfo.cpp b/noncore/apps/checkbook/graphinfo.cpp index 7b06bdb..ec6a465 100644 --- a/noncore/apps/checkbook/graphinfo.cpp +++ b/noncore/apps/checkbook/graphinfo.cpp | |||
@@ -29,52 +29,91 @@ | |||
29 | #include "graphinfo.h" | 29 | #include "graphinfo.h" |
30 | 30 | ||
31 | GraphInfo::GraphInfo( GraphType type, DataPointList *data, const QString &title, | 31 | GraphInfo::GraphInfo( GraphType type, DataPointList *data, const QString &title, |
32 | const QString &xtitle, const QString &ytitle ) | 32 | const QString &xtitle, const QString &ytitle ) |
33 | { | 33 | { |
34 | t = type; | 34 | t = type; |
35 | d = data; | 35 | d = data; |
36 | gt = title; | 36 | gt = title; |
37 | xt = xtitle; | 37 | xt = xtitle; |
38 | yt = ytitle; | 38 | yt = ytitle; |
39 | } | 39 | } |
40 | 40 | ||
41 | GraphInfo::~GraphInfo() | ||
42 | { | ||
43 | if ( d ) | ||
44 | { | ||
45 | for ( DataPointInfo *data = d->first(); data; data = d->next() ) | ||
46 | { | ||
47 | delete data; | ||
48 | } | ||
49 | } | ||
50 | } | ||
51 | |||
41 | GraphInfo::GraphType GraphInfo::graphType() | 52 | GraphInfo::GraphType GraphInfo::graphType() |
42 | { | 53 | { |
43 | return t; | 54 | return t; |
44 | } | 55 | } |
45 | 56 | ||
46 | void GraphInfo::setGraphType( GraphType type ) | 57 | void GraphInfo::setGraphType( GraphType type ) |
47 | { | 58 | { |
48 | t = type; | 59 | t = type; |
49 | } | 60 | } |
50 | 61 | ||
51 | DataPointList *GraphInfo::dataPoints() | 62 | DataPointList *GraphInfo::dataPoints() |
52 | { | 63 | { |
53 | return d; | 64 | return d; |
54 | } | 65 | } |
55 | 66 | ||
56 | void GraphInfo::setDataPoints( DataPointList *data ) | 67 | void GraphInfo::setDataPoints( DataPointList *data ) |
57 | { | 68 | { |
58 | d = data; | 69 | d = data; |
59 | } | 70 | } |
60 | 71 | ||
61 | float GraphInfo::maxValue() | 72 | DataPointInfo *GraphInfo::firstDataPoint() |
62 | { | 73 | { |
63 | float max; | 74 | return( d->first() ); |
75 | } | ||
64 | 76 | ||
77 | DataPointInfo *GraphInfo::nextDataPoint() | ||
78 | { | ||
79 | return( d->next() ); | ||
65 | } | 80 | } |
66 | 81 | ||
67 | float GraphInfo::minValue() | 82 | int GraphInfo::numberDataPoints() |
68 | { | 83 | { |
84 | return( d->count() ); | ||
85 | } | ||
86 | |||
87 | float GraphInfo::maxValue() | ||
88 | { | ||
89 | float max = 0.0; | ||
90 | for ( DataPointInfo *data = d->first(); data; data = d->next() ) | ||
91 | { | ||
92 | if ( data->value() > max ) | ||
93 | { | ||
94 | max = data->value(); | ||
95 | } | ||
96 | } | ||
97 | return max; | ||
98 | } | ||
99 | |||
100 | float GraphInfo::totalValue() | ||
101 | { | ||
102 | float sum = 0.0; | ||
103 | for ( DataPointInfo *data = d->first(); data; data = d->next() ) | ||
104 | { | ||
105 | sum += data->value(); | ||
106 | } | ||
107 | return sum; | ||
69 | } | 108 | } |
70 | 109 | ||
71 | void GraphInfo::setGraphTitle( const QString &title ) | 110 | void GraphInfo::setGraphTitle( const QString &title ) |
72 | { | 111 | { |
73 | gt = title; | 112 | gt = title; |
74 | } | 113 | } |
75 | 114 | ||
76 | void GraphInfo::setXAxisTitle( const QString &xtitle ) | 115 | void GraphInfo::setXAxisTitle( const QString &xtitle ) |
77 | { | 116 | { |
78 | xt = xtitle; | 117 | xt = xtitle; |
79 | } | 118 | } |
80 | 119 | ||