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** This function is here to capture the SummaryReport
91** clicked() txItem-> description() value. This value
92** is a simple text-value from the description of the
93** transaction as it was entered in the bill pay
94** sub system. Basically, there is no 'hard' connection
95** between the bill pay event and the transaction item
96** that gets entered. This needs to be fixed, as keying
97** these two widgets together like this is sloppy.
98**
99*/
100#define SEPARATOR " ("
101auto
103selectItem( const std::string _itemIdent )-> void
104{
105 clearSelection();
106
107 /*
108 ** strip off anything with the () SEPARATOR parenthesis
109 ** (ugly but functional)
110 */
111 auto id = _itemIdent;
112 if( id.find(SEPARATOR) != std::string::npos )
113 id = id.substr( 0, id.find(SEPARATOR) );
114
115 for( int row = 0; row< m_model-> rowCount(); row++ )
116 {
117 if( m_model-> item( row, 2 )-> text() == id )
118 {
119 select( m_model-> index( row, 2 ) );
120 }
121 }
122
123} // endselectItem( const std::string _itemIdent )-> void
124
#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