GnuCashew ~ GnuCash Enabled Web
GCW
AccountRegister.h
Go to the documentation of this file.
1 #line 2 "src/Gui/AccountRegister.h"
2 
3 #ifndef __GUI_ACCOUNTREGISTER_H___
4 #define __GUI_ACCOUNTREGISTER_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/WPopupMenu.h>
13 
14 #include "../GnuCashew.h"
15 #include "../Eng/AccountRegisterModel.h"
16 #include "TableView.h"
17 
18 
19 namespace GCW {
20 
21  // FIXME
22  // not sure why I need to forward-declare this class... it's
23  // right up there in the header
24  namespace Eng { class AccountRegisterModel; }
25 
26  namespace Gui {
27 
28 /*!
29 ** \brief AccountRegister
30 **
31 ** The AccountRegister is a widget that displays transactions from a single account
32 ** within the system. It displays the account transactions in a spreadsheet-table-like
33 ** format with multiple columns representing other field values such as;
34 ** date, check-number, description... and so on.
35 **
36 ** \image html AccountRegister.png "Account Register" width=480
37 **
38 ** The goal here is to make this widget behave just as closely as possible to the
39 ** GnuCash interface, because theirs is very slick and makes navigating the register
40 ** a no-mouse-necessary affair. One of the problems with web-based interfaces, however,
41 ** is trapping keys completely, such as the ~tab~ key. So... we'll see how this
42 ** goes!
43 **
44 ** The register view also grants the user editing abilities. When the user clicks on
45 ** fields that are ~not~ reconciled, and appropriate 'editor' will open. The editor
46 ** depends on the column selected, and is generated by the column Delegates.
47 **
48 */
50 : public Wt::WContainerWidget
51 {
52  private:
53 
54  /*!
55  ** The status-bar presents various totals from the register,
56  ** including the rowCount().
57  **
58  */
59  class StatusBar
60  : public Wt::WContainerWidget
61  {
62  public:
63  StatusBar();
64 
65  auto setPresent ( GCW_NUMERIC _value = GCW_NUMERIC(0) )-> void;
66  auto setFuture ( GCW_NUMERIC _value = GCW_NUMERIC(0) )-> void;
67  auto setCleared ( GCW_NUMERIC _value = GCW_NUMERIC(0) )-> void;
68  auto setReconciled( GCW_NUMERIC _value = GCW_NUMERIC(0) )-> void;
69  auto setProjected ( GCW_NUMERIC _value = GCW_NUMERIC(0) )-> void;
70  auto setRowCount ( int _value = 0 )-> void;
71 
72  private:
73 
74  Wt::WText * m_present = nullptr;
75  Wt::WText * m_future = nullptr;
76  Wt::WText * m_cleared = nullptr;
77  Wt::WText * m_reconciled = nullptr;
78  Wt::WText * m_projected = nullptr;
79  Wt::WText * m_rowCount = nullptr;
80 
81  }; // endclass StatusBar
82 
83  public:
84 
85  /*!
86  ** \brief Model
87  **
88  ** An alias for the Model in case this interface changes.
89  **
90  */
92  using SortFilterModel = Wt::WSortFilterProxyModel;
93  using BatchEditModel = Wt::WBatchEditProxyModel;
94 
95  /*!
96  ** \brief Constructor
97  **
98  ** A register must be opened to a specific AccountGuid. If the AccountGuid
99  ** is blank or cannot be found (why would that be?) then the register simply
100  ** opens, allows registry entries, but has no place to save them (dangerous?).
101  **
102  */
103  AccountRegister( const std::string & _accountGuid = "" );
104 
105  auto setAccountGuid( const std::string & _accountGuid )-> void ;
106 
107  /*!
108  ** \brief Table View
109  **
110  */
111  auto tableView ()-> GCW::Gui::TableView * { return m_tableView; }
112 
113  auto baseModel ()-> std::shared_ptr< BaseModel > { return m_baseModel; }
114  auto sortFilterModel ()-> std::shared_ptr< SortFilterModel > { return m_sortFilterModel; }
115  auto batchEditModel ()-> std::shared_ptr< BatchEditModel > { return m_batchEditModel; }
116 
117  auto statusBar()-> StatusBar * { return m_statusBar; }
118 
119  auto test()-> void;
120 
121  /*!
122  ** \brief Create View Properties JSON Object
123  **
124  ** This will pack all of the Widget display variables in to a JSON
125  ** object for restoration later.
126  **
127  ** \sa fromJson()
128  **
129  */
130  auto toJson() const-> Wt::Json::Object;
131 
132  /*!
133  ** \brief Set View Properties from JSON Object
134  **
135  ** This accepts a JSON object containing all of the view properties
136  ** and applys them to the view, essentially restoring it
137  ** to its previous layout.
138  **
139  */
140  auto fromJson( const Wt::Json::Object & _jobj )-> bool;
141 
142  private:
143 
144  auto loadData()-> void;
145  auto editRow( int _row )-> void;
146  auto deleteRow( int _row )-> void;
147 // auto editRow( Wt::WModelIndex _index )-> void;
148  auto lastIndex()-> Wt::WModelIndex;
149  auto on_showPopup_triggered( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void;
150 
151  auto on_sortBy_triggered()-> void;
152  auto on_filterBy_triggered()-> void;
153  auto on_renamePage_triggered()-> void;
154  auto on_duplicate_triggered()-> void;
155 
156  /*!
157  ** \brief Delete a Row
158  **
159  ** This will delete a row from the register
160  **
161  */
162  auto on_delete_triggered()-> void;
163 
164  auto on_removeSplits_triggered()-> void;
165  auto on_enter_triggered()-> void;
166  auto on_cancel_triggered()-> void;
167  auto on_manageDocument_triggered()-> void;
168  auto on_openDocument_triggered()-> void;
169  auto on_blankTransaction_triggered()-> void;
170  auto on_goDate_triggered()-> void;
171  auto on_splitTransaction_triggered()-> void;
172  auto on_editExchangeRate_triggered()-> void;
173  auto on_schedule_triggered()-> void;
174  auto on_jump_triggered()-> void;
175  auto on_assignPayment_triggered()-> void;
176 
177  Wt::WPopupMenu m_popupMenu ;
178  std::string m_accountGuid ;
179  std::shared_ptr< BaseModel > m_baseModel ;
180  std::shared_ptr< Wt::WSortFilterProxyModel > m_sortFilterModel ;
181  std::shared_ptr< Wt::WBatchEditProxyModel > m_batchEditModel ;
182  GCW::Gui::TableView * m_tableView = nullptr ;
183  StatusBar * m_statusBar = nullptr ;
184  int m_clickedRow = -1 ;
185  int m_clickedCol = -1 ;
186  int m_rightClickRow = -1 ;
187  int m_rightClickCol = -1 ;
188 
189 }; // endclass AccountRegister
190 
191  } // endnamespace Gui {
192 } // endnamespace GCW {
193 
194 #endif // end __GUI_ACCOUNTREGISTER_H___
195 
196 
auto setFuture(GCW_NUMERIC _value=GCW_NUMERIC(0)) -> void
auto setProjected(GCW_NUMERIC _value=GCW_NUMERIC(0)) -> void
auto setRowCount(int _value=0) -> void
auto setCleared(GCW_NUMERIC _value=GCW_NUMERIC(0)) -> void
auto setReconciled(GCW_NUMERIC _value=GCW_NUMERIC(0)) -> void
auto setPresent(GCW_NUMERIC _value=GCW_NUMERIC(0)) -> void
auto baseModel() -> std::shared_ptr< BaseModel >
auto on_duplicate_triggered() -> void
auto on_renamePage_triggered() -> void
std::shared_ptr< Wt::WSortFilterProxyModel > m_sortFilterModel
auto on_delete_triggered() -> void
Delete a Row.
auto editRow(int _row) -> void
auto batchEditModel() -> std::shared_ptr< BatchEditModel >
auto on_editExchangeRate_triggered() -> void
auto on_removeSplits_triggered() -> void
auto toJson() const -> Wt::Json::Object
Create View Properties JSON Object.
auto tableView() -> GCW::Gui::TableView *
Table View.
auto fromJson(const Wt::Json::Object &_jobj) -> bool
Set View Properties from JSON Object.
auto statusBar() -> StatusBar *
AccountRegister(const std::string &_accountGuid="")
Constructor.
auto sortFilterModel() -> std::shared_ptr< SortFilterModel >
auto lastIndex() -> Wt::WModelIndex
auto on_schedule_triggered() -> void
auto setAccountGuid(const std::string &_accountGuid) -> void
auto on_assignPayment_triggered() -> void
auto on_showPopup_triggered(const Wt::WModelIndex &_index, const Wt::WMouseEvent &_event) -> void
auto on_manageDocument_triggered() -> void
std::shared_ptr< BaseModel > m_baseModel
GCW::Gui::TableView * m_tableView
auto on_sortBy_triggered() -> void
auto deleteRow(int _row) -> void
auto on_filterBy_triggered() -> void
auto on_blankTransaction_triggered() -> void
auto on_openDocument_triggered() -> void
Wt::WSortFilterProxyModel SortFilterModel
Wt::WBatchEditProxyModel BatchEditModel
std::shared_ptr< Wt::WBatchEditProxyModel > m_batchEditModel
auto on_splitTransaction_triggered() -> void
Custom Table View Class.
Definition: TableView.h:24
#define GCW_NUMERIC
Internal Numeric Type.
Definition: gcwglobal.h:37
Definition: App.h:17
Definition: GncLock.h:6
Definition: guid.cpp:397