GnuCashew ~ GnuCash Enabled Web
GCW
Table.cpp
Go to the documentation of this file.
1 #line 2 "src/Gui/BillPay/Table.cpp"
2 
3 #include <Wt/WModelIndex.h>
4 #include <Wt/WStandardItem.h>
5 
6 #include "../../Dbo/Accounts/Accounts.h"
7 #include "BillPay.h"
8 
10 Table( 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  */
17  addStyleClass( asStyleClass( _status ) );
18 
19  /*
20  ** Set up some controls
21  **
22  */
23  setSortingEnabled ( false );
24  setSelectionBehavior ( Wt::SelectionBehavior::Rows );
25  setSelectionMode ( Wt::SelectionMode::Single );
26  setColumnResizeEnabled ( false );
27  setAlternatingRowColors ( true );
28 
29  /*
30  ** Make a data model
31  **
32  */
33  m_model = std::make_shared< Model >( _selectedMonth, _status );
34 
35  /*
36  ** Set the model in to the table
37  **
38  */
39  setModel( m_model );
40 
41  /*
42  ** Apply the column widths and alignments
43  **
44  */
45  for( int col=0; col< m_model-> columnCount(); col++ )
46  {
47  setColumnWidth ( col, m_model-> columnDef(col).width );
48  setColumnAlignment( col, m_model-> columnDef(col).alignment );
49  }
50 
51 } // endTable()
52 
53 
54 void
56 setMonth( int _month )
57 {
58  int selected_row = -1;
59 
60  if( selectedIndexes().size() > 0 )
61  {
62  selected_row = selectedIndexes().begin()-> row();
63  }
64 
65  m_model-> loadData( _month );
66 
67  if( selected_row > -1 )
68  {
69  select( m_model-> index( selected_row, 0 ) );
70  }
71 
72 } // endsetMonth( int _month )
73 
74 
std::shared_ptr< Model > m_model
Definition: Table.h:37
Table(int _selectedMonth, const Status _status)
Definition: Table.cpp:10
void setMonth(int _month)
Definition: Table.cpp:56
Status
Bill Status.
Definition: Status.h:21
std::string asStyleClass(Status _status)
Get Status as Style Class.
Definition: Status.cpp:21