GnuCashew ~ GnuCash Enabled Web
GCW
CustomersModel.cpp
Go to the documentation of this file.
1 #line 2 "src/Eng/CustomersModel.cpp"
2 
3 //#include <gnucash/gncCustomer.h>
4 
5 #include "../App.h"
6 #include "CustomersModel.h"
7 
10 //: Wt::WStandardItemModel()
11 : Wt::Dbo::QueryModel< GCW::Dbo::Customers::Item::Ptr >()
12 {
14 
15 #ifdef NEVER
16  dataChanged().connect( [=]( Wt::WModelIndex _index1, Wt::WModelIndex _index2 )
17  {
18 // std::cout << __FILE__ << ":" << __LINE__
19 // << " r1:" << _index1.row() << " c1:" << _index1.column()
20 // << " r2:" << _index2.row() << " c2:" << _index2.column()
21 // << std::endl;
22 
23  });
24 
25  itemChanged().connect( [=]( Wt::WStandardItem * _item )
26  {
27 // std::cout << __FILE__ << ":" << __LINE__ << " " << Wt::asString( _item-> data() ) << std::endl;
28 
29  });
30 #endif
31 
32  std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
33 
34 } // endGCW::Eng::CustomersModel::CustomersModel()
35 
37 CustomersModel( const std::vector< Wt::WFormModel::Field > & _fields )
38 //: Wt::WStandardItemModel(),
39 : Wt::Dbo::QueryModel< GCW::Dbo::Customers::Item::Ptr >(),
40  m_fields( _fields )
41 {
43 
44 }
45 
46 /*!
47 ** \brief Refresh From Disk
48 **
49 **
50 */
51 auto
53 refreshFromDisk()-> void
54 {
55 
56  if( GCW::app()-> gnucashew_session().isOpen() )
57  {
58  Wt::Dbo::Transaction t( GCW::app()-> gnucashew_session() );
59 
60  auto results =
61  GCW::app()-> gnucashew_session().find< GCW::Dbo::Customers::Item >()
62  ;
63 
64  setQuery( results );
65 
66  } // endif( GCW::app()-> gnucashew_session().isOpen() )
67 
68  if( m_fields.size() > 0 )
69  {
70  for( auto field : m_fields )
71  addColumn( field );
72  }
73 
74  else
75  {
76  addAllFieldsAsColumns();
77  }
78 
79 } // endGCW::Eng::CustomersModel::refreshFromDisk()
80 
81 
82 auto
84 guid( int _row )-> std::string
85 {
86  return resultRow( _row )-> guid();
87 
88 } // endguid( int _row )-> std::string
89 
90 
Customer Item Class.
Definition: Item.h:109
auto refreshFromDisk() -> void
Refresh From Disk.
auto guid(int _row) -> std::string
const Wt::WFormModel::Field guid
Definition: Accounts.cpp:46
Definition: App.h:17
App * app()
Definition: App.cpp:67
Definition: GncLock.h:6