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 m_summaryDetail = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WCheckBox >( TR("gcw.billPay.lbl.summaryDetail" ) ) );
87 m_summaryDetail-> setValueText( configItem()-> getVarString( "showSummaryDetail" ) );
89 clicked().connect( [&]( Wt::WMouseEvent _event )
90 {
91 auto item = configItem();
92 Wt::Dbo::Transaction t( GCW::app()-> gnucashew_session() );
93 item.modify()-> setVar( "showSummaryDetail", m_summaryDetail-> valueText() );
94 item.flush();
95
96 });
97
98
99#ifdef BILL_PAY_IMPORT_EXPORT
100 /*
101 ** import export buttons
102 */
103 {
104 auto pbImport = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WPushButton >( "import" ) );
105 auto pbExport = table-> elementAt( 0, col++ )-> addWidget( std::make_unique< Wt::WPushButton >( "export" ) );
106
107 pbImport-> setStyleClass( "btn-xs" );
108 pbExport-> setStyleClass( "btn-xs" );
109
110 pbImport-> clicked().connect( [=]{ m_importClicked.emit(); } );
111 pbExport-> clicked().connect( [=]{ m_exportClicked.emit(); } );
112
113 }
114#endif
115
116} // endToolBar()
117
118auto
120showInactive() const-> bool
121{
122 /*
123 ** default false
124 */
125 bool retVal = false;
126
127 if( inactiveButton() )
128 retVal = inactiveButton()-> checkState() == Wt::CheckState::Checked? true:false;
129
130 return retVal;
131
132} // endshowInactive() const-> bool
133
134auto
136showSummary() const-> bool
137{
138 /*
139 ** default false
140 */
141 bool retVal = false;
142
143 if( summaryButton() )
144 retVal = summaryButton()-> checkState() == Wt::CheckState::Checked? true:false;
145
146 return retVal;
147
148} // endshowSummary() const-> bool
149
150auto
152showSummaryDetail() const-> bool
153{
154 /*
155 ** default false
156 */
157 bool retVal = false;
158
159 if( summaryDetailButton() )
160 retVal = summaryDetailButton()-> checkState() == Wt::CheckState::Checked? true:false;
161
162 return retVal;
163
164} // endshowSummary() const-> bool
165
166auto
168selectedYear() const-> int
169{
170 /*!
171 ** default 0
172 */
173 int retVal = 0;
174
175 if( yearSelector() )
176 retVal = GCW::Core::stoi( yearSelector()-> valueText().toUTF8() );
177
178 return retVal;
179
180} // endselectedYear() const-> int
181
182auto
184finderText() const-> std::string
185{
186 /*
187 ** default empty
188 */
189 std::string retVal;
190
191 if( finderInput() )
192 retVal = finderInput()-> valueText().toUTF8();
193
194 return retVal;
195
196} // endfinderText() const-> std::string
197
198
auto showInactive() const -> bool
auto showSummary() const -> bool
auto showSummaryDetail() 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:579
auto configItem() -> GCW::Dbo::Vars::Item::Ptr
Config Item.
Definition BillPay.cpp:7
App * app()
Definition App.cpp:75