pivotgrid.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           pivotgrid.h
00003                              -------------------
00004     begin                : Sat May 22 2004
00005     copyright            : (C) 2004-2005 by Ace Jones
00006     email                : <ace.j@hotpop.com>
00007                            Thomas Baumgart <ipwizard@users.sourceforge.net>
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #ifndef PIVOTGRID_H
00020 #define PIVOTGRID_H
00021 
00022 // ----------------------------------------------------------------------------
00023 // QT Includes
00024 
00025 #include <qmap.h>
00026 #include <qvaluelist.h>
00027 
00028 // ----------------------------------------------------------------------------
00029 // KDE Includes
00030 
00031 // ----------------------------------------------------------------------------
00032 // Project Includes
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     // An inverted outergroup means that all values placed in subordinate rows
00122     // should have their sign inverted from typical cash-flow notation.  Also it
00123     // means that when the report is summed, the values should be inverted again
00124     // so that the grand total is really "non-inverted outergroup MINUS inverted outergroup".
00125     bool m_inverted;
00126 
00127     // The localized name of the group for display in the report. Outergoups need this
00128     // independently, because they will lose their association with the TGrid when the
00129     // report is rendered.
00130     QString m_displayName;
00131 
00132     // lower numbers sort toward the top of the report. defaults to 100, which is a nice
00133     // middle-of-the-road value
00134     unsigned m_sortOrder;
00135 
00136     // default sort order
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 // PIVOTGRID_H
00151 // vim:cin:si:ai:et:ts=2:sw=2:

Generated on Wed Jan 26 13:03:18 2011 for KMyMoney by  doxygen 1.5.6