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, 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, _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
51setMonth( int _month )
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 );
61
62 if( selected_row > -1 )
63 {
64 select( m_model-> index( selected_row, 0 ) );
65 }
66
67} // endsetMonth( int _month )
68
69
70auto
72rowCount()-> int
73{
74 return m_model-> rowCount();
75
76} // endrowCount()-> int
77
78/*
79** BUGBUG: this is really crappy
80**
81** This function is here to capture the SummaryReport
82** clicked() txItem-> description() value. This value
83** is a simple text-value from the description of the
84** transaction as it was entered in the bill pay
85** sub system. Basically, there is no 'hard' connection
86** between the bill pay event and the transaction item
87** that gets entered. This needs to be fixed, as keying
88** these two widgets together like this is sloppy.
89**
90*/
91#define SEPARATOR " ("
92auto
94selectItem( const std::string _itemIdent )-> void
95{
96 clearSelection();
97
98 /*
99 ** strip off anything with the () SEPARATOR parenthesis
100 ** (ugly but functional)
101 */
102 auto id = _itemIdent;
103 if( id.find(SEPARATOR) != std::string::npos )
104 id = id.substr( 0, id.find(SEPARATOR) );
105
106 for( int row = 0; row< m_model-> rowCount(); row++ )
107 {
108 if( m_model-> item( row, 2 )-> text() == id )
109 {
110 select( m_model-> index( row, 2 ) );
111 }
112 }
113
114} // endselectItem( const std::string _itemIdent )-> void
115
#define SEPARATOR
std::shared_ptr< TableModel > m_model
auto selectItem(const std::string _itemIdent) -> void
TableView(int _selectedMonth, const Status _status)
auto setMonth(int _month) -> void
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