GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
Widget.h
Go to the documentation of this file.
1#line 2 "src/Gui/AccountRegister/Widget.h"
2
3#ifndef __GUI_ACCOUNTREGISTER_WIDGET_H___
4#define __GUI_ACCOUNTREGISTER_WIDGET_H___
5
6#include <Wt/Json/Object.h>
7#include <Wt/WBatchEditProxyModel.h>
8#include <Wt/WContainerWidget.h>
9#include <Wt/WSortFilterProxyModel.h>
10#include <Wt/WStandardItem.h>
11#include <Wt/WStandardItemModel.h>
12#include <Wt/WItemDelegate.h>
13#include <Wt/WPopupMenu.h>
14
15#include "../../GnuCashew.h"
16#include "../TableView.h"
17#include "Model.h"
18#include "StatusBar.h"
19#include "ToolBar.h"
20#include "Editor.h"
21
22namespace GCW {
23 namespace Gui {
24
25 /*!
26 ** \brief Account Register
27 **
28 ** The Account Register
29 **
30 **
31 */
32 namespace AccountRegister {
33
34/*!
35** \brief AccountRegister
36**
37** The AccountRegister is a widget that displays transactions from a single account
38** within the system. It displays the account transactions in a spreadsheet-table-like
39** format with multiple columns representing other field values such as;
40** date, check-number, description... and so on.
41**
42** \image html AccountRegister.png "Account Register" width=480
43**
44** The goal here is to make this widget behave just as closely as possible to the
45** GnuCash interface, because gnucash is very slick and makes navigating the register
46** a no-mouse-necessary affair. One of the problems with web-based interfaces, however,
47** is trapping keys completely, such as the ~tab~ key. So... we'll see how this
48** goes!
49**
50** The register view also grants the user editing abilities. When the user clicks on
51** fields that are ~not~ reconciled, and appropriate 'editor' will open. The editor
52** depends on the column selected, and is generated by the column Delegates.
53*/
54class Widget
56{
57 private:
58
59 public:
60
61 /*!
62 ** \brief Model
63 **
64 ** An alias for the Model in case this interface changes.
65 */
66 using BaseModel = Model ;
69
70 /*!
71 ** \brief Constructor
72 **
73 */
74 Widget();
75
76 /*!
77 ** \brief Set Account
78 **
79 ** This sets the GUD of the account being represented by this
80 ** view
81 */
82 auto setAccountGuid( const std::string & _accountGuid )-> void ;
83
84 auto setDoubleLine( bool _state )-> void ;
85
86 /*!
87 ** \brief Table View
88 */
90
91 auto baseModel ()-> std::shared_ptr< BaseModel > { return m_baseModel; }
92 auto sortFilterModel ()-> std::shared_ptr< SortFilterModel > { return m_sortFilterModel; }
93 auto batchEditModel ()-> std::shared_ptr< BatchEditModel > { return m_batchEditModel; }
94
95 /*!
96 ** \brief Status Bar
97 **
98 ** This returns a pointer to the status bar
99 */
100 auto statusBar()-> StatusBar * { return m_statusBar; }
101
102 auto test()-> void ;
103
104 /*!
105 ** \brief Set Read Only
106 **
107 ** This makes the register view read-only
108 */
109 auto setReadOnly( bool _state = true )-> void ;
110
111 /*!
112 ** \brief Signal JumpToAccount
113 **
114 ** This signals when the user has clicked on the
115 ** jump to account menu option.
116 */
118
119 /*!
120 ** \brief Select Split
121 **
122 */
123 auto selectSplit( const std::string & _guid )-> void ;
124
125 /*!
126 ** \brief Create View Properties JSON Object
127 **
128 ** This will pack all of the Widget display variables in to a JSON
129 ** object for restoration later.
130 **
131 ** \sa fromJson()
132 */
133 auto toJson() const-> Wt::Json::Object ;
134
135 /*!
136 ** \brief Set View Properties from JSON Object
137 **
138 ** This accepts a JSON object containing all of the view properties
139 ** and applys them to the view, essentially restoring it
140 ** to its previous layout.
141 */
142 auto fromJson( const Wt::Json::Object & _jobj )-> bool ;
143
144 private:
145
146 /*!
147 ** \brief Internal Initializer
148 **
149 ** This takes care of all the basic initialization stuff.
150 */
151 auto init()-> void ;
152
153 /*!
154 ** \brief Editor Helper
155 **
156 */
157// auto editor()-> Editor & { return m_editor; }
158
159 /*!
160 ** \brief Load the Data
161 **
162 ** This loads all of the transactions in to the register.
163 */
164 auto loadData()-> void ;
165
166 /*!
167 ** \brief Select Row
168 **
169 ** This selects the row based on it's row number.
170 */
171 auto do_selectRow( Wt::WModelIndex _index )-> void ;
172
173 /*!
174 ** \brief Edit Row
175 **
176 ** This edits the row based on it's row number.
177 */
178 auto editRow( Wt::WModelIndex _index )-> void ;
179
180
181 /*!
182 ** \brief Delete Row
183 **
184 ** This Deletes a row based on it's row number.
185 */
186 auto deleteRow( int _row )-> void ;
187
188 /*!
189 ** \brief Last Index
190 **
191 ** This returns the last index in the model.
192 */
193 auto lastIndex()-> Wt::WModelIndex ;
194
195 /*!
196 ** \brief Show Popup
197 **
198 ** This responds to a mouse-right-click within the table view.
199 ** When triggered, this will pop-up an environment-sensitive
200 ** menu that the user can choose actions from. The context
201 ** sensitivity is driven by the type of item that is on the
202 ** row that the cursor was on with the click event was
203 ** triggered.
204 */
205 auto on_showPopup_triggered( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void ;
206
207 auto on_sortBy_triggered()-> void ;
208 auto on_filterBy_triggered()-> void ;
211
212 /*!
213 ** \brief Delete a Row
214 **
215 ** This will delete a row from the register
216 */
217 auto on_delete_triggered()-> void ;
218
219 /*!
220 ** \brief Remove Splits
221 **
222 ** This will remove the splits from the transaction
223 */
225
226 /*!
227 ** \brief Enter Transaction
228 **
229 ** This will enter the transaction, just like if the user
230 ** hit the ENTER key
231 */
232 auto on_enter_triggered()-> void ;
233
234 /*!
235 ** \brief Cancel Transaction
236 **
237 ** This will cancel the edits on the transaction. This
238 ** would be the same if the user hit the <esc> key
239 */
240 auto on_cancel_triggered()-> void ;
241
242 /*!
243 ** \brief Manage Document
244 **
245 ** This opens a dialog that allows the user to attach
246 ** a document to the transaction
247 */
249
250 /*!
251 ** \brief Open Document
252 **
253 ** This allows the user to open the document attached
254 ** to the transaction
255 */
257
258 /*!
259 ** \brief Blank Transaction
260 **
261 ** This will blank all the values in a transaction
262 */
264
265 /*!
266 ** \brief Go to Date
267 **
268 ** This will jump to a specific date within the register view
269 */
270 auto on_goDate_triggered()-> void ;
271
272 /*!
273 ** \brief Split Transaction
274 **
275 ** This will split the current transaction
276 */
278
279 /*!
280 ** \brief Edit Exchange Rate
281 **
282 ** This will edit the exchange rate on the transaction
283 */
285
286 /*!
287 ** \brief Schedule a Transaction
288 **
289 ** This will set up a scheduled transaction
290 */
291 auto on_schedule_triggered()-> void ;
292
293 /*!
294 ** \brief Jump to Transaction
295 **
296 ** This will jump to the other side of the transaction
297 */
298 auto on_jump_triggered()-> void ;
299
300 /*!
301 ** \brief Edit to Transaction
302 **
303 ** This will Edit to the other side of the transaction
304 */
305 auto on_edit_triggered()-> void ;
306
307 /*!
308 ** \brief Assign Payment
309 **
310 ** This allows the transaction to be assigned
311 ** as a payment to an invoice
312 */
314
315 /*!
316 ** \brief Clicked Handler
317 **
318 ** This captures clicks within the table view
319 */
320 auto on_tableView_clicked( Wt::WModelIndex _index, Wt::WMouseEvent _event )-> void ;
321
322// Editor m_editor ;
323 Wt::WPopupMenu m_popupMenu ;
326 std::shared_ptr< Wt::WSortFilterProxyModel > m_sortFilterModel ;
327 std::shared_ptr< Wt::WBatchEditProxyModel > m_batchEditModel ;
328 GCW::Gui::TableView * m_tableView = nullptr ;
329 StatusBar * m_statusBar = nullptr ;
330 ToolBar * m_toolBar = nullptr ;
331 Wt::WModelIndex m_selectIndex ;
332 Wt::WModelIndex m_clickedIndex ;
333 Wt::WModelIndex m_rightClickIndex ;
334 Wt::Signal< std::string > m_jumpToAccount ;
335
336}; // endclass AccountRegister
337
338 } // endnamespace AccountRegister {
339 } // endnamespace Gui {
340} // endnamespace GCW {
341
342#endif // end __GUI_ACCOUNTREGISTER_H___
343
344
Account Register Model.
Definition Model.h:30
auto selectSplit(const std::string &_guid) -> void
Select Split.
Definition Widget.cpp:710
auto on_showPopup_triggered(const Wt::WModelIndex &_index, const Wt::WMouseEvent &_event) -> void
Show Popup.
Definition Widget.cpp:451
auto fromJson(const Wt::Json::Object &_jobj) -> bool
Set View Properties from JSON Object.
Definition Widget.cpp:755
Wt::WModelIndex m_rightClickIndex
Definition Widget.h:333
auto batchEditModel() -> std::shared_ptr< BatchEditModel >
Definition Widget.h:93
auto on_cancel_triggered() -> void
Cancel Transaction.
Definition Widget.cpp:346
auto lastIndex() -> Wt::WModelIndex
Last Index.
Definition Widget.cpp:608
std::shared_ptr< BaseModel > m_baseModel
Definition Widget.h:325
auto on_removeSplits_triggered() -> void
Remove Splits.
Definition Widget.cpp:330
auto on_editExchangeRate_triggered() -> void
Edit Exchange Rate.
Definition Widget.cpp:395
auto on_renamePage_triggered() -> void
Definition Widget.cpp:224
auto setReadOnly(bool _state=true) -> void
Set Read Only.
Definition Widget.cpp:184
auto baseModel() -> std::shared_ptr< BaseModel >
Definition Widget.h:91
auto on_splitTransaction_triggered() -> void
Split Transaction.
Definition Widget.cpp:387
auto on_filterBy_triggered() -> void
Definition Widget.cpp:216
auto deleteRow(int _row) -> void
Delete Row.
Definition Widget.cpp:192
auto tableView() -> GCW::Gui::TableView *
Table View.
Definition Widget.h:89
std::shared_ptr< Wt::WBatchEditProxyModel > m_batchEditModel
Definition Widget.h:327
auto on_assignPayment_triggered() -> void
Assign Payment.
Definition Widget.cpp:443
GCW::Gui::TableView * m_tableView
Definition Widget.h:328
auto do_selectRow(Wt::WModelIndex _index) -> void
Select Row.
Definition Widget.cpp:678
auto sortFilterModel() -> std::shared_ptr< SortFilterModel >
Definition Widget.h:92
std::shared_ptr< Wt::WSortFilterProxyModel > m_sortFilterModel
Definition Widget.h:326
auto on_jump_triggered() -> void
Jump to Transaction.
Definition Widget.cpp:411
auto editRow(Wt::WModelIndex _index) -> void
Edit Row.
Definition Widget.cpp:727
auto setAccountGuid(const std::string &_accountGuid) -> void
Set Account.
Definition Widget.cpp:573
auto on_duplicate_triggered() -> void
Definition Widget.cpp:232
auto on_delete_triggered() -> void
Delete a Row.
Definition Widget.cpp:240
auto on_schedule_triggered() -> void
Schedule a Transaction.
Definition Widget.cpp:403
auto init() -> void
Internal Initializer.
Definition Widget.cpp:26
auto loadData() -> void
Editor Helper.
Definition Widget.cpp:616
auto on_blankTransaction_triggered() -> void
Blank Transaction.
Definition Widget.cpp:371
auto jumpToAccount() -> Wt::Signal< std::string > &
Signal JumpToAccount.
Definition Widget.h:117
Wt::WModelIndex m_clickedIndex
Definition Widget.h:332
auto on_manageDocument_triggered() -> void
Manage Document.
Definition Widget.cpp:354
auto setDoubleLine(bool _state) -> void
Definition Widget.cpp:592
auto on_openDocument_triggered() -> void
Open Document.
Definition Widget.cpp:363
auto on_goDate_triggered() -> void
Go to Date.
Definition Widget.cpp:379
auto on_enter_triggered() -> void
Enter Transaction.
Definition Widget.cpp:338
Wt::WModelIndex m_selectIndex
Definition Widget.h:331
auto on_edit_triggered() -> void
Edit to Transaction.
Definition Widget.cpp:435
Wt::Signal< std::string > m_jumpToAccount
Definition Widget.h:334
auto toJson() const -> Wt::Json::Object
Create View Properties JSON Object.
Definition Widget.cpp:746
auto on_tableView_clicked(Wt::WModelIndex _index, Wt::WMouseEvent _event) -> void
Clicked Handler.
Definition Widget.cpp:162
auto statusBar() -> StatusBar *
Status Bar.
Definition Widget.h:100
Custom Table View Class.
Definition TableView.h:25
Widget * addNew(Args &&...args)
Definition App.h:18