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