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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
/***************************************************************************
kmymoneyaccounttreeforecast.h
-------------------
begin : Fri Aug 01 2008
copyright : (C) 2008 by Alvaro Soliverez
email : asoliverez@gmail.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KMYMONEYACCOUNTTREEFORECAST_H
#define KMYMONEYACCOUNTTREEFORECAST_H
// ----------------------------------------------------------------------------
// QT Includes
#include <qtimer.h>
class QDragObject;
// ----------------------------------------------------------------------------
// KDE Includes
#include <klistview.h>
// ----------------------------------------------------------------------------
// Project Includes
#include "kmymoneyaccounttree.h"
#include "../../kmymoney/mymoneyforecast.h"
class KMyMoneyAccountTreeForecastItem;
class KMyMoneyAccountTreeForecast : public KMyMoneyAccountTreeBase
{
Q_OBJECT
public:
KMyMoneyAccountTreeForecast(QWidget* parent = 0, const char *name = 0);
virtual ~KMyMoneyAccountTreeForecast() {}
void showSummary(MyMoneyForecast& forecast);
void showDetailed(MyMoneyForecast& forecast);
void showAdvanced(MyMoneyForecast& forecast);
void showBudget(MyMoneyForecast& forecast);
void showAccount(void);
void clearColumns(void);
public slots:
void slotSelectObject(const QListViewItem* i);
};
class KMyMoneyAccountTreeForecastItem : public KMyMoneyAccountTreeBaseItem
{
public:
enum EForecastViewType { eSummary = 0, eDetailed, eAdvanced, eBudget, eUndefined };
/**
* Constructor to be used to construct an account
* entry object for a forecast.
*
* @param parent pointer to the parent KAccountListView object this entry should be
* added to.
* @param account const reference to MyMoneyAccount for which
* the KListView entry is constructed
* @param forecast const reference to the forecast to
* which the account belongs
* @param price price to be used to calculate value (defaults to 1)
* This is used for accounts denominated in foreign currencies or stocks
* @param security const reference to the security used to show the value. Usually
* one should pass MyMoneyFile::baseCurrency() here.
*/
KMyMoneyAccountTreeForecastItem(KMyMoneyAccountTreeForecastItem *parent, const MyMoneyAccount& account, const MyMoneyForecast& forecast, const QValueList<MyMoneyPrice>& price = QValueList<MyMoneyPrice>(), const MyMoneySecurity& security = MyMoneySecurity(), const EForecastViewType forecastViewType = eUndefined);
/**
* Constructor to be used to construct an account
* entry object for a forecast.
*
* @param parent pointer to the parent KAccountListView object this entry should be
* added to.
* @param account const reference to MyMoneyAccount for which
* the KListView entry is constructed
* @param forecast const reference to the forecast to
* which the account belongs
* @param security const reference to the security used to show the value. Usually
* one should pass MyMoneyFile::baseCurrency() here.
* @param name name of the account to be used instead of the one stored with @p account
* If empty, the one stored with @p account will be used. Default: empty
*/
KMyMoneyAccountTreeForecastItem(KListView *parent, const MyMoneyAccount& account, const MyMoneyForecast &forecast, const MyMoneySecurity& security = MyMoneySecurity(), const QString& name = QString());
~KMyMoneyAccountTreeForecastItem();
/**
* Sets the forecast object
*/
void setForecast(const MyMoneyForecast& forecast);
/**
* updates the item with summary information. Used in Summary tab of Forecast View
*/
void updateSummary(void);
/**
* updates the item with detailed information. Used in Detailed tab of Forecast View
*/
void updateDetailed(void);
/**
* updates the item with budget forecast information. Used in Budget tab of Forecast View
*/
void updateBudget(void);
/**
* sets when to begin a forecast cycle. This is used when showing forecast information per cycle, eg.
* on the summary tab of forecast view.
*/
void setDaysToBeginDay(int _days) {m_daysToBeginDay = _days;}
/**
* sets the type of forecast that the time will show, eg. summary, detailed, budget
*/
void setForecastViewType(EForecastViewType forecastType) { m_forecastType = forecastType; }
/**
* returns the forecast type of the item
*/
EForecastViewType forecastViewType(void) { return m_forecastType; }
/**
* it executes some logic specific to this class before calling the same method on the base class
*/
virtual void setOpen(bool o);
protected:
/**
* Returns the current balance of this account.
*
* This is a pure virtual function, to allow subclasses to calculate
* the balance in different ways.
*
* Parent items in the tree will only be recomputed if the balance() for
* a son changes.
* @param account Account to get the balance for
* @return Balance of this account
*/
MyMoneyMoney balance() const;
void showAmount(int column, const MyMoneyMoney amount, const MyMoneySecurity security);
void adjustParentValue(int column, const MyMoneyMoney& value);
void setValue(int column, MyMoneyMoney amount, QDate forecastDate);
void setAmount(int column, MyMoneyMoney amount);
private:
MyMoneyForecast m_forecast;
int m_daysToBeginDay;
QMap<int, MyMoneyMoney> m_values;
QMap<int, MyMoneyMoney> m_amounts;
EForecastViewType m_forecastType;
};
#endif
|