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 ** Always use a layout
19 */
20 auto lw = setLayout( std::make_unique< Wt::WHBoxLayout >() );
21 auto table = lw-> addWidget( std::make_unique< Wt::WTable >() );
22 table-> setAttributeValue( "style", "border-spacing:10px;border-collapse:separate;" );
23 lw-> addWidget( std::make_unique< Wt::WContainerWidget >(), 1 );
24
25 int col = 0;
26
27 /*
28 ** operating year selector
29 */
30 m_year = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< YearSelector >() );
31
32 /*
33 ** finder input
34 */
35 m_finder = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WLineEdit >() );
36 m_finder-> setPlaceholderText( TR("gcw.billPay.pht.finder") );
37
38 /*
39 ** click to add
40 */
41 m_refresh = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WPushButton >( TR("gcw.billPay.lbl.refresh") ) );
42 m_refresh-> setStyleClass( "btn-xs" );
43
44 /*
45 ** click to add
46 */
47 m_add = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WPushButton >( TR("gcw.billPay.lbl.add") ) );
48 m_add-> setStyleClass( "btn-xs" );
49
50 /*
51 ** click to edit
52 */
53 m_edit = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WPushButton >( TR("gcw.billPay.lbl.edit") ) );
54 m_edit-> setStyleClass( "btn-xs" );
55
56 /*
57 ** hide and show disabled items
58 */
59 m_inactive = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WCheckBox >( TR("gcw.billPay.lbl.inactive") ) );
60 m_inactive-> setValueText( configItem()-> getVarString( "showInactive" ) );
62 clicked().connect( [&]( Wt::WMouseEvent _event )
63 {
64 auto item = configItem();
65 Wt::Dbo::Transaction t( GCW::app()-> gnucashew_session() );
66 item.modify()-> setVar( "showInactive", m_inactive-> valueText() );
67 item.flush();
68
69 });
70
71 /*
72 ** hide and show the summary view
73 */
74 m_summary = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WCheckBox >( TR("gcw.billPay.lbl.summary") ) );
75 m_summary-> setValueText( configItem()-> getVarString( "showSummary" ) );
76 m_summary->
77 clicked().connect( [&]( Wt::WMouseEvent _event )
78 {
79 auto item = configItem();
80 Wt::Dbo::Transaction t( GCW::app()-> gnucashew_session() );
81 item.modify()-> setVar( "showSummary", m_summary-> valueText() );
82 item.flush();
83
84 });
85
86#ifdef BILL_PAY_IMPORT_EXPORT
87 /*
88 ** import export buttons
89 */
90 {
91 auto pbImport = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WPushButton >( "import" ) );
92 auto pbExport = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WPushButton >( "export" ) );
93
94 pbImport-> setStyleClass( "btn-xs" );
95 pbExport-> setStyleClass( "btn-xs" );
96
97 pbImport-> clicked().connect( [=]{ m_importClicked.emit(); } );
98 pbExport-> clicked().connect( [=]{ m_exportClicked.emit(); } );
99
100 }
101#endif
102
103} // endToolBar()
104
105auto
107showInactive() const-> bool
108{
109 /*
110 ** default false
111 */
112 bool retVal = false;
113
114 if( inactiveButton() )
115 retVal = inactiveButton()-> checkState() == Wt::CheckState::Checked? true:false;
116
117 return retVal;
118
119} // endshowInactive() const-> bool
120
121auto
123showSummary() const-> bool
124{
125 /*
126 ** default false
127 */
128 bool retVal = false;
129
130 if( summaryButton() )
131 retVal = summaryButton()-> checkState() == Wt::CheckState::Checked? true:false;
132
133 return retVal;
134
135} // endshowSummary() const-> bool
136
137auto
139selectedYear() const-> int
140{
141 /*!
142 ** default 0
143 */
144 int retVal = 0;
145
146 if( yearSelector() )
147 retVal = GCW::Core::stoi( yearSelector()-> valueText().toUTF8() );
148
149 return retVal;
150
151} // endselectedYear() const-> int
152
153auto
155finderText() const-> std::string
156{
157 /*
158 ** default empty
159 */
160 std::string retVal;
161
162 if( finderInput() )
163 retVal = finderInput()-> valueText().toUTF8();
164
165 return retVal;
166
167} // endfinderText() const-> std::string
168
169
auto showInactive() const -> bool
auto showSummary() const -> bool
auto finderText() const -> std::string
auto selectedYear() const -> int
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