summaryrefslogtreecommitdiffstats
path: root/kmymoney2/views/kforecastview.h
blob: fec693d822a41524bc1f659a6331734f867eb76e (plain)
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
/***************************************************************************
                             kforecastview.h
                             -------------------
    copyright            : (C) 2007 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 KFORECASTVIEW_H
#define KFORECASTVIEW_H

// ----------------------------------------------------------------------------
// TQt Includes

// ----------------------------------------------------------------------------
// TDE Includes


// ----------------------------------------------------------------------------
// Project Includes

#include <kmymoney/mymoneyaccount.h>
#include <kmymoney/mymoneyutils.h>

#include "../views/kforecastviewdecl.h"
#include "../widgets/kmymoneyaccounttreeforecast.h"
#include "../reports/kreportchartview.h"

using namespace reports;

/**
  * @author Alvaro Soliverez
  */

/**
  * This class implements the forecast 'view'.
  */
class KForecastView : public KForecastViewDecl
{
  TQ_OBJECT
  
private:

public:
  KForecastView(TQWidget *parent=0, const char *name=0);
  virtual ~KForecastView();

  void show(void);

public slots:
  void slotLoadForecast(void);
  void slotManualForecast(void);

protected:
  typedef enum {
    SummaryView = 0,
    ListView,
    AdvancedView,
    BudgetView,
    ChartView,
    // insert new values above this line
    MaxViewTabs
  } ForecastViewTab;

  TQMap<TQString, TQString> m_nameIdx;


  /**
    * This method loads the forecast view.
    */
  void loadForecast(ForecastViewTab tab);

  /**
    * This method loads the detailed view
    */
  void loadListView(void);

  /**
   * This method loads the summary view
   */
  void loadSummaryView(void);

  /**
   * This method loads the advanced view
   */
  void loadAdvancedView(void);

  /**
   * This method loads the budget view
   */
  void loadBudgetView(void);

  /**
   * This method loads the budget view
   */
  void loadChartView(void);

  /**
   * This method loads the settings from user configuration
   */
  void loadForecastSettings(void);

protected slots:
  void slotTabChanged(TQWidget*);

  /**
   * Get the list of prices for an account
   * This is used later to create an instance of KMyMoneyAccountTreeForecastItem
   *
   */
  TQValueList<MyMoneyPrice> getAccountPrices(const MyMoneyAccount& acc);

private:
  void addAssetLiabilityRows(const MyMoneyForecast& forecast);
  void addIncomeExpenseRows(const MyMoneyForecast& forecast);
  void addTotalRow(KMyMoneyAccountTreeForecast* forecastList, const MyMoneyForecast& forecast);
  bool includeAccount(MyMoneyForecast& forecast, const MyMoneyAccount& acc);
  void loadAccounts(MyMoneyForecast& forecast, const MyMoneyAccount& account, KMyMoneyAccountTreeForecastItem* parentItem, int forecastType);

  bool                                m_needReload[MaxViewTabs];
  KMyMoneyAccountTreeForecastItem*    m_totalItem;
  KMyMoneyAccountTreeForecastItem*    m_assetItem;
  KMyMoneyAccountTreeForecastItem*    m_liabilityItem;
  KMyMoneyAccountTreeForecastItem*    m_incomeItem;
  KMyMoneyAccountTreeForecastItem*    m_expenseItem;

  KReportChartView* m_forecastChart;

};

#endif