GnuCashew ~ Web Application compatible with GnuCash sql data files.
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 m_tableView = lw-> addWidget( std::make_unique< GCW::Gui::TableView >(), 1 );
33// tableView()-> setRowHeight( "20px" );
34
35 /*
36 ** Configure the table view.
37 **
38 */
39 tableView()-> setSortingEnabled ( true );
40 tableView()-> setAlternatingRowColors ( true );
41 tableView()-> setSelectionBehavior ( Wt::SelectionBehavior::Rows );
42 tableView()-> setSelectionMode ( Wt::SelectionMode::Single );
43// tableView()-> setEditTriggers ( Wt::EditTrigger::SingleClicked );
44// 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
45
46 loadData();
47
48} // endSlotsWidget()
49
50void
53{
54 Wt::Dbo::Transaction t( GCW::app()-> gnucashew_session() );
55
56 auto query =
57 GCW::app()-> gnucashew_session().find< GCW::Dbo::Slots::Item >()
58 .orderBy( "id" )
59 ;
60
61 m_model = std::make_shared< Model >();
62 m_model-> setQuery( query );
63 m_model-> reload();
64 m_model-> addAllFieldsAsColumns();
65
66 tableView()-> setModel( m_model );
67
68#ifdef NEVER
69 // 0 = Date
70 tableView()-> setColumnWidth ( 0, "150px" );
71 tableView()-> setHeaderAlignment( 0, Wt::AlignmentFlag::Right );
72 tableView()-> setColumnAlignment( 0, Wt::AlignmentFlag::Right );
73
74 // 1 = Action/Num
75 tableView()-> setColumnWidth ( 1, "50px" );
76 tableView()-> setHeaderAlignment( 1, Wt::AlignmentFlag::Center );
77 tableView()-> setColumnAlignment( 1, Wt::AlignmentFlag::Center );
78
79 // 2 = Memo/Description
80 tableView()-> setColumnWidth ( 2, "99%" );
81 tableView()-> setHeaderAlignment( 2, Wt::AlignmentFlag::Left );
82 tableView()-> setColumnAlignment( 2, Wt::AlignmentFlag::Left );
83
84 // 3 = Account/Transfer
85 tableView()-> setColumnWidth ( 3, "200px" );
86 tableView()-> setHeaderAlignment( 3, Wt::AlignmentFlag::Right );
87 tableView()-> setColumnAlignment( 3, Wt::AlignmentFlag::Right );
88
89 // 4 = Reconciliation
90 tableView()-> setColumnWidth ( 4, "25px" );
91 tableView()-> setHeaderAlignment( 4, Wt::AlignmentFlag::Center );
92 tableView()-> setColumnAlignment( 4, Wt::AlignmentFlag::Center );
93
94 // 5 = Debit
95 tableView()-> setColumnWidth ( 5, "100px" );
96 tableView()-> setHeaderAlignment( 5, Wt::AlignmentFlag::Right );
97 tableView()-> setColumnAlignment( 5, Wt::AlignmentFlag::Right );
98
99 // 6 = Credit
100 tableView()-> setColumnWidth ( 6, "100px" );
101 tableView()-> setHeaderAlignment( 6, Wt::AlignmentFlag::Right );
102 tableView()-> setColumnAlignment( 6, Wt::AlignmentFlag::Right );
103
104 // 7 = Balance
105 tableView()-> setColumnWidth ( 7, "100px" );
106 tableView()-> setHeaderAlignment( 7, Wt::AlignmentFlag::Right );
107 tableView()-> setColumnAlignment( 7, Wt::AlignmentFlag::Right );
108
109 auto lastIndex = model()-> index( model()-> rowCount() -1, 0 );
110 tableView()-> scrollTo( lastIndex );
111 tableView()-> edit( lastIndex );
112#endif
113
114} // endvoid GCW::Gui::SlotsWidget::loadData()
115
116
117
Variables Item Class.
GCW::Gui::TableView * tableView()
Table View.
Definition SlotsWidget.h:51
GCW::Gui::TableView * m_tableView
Definition SlotsWidget.h:60
SlotsWidget()
Constructor.
Widget * addNew(Args &&...args)
void setLayout(std::unique_ptr< WLayout > layout)
virtual void addWidget(std::unique_ptr< WWidget > widget)
virtual void addStyleClass(const WString &styleClass, bool force=false) override
App * app()
Definition App.cpp:75