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