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