GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
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
37CustomersModel( 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*/
50auto
52refreshFromDisk()-> void
53{
54
55 if( GCW::app()-> gnucashew_session().isOpen() )
56 {
57 Wt::Dbo::Transaction t( GCW::app()-> gnucashew_session() );
58
59 auto results =
60 GCW::app()-> gnucashew_session().find< GCW::Dbo::Customers::Item >()
61 ;
62
63 setQuery( results );
64
65 } // endif( GCW::app()-> gnucashew_session().isOpen() )
66
67 if( m_fields.size() > 0 )
68 {
69 for( auto field : m_fields )
70 addColumn( field );
71 }
72
73 else
74 {
75 addAllFieldsAsColumns();
76 }
77
78} // endGCW::Eng::CustomersModel::refreshFromDisk()
79
80
81auto
83guid( int _row )-> std::string
84{
85 return resultRow( _row )-> guid();
86
87} // endguid( int _row )-> std::string
88
89
auto refreshFromDisk() -> void
Refresh From Disk.
auto guid(int _row) -> std::string
virtual Signal< WModelIndex, WModelIndex > & dataChanged()
Definition App.h:18
App * app()
Definition App.cpp:75