GnuCashew ~ GnuCash Enabled Web
GCW
AccountRegister.cpp
Go to the documentation of this file.
1 #line 2 "src/Gui/AccountRegister.cpp"
2 
3 #include <Wt/WDateEdit.h>
4 #include <Wt/WItemDelegate.h>
5 #include <Wt/WPushButton.h>
6 #include <Wt/WSuggestionPopup.h>
7 #include <Wt/WText.h>
8 #include <Wt/WTableView.h>
9 #include <Wt/WTheme.h>
10 #include <Wt/WVBoxLayout.h>
11 #include <Wt/WHBoxLayout.h>
12 
13 #include "../define.h"
14 #include "../App.h"
15 #include "../Dbo/Accounts/Accounts.h"
16 #include "../Dbo/Prefrences.h"
17 #include "../Dbo/Splits/Splits.h"
18 #include "../Dbo/Transactions/Manager.h"
19 #include "AccountSuggestionPopup.h"
20 #include "AccountRegister.h"
21 
22 namespace {
23 
24 auto
25 setText_( Wt::WText * _widget, GCW_NUMERIC _value )-> void
26 {
27  _widget-> setText( "$" + toString( _value, GCW::Cfg::decimal_format() ) );
28 }
29 
30 auto
31 setText_( Wt::WText * _widget, int _value )-> void
32 {
33  _widget-> setText( std::to_string( _value ) );
34 }
35 
36 /* * * * * * * * * * * * * * * * * * * * * * * * * * */
37 
38 class HeaderDelegate
39 : public Wt::WItemDelegate
40 {
41  public:
42 
43 
44  auto createEditor
45  (
46  const Wt::WModelIndex & _index,
47  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
48  ) const-> std::unique_ptr< Wt::WWidget >;
49 
50  virtual auto editState( Wt::WWidget *editor, const Wt::WModelIndex &index ) const-> Wt::cpp17::any override;
51 
52 }; // endclass HeaderDelegate
53 
54 auto
55 HeaderDelegate::
56 createEditor
57 (
58  const Wt::WModelIndex & _index,
59  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
60 ) const-> std::unique_ptr< Wt::WWidget >
61 {
62  std::cout << __FILE__ << ":" << __LINE__ << " HeaderDelegate::" << __FUNCTION__ << "(): " << _index.row() << " " << _index.column() << std::endl;
63 
64  auto retVal = std::make_unique< Wt::WDateEdit >();
65 
66  return std::move( retVal );
67 
68 } // endcreateEditor
69 
70 Wt::cpp17::any
71 HeaderDelegate::
72 editState( Wt::WWidget *editor, const Wt::WModelIndex &index ) const
73 {
74  auto dateEdit = dynamic_cast< Wt::WDateEdit* >( editor );
75 
76  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
77 
78  return dateEdit-> text();
79 }
80 
81 
82 /* * * * * * * * * * * * * * * * * * * * * * * * * * */
83 
84 class DateDelegate
85 : public Wt::WItemDelegate
86 {
87  public:
88 
89  ~DateDelegate()
90  {
91 // std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
92  }
93 
94  std::unique_ptr< Wt::WWidget > createEditor
95  (
96  const Wt::WModelIndex & _index,
97  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
98  ) const;
99 
100  virtual Wt::cpp17::any editState( Wt::WWidget *editor, const Wt::WModelIndex &index ) const override;
101  void setEditState( Wt::WWidget * _editor, const Wt::WModelIndex & _index, const Wt::cpp17::any & _value ) const;
102  void setModelData ( const Wt::cpp17::any & _editState, Wt::WAbstractItemModel * _model, const Wt::WModelIndex & _index ) const;
103 
104  void doCloseEditor( Wt::WDateEdit * _dateEdit, bool save ) const;
105  void doTabAction( Wt::WKeyEvent _keyEvent ) const;
106 
107  mutable Wt::WDateEdit * m_dateEdit = nullptr;
108 
109 }; // endclass DateDelegate
110 
111 std::unique_ptr< Wt::WWidget >
112 DateDelegate::
113 createEditor
114 (
115  const Wt::WModelIndex & _index,
116  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
117 ) const
118 {
119 #ifdef NEVER
120  std::cout << __FILE__ << ":" << __LINE__ << " DateDelegate::" << __FUNCTION__ << "(): " << _index.row() << "," << _index.column() << std::endl;
121 #endif
122 
123  /*
124  ** The editor is placed in to a container for layout
125  ** management
126  **
127  */
128  auto retVal = std::make_unique< Wt::WContainerWidget >();
129 #ifndef NEVER
130  retVal-> setSelectable( true );
131 
132  /*
133  ** Get the date from the string value
134  **
135  */
136  auto date =
137  Wt::WDate::fromString
138  (
139  Wt::asString( _index.data( Wt::ItemDataRole::Edit ) ),
141  );
142 
143  /*
144  ** Build an editor
145  **
146  ** Hitting the 'enter' key or the 'esc' key closes the editor
147  **
148  */
149  auto dateEdit = std::make_unique< Wt::WDateEdit >();
150  m_dateEdit = dateEdit.get();
151  dateEdit-> setFormat( GCW::Cfg::date_format() );
152  dateEdit-> setDate( date );
153  dateEdit-> enterPressed ().connect( [&](){ doCloseEditor( dateEdit.get(), true ); });
154  dateEdit-> escapePressed ().connect( [&](){ doCloseEditor( dateEdit.get(), false ); });
155  dateEdit-> keyWentDown ().connect( [&]( Wt::WKeyEvent _keyEvent ){ doTabAction( _keyEvent ); });
156 
157  /*
158  ** Stuff it in to the layout
159  **
160  */
161  retVal-> setLayout( std::make_unique< Wt::WHBoxLayout >() );
162  retVal-> layout()-> setContentsMargins( 1,1,1,1 );
163  retVal-> layout()-> addWidget( std::move( dateEdit ) );
164 #endif
165 
166 #ifdef NEVER
167  std::cout << __FILE__ << ":" << __LINE__ << " DateDelegate::createEditor<end>" << std::endl;
168 #endif
169 
170  return retVal;
171 
172 } // endstd::unique_ptr< Wt::WWidget > DateDelegate::createEditor
173 
174 void
175 DateDelegate::
176 doCloseEditor( Wt::WDateEdit * _dateEdit, bool save ) const
177 {
178 #ifndef NEVER
179  std::cout << __FILE__ << ":" << __LINE__ << " DateDelegate::doCloseEditor()" << std::endl;
180 #endif
181 
182  closeEditor().emit( _dateEdit, save );
183 
184 } // endvoid DateDelegate::doCloseEditor( Wt::WDateEdit * _dateEdit, bool save ) const
185 
186 void
187 DateDelegate::
188 doTabAction( Wt::WKeyEvent _keyEvent ) const
189 {
190 #ifndef NEVER
191  std::cout << __FILE__ << ":" << __LINE__ << " DateDelegate::doTabAction()" << std::endl;
192 #endif
193 
194 }
195 
196 Wt::cpp17::any
197 DateDelegate::
198 editState( Wt::WWidget * _editor, const Wt::WModelIndex & _index ) const
199 {
200  auto cw = dynamic_cast< Wt::WContainerWidget* >( _editor );
201 
202  auto de = dynamic_cast< Wt::WDateEdit* >( cw-> children().at(0) );
203 
204 #ifdef NEVER
205  std::cout << __FILE__ << ":" << __LINE__
206  << " Wt::cpp17::any DateDelegate::editState()"
207  << " row:" << _index.row()
208  << " col:" << _index.column()
209  << " id:" << cw-> id()
210  << " oname:" << cw-> objectName()
211  << " chlds:" << cw-> children().size()
212  << " typid:" << typeid( cw-> children().at(0) ).name()
213  << " dated:" << de
214  << " mdted:" << m_dateEdit
215  << " txt:" << m_dateEdit-> text()
216  << std::endl
217  ;
218 #endif
219 
220 // return "";
221  return m_dateEdit-> text();
222 
223 } // endWt::cpp17::any DateDelegate::editState( Wt::WWidget * _editor, const Wt::WModelIndex & _index ) const
224 
225 void
226 DateDelegate::
227 setEditState( Wt::WWidget * _editor, const Wt::WModelIndex & _index, const Wt::cpp17::any & _value ) const
228 {
229 // the '_editor' and 'm_dateEdit' are not the same widget
230 #ifndef NEVER
231  std::cout << FUNCTION_HEADER
232  << " " << _editor << " " << typeid( _editor ).name()
233  << " " << m_dateEdit << " " << typeid( m_dateEdit ).name()
234  << std::endl;
235 #endif
236 
237 // Wt::WItemDelegate::setEditState( _editor, _index, _value );
238 
239 } // endvoid DateDelegate::setEditState( Wt::WWidget * _editor, const Wt::WModelIndex & _index, const Wt::cpp17::any & _value ) const
240 
241 void
242 DateDelegate::
243 setModelData( const Wt::cpp17::any & _editState, Wt::WAbstractItemModel * _model, const Wt::WModelIndex & _index ) const
244 {
245 #ifdef NEVER
246  std::cout << __FILE__ << ":" << __LINE__
247  << " setModelData()"
248  << " " << _index.row()
249  << " " << _index.column()
250  << " " << Wt::asString( _editState )
251  << " " << _model
252  << std::endl;
253 #endif
254 
255  Wt::WItemDelegate::setModelData( _editState, _model, _index );
256 
257 } // endvoid DateDelegate::setModelData( const Wt::cpp17::any & _editState, Wt::WAbstractItemModel * _model, const Wt::WModelIndex & _index ) const
258 
259 
260 
261 
262 /* * * * * * * * * * * * * * * * * * * * * * * * * * */
263 
264 class ReconcileDelegate
265 : public Wt::WItemDelegate
266 {
267  public:
268 
269  std::unique_ptr< Wt::WWidget > createEditor
270  (
271  const Wt::WModelIndex & _index,
272  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
273  ) const;
274 
275  virtual Wt::cpp17::any editState( Wt::WWidget *editor, const Wt::WModelIndex &index ) const override;
276  void setEditState( Wt::WWidget * _editor, const Wt::WModelIndex & _index, const Wt::cpp17::any & _value ) const;
277  void setModelData ( const Wt::cpp17::any & _editState, Wt::WAbstractItemModel * _model, const Wt::WModelIndex & _index ) const;
278 
279  void doCloseEditor( Wt::WLineEdit * _editor, bool save ) const;
280  void doTabAction( Wt::WKeyEvent _keyEvent ) const;
281 
282 };
283 
284 std::unique_ptr< Wt::WWidget >
285 ReconcileDelegate::
286 createEditor
287 (
288  const Wt::WModelIndex & _index,
289  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
290 ) const
291 {
292 #ifdef NEVER
293  std::cout << __FILE__ << ":" << __LINE__ << " ReconcileDelegate::" << __FUNCTION__ << "(): " << _index.row() << " " << _index.column() << std::endl;
294 #endif
295 
296  /*
297  ** The editor is placed in to a container for layout
298  ** management
299  **
300  */
301  auto retVal = std::make_unique< Wt::WContainerWidget >();
302  retVal-> setSelectable( true );
303 
304  /*
305  ** Get the date from the string value
306  **
307  */
308  auto reconciled = Wt::asString( _index.data( Wt::ItemDataRole::Edit ) );
309 
310  /*
311  ** Build an editor
312  **
313  ** Hitting the 'enter' key or the 'esc' key closes the editor
314  **
315  */
316  auto reconciledEdit = std::make_unique< Wt::WLineEdit >();
317  reconciledEdit-> setReadOnly( true );
318  reconciledEdit-> setText( reconciled );
319  reconciledEdit-> enterPressed ().connect( [&](){ doCloseEditor( reconciledEdit.get(), true ); });
320  reconciledEdit-> escapePressed ().connect( [&](){ doCloseEditor( reconciledEdit.get(), false ); });
321  reconciledEdit-> keyWentDown ().connect( [&]( Wt::WKeyEvent _keyEvent ){ doTabAction( _keyEvent ); });
322 
323  /*
324  ** Stuff it in to the layout
325  **
326  */
327  retVal-> setLayout( std::make_unique< Wt::WHBoxLayout >() );
328  retVal-> layout()-> setContentsMargins( 0,0,0,0 );
329  retVal-> layout()-> addWidget( std::move( reconciledEdit ) );
330 
331  return retVal;
332 
333 } // endstd::unique_ptr< Wt::WWidget > ReconciledDelegate::createEditor
334 
335 void
336 ReconcileDelegate::
337 doCloseEditor( Wt::WLineEdit * _editor, bool save ) const
338 {
339 #ifdef NEVER
340  std::cout << __FILE__ << ":" << __LINE__ << " ReconciledDelegate::doCloseEditor()" << std::endl;
341 #endif
342 
343  closeEditor().emit( _editor, save );
344 
345 #ifdef NEVER
346  m_editorClosed.emit( m_row, m_col );
347  m_row = -1;
348  m_col = -1;
349 #endif
350 
351 } // endvoid ReconciledDelegate::doCloseEditor( Wt::WDateEdit * _dateEdit, bool save ) const
352 
353 void
354 ReconcileDelegate::
355 doTabAction( Wt::WKeyEvent _keyEvent ) const
356 {
357 #ifdef NEVER
358  std::cout << __FILE__ << ":" << __LINE__ << " ReconciledDelegate::doTabAction()" << std::endl;
359 #endif
360 
361 }
362 
363 Wt::cpp17::any
364 ReconcileDelegate::
365 editState( Wt::WWidget * _editor, const Wt::WModelIndex & _index ) const
366 {
367  auto cw = dynamic_cast< Wt::WContainerWidget* >( _editor );
368 
369  auto ed = dynamic_cast< Wt::WLineEdit* >( cw-> children().at(0) );
370 
371 #ifdef NEVER
372  std::cout << __FILE__ << ":" << __LINE__
373  << " Wt::cpp17::any ReconcileDelegate::editState()"
374  << " r:" << _index.row()
375  << " c:" << _index.column()
376  << " i:" << cw-> id()
377  << " n:" << cw-> objectName()
378  << " s:" << cw-> children().size()
379  << " t:" << typeid( cw-> children().at(0) ).name()
380  << " d:" << ed
381  << std::endl
382  ;
383 #endif
384 
385 // return "";
386  return ed-> text();
387 
388 } // endWt::cpp17::any ReconcileDelegate::editState( Wt::WWidget * _editor, const Wt::WModelIndex & _index ) const
389 
390 void
391 ReconcileDelegate::
392 setEditState( Wt::WWidget * _editor, const Wt::WModelIndex & _index, const Wt::cpp17::any & _value ) const
393 {
394 // the '_editor' and 'm_dateEdit' are not the same widget
395 // std::cout << __FILE__ << ":" << __LINE__ << " " << _editor << " " << typeid( _editor ).name() << std::endl;
396 // std::cout << __FILE__ << ":" << __LINE__ << " " << m_dateEdit << " " << typeid( m_dateEdit ).name() << std::endl;
397 
398 
399 } // endvoid DateDelegate::setEditState( Wt::WWidget * _editor, const Wt::WModelIndex & _index, const Wt::cpp17::any & _value ) const
400 
401 void
402 ReconcileDelegate::
403 setModelData( const Wt::cpp17::any & _editState, Wt::WAbstractItemModel * _model, const Wt::WModelIndex & _index ) const
404 {
405 #ifdef NEVER
406  std::cout << __FILE__ << ":" << __LINE__
407  << " ReconciledDelegate::setModelData()"
408  << " " << _index.row()
409  << " " << _index.column()
410  << " " << Wt::asString( _editState )
411  << " " << _model
412  << std::endl;
413 #endif
414 
415 } // endvoid ReconciledDelegate::setModelData( const Wt::cpp17::any & _editState, Wt::WAbstractItemModel * _model, const Wt::WModelIndex & _index ) const
416 
417 
418 /* * * * * * * * * * * * * * * * * * * * * * * * * * */
419 
420 
421 class ValueDelegate
422 : public Wt::WItemDelegate
423 {
424  public:
425 
426  std::unique_ptr< Wt::WWidget > createEditor
427  (
428  const Wt::WModelIndex & _index,
429  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
430  ) const;
431 
432 };
433 
434 std::unique_ptr< Wt::WWidget >
435 ValueDelegate::
436 createEditor
437 (
438  const Wt::WModelIndex & _index,
439  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
440 ) const
441 {
442  auto retVal = Wt::WItemDelegate::createEditor( _index, _flags );
443  auto cw = dynamic_cast< Wt::WContainerWidget* >( retVal.get() );
444  auto lineEdit = dynamic_cast< Wt::WLineEdit* >( cw-> widget(0) );
445 
446  return retVal;
447 
448 } // endstd::unique_ptr< Wt::WWidget > ValueDelegate::createEditor
449 
450 
451 /* * * * * * * * * * * * * * * * * * * * * * * * * * */
452 
453 /*
454 ** Balance delegate works just like the ValueDelegate but
455 ** also adds a read-only attribute to the input, so it
456 ** displays the same, but cannot be edited. This is done
457 ** so that the entire line is highlighted fully when
458 ** selected.
459 **
460 */
461 class BalanceDelegate
462 : public Wt::WItemDelegate
463 {
464  public:
465 
466  auto createEditor( const Wt::WModelIndex & _index, Wt::WFlags< Wt::ViewItemRenderFlag > _flags ) const-> std::unique_ptr< Wt::WWidget > ;
467 
468 }; // endclass BalanceDelegate
469 
470 auto
471 BalanceDelegate::
472 createEditor
473 (
474  const Wt::WModelIndex & _index,
475  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
476 ) const-> std::unique_ptr< Wt::WWidget >
477 {
478  auto retVal = Wt::WItemDelegate::createEditor( _index, _flags );
479  auto cw = dynamic_cast< Wt::WContainerWidget* >( retVal.get() );
480  auto lineEdit = dynamic_cast< Wt::WLineEdit* >( cw-> widget(0) );
481  lineEdit-> setReadOnly( true );
482  lineEdit-> setAttributeValue( "style", "text-align:right;" );
483 
484  return retVal;
485 
486 } // endstd::unique_ptr< Wt::WWidget > ValueDelegate::createEditor
487 
488 
489 /* * * * * * * * * * * * * * * * * * * * * * * * * * */
490 
491 
492 class SuggestionDelegate
493 : public Wt::WItemDelegate
494 {
495  public:
496 
497  std::unique_ptr< Wt::WWidget > createEditor
498  (
499  const Wt::WModelIndex & _index,
500  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
501  ) const;
502 
503 };
504 
505 std::unique_ptr< Wt::WWidget >
506 SuggestionDelegate::
507 createEditor
508 (
509  const Wt::WModelIndex & _index,
510  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
511 ) const
512 {
513 #ifdef NEVER
514  std::cout << __FILE__ << ":" << __LINE__ << " SuggestionDelegate::" << __FUNCTION__ << "(): " << _index.row() << " " << _index.column() << std::endl;
515 #endif
516 
517  auto retVal = Wt::WItemDelegate::createEditor( _index, _flags );
518  auto cw = dynamic_cast< Wt::WContainerWidget* >( retVal.get() );
519  auto lineEdit = dynamic_cast< Wt::WLineEdit* >( cw-> widget(0) );
520 
521  if( lineEdit )
522  {
523  // options for email address suggestions
524  Wt::WSuggestionPopup::Options popupOptions =
525  {
526  "<b>", // highlightBeginTag
527  "</b>", // highlightEndTag
528  ',', // listSeparator (for multiple addresses)
529  " \n", // whitespace
530  "()[]{}-., \"@\n;:", // wordSeparators (within an address)
531  "" // appendReplacedText (prepare next email address)
532  };
533 
534  auto popup = retVal-> addChild( std::make_unique< Wt::WSuggestionPopup >( popupOptions ) );
535  popup-> forEdit( lineEdit );
536 
537 // auto batchEditModel = dynamic_cast< const Wt::WBatchEditProxyModel* >( _index.model() );
538 // auto sortFilterModel = dynamic_cast< const Wt::WSortFilterProxyModel* >( _index.model() );;
539 // auto baseModel = dynamic_cast< const GCW::Gui::AccountRegister::BaseModel* >( sortFilterModel-> sourceModel().get() );
540  auto baseModel = dynamic_cast< const GCW::Gui::AccountRegister::BaseModel* >( _index.model() );
541 
542  for( auto item : baseModel-> suggestionsFromColumn( _index.column() ) )
543  popup-> addSuggestion( item, item );
544  }
545 
546  return retVal;
547 
548 } // endstd::unique_ptr< Wt::WWidget > SuggestionDelegate::createEditor
549 
550 
551 /* * * * * * * * * * * * * * * * * * * * * * * * * * */
552 
553 class AccountDelegate
554 : public Wt::WItemDelegate
555 {
556  public:
557 
558  std::unique_ptr< Wt::WWidget > createEditor
559  (
560  const Wt::WModelIndex & _index,
561  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
562  ) const;
563 
564 };
565 
566 std::unique_ptr< Wt::WWidget >
567 AccountDelegate::
568 createEditor
569 (
570  const Wt::WModelIndex & _index,
571  Wt::WFlags< Wt::ViewItemRenderFlag > _flags
572 ) const
573 {
574 #ifdef NEVER
575  std::cout << __FILE__ << ":" << __LINE__ << " AccountDelegate::" << __FUNCTION__ << "(): " << _index.row() << " " << _index.column() << std::endl;
576 #endif
577 
578  auto retVal = Wt::WItemDelegate::createEditor ( _index, _flags );
579  auto cw = dynamic_cast< Wt::WContainerWidget* > ( retVal.get() );
580  auto lineEdit = dynamic_cast< Wt::WLineEdit* > ( cw-> widget(0) );
581 
582  auto popup = retVal-> addChild( std::make_unique< GCW::Gui::AccountSuggestionPopup >() );
583  popup-> forEdit( lineEdit, Wt::PopupTrigger::Editing /* | Wt::PopupTrigger::DropDownIcon */ );
584 
585  return retVal;
586 
587 } // endstd::unique_ptr< Wt::WWidget > AccountDelegate::createEditor
588 
589 /* * * * * * * * * * * * * * * * * * * * * * * * * * */
590 
591 } // endnamespace {
592 
594 StatusBar()
595 {
596  addStyleClass( "StatusBar" );
597 
598  auto lw = setLayout( std::make_unique< Wt::WHBoxLayout >() );
599 
600  lw-> setSpacing( 0 );
601 
602  auto _addWidget = [&]( const std::string & _key, int _spacing = 0 )
603  {
604  lw-> addWidget( std::make_unique< Wt::WText >( TR("gcw.AccountRegister.StatusBar." + _key ) + ":" ) );
605  auto retVal = lw-> addWidget( std::make_unique< Wt::WText >(), _spacing );
606  retVal-> setAttributeValue( "style", "margin-right:10px" );
607  return retVal;
608  };
609 
610  m_present = _addWidget( "present" );
611  m_future = _addWidget( "future" );
612  m_cleared = _addWidget( "cleared" );
613  m_reconciled = _addWidget( "reconciled" );
614  m_projected = _addWidget( "projected", 1 );
615  m_rowCount = _addWidget( "rowCount" );
616 
617  setPresent ();
618  setFuture ();
619  setCleared ();
620  setReconciled ();
621  setProjected ();
622  setRowCount ();
623 
624 } // endStatusBar()
625 
626 auto GCW::Gui::AccountRegister::StatusBar:: setPresent ( GCW_NUMERIC _value )-> void { setText_( m_present , _value ); }
627 auto GCW::Gui::AccountRegister::StatusBar:: setFuture ( GCW_NUMERIC _value )-> void { setText_( m_future , _value ); }
628 auto GCW::Gui::AccountRegister::StatusBar:: setCleared ( GCW_NUMERIC _value )-> void { setText_( m_cleared , _value ); }
629 auto GCW::Gui::AccountRegister::StatusBar:: setReconciled ( GCW_NUMERIC _value )-> void { setText_( m_reconciled , _value ); }
630 auto GCW::Gui::AccountRegister::StatusBar:: setProjected ( GCW_NUMERIC _value )-> void { setText_( m_projected , _value ); }
631 auto GCW::Gui::AccountRegister::StatusBar:: setRowCount ( int _value )-> void { setText_( m_rowCount , _value ); }
632 
634 AccountRegister( const std::string & _accountGuid )
635 {
636  /*
637  ** Look in gcw.css for styling.
638  **
639  */
640  addStyleClass( "AccountRegister" );
641 
642  /*
643  ** use a layout manager to install the table view into, so
644  ** that the widget will fit and scroll properly.
645  **
646  */
647  auto lw = setLayout( std::make_unique< Wt::WVBoxLayout >() );
648  auto w = std::make_unique< GCW::Gui::TableView >();
649  m_tableView = w.get();
650  lw-> addWidget( std::move( w ), 1 );
651 // tableView()-> setRowHeight( "20px" );
652 
653  /*
654  ** Poke a status bar down at the bottom of the area.
655  **
656  */
657  m_statusBar = lw-> addWidget( std::make_unique< StatusBar >() );
658 
659  /*
660  ** Configure the table view.
661  **
662  */
663  tableView()-> setSortingEnabled ( false );
664  tableView()-> setAlternatingRowColors ( true );
665  tableView()-> setSelectionBehavior ( Wt::SelectionBehavior::Rows );
666  tableView()-> setSelectionMode ( Wt::SelectionMode::Single );
667 // tableView()-> setEditTriggers ( Wt::EditTrigger::None );
668  tableView()-> setEditTriggers ( Wt::EditTrigger::SingleClicked );
669 // tableView()-> setEditOptions ( Wt::EditOption::SingleEditor | Wt::EditOption::SaveWhenClosed );
670  tableView()-> setEditOptions ( Wt::EditOption::MultipleEditors | Wt::EditOption::LeaveEditorsOpen );
671  tableView()-> setHeaderItemDelegate ( std::make_shared< HeaderDelegate >() );
672  tableView()-> setAttributeValue ( "oncontextmenu","event.cancelBubble=true;event.returnValue=false;return false;" );
673  tableView()-> mouseWentUp().connect ( this, &AccountRegister::on_showPopup_triggered );
674 
675  /*
676  ** set column delegates so the editors have assistance with list pickers and
677  ** whatnot
678  **
679  */
680  tableView()-> setItemDelegateForColumn ( 0, std::make_shared< DateDelegate >() );
681  tableView()-> setItemDelegateForColumn ( 1, std::make_shared< SuggestionDelegate >() );
682  tableView()-> setItemDelegateForColumn ( 2, std::make_shared< SuggestionDelegate >() );
683  tableView()-> setItemDelegateForColumn ( 3, std::make_shared< AccountDelegate >() );
684  tableView()-> setItemDelegateForColumn ( 4, std::make_shared< ReconcileDelegate >() );
685  tableView()-> setItemDelegateForColumn ( 5, std::make_shared< ValueDelegate >() );
686  tableView()-> setItemDelegateForColumn ( 6, std::make_shared< ValueDelegate >() );
687  tableView()-> setItemDelegateForColumn ( 7, std::make_shared< BalanceDelegate >() );
688 
689  {
690 // dateDelegate->
691 // closeEditor().connect( [&]( Wt::WWidget* _widget, bool _save )
692 // {
693 // std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
694 //
695 // });
696 
697 
698 #ifdef NEVER
699  dateDelegate->
700  editorCreated().connect( [&]( int _row, int _column)
701  {
702  std::cout << __FILE__ << ":" << __LINE__
703  << " row:" << _row
704  << " col:" << _column
705  << std::endl;
706 
707  for( int column = 0; column< tableView()-> model()-> columnCount(); column++ )
708  {
709  std::cout << __FILE__ << ":" << __LINE__
710  << " row:" << _row
711  << " col:" << column
712  << std::endl;
713 
714  tableView()-> itemWidget( tableView()-> model()-> index( _row, column ) )-> addStyleClass( "active" );
715  }
716 
717  });
718 
719  dateDelegate->
720  editorClosed().connect( [&]( int _row, int _column )
721  {
722  std::cout << __FILE__ << ":" << __LINE__
723  << " row:" << _row
724  << " col:" << _column
725  << std::endl;
726 
727  for( int column = 0; column< tableView()-> model()-> columnCount(); column++ )
728  {
729  std::cout << __FILE__ << ":" << __LINE__
730  << " row:" << _row
731  << " col:" << column
732  << std::endl;
733 
734  tableView()-> itemWidget( tableView()-> model()-> index( _row, column ) )-> removeStyleClass( "active" );
735  }
736 
737  });
738 #endif
739 
740  }
741 
742 
743  tableView()-> headerClicked().connect( [=]( int col, Wt::WMouseEvent event )
744  {
745 #ifdef NEVER
746  if( tableView()-> selectedIndexes().size() == 0 )
747  tableView()-> select( baseModel()-> index( 893, 0 ) );
748  else
749  tableView()-> clearSelection();
750 #endif
751  std::cout << __FILE__ << ":" << __LINE__ << " " << col << std::endl;
752 
753  });
754 
755 #ifdef NEVER
756  /*
757  ** This 'selectionChanged' procedure is 'clunky'.
758  **
759  ** This procedure is designed to respond to a row-selection
760  ** change event. When a different row is selected, we want
761  ** any open editors to be closed, and the row selection to
762  ** move to the newly selected row.
763  **
764  ** Right now the problem is with the 'select' command, where
765  ** it calling 'select' cause this 'selectionChanged' event
766  ** to fire again. So, ther is a littl 'selecting' interlock
767  ** built around it to try to prevent this weirdness.
768  **
769  ** The other problem with this routine is when 'selecting'
770  ** a cell that is editable, the editor is immediately engaged
771  ** but this 'selectionChanged' signal never fires... so we have
772  ** to sort that out.
773  **
774  */
775  tableView()->
776  selectionChanged().connect( [=]()
777  {
778  std::cout << __FILE__ << ":" << __LINE__ << " selectionChanged" << std::endl;
779  });
780 #endif
781 
782 #ifdef CLICKED_FIRES_FROM_THE_TABLEVIEW_HANDLECLICK_EVENT_HANDLER_MIGHT_NOT_BE_USEFUL_HERE
783  /*
784  ** the 'clicked()' signal seems to fire even when an editor is open
785  **
786  */
787  tableView()->
788  clicked().connect( [=]( Wt::WModelIndex _index, Wt::WMouseEvent _event )
789  {
790  std::cout << __FILE__ << ":" << __LINE__ << " clicked"
791  << " row:" << _index.row()
792  << " col:" << _index.column()
793  << std::endl
794  ;
795 
796  if( !tableView()-> isEditing( _index ) )
797  {
798  tableView()-> closeEditors();
799 
800  for( int column = 0; column< 7; column++ )
801  {
802  std::cout << __FILE__ << ":" << __LINE__ << " edit:" << column << std::endl;
803 
804  auto index = tableView()-> model()-> index( _index.row(), column );
805  tableView()-> edit( index );
806  }
807  }
808 
809  else
810  {
811  std::cout << __FILE__ << ":" << __LINE__ << " already editing " << std::endl;
812 
813  }
814 
815  });
816 #endif
817 
818 #ifdef KEYPRESSED_ONLY_FIRES_WHEN_EDITORS_ARE_NOT_OPEN
819  tableView()->
820  keyPressed().connect( [=]( Wt::WKeyEvent _event )
821  {
822  std::cout << __FILE__ << ":" << __LINE__ << " " << _event.charCode() << std::endl;
823  });
824 #endif
825 
826 #ifndef NEVER
827  tableView()->
828  clicked().connect( [=]( Wt::WModelIndex _index, Wt::WMouseEvent _event )
829  {
830 #ifdef NEVER
831  std::cout << __FILE__ << ":" << __LINE__ << " clicked"
832  << " row:" << _index.row()
833  << " col:" << _index.column()
834  << std::endl
835  ;
836 #endif
837 
838 #ifdef NEVER
839  if( m_clickedRow != -1
840  && m_clickedCol != -1
841  )
842  {
843  std::cout << __FILE__ << ":" << __LINE__ << " unselect:" << m_clickedRow << std::endl;
844 
845  for( int column = 0; column< tableView()-> model()-> columnCount(); column++ )
846  {
847  tableView()->
848  itemWidget( tableView()-> model()-> index( m_clickedRow, column ) )->
849  removeStyleClass( "active" );
850  }
851 
852  if( m_clickedRow != _index.row()
853  )
854  tableView()-> closeEditors( true );
855  }
856 #endif
857 
858  /*
859  ** If we clicked on a different row, edit the whole row.
860  ** if we clicked and it's the same row, then just ignore
861  ** it.
862  **
863  */
864  if( m_clickedRow != _index.row() )
865  {
866  m_clickedRow = _index.row();
867  m_clickedCol = _index.column();
868  editRow( _index.row() );
869  }
870 
871 #ifdef NEVER
872  for( int column = 0; column< tableView()-> model()-> columnCount(); column++ )
873  {
874  std::cout << __FILE__ << ":" << __LINE__ << " select:" << m_clickedRow << std::endl;
875 
876  tableView()-> itemWidget( tableView()-> model()-> index( m_clickedRow, column ) )->
877  addStyleClass( "active" );
878  }
879 #endif
880 
881 #ifdef NEVER
882  std::cout << __FILE__ << ":" << __LINE__
883  << " " << Wt::WApplication::instance()-> theme()-> activeClass()
884  << std::endl;
885 #endif
886 
887 // tableView()-> clearSelection();
888 
889 // tableView()-> closeEditors();
890  });
891 #endif
892 
893  m_baseModel = std::make_shared< BaseModel >();
894 // m_sortFilterModel = std::make_shared< Wt::WSortFilterProxyModel >();
895  m_batchEditModel = std::make_shared< Wt::WBatchEditProxyModel >();
896 //
897 // m_sortFilterModel-> setSourceModel( m_baseModel );
898 // m_sortFilterModel-> sort(0);
899 // m_batchEditModel -> setSourceModel( m_sortFilterModel );
900  m_batchEditModel -> setSourceModel( m_baseModel );
901 
902  baseModel()->
903  goneDirty().connect( [&]( Wt::WModelIndex _index )
904  {
905  std::cout << __FILE__ << ":" << __LINE__ << " " << _index.row() << std::endl;
906  baseModel()-> refreshFromDisk();
907 // m_batchEditModel -> setSourceModel( m_baseModel );
908  std::cout << __FILE__ << ":" << __LINE__ << " " << _index.row() << std::endl;
909  });
910 
911 
912 } // endGCW::AccountRegister::AccountRegister( const std::string & _accountGuid )
913 
914 auto
916 setReadOnly( bool _state )-> void
917 {
918  baseModel()-> setReadOnly( _state );
919 
920 } // endsetReadOnly( bool _state = true )
921 
922 auto
924 deleteRow( int _row )-> void
925 {
926  auto splitGuid = baseModel()-> getSplitGuid( _row );
927  auto transMan = GCW::Dbo::Transactions::Manager();
928  transMan.loadSplit( splitGuid );
929  transMan.deleteTransaction();
930 
931  baseModel()-> refreshFromDisk();
932 
933 } // enddeleteRow( int _row )-> void
934 
935 auto
937 on_sortBy_triggered()-> void
938 {
939  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
940 
941 } // endon_sortBy_triggered()-> void
942 
943 auto
945 on_filterBy_triggered()-> void
946 {
947  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
948 
949 } // endon_filterBy_triggered()-> void
950 
951 auto
954 {
955  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
956 
957 } // endon_renamePage_triggered()-> void
958 
959 auto
961 on_duplicate_triggered()-> void
962 {
963  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
964 
965 } // endon_duplicate_triggered()-> void
966 
967 auto
969 on_delete_triggered()-> void
970 {
971  /*!
972  ** by default, the user will be asked to delete
973  ** an item from the register, unless they
974  ** have chosen to never be asked.
975  **
976  ** \bug the logic here is not correct
977  */
978  static bool askThisSession = true;
979  bool askForever = GCW::Dbo::Prefrences::get().askOnDelete();
980 
981  /*
982  ** ask sometimes
983  */
984  if( askThisSession || askForever )
985  {
986  /*
987  ** build out a dialog box to prompt the user to delete or not
988  **
989  */
990  auto msgBox = addChild( std::make_unique< Wt::WDialog >( TR("gcw.AccountRegister.delete.title") ) );
991  auto templt = msgBox-> contents()-> addNew< Wt::WTemplate >( TR("gcw.AccountRegister.delete.contents") );
992  msgBox-> setClosable( true );
993  msgBox-> setMovable ( true );
994  msgBox-> show();
995 
996  auto rememberAlways = templt-> bindNew< Wt::WCheckBox >( "rememberAlways" , TR("gcw.AccountRegister.delete.rem1" ) );
997  auto rememberSession = templt-> bindNew< Wt::WCheckBox >( "rememberSession", TR("gcw.AccountRegister.delete.rem2" ) );
998  auto pbCancel = templt-> bindNew< Wt::WPushButton >( "cancel" , TR("gcw.AccountRegister.delete.cancel") );
999  auto pbDelete = templt-> bindNew< Wt::WPushButton >( "delete" , TR("gcw.AccountRegister.delete.delete") );
1000 
1001  auto splitGuid = baseModel()-> getSplitGuid( m_rightClickRow );
1002  auto transMan = GCW::Dbo::Transactions::Manager();
1003  transMan.loadSplit( splitGuid );
1004 
1005  templt-> bindString( "date" , transMan.getDate().toString( GCW_DATE_FORMAT_DISPLAY ) );
1006  templt-> bindString( "desc" , transMan.getDescription () );
1007  templt-> bindString( "amount", transMan.getValueAsString() );
1008 
1009  pbCancel-> clicked().connect( msgBox, &Wt::WDialog::reject );
1010  pbDelete-> clicked().connect( msgBox, &Wt::WDialog::accept );
1011 
1012  /*
1013  ** when this option is selected, disable the other one
1014  */
1015  rememberAlways->
1016  clicked().connect( [rememberSession,rememberAlways]()
1017  {
1018  rememberSession-> setDisabled( rememberAlways-> checkState() == Wt::CheckState::Checked );
1019  });
1020 
1021  /*
1022  ** When the dialog finishes, it is either accepted or rejected.
1023  ** In either case, the dialog will be removed from the addChild
1024  ** from earlier so we don't got no memory leaks.
1025  **
1026  */
1027  msgBox->
1028  finished().connect( [this,rememberSession,msgBox]( Wt::DialogCode _code )
1029  {
1030  if( _code == Wt::DialogCode::Accepted )
1031  {
1032  askThisSession = rememberSession-> checkState() == Wt::CheckState::Checked;
1033 
1035 
1036  }
1037  removeChild( msgBox );
1038  });
1039 
1040  } // endif( ..askFirst.. )
1041 
1042  /*
1043  ** don't ask, just delete
1044  */
1045  else
1046  {
1048  }
1049 
1050 } // endon_delete_triggered()-> void
1051 
1052 auto
1055 {
1056  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1057 
1058 } // endon_removeSplits_triggered()-> void
1059 
1060 auto
1062 on_enter_triggered()-> void
1063 {
1064  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1065 
1066 } // endon_enter_triggered()-> void;
1067 
1068 auto
1070 on_cancel_triggered()-> void
1071 {
1072  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1073 
1074 } // endon_cancel_triggered()-> void;
1075 
1076 auto
1079 {
1080  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1081 
1082 
1083 } // endon_manageDocument_triggered()-> void
1084 
1085 auto
1088 {
1089  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1090 
1091 } // endon_openDocument_triggered()-> void
1092 
1093 auto
1096 {
1097  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1098 
1099 } // endon_blankTransaction_triggered()-> void
1100 
1101 auto
1103 on_goDate_triggered()-> void
1104 {
1105  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1106 
1107 } // endon_goDate_triggered()-> void
1108 
1109 auto
1112 {
1113  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1114 
1115 } // endon_splitTransaction_triggered()-> void
1116 
1117 auto
1120 {
1121  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1122 
1123 } // endon_editExchangeRate_triggered()-> void
1124 
1125 auto
1127 on_schedule_triggered()-> void
1128 {
1129  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1130 
1131 } // endon_schedule_triggered()-> void
1132 
1133 auto
1135 on_jump_triggered()-> void
1136 {
1137  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1138 
1139 } // endon_jump_triggered()-> void
1140 
1141 auto
1144 {
1145  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
1146 
1147 } // endon_assignPayment_triggered()-> void
1148 
1149 auto
1151 on_showPopup_triggered( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void
1152 {
1153  if( _event.button() == Wt::MouseButton::Right )
1154  {
1155  m_rightClickRow = _index.row();
1156  m_rightClickCol = _index.column();
1157 
1158  /*
1159  ** Set up the items in the pop-up menu
1160  ** (some of the items are dependent on which row was clicked on
1161  ** so we dump everything from the popup and reload)
1162  **
1163  */
1164  while( m_popupMenu.count() )
1165  m_popupMenu.removeItem( m_popupMenu.itemAt(0) );
1166 
1167 #ifdef NEVER
1168  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.SortBy" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1169  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.FilterBy" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1170  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.RenamePage" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1171  m_popupMenu.addSeparator();
1172  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Duplicate" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1173 #endif
1174 
1175  // delete
1176  {
1177  auto item = m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Delete"), this, &AccountRegister::on_delete_triggered );
1178 
1179  /*
1180  ** delete doesn't work on the 'new' line (need a split guid)
1181  */
1182  if( !(baseModel()-> isDeletable( _index )) )
1183  item-> setDisabled( true );
1184  }
1185 
1186 #ifdef NEVER
1187  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.RemoveSplits" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1188  m_popupMenu.addSeparator();
1189  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Enter" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1190  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Cancel" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1191  m_popupMenu.addSeparator();
1192  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.ManageDocument" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1193  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.OpenDocument" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1194  m_popupMenu.addSeparator();
1195  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Jump" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1196  m_popupMenu.addSeparator();
1197  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.BlankTransaction" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1198  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.GoDate" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1199  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.SplitTransaction" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1200  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.EditExchangeRate" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1201  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Schedule" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1202  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Jump" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1203  m_popupMenu.addSeparator();
1204  m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.AssignPayment" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
1205 #endif
1206 
1207  // Select the item, if it was not yet selected.
1208  if( !tableView()-> isSelected( _index ) )
1209  {
1210  editRow( _index.row() );
1211  }
1212 
1213  if( m_popupMenu.isHidden() )
1214  {
1215  m_popupMenu.popup( _event );
1216  }
1217  else
1218  {
1219  m_popupMenu.hide();
1220  }
1221 
1222  } // endif( ..right-click.. )
1223 
1224 } // endon_showPopup_triggered( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void
1225 
1226 
1227 auto
1229 setAccountGuid( const std::string & _accountGuid )-> void
1230 {
1231  m_accountGuid = _accountGuid;
1232 
1233  baseModel()-> setAccountGuid( _accountGuid );
1234 
1235  loadData();
1236 
1237  /*
1238  ** Scroll to the bottom of the view, and select the last row.
1239  **
1240  */
1241  editRow( lastIndex().row() );
1242 
1243 } // endsetAccountGuid( const std::string & _accountGuid )-> void
1244 
1245 auto
1247 lastIndex()-> Wt::WModelIndex
1248 {
1249  return baseModel()-> index( baseModel()-> rowCount() -1, 0 );
1250 
1251 } // endlastIndex()-> Wt::WModelIndex
1252 
1253 auto
1255 loadData()-> void
1256 {
1257  tableView()-> setModel( m_baseModel );
1258 
1259  // 0 = Date
1260  tableView()-> setColumnWidth ( 0, "150px" );
1261  tableView()-> setHeaderAlignment( 0, Wt::AlignmentFlag::Right );
1262  tableView()-> setColumnAlignment( 0, Wt::AlignmentFlag::Right );
1263 
1264  // 1 = Action/Num
1265  tableView()-> setColumnWidth ( 1, "50px" );
1266  tableView()-> setHeaderAlignment( 1, Wt::AlignmentFlag::Center );
1267  tableView()-> setColumnAlignment( 1, Wt::AlignmentFlag::Center );
1268 
1269  // 2 = Memo/Description
1270  tableView()-> setColumnWidth ( 2, "99%" );
1271  tableView()-> setHeaderAlignment( 2, Wt::AlignmentFlag::Left );
1272  tableView()-> setColumnAlignment( 2, Wt::AlignmentFlag::Left );
1273 
1274  // 3 = Account/Transfer
1275  tableView()-> setColumnWidth ( 3, "150px" );
1276  tableView()-> setHeaderAlignment( 3, Wt::AlignmentFlag::Right );
1277  tableView()-> setColumnAlignment( 3, Wt::AlignmentFlag::Right );
1278 
1279  // 4 = Reconciliation
1280  tableView()-> setColumnWidth ( 4, "25px" );
1281  tableView()-> setHeaderAlignment( 4, Wt::AlignmentFlag::Center );
1282  tableView()-> setColumnAlignment( 4, Wt::AlignmentFlag::Center );
1283 
1284  // 5 = Debit
1285  tableView()-> setColumnWidth ( 5, "100px" );
1286  tableView()-> setHeaderAlignment( 5, Wt::AlignmentFlag::Right );
1287  tableView()-> setColumnAlignment( 5, Wt::AlignmentFlag::Right );
1288 
1289  // 6 = Credit
1290  tableView()-> setColumnWidth ( 6, "100px" );
1291  tableView()-> setHeaderAlignment( 6, Wt::AlignmentFlag::Right );
1292  tableView()-> setColumnAlignment( 6, Wt::AlignmentFlag::Right );
1293 
1294  // 7 = Balance
1295  tableView()-> setColumnWidth ( 7, "100px" );
1296  tableView()-> setHeaderAlignment( 7, Wt::AlignmentFlag::Right );
1297  tableView()-> setColumnAlignment( 7, Wt::AlignmentFlag::Right );
1298 
1299  statusBar()-> setPresent ( baseModel()-> present () );
1300  statusBar()-> setProjected ( baseModel()-> projected () );
1301  statusBar()-> setReconciled ( baseModel()-> reconciled () );
1302  statusBar()-> setFuture ( baseModel()-> future () );
1303  statusBar()-> setCleared ( baseModel()-> cleared () );
1304  statusBar()-> setRowCount ( baseModel()-> rowCount () );
1305 
1306 } // endloadData()-> void
1307 
1308 //auto
1309 //GCW::Gui::AccountRegister::
1310 //editRow( Wt::WModelIndex _index )-> void
1311 //{
1312 // tableView()-> closeEditors( true );
1313 // ( _index.row() );
1314 //
1315 //} // endeditRow( Wt::WModelIndex _index )-> void
1316 
1317 auto
1319 editRow( int _row )-> void
1320 {
1321  /*
1322  ** If the row we're editing ~can~ be edited, then
1323  ** we want to make sure we un-select any other rows
1324  ** that may still be selected
1325  **
1326  */
1327  if( !baseModel()-> isReadOnly( _row ) )
1328  tableView()-> clearSelection();
1329 
1330  /*
1331  ** Close all the editor then scroll down
1332  ** to that 0-col index row and make sure
1333  ** it is in view.
1334  **
1335  */
1336  tableView()-> closeEditors( true );
1337  {
1338  auto index = baseModel()-> index( _row, 0 );
1339  tableView()-> scrollTo( index );
1340  }
1341 
1342  for( int column=0; column< baseModel()-> columnCount(); column++ )
1343  {
1344  auto index = baseModel()-> index( _row, column );
1345  tableView()-> edit( index );
1346  }
1347 
1348 } // endeditRow( int _row )-> void
1349 
1350 auto
1352 toJson() const-> Wt::Json::Object
1353 {
1354  Wt::Json::Object jobj;
1355 
1356  return jobj;
1357 }
1358 
1359 auto
1361 fromJson( const Wt::Json::Object & _jobj )-> bool
1362 {
1363  return true;
1364 }
1365 
1366 
1367 
1368 void
1370 test()
1371 {
1372  std::cout << __FILE__ << ":" << __LINE__ << " ::test::" << std::endl;
1373 
1374  std::cout << __FILE__ << ":" << __LINE__ << " " << tableView()-> selectedIndexes().size() << std::endl;
1375 
1376  auto selectedIndex = *tableView()-> selectedIndexes().begin();
1377 
1378  if( selectedIndex.isValid() )
1379  {
1380 
1381  std::cout << __FILE__ << ":" << __LINE__ << " " << tableView()-> selectedIndexes().size() << std::endl;
1382 
1383  }
1384 
1385 
1386 } // endvoid GCW::Gui::AccountRegister::test()
1387 
1388 
1389 
1390 
Transaction Manager.
Definition: Manager.h:30
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
auto setReadOnly(bool _state=true) -> void
auto on_delete_triggered() -> void
Delete a Row.
auto editRow(int _row) -> void
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 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
std::shared_ptr< Wt::WBatchEditProxyModel > m_batchEditModel
auto on_splitTransaction_triggered() -> void
#define TR(X)
Definition: define.h:17
#define FUNCTION_HEADER
Definition: gcwglobal.h:39
#define GCW_DATE_FORMAT_DISPLAY
Definition: gcwglobal.h:13
#define GCW_NUMERIC
Internal Numeric Type.
Definition: gcwglobal.h:37
std::string date_format()
Date Format Specifier.
Definition: GnuCashew.cpp:27
DECIMAL::decimal_format decimal_format()
Decimal Format Specifier.
Definition: GnuCashew.cpp:21
const Wt::WFormModel::Field name
Definition: Accounts.cpp:47
const Wt::WFormModel::Field date
Definition: Entries.cpp:11
const Wt::WFormModel::Field id
Definition: Definition.h:17
auto get() -> GCW::Dbo::Prefrences::Item
Definition: Prefrences.cpp:19
std::string asString(Status _status)
Get Status as String.
Definition: Status.cpp:7
auto toString(int _value) -> std::string
Convert Integer to String.
Definition: BillPay.cpp:41
Definition: GncLock.h:6