GnuCashew ~ GnuCash Enabled Web
GCW
MainWidget.cpp
Go to the documentation of this file.
1 #line 2 "src/Gui/Customer/MainWidget.cpp"
2 
3 #include <Wt/WText.h>
4 #include <Wt/WVBoxLayout.h>
5 #include <Wt/WHBoxLayout.h>
6 
7 #include "../../define.h"
8 #include "../../GnuCashew.h"
9 #include "MainWidget.h"
10 #include "ToolBar.h"
11 
13 MainWidget()
14 {
15  addStyleClass( "CustomerWidget" );
16 
17  /*
18  ** Apply a layout so everything will fit in the window
19  **
20  */
21  auto vlw = setLayout( std::make_unique< Wt::WVBoxLayout >() );
22  vlw-> setSpacing( 0 );
23 
24  /*
25  ** Install the tool bar
26  **
27  */
28  auto tb_ = std::make_unique< GCW::Gui::Customer::ToolBar >();
29  vlw-> addWidget( std::move( tb_ ) );
30 
31  auto hlw = vlw-> addLayout( std::make_unique< Wt::WHBoxLayout >(), 1 );
32 
33  {
34  /*
35  ** Standard TableView for now
36  **
37  */
38  auto w_ = std::make_unique< Wt::WTableView >();
39  m_view = w_.get();
40  hlw-> addWidget( std::move( w_ ), 1 );
41  }
42 
43  /*
44  ** Setup standard control
45  **
46  */
47  view()-> setSelectionBehavior ( Wt::SelectionBehavior::Rows );
48  view()-> setSelectionMode ( Wt::SelectionMode::Single );
49  view()-> setAlternatingRowColors ( true );
50  view()-> doubleClicked().connect ( this, &MainWidget::doubleClicked );
51 
52  /*
53  ** Prepare a column list
54  **
55  */
56  std::vector< Wt::WFormModel::Field > fields =
57  {
62  };
63 
64  /*
65  ** Create the model and apply it to the view
66  **
67  */
68  m_model = std::make_shared< GCW::Eng::CustomersModel >( fields );
69  model()-> sort( 0 );
70  view()-> setModel( model() );
71 
72  auto tabWidget_ = std::make_unique< Wt::WTabWidget >();
73  auto m_tabWidget = tabWidget_.get();
74  hlw-> addWidget( std::move( tabWidget_ ), 1 );
75 
76  {
77  auto w_ = std::make_unique< GCW::Gui::Customer::Invoices >();
78  m_invoicesView = w_.get();
79  m_tabWidget-> addTab( std::move( w_ ), "Invoices" );
80 
81  hlw-> setResizable( 0, true, "25%" );
82 
83  view()->
84  clicked().connect( [&]( Wt::WModelIndex _index, Wt::WMouseEvent _event )
85  {
86  m_invoicesView-> setCustomerGuid( m_model-> guid( _index.row() ) );
87 
88  });
89  }
90 
91 } // endGCW::Gui::CustomersWidget::CustomersWidget()
92 
94 doubleClicked( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )
95 {
96  /*
97  ** get to the customerItem that was clicked on
98  */
99 // auto customerItem = model()-> resultRow( _index.row() );
100 
101  /*
102  ** emit the guid of the item
103  */
104 // doubleClicked().emit( customerItem-> guid() );
105 
106 } // endvoid GCW::Gui::CustomersWidget::doubleClicked( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )
107 
108 
109 
Wt::Signal< std::string > & doubleClicked()
Definition: MainWidget.h:32
std::shared_ptr< Model > m_model
Definition: MainWidget.h:49
Wt::WTableView * view() const
Definition: MainWidget.h:30
std::shared_ptr< Model > model() const
Definition: MainWidget.h:29
GCW::Gui::Customer::Invoices * m_invoicesView
Definition: MainWidget.h:52
const Wt::WFormModel::Field guid
Definition: Accounts.cpp:46
Wt::WFormModel::Field addr_phone
Definition: Customers.cpp:24
Wt::WFormModel::Field addr_email
Definition: Customers.cpp:26
Wt::WFormModel::Field name
Definition: Customers.cpp:9
Wt::WFormModel::Field id
Definition: Customers.cpp:10