summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/graphinfo.cpp
Unidiff
Diffstat (limited to 'noncore/apps/checkbook/graphinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/graphinfo.cpp45
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
@@ -35,12 +35,23 @@ GraphInfo::GraphInfo( GraphType type, DataPointList *data, const QString &title,
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
41GraphInfo::~GraphInfo()
42{
43 if ( d )
44 {
45 for ( DataPointInfo *data = d->first(); data; data = d->next() )
46 {
47 delete data;
48 }
49 }
50}
51
41GraphInfo::GraphType GraphInfo::graphType() 52GraphInfo::GraphType GraphInfo::graphType()
42{ 53{
43 return t; 54 return t;
44} 55}
45 56
46void GraphInfo::setGraphType( GraphType type ) 57void GraphInfo::setGraphType( GraphType type )
@@ -55,20 +66,48 @@ DataPointList *GraphInfo::dataPoints()
55 66
56void GraphInfo::setDataPoints( DataPointList *data ) 67void GraphInfo::setDataPoints( DataPointList *data )
57{ 68{
58 d = data; 69 d = data;
59} 70}
60 71
61float GraphInfo::maxValue() 72DataPointInfo *GraphInfo::firstDataPoint()
62{ 73{
63 float max; 74 return( d->first() );
75}
64 76
77DataPointInfo *GraphInfo::nextDataPoint()
78{
79 return( d->next() );
80}
81
82int GraphInfo::numberDataPoints()
83{
84 return( d->count() );
85}
86
87float 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
67float GraphInfo::minValue() 100float 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
71void GraphInfo::setGraphTitle( const QString &title ) 110void GraphInfo::setGraphTitle( const QString &title )
72{ 111{
73 gt = title; 112 gt = title;
74} 113}