pivotgrid.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PIVOTGRID_H
00020 #define PIVOTGRID_H
00021
00022
00023
00024
00025 #include <qmap.h>
00026 #include <qvaluelist.h>
00027
00028
00029
00030
00031
00032
00033
00034 #include "reportaccount.h"
00035
00036 namespace reports {
00037
00038 enum ERowType {eActual, eBudget, eBudgetDiff, eForecast, eAverage, ePrice };
00039
00064 class PivotCell: public MyMoneyMoney
00065 {
00066 public:
00067 PivotCell() : m_stockSplit(MyMoneyMoney(1,1)), m_cellUsed(false) {}
00068 PivotCell(const MyMoneyMoney& value);
00069 static PivotCell stockSplit(const MyMoneyMoney& factor);
00070 PivotCell operator += (const PivotCell& right);
00071 PivotCell operator += (const MyMoneyMoney& value);
00072 const QString formatMoney(int fraction, bool showThousandSeparator = true) const;
00073 const QString formatMoney(const QString& currency, const int prec, bool showThousandSeparator = true) const;
00074 MyMoneyMoney calculateRunningSum(const MyMoneyMoney& runningSum);
00075 MyMoneyMoney cellBalance(const MyMoneyMoney& _balance);
00076 bool isUsed(void) const { return m_cellUsed; }
00077 private:
00078 MyMoneyMoney m_stockSplit;
00079 MyMoneyMoney m_postSplit;
00080 bool m_cellUsed;
00081 };
00082 class PivotGridRow: public QValueList<PivotCell>
00083 {
00084 public:
00085
00086 PivotGridRow( unsigned _numcolumns = 0 )
00087 {
00088 if ( _numcolumns )
00089 insert( end(), _numcolumns, PivotCell() );
00090 }
00091 MyMoneyMoney m_total;
00092 };
00093
00094 class PivotGridRowSet: public QMap<ERowType, PivotGridRow>
00095 {
00096 public:
00097 PivotGridRowSet( unsigned _numcolumns = 0 );
00098 };
00099
00100 class PivotInnerGroup: public QMap<ReportAccount,PivotGridRowSet>
00101 {
00102 public:
00103 PivotInnerGroup( unsigned _numcolumns = 0 ): m_total(_numcolumns) {}
00104
00105 PivotGridRowSet m_total;
00106 };
00107
00108 class PivotOuterGroup: public QMap<QString,PivotInnerGroup>
00109 {
00110 public:
00111 PivotOuterGroup( unsigned _numcolumns = 0, unsigned _sort=m_kDefaultSortOrder, bool _inverted=false): m_total(_numcolumns), m_inverted(_inverted), m_sortOrder(_sort) {}
00112 int operator<( const PivotOuterGroup& _right )
00113 {
00114 if ( m_sortOrder != _right.m_sortOrder )
00115 return m_sortOrder < _right.m_sortOrder;
00116 else
00117 return m_displayName < _right.m_displayName;
00118 }
00119 PivotGridRowSet m_total;
00120
00121
00122
00123
00124
00125 bool m_inverted;
00126
00127
00128
00129
00130 QString m_displayName;
00131
00132
00133
00134 unsigned m_sortOrder;
00135
00136
00137 static const unsigned m_kDefaultSortOrder;
00138 };
00139 class PivotGrid: public QMap<QString,PivotOuterGroup>
00140 {
00141 public:
00142 PivotGridRowSet rowSet (QString id);
00143
00144 PivotGridRowSet m_total;
00145 };
00146
00147 }
00148
00149 #endif
00150
00151