GnuCashew ~ GnuCash Enabled Web
GCW
Loading...
Searching...
No Matches
SlotsWidget.cpp
Go to the documentation of this file.
1#line 2 "src/Gui/SlotsWidget.cpp"
2
3#include <Wt/WDateEdit.h>
4#include <Wt/WItemDelegate.h>
5#include <Wt/WSuggestionPopup.h>
6#include <Wt/WText.h>
7#include <Wt/WTableView.h>
8#include <Wt/WTheme.h>
9#include <Wt/WVBoxLayout.h>
10#include <Wt/WHBoxLayout.h>
11
12#include "../define.h"
13#include "../App.h"
14#include "SlotsWidget.h"
15
16
19{
20 /*
21 ** Look in gcw.css for styling.
22 **
23 */
24 addStyleClass( "SlotsWidget" );
25
26 /*
27 ** use a layout manager to install the table view into, so
28 ** that the widget will fit and scroll properly.
29 **
30 */
31 auto lw = setLayout( std::make_unique< Wt::WVBoxLayout >() );
32 auto w = std::make_unique< GCW::Gui::TableView >();
33 m_tableView = w.get();
34 lw-> addWidget( std::move( w ), 1 );
35// tableView()-> setRowHeight( "20px" );
36
37 /*
38 ** Configure the table view.
39 **
40 */
41 tableView()-> setSortingEnabled ( true );
42 tableView()-> setAlternatingRowColors ( true );
43 tableView()-> setSelectionBehavior ( Wt::SelectionBehavior::Rows );
44 tableView()-> setSelectionMode ( Wt::SelectionMode::Single );
45// tableView()-> setEditTriggers ( Wt::EditTrigger::SingleClicked );
46// tableView()-> setEditOptions ( Wt::EditOption::SingleEditor | Wt::EditOption::SaveWhenClosed ); // FIXME: this should probably be: MultipleEditor | LeaveEditorsOpen so we can open all editors on a single entry
47
48 loadData();
49
50} // endSlotsWidget()
51
52void
55{
56 Wt::Dbo::Transaction t( GCW::app()-> gnucashew_session() );
57
58 auto query =
59 GCW::app()-> gnucashew_session().find< GCW::Dbo::Slots::Item >()
60 .orderBy( "id" )
61 ;
62
63 m_model = std::make_shared< Model >();
64 m_model-> setQuery( query );
65 m_model-> reload();
66 m_model-> addAllFieldsAsColumns();
67
68 tableView()-> setModel( m_model );
69
70#ifdef NEVER
71 // 0 = Date
72 tableView()-> setColumnWidth ( 0, "150px" );
73 tableView()-> setHeaderAlignment( 0, Wt::AlignmentFlag::Right );
74 tableView()-> setColumnAlignment( 0, Wt::AlignmentFlag::Right );
75
76 // 1 = Action/Num
77 tableView()-> setColumnWidth ( 1, "50px" );
78 tableView()-> setHeaderAlignment( 1, Wt::AlignmentFlag::Center );
79 tableView()-> setColumnAlignment( 1, Wt::AlignmentFlag::Center );
80
81 // 2 = Memo/Description
82 tableView()-> setColumnWidth ( 2, "99%" );
83 tableView()-> setHeaderAlignment( 2, Wt::AlignmentFlag::Left );
84 tableView()-> setColumnAlignment( 2, Wt::AlignmentFlag::Left );
85
86 // 3 = Account/Transfer
87 tableView()-> setColumnWidth ( 3, "200px" );
88 tableView()-> setHeaderAlignment( 3, Wt::AlignmentFlag::Right );
89 tableView()-> setColumnAlignment( 3, Wt::AlignmentFlag::Right );
90
91 // 4 = Reconciliation
92 tableView()-> setColumnWidth ( 4, "25px" );
93 tableView()-> setHeaderAlignment( 4, Wt::AlignmentFlag::Center );
94 tableView()-> setColumnAlignment( 4, Wt::AlignmentFlag::Center );
95
96 // 5 = Debit
97 tableView()-> setColumnWidth ( 5, "100px" );
98 tableView()-> setHeaderAlignment( 5, Wt::AlignmentFlag::Right );
99 tableView()-> setColumnAlignment( 5, Wt::AlignmentFlag::Right );
100
101 // 6 = Credit
102 tableView()-> setColumnWidth ( 6, "100px" );
103 tableView()-> setHeaderAlignment( 6, Wt::AlignmentFlag::Right );
104 tableView()-> setColumnAlignment( 6, Wt::AlignmentFlag::Right );
105
106 // 7 = Balance
107 tableView()-> setColumnWidth ( 7, "100px" );
108 tableView()-> setHeaderAlignment( 7, Wt::AlignmentFlag::Right );
109 tableView()-> setColumnAlignment( 7, Wt::AlignmentFlag::Right );
110
111 auto lastIndex = model()-> index( model()-> rowCount() -1, 0 );
112 tableView()-> scrollTo( lastIndex );
113 tableView()-> edit( lastIndex );
114#endif
115
116} // endvoid GCW::Gui::SlotsWidget::loadData()
117
118
119
Variables Item Class.
Definition Item.h:54
GCW::Gui::TableView * tableView()
Table View.
Definition SlotsWidget.h:51
GCW::Gui::TableView * m_tableView
Definition SlotsWidget.h:60
SlotsWidget()
Constructor.
App * app()
Definition App.cpp:68