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// m_sortFilterModel-> setSourceModel( m_baseModel );
135// m_sortFilterModel-> sort(0);
136// m_batchEditModel -> setSourceModel( m_sortFilterModel );
137// m_batchEditModel -> setSourceModel( m_baseModel );
138
139 baseModel()->
140 goneDirty().connect( [&]( Wt::WModelIndex _index )
141 {
142// std::cout << __FILE__ << ":" << __LINE__ << " " << _index.row() << std::endl;
143// baseModel()-> refreshFromDisk();
144// m_batchEditModel -> setSourceModel( m_baseModel );
145// std::cout << __FILE__ << ":" << __LINE__ << " " << _index.row() << std::endl;
146 });
147
148} // endinit()-> void
149
150
152Widget()
153{
154 init();
155
156
157} // endGCW::AccountRegister::AccountRegister( const std::string & _accountGuid )
158
159
160auto
163{
164#ifdef NEVER
165 std::cout << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__
166 << " index(" << _index.row() << "," << _index.column() << ")"
167 << " m_clicked(" << m_clickedIndex.row() << "," << m_clickedIndex.column() << ")"
168 << std::endl
169 ;
170#endif
171
172 /*
173 ** do the select-row business. this may seem somewhat redundant to call
174 ** selectRow again here, since clicking on the row causes it to be selected,
175 ** but we have additional logic we want to employ.
176 */
177 do_selectRow( _index );
178
179} // endtableView()->clicked().connect( [=]( Wt::WModelIndex _index, Wt::WMouseEvent _event )
180
181
182auto
184setReadOnly( bool _state )-> void
185{
186 baseModel()-> setReadOnly( _state );
187
188} // endsetReadOnly( bool _state = true )
189
190auto
192deleteRow( int _row )-> void
193{
194 /// \todo BUGBUG working on the register, fix this!
195
196 auto splitGuid = baseModel()-> getSplitGuid( _row );
197 auto transMan = GCW::Eng::Transaction::Manager();
198 transMan.loadSplit( splitGuid );
199 if( transMan.deleteTransaction() )
200 {
201 baseModel()-> removeRow( _row );
202 }
203
204} // enddeleteRow( int _row )-> void
205
206auto
208on_sortBy_triggered()-> void
209{
210 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
211
212} // endon_sortBy_triggered()-> void
213
214auto
217{
218 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
219
220} // endon_filterBy_triggered()-> void
221
222auto
225{
226 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
227
228} // endon_renamePage_triggered()-> void
229
230auto
233{
234 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
235
236} // endon_duplicate_triggered()-> void
237
238auto
240on_delete_triggered()-> void
241{
242 /*!
243 ** by default, the user will be asked to delete
244 ** an item from the register, unless they
245 ** have chosen to never be asked.
246 **
247 ** \bug the logic here is not correct
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() doesn't
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 don't got 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 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
333
334} // endon_removeSplits_triggered()-> void
335
336auto
338on_enter_triggered()-> void
339{
340 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
341
342} // endon_enter_triggered()-> void;
343
344auto
346on_cancel_triggered()-> void
347{
348 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
349
350} // endon_cancel_triggered()-> void;
351
352auto
355{
356 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
357
358
359} // endon_manageDocument_triggered()-> void
360
361auto
364{
365 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
366
367} // endon_openDocument_triggered()-> void
368
369auto
372{
373 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
374
375} // endon_blankTransaction_triggered()-> void
376
377auto
379on_goDate_triggered()-> void
380{
381 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
382
383} // endon_goDate_triggered()-> void
384
385auto
388{
389 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
390
391} // endon_splitTransaction_triggered()-> void
392
393auto
396{
397 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
398
399} // endon_editExchangeRate_triggered()-> void
400
401auto
404{
405 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
406
407} // endon_schedule_triggered()-> void
408
409auto
411on_jump_triggered()-> void
412{
413 /*
414 ** use a transaction manager so we can find the other split guid
415 */
416 auto transMan = GCW::Eng::Transaction::Manager();
417 transMan.loadSplit( baseModel()-> getSplitGuid( m_rightClickIndex.row() ) );
418
419 /*!
420 ** \todo should deal with multiple splits
421 **
422 ** This function will emit the guid of the account of the 'other'
423 ** split used in this transaction. But, a transaction may contain
424 ** multiple splits. In that instance, this jump routine should
425 ** make some different decisions about where to jump. In gnucash,
426 ** it indicates that the jump will jump to the 'highest value'
427 ** split... that could work.
428 */
429 jumpToAccount().emit( transMan.thatSplit()-> guid() );
430
431} // endon_jump_triggered()-> void
432
433auto
435on_edit_triggered()-> void
436{
437
438
439} // endon_edit_triggered()-> void
440
441auto
444{
445 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
446
447} // endon_assignPayment_triggered()-> void
448
449auto
451on_showPopup_triggered( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void
452{
453 /*
454 ** pop-up is only on right-click
455 */
456 if( _event.button() != Wt::MouseButton::Right )
457 return;
458
459 /*
460 ** remember
461 */
462 m_rightClickIndex = _index;
463
464 /*
465 ** Set up the items in the pop-up menu
466 ** (some of the items are dependent on which row was clicked on
467 ** so we dump everything from the popup and reload)
468 **
469 ** NOTE: we're doing this because m_popupMenu is local (ie; not
470 ** a pointer!) so it is persistent within this object. So,
471 ** anything we do in it needs to be reset before we do anything
472 ** else.
473 */
474 while( m_popupMenu.count() )
475 m_popupMenu.removeItem( m_popupMenu.itemAt(0) );
476
477#ifdef NEVER
478 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.SortBy" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
479 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.FilterBy" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
480 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.RenamePage" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
481 m_popupMenu.addSeparator();
482 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Duplicate" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
483#endif
484
485 // delete
486 {
487 auto item = m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Delete"), this, &Widget::on_delete_triggered );
488
489 /*
490 ** delete doesn't work on the 'new' line (need a split guid)
491 */
492 if( !(baseModel()-> isDeletable( _index )) )
493 item-> setDisabled( true );
494 }
495
496#ifdef NEVER
497 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.RemoveSplits" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
498 m_popupMenu.addSeparator();
499 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Enter" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
500 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Cancel" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
501 m_popupMenu.addSeparator();
502 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.ManageDocument" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
503 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.OpenDocument" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
504#endif
505
506 m_popupMenu.addSeparator();
507
508 // jump
509 {
510 /*
511 ** create the menu item
512 */
513 auto item =
514 m_popupMenu
515 .addItem
516 (
517 TR( "gcw.AccountRegister.Popup.Jump" ),
518 this,
520 );
521
522 if( !(baseModel()-> isJumpable( _index )) )
523 item-> setDisabled( true );
524 }
525
526 // edit
527// {
528// auto item =
529// m_popupMenu
530// .addItem
531// (
532// TR( "gcw.AccountRegister.Popup.edit" ),
533// this,
534// &Widget::on_edit_triggered
535// );
536// }
537
538
539
540#ifdef NEVER
541 m_popupMenu.addSeparator();
542 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.BlankTransaction" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
543 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.GoDate" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
544 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.SplitTransaction" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
545 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.EditExchangeRate" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
546 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Schedule" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
547 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.Jump" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
548 m_popupMenu.addSeparator();
549 m_popupMenu.addItem( TR( "gcw.AccountRegister.Popup.AssignPayment" ), std::make_unique< Wt::WText >() )-> setDisabled( true );
550#endif
551
552 // Select the item, if it was not yet selected.
553 if( !tableView()-> isSelected( _index ) )
554 {
555 tableView()-> select( _index, Wt::SelectionFlag::ClearAndSelect );
556 editRow( _index );
557 }
558
559 if( m_popupMenu.isHidden() )
560 {
561 m_popupMenu.popup( _event );
562 }
563 else
564 {
565 m_popupMenu.hide();
566 }
567
568} // endon_showPopup_triggered( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void
569
570
571auto
573setAccountGuid( const std::string & _accountGuid )-> void
574{
575 m_accountGuid = _accountGuid;
576
577 baseModel()-> setAccountGuid( _accountGuid );
578
579 tableView()-> setModel( m_baseModel );
580
581 loadData();
582
583 /*
584 ** Scroll to the bottom of the view, and select the last row.
585 */
586 do_selectRow( lastIndex() );
587
588} // endsetAccountGuid( const std::string & _accountGuid )-> void
589
590auto
592setDoubleLine( bool _state )-> void
593{
594 baseModel()-> setDoubleLine( _state );
595
596 if( tableView()-> selectedIndexes().size() )
597 {
598 auto index = *tableView()-> selectedIndexes().begin();
599
600 tableView()-> scrollTo( index );
601 tableView()-> select( index, Wt::SelectionFlag::ClearAndSelect );
602 }
603
604} // endsetDoubleLine( bool _state )-> void
605
606auto
609{
610 return baseModel()-> index( baseModel()-> rowCount() -1, 0 );
611
612} // endlastIndex()-> Wt::WModelIndex
613
614auto
616loadData()-> void
617{
618 // 0 = Date
619 tableView()-> setColumnWidth ( asInt( Col::DATE ), "125px" );
620 tableView()-> setHeaderAlignment( asInt( Col::DATE ), Wt::AlignmentFlag::Right );
621 tableView()-> setColumnAlignment( asInt( Col::DATE ), Wt::AlignmentFlag::Right );
622
623 // 1 = Action/Num
624 tableView()-> setColumnWidth ( asInt( Col::ACTION ), "50px" );
625 tableView()-> setHeaderAlignment( asInt( Col::ACTION ), Wt::AlignmentFlag::Center );
626 tableView()-> setColumnAlignment( asInt( Col::ACTION ), Wt::AlignmentFlag::Center );
627
628 // 2 = Memo/Description
629 tableView()-> setColumnWidth ( asInt( Col::DESCRIPTION ), "99%" );
630 tableView()-> setHeaderAlignment( asInt( Col::DESCRIPTION ), Wt::AlignmentFlag::Left );
631 tableView()-> setColumnAlignment( asInt( Col::DESCRIPTION ), Wt::AlignmentFlag::Left );
632
633 // 3 = Account/Transfer
634 tableView()-> setColumnWidth ( asInt( Col::TRANSFER ), "150px" );
635 tableView()-> setHeaderAlignment( asInt( Col::TRANSFER ), Wt::AlignmentFlag::Right );
636 tableView()-> setColumnAlignment( asInt( Col::TRANSFER ), Wt::AlignmentFlag::Right );
637
638 // 4 = Reconciliation
639 tableView()-> setColumnWidth ( asInt( Col::RECONCILE ), "25px" );
640 tableView()-> setHeaderAlignment( asInt( Col::RECONCILE ), Wt::AlignmentFlag::Center );
641 tableView()-> setColumnAlignment( asInt( Col::RECONCILE ), Wt::AlignmentFlag::Center );
642
643 // 5 = Debit
644 tableView()-> setColumnWidth ( asInt( Col::DEBIT ), "85px" );
645 tableView()-> setHeaderAlignment( asInt( Col::DEBIT ), Wt::AlignmentFlag::Right );
646 tableView()-> setColumnAlignment( asInt( Col::DEBIT ), Wt::AlignmentFlag::Right );
647
648 // 6 = Credit
649 tableView()-> setColumnWidth ( asInt( Col::CREDIT ), "85px" );
650 tableView()-> setHeaderAlignment( asInt( Col::CREDIT ), Wt::AlignmentFlag::Right );
651 tableView()-> setColumnAlignment( asInt( Col::CREDIT ), Wt::AlignmentFlag::Right );
652
653 // 7 = Balance
654 tableView()-> setColumnWidth ( asInt( Col::BALANCE ), "85px" );
655 tableView()-> setHeaderAlignment( asInt( Col::BALANCE ), Wt::AlignmentFlag::Right );
656 tableView()-> setColumnAlignment( asInt( Col::BALANCE ), Wt::AlignmentFlag::Right );
657
658 statusBar()-> setPresent ( baseModel()-> present () );
659 statusBar()-> setProjected ( baseModel()-> projected () );
660 statusBar()-> setReconciled ( baseModel()-> reconciled () );
661 statusBar()-> setFuture ( baseModel()-> future () );
662 statusBar()-> setCleared ( baseModel()-> cleared () );
663 statusBar()-> setRowCount ( baseModel()-> splitCount () );
664
665} // endloadData()-> void
666
667//auto
668//GCW::Gui::AccountRegister::
669//editRow( Wt::WModelIndex _index )-> void
670//{
671// tableView()-> closeEditors( true );
672// ( _index.row() );
673//
674//} // endeditRow( Wt::WModelIndex _index )-> void
675
676auto
678do_selectRow( Wt::WModelIndex _index )-> void
679{
680 /*
681 ** if the row hasn't changed, do nothing
682 */
683 if( m_selectIndex.isValid() )
684 if( m_selectIndex.row() == _index.row() )
685 return;
686
687 m_selectIndex = _index;
688
689#ifdef NEVER
690 std::cout << __FILE__ << ":" << __LINE__
691 << " " << __FUNCTION__ << "(" << _index.row() << ")"
692 << " isR/O:" << baseModel()-> isReadOnly( _index.row() )
693 << " i(" << _index.row() << "," << _index.column() << ")"
694 << " si(" << m_selectIndex.row() << "," << m_selectIndex.column() << ")"
695 << std::endl;
696 wApp-> processEvents();
697#endif
698
699 tableView()-> closeEditors( true );
700 tableView()-> scrollTo( _index );
701 tableView()-> select( _index, Wt::SelectionFlag::ClearAndSelect );
702
703 if( !baseModel()-> isReadOnly( _index.row() ) )
704 editRow( _index );
705
706} // enddo_selectRow( Wt::WModelIndex _index )-> void
707
708auto
710selectSplit( const std::string & _guid )-> void
711{
712 auto row = baseModel()-> getSplitRow( _guid );
713
714 if( row > -1 )
715 {
716 /*!
717 ** \todo determine best method to use here - table is not 'selecting/highlighting' properly
718 */
719 tableView()-> clicked().emit( baseModel()-> index( row, 0 ), Wt::WMouseEvent() );
720// on_tableView_clicked( baseModel()-> index( row, 0 ), Wt::WMouseEvent() );
721 }
722
723} // enddo_selectRow( Wt::WModelIndex _index )-> void
724
725auto
727editRow( Wt::WModelIndex _index )-> void
728{
729#ifdef NEVER
730 std::cout << __FILE__ << ":" << __LINE__
731 << " " << __FUNCTION__ << "(" << _index.row() << "," << _index.column() << ")"
732 << " ro:" << baseModel()-> isReadOnly( _index.row() )
733 << " sel:" << tableView()-> selectedIndexes().size()
734 << std::endl;
735#endif
736
737// tableView()-> clearSelection();
738 tableView()-> closeEditors( true );
739 Editor editor( tableView() );
740 editor.editRow( _index );
741
742} // endeditRow( Wt::WModelIndex _index )-> void
743
744auto
746toJson() const-> Wt::Json::Object
747{
748 Wt::Json::Object jobj;
749
750 return jobj;
751}
752
753auto
755fromJson( const Wt::Json::Object & _jobj )-> bool
756{
757 return true;
758}
759
760
761
762void
764test()
765{
766 std::cout << __FILE__ << ":" << __LINE__ << " ::test::" << std::endl;
767
768 std::cout << __FILE__ << ":" << __LINE__ << " " << tableView()-> selectedIndexes().size() << std::endl;
769
770 auto selectedIndex = *tableView()-> selectedIndexes().begin();
771
772 if( selectedIndex.isValid() )
773 {
774
775 std::cout << __FILE__ << ":" << __LINE__ << " " << tableView()-> selectedIndexes().size() << std::endl;
776
777 }
778
779
780} // endvoid GCW::Gui::AccountRegister::test()
781
782
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:710
auto on_showPopup_triggered(const Wt::WModelIndex &_index, const Wt::WMouseEvent &_event) -> void
Show Popup.
Definition Widget.cpp:451
auto fromJson(const Wt::Json::Object &_jobj) -> bool
Set View Properties from JSON Object.
Definition Widget.cpp:755
auto on_cancel_triggered() -> void
Cancel Transaction.
Definition Widget.cpp:346
auto lastIndex() -> Wt::WModelIndex
Last Index.
Definition Widget.cpp:608
auto on_removeSplits_triggered() -> void
Remove Splits.
Definition Widget.cpp:330
auto on_editExchangeRate_triggered() -> void
Edit Exchange Rate.
Definition Widget.cpp:395
auto on_renamePage_triggered() -> void
Definition Widget.cpp:224
auto setReadOnly(bool _state=true) -> void
Set Read Only.
Definition Widget.cpp:184
auto on_splitTransaction_triggered() -> void
Split Transaction.
Definition Widget.cpp:387
auto on_filterBy_triggered() -> void
Definition Widget.cpp:216
auto deleteRow(int _row) -> void
Delete Row.
Definition Widget.cpp:192
auto on_assignPayment_triggered() -> void
Assign Payment.
Definition Widget.cpp:443
auto do_selectRow(Wt::WModelIndex _index) -> void
Select Row.
Definition Widget.cpp:678
auto on_jump_triggered() -> void
Jump to Transaction.
Definition Widget.cpp:411
auto editRow(Wt::WModelIndex _index) -> void
Edit Row.
Definition Widget.cpp:727
auto setAccountGuid(const std::string &_accountGuid) -> void
Set Account.
Definition Widget.cpp:573
auto on_duplicate_triggered() -> void
Definition Widget.cpp:232
auto on_delete_triggered() -> void
Delete a Row.
Definition Widget.cpp:240
auto on_schedule_triggered() -> void
Schedule a Transaction.
Definition Widget.cpp:403
auto init() -> void
Internal Initializer.
Definition Widget.cpp:26
auto loadData() -> void
Editor Helper.
Definition Widget.cpp:616
auto on_blankTransaction_triggered() -> void
Blank Transaction.
Definition Widget.cpp:371
auto on_manageDocument_triggered() -> void
Manage Document.
Definition Widget.cpp:354
auto setDoubleLine(bool _state) -> void
Definition Widget.cpp:592
auto on_openDocument_triggered() -> void
Open Document.
Definition Widget.cpp:363
auto on_goDate_triggered() -> void
Go to Date.
Definition Widget.cpp:379
auto on_enter_triggered() -> void
Enter Transaction.
Definition Widget.cpp:338
auto on_edit_triggered() -> void
Edit to Transaction.
Definition Widget.cpp:435
auto toJson() const -> Wt::Json::Object
Create View Properties JSON Object.
Definition Widget.cpp:746
auto on_tableView_clicked(Wt::WModelIndex _index, Wt::WMouseEvent _event) -> void
Clicked Handler.
Definition Widget.cpp:162
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