GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
Customer/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
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< 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< 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< Invoices >();
78 m_invoicesView = w_.get();
79 m_tabWidget-> addTab( std::move( w_ ), "Invoices" );
80
81 hlw-> setResizable( 0, true, "25%" );
82
83 view()->
85 {
86 m_invoicesView-> setCustomerGuid( m_model-> guid( _index.row() ) );
87
88 });
89 }
90
91} // endMainWidget()
92
93auto
95doubleClicked( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void
96{
97 /*
98 ** get to the customerItem that was clicked on
99 */
100// auto customerItem = model()-> resultRow( _index.row() );
101
102 /*
103 ** emit the guid of the item
104 */
105// doubleClicked().emit( customerItem-> guid() );
106
107} // enddoubleClicked( const Wt::WModelIndex & _index, const Wt::WMouseEvent & _event )-> void
108
109
110
auto view() const -> Wt::WTableView *
std::shared_ptr< Model > m_model
auto doubleClicked() -> Wt::Signal< std::string > &
auto model() const -> std::shared_ptr< Model >
GCW::Gui::Customer::Invoices * m_invoicesView
Widget * addNew(Args &&...args)
void setLayout(std::unique_ptr< WLayout > layout)
virtual void addWidget(std::unique_ptr< WWidget > widget)
EventSignal< WMouseEvent > & clicked()
virtual void addStyleClass(const WString &styleClass, bool force=false) override
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