GnuCashew ~ GnuCash Enabled Web
GCW
Model.h
Go to the documentation of this file.
1 #line 2 "src/Gui/BillPay/Model.h"
2 
3 #ifndef __GUI_BILLPAY_MODEL_H___
4 #define __GUI_BILLPAY_MODEL_H___
5 
6 #include <Wt/WLength.h>
7 #include <Wt/WStandardItemModel.h>
8 
9 #include "Item.h"
10 #include "Status.h"
11 
12 namespace GCW {
13  namespace Gui {
14  namespace BillPay {
15 
16 /*!
17 ** \Brief Model Column Definitions
18 **
19 ** This holds the column definitions for the Model and Table. It
20 ** includes the field name, field width (for the table), alignment
21 ** (also for the table), and toolTip (which is applied to the model
22 ** but gets displayed in the table).
23 **
24 */
25 typedef struct COLUMNDEF
26 {
27  /// field name
28  const char * name;
29 
30  /// column width for the table view
31  Wt::WLength width;
32 
33  /// alignment flag for the table view
34  Wt::AlignmentFlag alignment;
35 
36  /// tool tip for the table view
37  const char * toolTip;
38 
40 
41 /*!
42 ** \brief Data Model
43 **
44 ** Contains paid, unpaid and disabled accounts.
45 **
46 ** When constructing the Model, the parameters control the subset
47 ** of items that will appear in the model. Therefore, the final
48 ** model contains only 'paid', 'unpaid' or 'disabled' items for
49 ** the month selected.
50 **
51 */
52 class Model
53 : public Wt::WStandardItemModel
54 {
55  public:
56 
57  /*!
58  ** \brief ctor
59  **
60  ** During construction, the model examines all the billpay-items
61  ** to detemine if the item meets the parameter criteria. This
62  ** allows a TableView to be constructed to present the items
63  ** that meet this criteria as a grouped set of items.
64  **
65  ** To return all the items in the month of February that are
66  ** 'paid', the constructor would appear as follows;
67  **
68  ** \code
69  ** auto model = std::make_shared< Model >( 2, BillPay::Status::Paid );
70  ** \endcode
71  **
72  */
73  Model
74  (
75  /// Select a 'calendar month' to compare status
76  int _selectedMonth,
77 
78  /// Select a BillPay::Status to evaluate to
79  Status _status
80  );
81 
82  /*!
83  ** \brief Column Definition
84  **
85  ** Return the column definition for the selected column.
86  **
87  */
88  auto columnDef( int _col )-> ColumnDef_t ;
89 
90  /*!
91  ** \brief Reload the data based on the selected month.
92  **
93  ** This will drop all the data in the model and reload it with
94  ** the month selected.
95  **
96  */
97  auto loadData( int _selectedMonth )-> void ;
98 
99  private:
100 
101  /*!
102  ** \brief Sorter
103  **
104  ** This sorter produces a sorted list of bills-to-pay sorted
105  ** by first 'group' then 'dueDay'. This produces a number
106  ** that might be like 20.22, meaning group=20, day=22. The
107  ** result in the view is all the "due next" items at the top
108  ** of the list, and so on. The group-value is to just help
109  ** clean the display. The result makes it very clear what bills
110  ** are due next in line.
111  **
112  */
113  auto sort( std::vector< GCW::Gui::BillPay::Item > & _bpItems )-> void ;
114 
115  /*!
116  ** \brief Model Status
117  **
118  ** Each model represents items of a partcular status. The model set
119  ** contains, therefore, only items that match the selected status
120  ** and the selected month.
121  **
122  */
124 
125 }; // endclass Model
126 
127  } // endnamespace BillPay {
128  } // endnamespace Gui {
129 } // endnamespace GCW {
130 
131 #endif // __GUI_BILLPAY_MODEL_H___
132 
133 
Data Model.
Definition: Model.h:54
Status m_status
Model Status.
Definition: Model.h:123
auto sort(std::vector< GCW::Gui::BillPay::Item > &_bpItems) -> void
Sorter.
Definition: Model.cpp:282
auto loadData(int _selectedMonth) -> void
Reload the data based on the selected month.
Definition: Model.cpp:78
Model(int _selectedMonth, Status _status)
ctor
Definition: Model.cpp:44
auto columnDef(int _col) -> ColumnDef_t
Column Definition.
Definition: Model.cpp:275
Status
Bill Status.
Definition: Status.h:21
struct GCW::Gui::BillPay::COLUMNDEF ColumnDef_t
Definition: App.h:17
Wt::AlignmentFlag alignment
alignment flag for the table view
Definition: Model.h:34
const char * name
field name
Definition: Model.h:28
Wt::WLength width
column width for the table view
Definition: Model.h:31
const char * toolTip
tool tip for the table view
Definition: Model.h:37