GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
Widget.cpp
Go to the documentation of this file.
1#line 2 "src/Gui/AccountRegister/Widget.cpp"
2
3#include <Wt/WDateEdit.h>
4#include <Wt/WPushButton.h>
5#include <Wt/WSuggestionPopup.h>
6#include <Wt/WText.h>
7#include <Wt/WTableView.h>
8#include <Wt/WTheme.h>
9#include <Wt/WVBoxLayout.h>
10#include <Wt/WHBoxLayout.h>
11
12#include "../define.h"
13#include "../App.h"
14#include "../Dbo/Accounts/Accounts.h"
15#include "../Dbo/Prefrences.h"
16#include "../Dbo/Splits/Splits.h"
17#include "../Eng/TransactionManager.h"
18#include "../TransactionDetailWidget.h"
19#include "SuggestionPopup.h"
20#include "Widget.h"
21
22/* * * * * * * * * * * * * * * * * * * * * * * * * * */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25auto
27init()-> void
28{
29 /*
30 ** see; gcw.css for styling.
31 */
32 addStyleClass( "AccountRegister" );
33
34 /*
35 ** use a layout manager to install the table view into, so
36 ** that the widget will fit and scroll properly.
37 */
38 auto lw = setLayout( std::make_unique< Wt::WVBoxLayout >() );
39
40 /*
41 ** Poke a tool bar up at the top of the area.
42 */
43 m_toolBar = lw-> addWidget( std::make_unique< ToolBar >() );
44
45 /*
46 ** table view right under the toolbar
47 */
48 m_tableView = lw-> addWidget( std::make_unique< GCW::Gui::TableView >(), 1 );
49// tableView()-> setRowHeight( "20px" );
50
51 /*
52 ** Poke a status bar down at the bottom of the area.
53 */
54 m_statusBar = lw-> addWidget( std::make_unique< StatusBar >() );
55
56 /*
57 ** Configure the table view.
58 */
59 tableView()-> setSortingEnabled ( false );
60// tableView()-> setAlternatingRowColors ( true ); /// \todo need to redo this
61 tableView()-> setSelectionBehavior ( Wt::SelectionBehavior::Rows );
62 tableView()-> setSelectionMode ( Wt::SelectionMode::Single );
63// tableView()-> setEditTriggers ( Wt::EditTrigger::None );
64 tableView()-> setEditTriggers ( Wt::EditTrigger::SingleClicked );
65// tableView()-> setEditOptions ( Wt::EditOption::SingleEditor | Wt::EditOption::SaveWhenClosed );
66 tableView()-> setEditOptions ( Wt::EditOption::MultipleEditors | Wt::EditOption::LeaveEditorsOpen );
67
68 /*
69 ** in order to allow right-click in the browser this oncontextmenu
70 ** attribute must be set in the table which allows Wt to pick up the
71 ** right-click event.
72 */
73 tableView()-> setAttributeValue ( "oncontextmenu","event.cancelBubble=true;event.returnValue=false;return false;" );
74 tableView()-> mouseWentUp().connect( this, &Widget::on_showPopup_triggered );
75
76 /*
77 ** set the column delegates/editors
78 */
79 Editor::applyDelegates( tableView() );
80
81 tableView()-> headerClicked().connect( [=]( int col, Wt::WMouseEvent event )
82 {
83#ifdef NEVER
84 if( tableView()-> selectedIndexes().size() == 0 )
85 tableView()-> select( baseModel()-> index( 893, 0 ) );
86 else
87 tableView()-> clearSelection();
88#endif
89
90 std::cout << __FILE__ << ":" << __LINE__ << " headerClicked:" << col << std::endl;
91
92 });
93
94#ifdef NEVER
95 /*
96 ** This 'selectionChanged' procedure is 'clunky'.
97 **
98 ** This procedure is designed to respond to a row-selection
99 ** change event. When a different row is selected, we want
100 ** any open editors to be closed, and the row selection to
101 ** move to the newly selected row.
102 **
103 ** Right now the problem is with the 'select' command, where
104 ** it calling 'select' cause this 'selectionChanged' event
105 ** to fire again. So, there is a little 'selecting' interlock
106 ** built around it to try to prevent this weirdness.
107 **
108 ** The other problem with this routine is when 'selecting'
109 ** a cell that is editable, the editor is immediately engaged
110 ** but this 'selectionChanged' signal never fires... so we have
111 ** to sort that out.
112 */
113 tableView()->
114 selectionChanged().connect( [=]()
115 {
116 std::cout << __FILE__ << ":" << __LINE__
117 << " selectionChanged"
118 << std::endl;
119 });
120#endif
121
122#ifdef KEYPRESSED_ONLY_FIRES_WHEN_EDITORS_ARE_NOT_OPEN_NOT_USEFUL_HERE
123 tableView()->
124 keyPressed().connect( [=]( Wt::WKeyEvent _event )
125 {
126 std::cout << __FILE__ << ":" << __LINE__ << " " << _event.charCode() << std::endl;
127 });
128#endif
129
130 tableView()-> clicked().connect( this, &Widget::on_tableView_clicked );
131
132 m_baseModel = std::make_shared< BaseModel >();
133 m_sortFilterModel = std::make_shared< Wt::WSortFilterProxyModel >();
134// m_batchEditModel = std::make_shared< Wt::WBatchEditProxyModel >();
135
136//
137// m_sortFilterModel-> setSourceModel( m_baseModel );
138// m_sortFilterModel-> sort(0);
139// m_batchEditModel -> setSourceModel( m_sortFilterModel );
140// m_batchEditModel -> setSourceModel( m_baseModel );
141
142 baseModel()->
143 goneDirty().connect( [&]( Wt::WModelIndex _index )
144 {
145// std::cout << __FILE__ << ":" << __LINE__ << " " << _index.row() << std::endl;
146// baseModel()-> refreshFromDisk();
147// m_batchEditModel -> setSourceModel( m_baseModel );
148// std::cout << __FILE__ << ":" << __LINE__ << " " << _index.row() << std::endl;
149 });
150
151} // endinit()-> void
152
153
155Widget()
156{
157 init();
158
159
160} // endGCW::AccountRegister::AccountRegister( const std::string & _accountGuid )
161
162
163auto
166{
167#ifdef NEVER
168 std::cout << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__
169 << " index(" << _index.row() << "," << _index.column() << ")"
170 << " m_clicked(" << m_clickedIndex.row() << "," << m_clickedIndex.column() << ")"
171 << std::endl
172 ;
173#endif
174
175 /*
176 ** do the select-row business. this may seem somewhat redundant to call
177 ** selectRow again here, since clicking on the row causes it to be selected,
178 ** but we have additional logic we want to employ.
179 */
180 do_selectRow( _index );
181
182} // endtableView()->clicked().connect( [=]( Wt::WModelIndex _index, Wt::WMouseEvent _event )
183
184
185auto
187setReadOnly( bool _state )-> void
188{
189 baseModel()-> setReadOnly( _state );
190
191} // endsetReadOnly( bool _state = true )
192
193auto
195deleteRow( int _row )-> void
196{
197 /// \todo BUGBUG working on the register, fix this!
198
199 auto splitGuid = baseModel()-> getSplitGuid( _row );
200 auto transMan = GCW::Eng::Transaction::Manager();
201 transMan.loadSplit( splitGuid );
202 if( transMan.deleteTransaction() )
203 {
204 baseModel()-> removeRow( _row );
205 }
206
207} // enddeleteRow( int _row )-> void
208
209auto
211on_sortBy_triggered()-> void
212{
213 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
214
215} // endon_sortBy_triggered()-> void
216
217auto
220{
221 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
222
223} // endon_filterBy_triggered()-> void
224
225auto
228{
229 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
230
231} // endon_renamePage_triggered()-> void
232
233auto
236{
237 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
238
239} // endon_duplicate_triggered()-> void
240
241auto
243on_delete_triggered()-> void
244{
245 /*!
246 ** by default, the user will be asked to delete
247 ** an item from the register, unless they
248 ** have chosen to not be asked.
249 **
250 */
251 bool askThisSession = GCW::Dbo::Prefrences::get().askOnDeleteThisSession();
252 bool askForever = GCW::Dbo::Prefrences::get().askOnDeleteForever();
253
254 /*
255 ** ask sometimes
256 */
257 if( askThisSession && askForever )
258 {
259 /*
260 ** build out a dialog box to prompt the user to delete or not
261 */
262 auto msgBox = addChild( std::make_unique< Wt::WDialog >( TR("gcw.AccountRegister.delete.title") ) );
263 auto templt = msgBox-> contents()-> addNew< Wt::WTemplate >( TR("gcw.AccountRegister.delete.contents") );
264 msgBox-> setClosable( true );
265 msgBox-> setMovable ( true );
266 msgBox-> show(); // exec() blocks other users, show() does not
267
268 auto rememberAlways = templt-> bindNew< Wt::WCheckBox >( "rememberAlways" , TR("gcw.AccountRegister.delete.rem1" ) );
269 auto rememberSession = templt-> bindNew< Wt::WCheckBox >( "rememberSession", TR("gcw.AccountRegister.delete.rem2" ) );
270 auto pbCancel = templt-> bindNew< Wt::WPushButton >( "cancel" , TR("gcw.AccountRegister.delete.cancel") );
271 auto pbDelete = templt-> bindNew< Wt::WPushButton >( "delete" , TR("gcw.AccountRegister.delete.delete") );
272
273 rememberAlways -> setToolTip( TR( "gcw.AccountRegister.delete.rem1.toolTip" ) );
274 rememberSession -> setToolTip( TR( "gcw.AccountRegister.delete.rem2.toolTip" ) );
275 pbCancel -> setToolTip( TR( "gcw.AccountRegister.delete.cancel.toolTip" ) );
276 pbDelete -> setToolTip( TR( "gcw.AccountRegister.delete.delete.toolTip" ) );
277
278 auto splitGuid = baseModel()-> getSplitGuid( m_rightClickIndex.row() );
279 auto transMan = GCW::Eng::Transaction::Manager();
280 transMan.loadSplit( splitGuid );
281
282 templt-> bindString( "payFrom" , transMan.getFromAccount () );
283 templt-> bindString( "payTo" , transMan.getToAccount () );
284 templt-> bindString( "date" , transMan.getDateAsString () );
285 templt-> bindString( "desc" , transMan.getDescription () );
286 templt-> bindString( "amount" , transMan.getValueAsString() );
287
288 pbCancel-> clicked().connect( msgBox, &Wt::WDialog::reject );
289 pbDelete-> clicked().connect( msgBox, &Wt::WDialog::accept );
290
291 /*
292 ** when this option is selected, disable the other one
293 */
294 rememberAlways->
295 clicked().connect( [rememberSession,rememberAlways]()
296 {
297 rememberSession-> setDisabled( rememberAlways-> checkState() == Wt::CheckState::Checked );
298 });
299
300 /*
301 ** When the dialog finishes, it is either accepted or rejected.
302 ** In either case, the dialog will be removed from the addChild
303 ** from earlier so we ain't gots no memory leaks.
304 */
305 msgBox->
306 finished().connect( [this,rememberSession,msgBox]( Wt::DialogCode _code )
307 {
308 if( _code == Wt::DialogCode::Accepted )
309 {
310 GCW::Dbo::Prefrences::get().setAskOnDeleteThisSession( rememberSession-> checkState() != Wt::CheckState::Checked );
311
312 deleteRow( m_rightClickIndex.row() );
313
314 }
315 removeChild( msgBox );
316 });
317
318 } // endif( ..askFirst.. )
319
320 /*
321 ** don't ask, just delete
322 */
323 else
324 {
325 deleteRow( m_rightClickIndex.row() );
326 }
327
328} // endon_delete_triggered()-> void
329
330auto
333{
334 /*
335 ** build out a dialog box to prompt the user to delete or not
336 */
337 auto msgBox = addChild( std::make_unique< Wt::WDialog >( TR("gcw.AccountRegister.details.title") ) );
338
339 auto detailWidget = msgBox-> contents()-> addNew< GCW::Gui::TransactionDetailWidget >();
340 msgBox-> setClosable( true );
341 msgBox-> rejectWhenEscapePressed();
342 msgBox-> setMovable ( true );
343 msgBox-> show(); // exec() blocks other users, show() does not
344
345 auto splitGuid = baseModel()-> getSplitGuid( m_rightClickIndex.row() );
346 detailWidget-> setSplitGuid( splitGuid );
347
348 /*
349 ** hitting OK will save the data, then close the window
350 */
351 msgBox-> contents()-> addNew< Wt::WPushButton >( TR("gcw.ok") )->
352 clicked().connect( [this,msgBox,detailWidget]()
353 {
354 detailWidget-> saveData();
355 msgBox-> done( Wt::DialogCode::Accepted );
356 });
357
358 /*
359 ** When the widget finishes the dialog will be removed from
360 ** the addChild from earlier so we ain't gots no memory leaks.
361 */
362 msgBox->
363 finished().connect( [this,msgBox]( Wt::DialogCode _code )
364 {
365 removeChild( msgBox );
366 });
367
368
369} // endon_details_triggered()-> void
370
371auto
374{
375 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
376
377} // endon_removeSplits_triggered()-> void
378
379auto
381on_enter_triggered()-> void
382{
383 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
384
385} // endon_enter_triggered()-> void;
386
387auto
389on_cancel_triggered()-> void
390{
391 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
392
393} // endon_cancel_triggered()-> void;
394
395auto
398{
399 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
400
401
402} // endon_manageDocument_triggered()-> void
403
404auto
407{
408 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
409
410} // endon_openDocument_triggered()-> void
411
412auto
415{
416 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
417
418} // endon_blankTransaction_triggered()-> void
419
420auto
422on_goDate_triggered()-> void
423{
424 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
425
426} // endon_goDate_triggered()-> void
427
428auto
431{
432 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
433
434} // endon_splitTransaction_triggered()-> void
435
436auto
439{
440 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
441
442} // endon_editExchangeRate_triggered()-> void
443
444auto
447{
448 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
449
450} // endon_schedule_triggered()-> void
451
452auto
454on_jump_triggered()-> void
455{
456 /*
457 ** use a transaction manager so we can find the other split guid
458 */
459 auto transMan = GCW::Eng::Transaction::Manager();
460 transMan.loadSplit( baseModel()-> getSplitGuid( m_rightClickIndex.row() ) );
461
462 /*!
463 ** \todo should deal with multiple splits
464 **
465 ** This function will emit the guid of the account of the 'other'
466 ** split used in this transaction. But, a transaction may contain
467 ** multiple splits. In that instance, this jump routine should
468 ** make some different decisions about where to jump. In gnucash,
469 ** it indicates that the jump will jump to the 'highest value'
470 ** split... that could work.
471 */
472 jumpToAccount().emit( transMan.thatSplit()-> guid() );
473
474} // endon_jump_triggered()-> void
475
476auto
478on_edit_triggered()-> void
479{
480
481
482} // endon_edit_triggered()-> void
483
484auto
487{
488 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
489
490} // endon_assignPayment_triggered()-> void
491
492auto
494on_showPopup_triggered( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void
495{
496 /*
497 ** pop-up is only on right-click
498 */
499 if( _event.button() != Wt::MouseButton::Right )
500 return;
501
502 /*
503 ** remember
504 */
505 m_rightClickIndex = _index;
506
507 /*
508 ** Set up the items in the pop-up menu
509 ** (some of the items are dependent on which row was clicked on
510 ** so we dump everything from the popup and reload)
511 **
512 ** NOTE: we're doing this because m_popupMenu is local (ie; not
513 ** a pointer!) so it is persistent within this object. So,
514 ** anything we do in it needs to be reset before we do anything
515 ** else.
516 */
517 while( m_popupMenu.count() )
518 m_popupMenu.removeItem( m_popupMenu.itemAt(0) );
519
520#ifdef NEVER
521 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.SortBy" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
522 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.FilterBy" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
523 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.RenamePage" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
524 m_popupMenu.addSeparator();
525 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Duplicate" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
526#endif
527
528 // delete
529 {
530 auto item = m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Delete"), this, &Widget::on_delete_triggered );
531
532 /*
533 ** delete doesn't work on the 'new' line (need a split guid)
534 */
535 if( !(baseModel()-> isDeletable( _index )) )
536 item-> setDisabled( true );
537 }
538
539 // details
540 {
541 auto item = m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Details"), this, &Widget::on_details_triggered );
542 }
543
544#ifdef NEVER
545 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.RemoveSplits" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
546 m_popupMenu.addSeparator();
547 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Enter" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
548 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Cancel" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
549 m_popupMenu.addSeparator();
550 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.ManageDocument" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
551 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.OpenDocument" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
552#endif
553
554 m_popupMenu.addSeparator();
555
556 // jump
557 {
558 /*
559 ** create the menu item
560 */
561 auto item =
562 m_popupMenu
563 .addItem
564 (
565 TR( "gcw.AccountRegister.Popup.Jump" ),
566 this,
568 );
569
570 if( !(baseModel()-> isJumpable( _index )) )
571 item-> setDisabled( true );
572 }
573
574 // edit
575// {
576// auto item =
577// m_popupMenu
578// .addItem
579// (
580// TR( "gcw.AccountRegister.Popup.edit" ),
581// this,
582// &Widget::on_edit_triggered
583// );
584// }
585
586
587
588#ifdef NEVER
589 m_popupMenu.addSeparator();
590 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.BlankTransaction" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
591 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.GoDate" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
592 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.SplitTransaction" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
593 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.EditExchangeRate" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
594 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Schedule" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
595 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Jump" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
596 m_popupMenu.addSeparator();
597 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.AssignPayment" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
598#endif
599
600 // Select the item, if it was not yet selected.
601 if( !tableView()-> isSelected( _index ) )
602 {
603 tableView()-> select( _index, Wt::SelectionFlag::ClearAndSelect );
604 editRow( _index );
605 }
606
607 if( m_popupMenu.isHidden() )
608 {
609 m_popupMenu.popup( _event );
610 }
611 else
612 {
613 m_popupMenu.hide();
614 }
615
616} // endon_showPopup_triggered( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void
617
618
619auto
621setAccountGuid( const std::string & _accountGuid )-> void
622{
623 m_accountGuid = _accountGuid;
624
625 baseModel()-> setAccountGuid( _accountGuid );
626
627 tableView()-> setModel( m_baseModel );
628
629 loadData();
630
631 /*
632 ** Scroll to the bottom of the view, and select the last row.
633 */
634 do_selectRow( lastIndex() );
635
636} // endsetAccountGuid( const std::string & _accountGuid )-> void
637
638auto
640setDoubleLine( bool _state )-> void
641{
642 baseModel()-> setDoubleLine( _state );
643
644 if( tableView()-> selectedIndexes().size() )
645 {
646 auto index = *tableView()-> selectedIndexes().begin();
647
648 tableView()-> scrollTo( index );
649 tableView()-> select( index, Wt::SelectionFlag::ClearAndSelect );
650 }
651
652} // endsetDoubleLine( bool _state )-> void
653
654auto
657{
658 return baseModel()-> index( baseModel()-> rowCount() -1, 0 );
659
660} // endlastIndex()-> Wt::WModelIndex
661
662auto
664loadData()-> void
665{
666 // 0 = Date
667 tableView()-> setColumnWidth ( asInt( Col::DATE ), "125px" );
668 tableView()-> setHeaderAlignment( asInt( Col::DATE ), Wt::AlignmentFlag::Right );
669 tableView()-> setColumnAlignment( asInt( Col::DATE ), Wt::AlignmentFlag::Right );
670
671 // 1 = Action/Num
672 tableView()-> setColumnWidth ( asInt( Col::ACTION ), "50px" );
673 tableView()-> setHeaderAlignment( asInt( Col::ACTION ), Wt::AlignmentFlag::Center );
674 tableView()-> setColumnAlignment( asInt( Col::ACTION ), Wt::AlignmentFlag::Center );
675
676 // 2 = Memo/Description
677 tableView()-> setColumnWidth ( asInt( Col::DESCRIPTION ), "99%" );
678 tableView()-> setHeaderAlignment( asInt( Col::DESCRIPTION ), Wt::AlignmentFlag::Left );
679 tableView()-> setColumnAlignment( asInt( Col::DESCRIPTION ), Wt::AlignmentFlag::Left );
680
681 // 3 = Account/Transfer
682 tableView()-> setColumnWidth ( asInt( Col::TRANSFER ), "150px" );
683 tableView()-> setHeaderAlignment( asInt( Col::TRANSFER ), Wt::AlignmentFlag::Right );
684 tableView()-> setColumnAlignment( asInt( Col::TRANSFER ), Wt::AlignmentFlag::Right );
685
686 // 4 = Reconciliation
687 tableView()-> setColumnWidth ( asInt( Col::RECONCILE ), "25px" );
688 tableView()-> setHeaderAlignment( asInt( Col::RECONCILE ), Wt::AlignmentFlag::Center );
689 tableView()-> setColumnAlignment( asInt( Col::RECONCILE ), Wt::AlignmentFlag::Center );
690
691 // 5 = Debit
692 tableView()-> setColumnWidth ( asInt( Col::DEBIT ), "85px" );
693 tableView()-> setHeaderAlignment( asInt( Col::DEBIT ), Wt::AlignmentFlag::Right );
694 tableView()-> setColumnAlignment( asInt( Col::DEBIT ), Wt::AlignmentFlag::Right );
695
696 // 6 = Credit
697 tableView()-> setColumnWidth ( asInt( Col::CREDIT ), "85px" );
698 tableView()-> setHeaderAlignment( asInt( Col::CREDIT ), Wt::AlignmentFlag::Right );
699 tableView()-> setColumnAlignment( asInt( Col::CREDIT ), Wt::AlignmentFlag::Right );
700
701 // 7 = Balance
702 tableView()-> setColumnWidth ( asInt( Col::BALANCE ), "85px" );
703 tableView()-> setHeaderAlignment( asInt( Col::BALANCE ), Wt::AlignmentFlag::Right );
704 tableView()-> setColumnAlignment( asInt( Col::BALANCE ), Wt::AlignmentFlag::Right );
705
706 statusBar()-> setPresent ( baseModel()-> present () );
707 statusBar()-> setProjected ( baseModel()-> projected () );
708 statusBar()-> setReconciled ( baseModel()-> reconciled () );
709 statusBar()-> setFuture ( baseModel()-> future () );
710 statusBar()-> setCleared ( baseModel()-> cleared () );
711 statusBar()-> setRowCount ( baseModel()-> splitCount () );
712
713} // endloadData()-> void
714
715//auto
716//GCW::Gui::AccountRegister::
717//editRow( Wt::WModelIndex _index )-> void
718//{
719// tableView()-> closeEditors( true );
720// ( _index.row() );
721//
722//} // endeditRow( Wt::WModelIndex _index )-> void
723
724auto
726do_selectRow( Wt::WModelIndex _index )-> void
727{
728 /*
729 ** if the row hasn't changed, do nothing
730 */
731 if( m_selectIndex.isValid() )
732 if( m_selectIndex.row() == _index.row() )
733 return;
734
735 m_selectIndex = _index;
736
737#ifdef NEVER
738 std::cout << __FILE__ << ":" << __LINE__
739 << " " << __FUNCTION__ << "(" << _index.row() << ")"
740 << " isR/O:" << baseModel()-> isReadOnly( _index.row() )
741 << " i(" << _index.row() << "," << _index.column() << ")"
742 << " si(" << m_selectIndex.row() << "," << m_selectIndex.column() << ")"
743 << std::endl;
744 wApp-> processEvents();
745#endif
746
747 tableView()-> closeEditors( true );
748 tableView()-> scrollTo( _index );
749 tableView()-> select( _index, Wt::SelectionFlag::ClearAndSelect );
750
751 if( !baseModel()-> isReadOnly( _index.row() ) )
752 editRow( _index );
753
754} // enddo_selectRow( Wt::WModelIndex _index )-> void
755
756auto
758selectSplit( const std::string & _guid )-> void
759{
760 auto row = baseModel()-> getSplitRow( _guid );
761
762 if( row > -1 )
763 {
764 /*!
765 ** \todo determine best method to use here - table is not 'selecting/highlighting' properly
766 */
767 tableView()-> clicked().emit( baseModel()-> index( row, 0 ), Wt::WMouseEvent() );
768// on_tableView_clicked( baseModel()-> index( row, 0 ), Wt::WMouseEvent() );
769 }
770
771} // enddo_selectRow( Wt::WModelIndex _index )-> void
772
773auto
775editRow( Wt::WModelIndex _index )-> void
776{
777#ifdef NEVER
778 std::cout << __FILE__ << ":" << __LINE__
779 << " " << __FUNCTION__ << "(" << _index.row() << "," << _index.column() << ")"
780 << " ro:" << baseModel()-> isReadOnly( _index.row() )
781 << " sel:" << tableView()-> selectedIndexes().size()
782 << std::endl;
783#endif
784
785// tableView()-> clearSelection();
786 tableView()-> closeEditors( true );
787 Editor editor( tableView() );
788 editor.editRow( _index );
789
790} // endeditRow( Wt::WModelIndex _index )-> void
791
792auto
794toJson() const-> Wt::Json::Object
795{
796 Wt::Json::Object jobj;
797
798 return jobj;
799}
800
801auto
803fromJson( const Wt::Json::Object & _jobj )-> bool
804{
805 return true;
806}
807
808
809
810void
812test()
813{
814 std::cout << __FILE__ << ":" << __LINE__ << " ::test::" << std::endl;
815
816 std::cout << __FILE__ << ":" << __LINE__ << " " << tableView()-> selectedIndexes().size() << std::endl;
817
818 auto selectedIndex = *tableView()-> selectedIndexes().begin();
819
820 if( selectedIndex.isValid() )
821 {
822
823 std::cout << __FILE__ << ":" << __LINE__ << " " << tableView()-> selectedIndexes().size() << std::endl;
824
825 }
826
827
828} // endvoid GCW::Gui::AccountRegister::test()
829
830
Account Register Editor.
Definition Editor.h:43
auto editRow(Wt::WModelIndex _index) -> void
Edit Row.
Definition Editor.cpp:172
auto selectSplit(const std::string &_guid) -> void
Select Split.
Definition Widget.cpp:758
auto on_showPopup_triggered(const Wt::WModelIndex &_index, const Wt::WMouseEvent &_event) -> void
Show Popup.
Definition Widget.cpp:494
auto fromJson(const Wt::Json::Object &_jobj) -> bool
Set View Properties from JSON Object.
Definition Widget.cpp:803
auto on_cancel_triggered() -> void
Cancel Transaction.
Definition Widget.cpp:389
auto lastIndex() -> Wt::WModelIndex
Last Index.
Definition Widget.cpp:656
auto on_details_triggered() -> void
Detail a Row.
Definition Widget.cpp:332
auto on_removeSplits_triggered() -> void
Remove Splits.
Definition Widget.cpp:373
auto on_editExchangeRate_triggered() -> void
Edit Exchange Rate.
Definition Widget.cpp:438
auto on_renamePage_triggered() -> void
Definition Widget.cpp:227
auto setReadOnly(bool _state=true) -> void
Set Read Only.
Definition Widget.cpp:187
auto on_splitTransaction_triggered() -> void
Split Transaction.
Definition Widget.cpp:430
auto on_filterBy_triggered() -> void
Definition Widget.cpp:219
auto deleteRow(int _row) -> void
Delete Row.
Definition Widget.cpp:195
auto on_assignPayment_triggered() -> void
Assign Payment.
Definition Widget.cpp:486
auto do_selectRow(Wt::WModelIndex _index) -> void
Select Row.
Definition Widget.cpp:726
auto on_jump_triggered() -> void
Jump to Transaction.
Definition Widget.cpp:454
auto editRow(Wt::WModelIndex _index) -> void
Edit Row.
Definition Widget.cpp:775
auto setAccountGuid(const std::string &_accountGuid) -> void
Set Account.
Definition Widget.cpp:621
auto on_duplicate_triggered() -> void
Definition Widget.cpp:235
auto on_delete_triggered() -> void
Delete a Row.
Definition Widget.cpp:243
auto on_schedule_triggered() -> void
Schedule a Transaction.
Definition Widget.cpp:446
auto init() -> void
Internal Initializer.
Definition Widget.cpp:27
auto loadData() -> void
Editor Helper.
Definition Widget.cpp:664
auto on_blankTransaction_triggered() -> void
Blank Transaction.
Definition Widget.cpp:414
auto on_manageDocument_triggered() -> void
Manage Document.
Definition Widget.cpp:397
auto setDoubleLine(bool _state) -> void
Definition Widget.cpp:640
auto on_openDocument_triggered() -> void
Open Document.
Definition Widget.cpp:406
auto on_goDate_triggered() -> void
Go to Date.
Definition Widget.cpp:422
auto on_enter_triggered() -> void
Enter Transaction.
Definition Widget.cpp:381
auto on_edit_triggered() -> void
Edit to Transaction.
Definition Widget.cpp:478
auto toJson() const -> Wt::Json::Object
Create View Properties JSON Object.
Definition Widget.cpp:794
auto on_tableView_clicked(Wt::WModelIndex _index, Wt::WMouseEvent _event) -> void
Clicked Handler.
Definition Widget.cpp:165
virtual void accept()
virtual void reject()
int charCode() const
#define TR(X)
Definition define.h:17
auto get() -> GCW::Dbo::Prefrences::Item
constexpr int asInt(Col col) noexcept
Definition ViewMode.h:67
DialogCode