GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
BillPay/TableView.cpp
Go to the documentation of this file.
1#line 2 "src/Gui/BillPay/TableView.cpp"
2
3#include <Wt/WModelIndex.h>
4#include <Wt/WStandardItem.h>
5
6#include "../../Dbo/Accounts/Accounts.h"
7#include "BillPay.h"
8
10TableView( int _selectedMonth, int _selectedYear, const Status _status )
11{
12 /*
13 ** Add 'Unpaid', 'Paid', 'Disabled' to the style class of this
14 ** table for styling and such as.
15 */
16 addStyleClass( asStyleClass( _status ) );
17
18 /*
19 ** Set up some controls
20 */
21 setSortingEnabled ( false );
22 setSelectionBehavior ( Wt::SelectionBehavior::Rows );
23 setSelectionMode ( Wt::SelectionMode::Single );
24 setColumnResizeEnabled ( false );
26
27 /*
28 ** Make a data model
29 */
30 m_model = std::make_shared< TableModel >( _selectedMonth, _selectedYear, _status );
31
32 /*
33 ** Set the model in to the table
34 */
36
37 /*
38 ** Apply the column widths and alignments
39 */
40 for( int col=0; col< m_model-> columnCount(); col++ )
41 {
42 setColumnWidth ( col, m_model-> columnDef(col).width );
43 setColumnAlignment( col, m_model-> columnDef(col).alignment );
44 }
45
46} // endTableView()
47
48
49void
51setDate( int _month, int _year )
52{
53 int selected_row = -1;
54
55 if( selectedIndexes().size() > 0 )
56 {
57 selected_row = selectedIndexes().begin()-> row();
58 }
59
60 m_model-> loadData( _month, _year );
61
62 if( selected_row > -1 )
63 {
64 select( m_model-> index( selected_row, 0 ) );
65 }
66
67} // endsetMonth( int _month )
68
69
70auto
72setFilter( const std::string & _filter )-> void
73{
74 m_model-> setFilter( _filter );
75
76} // endsetFilter( const std::string & _filter )-> void
77
78
79auto
81rowCount()-> int
82{
83 return m_model-> rowCount();
84
85} // endrowCount()-> int
86
87/*!
88** BUGBUG: this is really crappy
89**
90** \todo fix this
91** This function is here to capture the SummaryReport
92** clicked() txItem-> description() value. This value
93** is a simple text-value from the description of the
94** transaction as it was entered in the bill pay
95** sub system. Basically, there is no 'hard' connection
96** between the bill pay event and the transaction item
97** that gets entered. This needs to be fixed, as keying
98** these two widgets together like this is sloppy.
99**
100*/
101#define SEPARATOR " ("
102auto
104selectItem( const std::string _itemIdent )-> void
105{
106 clearSelection();
107
108 /*
109 ** strip off anything with the () SEPARATOR parenthesis
110 ** (ugly but functional)
111 */
112 auto id = _itemIdent;
113 if( id.find(SEPARATOR) != std::string::npos )
114 id = id.substr( 0, id.find(SEPARATOR) );
115
116 for( int row = 0; row< m_model-> rowCount(); row++ )
117 {
118 if( m_model-> item( row, 2 )-> text() == id )
119 {
120 /*
121 ** this selects the item in the view and also
122 ** emits a 'clicked' signal so any other entity
123 ** interested in this selection can respond
124 ** accordinly.
125 */
126 auto index = m_model-> index( row, 2 );
127 select( index );
128 clicked().emit( index, Wt::WMouseEvent() );
129 return;
130 }
131 }
132
133} // endselectItem( const std::string _itemIdent )-> void
134
#define SEPARATOR
auto setFilter(const std::string &_filter) -> void
std::shared_ptr< TableModel > m_model
auto setDate(int _month, int _year) -> void
auto selectItem(const std::string _itemIdent) -> void
TableView(int _selectedMonth, int _selectedYear, const Status _status)
void setColumnResizeEnabled(bool enabled)
virtual void setColumnAlignment(int column, AlignmentFlag alignment)
void setSelectionBehavior(SelectionBehavior behavior)
void setSortingEnabled(bool enabled)
void setSelectionMode(SelectionMode mode)
virtual WLength width() const override
virtual void addStyleClass(const WString &styleClass, bool force=false) override
virtual void setColumnWidth(int column, const WLength &width) override
virtual void setModel(const std::shared_ptr< WAbstractItemModel > &model) override
virtual void setAlternatingRowColors(bool enable) override
Status
Bill Status.
Definition Status.h:27
auto asStyleClass(Status _status) -> std::string
Get Status as Style Class.
Definition Status.cpp:23