Diffstat (limited to 'noncore/apps/checkbook/graphinfo.cpp') (more/less context) (ignore 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 | |||
@@ -38,6 +38,17 @@ GraphInfo::GraphInfo( GraphType type, DataPointList *data, const QString &title, | |||
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; |
@@ -58,14 +69,42 @@ void GraphInfo::setDataPoints( DataPointList *data ) | |||
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() ); | ||
80 | } | ||
81 | |||
82 | int GraphInfo::numberDataPoints() | ||
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; | ||
65 | } | 98 | } |
66 | 99 | ||
67 | float GraphInfo::minValue() | 100 | float GraphInfo::totalValue() |
68 | { | 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 ) |