GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
BillPay/ToolBar.cpp
Go to the documentation of this file.
1#line 2 "src/Gui/BillPay/ToolBar.cpp"
2
3#include <Wt/WHBoxLayout.h>
4#include <Wt/WTable.h>
5#include <Wt/WContainerWidget.h>
6#include <Wt/WPushButton.h>
7#include <Wt/WComboBox.h>
8
9#include "../../Glb/Core.h"
10#include "BillPay.h"
11
13ToolBar()
14{
15 addStyleClass( "ToolBar" );
16
17
18 /*
19 ** Always use a layout
20 */
21 auto lw = setLayout( std::make_unique< Wt::WHBoxLayout >() );
22 auto table = lw-> addWidget( std::make_unique< Wt::WTable >() );
23 table-> setAttributeValue( "style", "border-spacing:10px;border-collapse:separate;" );
24 lw-> addWidget( std::make_unique< Wt::WContainerWidget >(), 1 );
25
26 /*
27 ** select operating year
28 */
29 int col = 0;
30 m_year = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< YearSelector >() );
31
32 /*
33 ** click to add
34 */
35 auto pbAdd = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WPushButton >( TR("gcw.billPay.lbl.add") ) );
36 pbAdd-> setStyleClass( "btn-xs" );
37 pbAdd-> clicked().connect( [=](){ m_addClicked.emit(); } );
38
39 /*
40 ** click to edit
41 */
42 auto pbEdit = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WPushButton >( TR("gcw.billPay.lbl.edit") ) );
43 pbEdit-> setStyleClass( "btn-xs" );
44 pbEdit-> clicked().connect( [=](){ m_editClicked.emit(); } );
45
46 /*
47 ** hide and show disabled items
48 */
49 m_inactive = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WCheckBox >( TR("gcw.billPay.lbl.inactive") ) );
50 m_inactive-> setValueText( configItem()-> getVarString( "showInactive" ) );
52 clicked().connect( [&]( Wt::WMouseEvent _event )
53 {
54 auto item = configItem();
55 Wt::Dbo::Transaction t( GCW::app()-> gnucashew_session() );
56 item.modify()-> setVar( "showInactive", m_inactive-> valueText() );
57 item.flush();
58
59 });
60
61 /*
62 ** hide and show the summary view
63 */
64 m_summary = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WCheckBox >( TR("gcw.billPay.lbl.summary") ) );
65 m_summary-> setValueText( configItem()-> getVarString( "showSummary" ) );
66 m_summary->
67 clicked().connect( [&]( Wt::WMouseEvent _event )
68 {
69 auto item = configItem();
70 Wt::Dbo::Transaction t( GCW::app()-> gnucashew_session() );
71 item.modify()-> setVar( "showSummary", m_summary-> valueText() );
72 item.flush();
73
74 });
75
76#ifdef NEVER
77 /*
78 ** import export buttons
79 */
80 {
81 auto pbImport = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WPushButton >( "import" ) );
82 auto pbExport = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WPushButton >( "export" ) );
83
84 pbImport-> setStyleClass( "btn-xs" );
85 pbExport-> setStyleClass( "btn-xs" );
86
87 pbImport-> clicked().connect( [=]{ m_importClicked.emit(); } );
88 pbExport-> clicked().connect( [=]{ m_exportClicked.emit(); } );
89
90 }
91#endif
92
93} // endToolBar()
94
95bool
97showInactive() const
98{
99 return inactiveButton()-> checkState() == Wt::CheckState::Checked? true:false;
100}
101
102bool
104showSummary() const
105{
106 return summaryButton()-> checkState() == Wt::CheckState::Checked? true:false;
107}
108
109auto
111selectedYear() const-> int
112{
113 return
114 GCW::Core::stoi( yearSelector()-> valueText().toUTF8() );
115
116} // endselectedYear() const-> int
117
118
auto showSummary() const -> bool
auto selectedYear() const -> int
auto showInactive() const -> bool
void emit(A... args) const
Widget * addNew(Args &&...args)
void setLayout(std::unique_ptr< WLayout > layout)
virtual void addWidget(std::unique_ptr< WWidget > widget)
EventSignal< WMouseEvent > & clicked()
virtual void setAttributeValue(const std::string &name, const WString &value) override
virtual void setStyleClass(const WString &styleClass) override
virtual void addStyleClass(const WString &styleClass, bool force=false) override
#define TR(X)
Definition define.h:17
int stoi(const std::string &value)
Convert a String to an Integer.
Definition Core.cpp:569
auto configItem() -> GCW::Dbo::Vars::Item::Ptr
Config Item.
Definition BillPay.cpp:7
App * app()
Definition App.cpp:75