Wtx ~ Wt Extension Library
WtxLib
TableViewManager.h
1 /**************************************************************************
2 ###########################################################################
3 ##
4 ## $SHOWOFFDB_BEGIN_LICENSE$
5 ## Copyright (C) 2011 Lorimark Solutions, LLC and/or its subsidiary(-ies).
6 ## All rights reserved.
7 ## Contact: Lorimark Solutions, LLC (info@showoff-db.org)
8 ##
9 ## This file is part of the Showoff Database Application Framework.
10 ##
11 ## Commercial Usage
12 ## Licensees holding valid ShowoffDB Commercial licenses may use this file in
13 ## accordance with the ShowoffDB Commercial License Agreement provided with the
14 ## Software or, alternatively, in accordance with the terms contained in
15 ## a written agreement between you and Lorimark Solutions, LLC.
16 ##
17 ## GNU Lesser General Public License Usage
18 ## Alternatively, this file may be used under the terms of the GNU Lesser
19 ## General Public License version 2.1 as published by the Free Software
20 ## Foundation and appearing in the file LICENSE.LGPL included in the
21 ## packaging of this file. Please review the following information to
22 ## ensure the GNU Lesser General Public License version 2.1 requirements
23 ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ##
25 ## In addition, as a special exception, Lorimark Solutions, LLC gives
26 ## you certain additional rights. These rights are described in the
27 ## Lorimark Solutions, LLC ShowoffDB LGPL Exception version 1.0, included in
28 ## the file LGPL_EXCEPTION.txt in this package.
29 ##
30 ## GNU General Public License Usage
31 ## Alternatively, this file may be used under the terms of the GNU
32 ## General Public License version 3.0 as published by the Free Software
33 ## Foundation and appearing in the file LICENSE.GPL included in the
34 ## packaging of this file. Please review the following information to
35 ## ensure the GNU General Public License version 3.0 requirements will be
36 ## met: http://www.gnu.org/copyleft/gpl.html.
37 ##
38 ## If you have questions regarding the use of this file, please contact
39 ## Lorimark Solutions, LLC at info@showoff-db.org.
40 ## $SHOWOFFDB_END_LICENSE$
41 ##
42 #############################################################################
43 ****************************************************************************/
44 
45 
46 #ifndef __WTX_DBO_TABLEVIEWMANAGER_H_234e0174_6b7d_11e8_b503_fb1ef3651ec0__
47 #define __WTX_DBO_TABLEVIEWMANAGER_H_234e0174_6b7d_11e8_b503_fb1ef3651ec0__
48 
49 #include "TableView.h"
50 
51 namespace Wtx {
52 
53 extern Wt::WLength g_dialogWidth;
54 extern Wt::WLength g_dialogHeight;
55 
56  namespace Dbo {
57 
63 template <class C, class D>
65 : public Wt::WContainerWidget
66 {
67 
68  public:
69 
71  : public Wt::WContainerWidget
72  {
73  public:
74 
75  SearchWidget( bool autohide );
76 
77  void setFilter( const Wt::WString & value );
78  void setSearch( const Wt::WString & value );
79 
80  void setToolTip( const Wt::WString & value );
81 
82  Wt::WHBoxLayout * lw() const { return m_lw; }
83 
84  Wt::WHBoxLayout * m_lw = nullptr;
85  Wt::WLineEdit * m_filter = nullptr;
86  bool m_autohide;
87  };
88 
90  : public Wt::WContainerWidget
91  {
92  public:
93 
94  FooterWidget();
95 
96  void setRowCount( int query, int total );
97  void setQueryRowCount( int value );
98  void setTotalRowCount( int value );
99 
100  private:
101 
102  void updateWidgets();
103 
104  int m_queryRowCount = 0;
105  int m_totalRowCount = 0;
106 
107  Wt::WText * m_rowCounts = nullptr;
108  Wt::WText * m_center = nullptr;
109  Wt::WText * m_right = nullptr;
110  };
111 
113  : public Wt::WContainerWidget
114  {
115  public:
116 
117  PrevNextWidget();
118 
119  void setRow( int row, int rowCount );
120 
121  Wt::WText * m_text ;
122  Wt::WPushButton * m_top ;
123  Wt::WPushButton * m_prev ;
124  Wt::WPushButton * m_next ;
125  Wt::WPushButton * m_bottom ;
126  };
127 
129  TableViewManager( const std::string & viewDefName, Wtx::Dbo::Session * s );
131  TableViewManager( const std::string & viewDefName, const Wtx::TableViewDef::ViewDef & viewDef, Wtx::Dbo::Session * s );
132 
133  Wtx::Dbo::TableView<C> * tableView() { return m_tableView; }
134 
135  const std::string & filter() const;
136  Wtx::Dbo::Session * session() const { return m_session; }
137  Wt::WVBoxLayout * lw() const { return m_lw; }
138  SearchWidget * searchWidget() const { return m_searchWidget; }
139  Wtx::Dbo::TableView<C> * tableView() const { return m_tableView; }
140 
141  void updateFooter();
142 
143  Wt::WContainerWidget * toolBar();
144  Wt::WContainerWidget * buttonBar();
145 
150  Wt::Signal< typename C::Ptr > & addClicked() { return m_addClicked ; }
151  Wt::Signal< typename C::Ptr > & deleteClicked() { return m_deleteClicked ; }
152  Wt::Signal< typename C::Ptr > & itemClicked() { return m_itemClicked ; }
153  Wt::Signal< typename C::Ptr > & doubleClicked() { return m_doubleClicked ; }
154  Wt::Signal< typename C::Ptr > & editClicked() { return m_editClicked ; }
155  Wt::Signal< typename C::Ptr > & itemSaved() { return m_itemSaved ; }
156  Wt::Signal< std::string > & exportClicked() { return m_exportClicked ; }
157  Wt::Signal< std::string > & printClicked() { return m_printClicked ; }
158  Wt::Signal< std::string > & additionalClicked() { return m_additionalClicked ; }
159 
160  std::unique_ptr<D> makeDetail( typename C::Ptr item );
161  D * openDetail( Wt::WModelIndex index );
162  D * openDetail( typename C::Ptr item );
163 
164  bool doSave( D * detail );
165  void doClose( D * detail );
166 
167  void setReadOnly( bool value );
168 
169  Wt::WTemplate * buttonTemplt() { return m_buttonTemplt; }
170 
171  bool m_openDetail = true;
172 
173  Wt::WPushButton * m_pbAdd = nullptr;
174  Wt::WPushButton * m_pbEdit = nullptr;
175  Wt::WPushButton * m_pbDelete = nullptr;
176  Wt::WPushButton * m_pbPrint = nullptr;
177  Wt::WPushButton * m_pbExport = nullptr;
178 
179  void setDialogSize( Wt::WLength width, Wt::WLength height );
180 
181  private:
182 
183  void initHead();
184  void initFoot();
185 
186  void on_clicked( Wt::WModelIndex index, Wt::WMouseEvent event );
187  void on_doubleClicked( Wt::WModelIndex index, Wt::WMouseEvent event );
188  void on_keyPressed( Wt::WKeyEvent keyEvent );
189  void on_keyWentDown( Wt::WKeyEvent keyEvent );
190  void on_filterEntered();
191  void on_filterTyped();
192  void on_add_clicked();
193  void on_edit_clicked();
194  void do_on_delete_clicked() { on_delete_clicked(false); }
195  void on_delete_clicked( bool noask );
196  void on_export_clicked();
197  void on_print_clicked();
198  void on_additional_clicked();
199  void on_unlock_clicked();
200 
201  Wt::WLength m_dialogWidth = Wtx::g_dialogWidth ;
202  Wt::WLength m_dialogHeight = Wtx::g_dialogHeight ;
203 
204  Wt::WTemplate * m_buttonTemplt = nullptr ;
205  Wtx::Dbo::Session * m_session = nullptr ;
206  Wt::WVBoxLayout * m_lw = nullptr ;
207  Wtx::Dbo::TableView< C > * m_tableView = nullptr ;
208  SearchWidget * m_searchWidget = nullptr ;
209  FooterWidget * m_footerWidget = nullptr ;
210  PrevNextWidget * m_prevNextWidget = nullptr ;
211  Wt::WContainerWidget * m_toolBar = nullptr ;
212  Wt::WContainerWidget * m_buttonBar = nullptr ;
213  Wt::Signal< typename C::Ptr > m_itemClicked ;
214  Wt::Signal< typename C::Ptr > m_addClicked ;
215  Wt::Signal< typename C::Ptr > m_deleteClicked ;
216  Wt::Signal< typename C::Ptr > m_doubleClicked ;
217  Wt::Signal< typename C::Ptr > m_editClicked ;
218  Wt::Signal< typename C::Ptr > m_itemSaved ;
219  Wt::Signal< std::string > m_exportClicked ;
220  Wt::Signal< std::string > m_printClicked ;
221  Wt::Signal< std::string > m_additionalClicked ;
222 
223  bool m_readOnly = false;
224 
225 }; // endclass TableViewManager
226 
227  } // endnamespace Dbo
228 } // endnamespace Wtx
229 
230 #include "TableViewManager_imp.h"
231 
232 #endif // __WTX_DBO_TABLEVIEWMANAGER_H___
233 
Wt::WLength g_dialogWidth
Default Dialog Width.
Definition: TableViewDef.h:58
Wt::WLength g_dialogHeight
Default Dialog Height.
Definition: TableViewDef.h:59
Wt::Signal< typename C::Ptr > & addClicked()
Add.
Table View Definition.
Definition: TableViewDef.h:171
witty extension library
Definition: Activity.h:51
Dbo Table View.
Definition: TableView.h:68