OpenWalnut  1.5.0dev
WUIQtPropertyGroupWidget.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WUIQTPROPERTYGROUPWIDGET_H
26 #define WUIQTPROPERTYGROUPWIDGET_H
27 
28 #include <memory>
29 #include <string>
30 
31 
32 #include "../WMainWindow.h"
33 #include "../controlPanel/WQtPropertyGroupWidget.h"
34 #include "WUIQtWidgetBase.h"
35 #include "core/ui/WUIPropertyGroupWidget.h"
36 
37 /**
38  * Implementation of \ref WUIPropertyGroupWidget.
39  */
41  public WUIQtWidgetBase
42 {
43 public:
44  /**
45  * Convenience typedef for a std::shared_ptr< WUIQtPropertyGroupWidget >.
46  */
47  typedef std::shared_ptr< WUIQtPropertyGroupWidget > SPtr;
48 
49  /**
50  * Convenience typedef for a std::shared_ptr< const WUIQtPropertyGroupWidget >.
51  */
52  typedef std::shared_ptr< const WUIQtPropertyGroupWidget > ConstSPtr;
53 
54  /**
55  * Default constructor.
56  *
57  * \param mainWindow the main window instance
58  * \param properties the properties to show
59  * \param parent the Qt parent. Can be NULL.
60  * \param title the title of the widget
61  */
63  std::string title,
64  WPropGroup properties,
65  WMainWindow* mainWindow,
67 
68  /**
69  * Destructor.
70  */
71  virtual ~WUIQtPropertyGroupWidget();
72 
73  /**
74  * Title as QString.
75  *
76  * \return the title
77  */
78  virtual QString getTitleQString() const;
79 
80  /**
81  * Show this widget if not yet visible.
82  */
83  virtual void show();
84 
85  /**
86  * Hide/show this widget. Unlike close(), you can show the widget again using show().
87  *
88  * \param visible false to hide widget
89  */
90  virtual void setVisible( bool visible = true );
91 
92  /**
93  * Check if the widget is hidden or not.
94  *
95  * \return true if visible.
96  */
97  virtual bool isVisible() const;
98 
99  /**
100  * Handle shutdown. This includes notification of the creating module and closing the widget. Can be called from any thread.
101  * Implement in your implementation.
102  */
103  virtual void close();
104 
105  /**
106  * The property group shown by this widget.
107  *
108  * \return the group
109  */
110  virtual WPropGroup getPropertyGroup() const;
111 
112  /**
113  * Implement \ref WUIWidgetBase::addAction.
114  *
115  * \param group the property to use.
116  * \param icon the icon to use. Consider a minimum size of 32x32.
117  */
118  virtual void addAction( WPropGroup group, WGEImage::SPtr icon = WGEImage::SPtr() )
119  {
120  WUIQtWidgetBase::addAction( group, icon );
121  }
122 
123  /**
124  * Implement \ref WUIWidgetBase::addAction.
125  *
126  * \param trigger the property to use.
127  * \param icon the icon to use. Consider a minimum size of 32x32.
128  */
129  virtual void addAction( WPropTrigger trigger, WGEImage::SPtr icon = WGEImage::SPtr() )
130  {
131  WUIQtWidgetBase::addAction( trigger, icon );
132  }
133 
134  /**
135  * Implement \ref WUIWidgetBase::addAction.
136  *
137  * \param toggle the property to use.
138  * \param icon the icon to use. Consider a minimum size of 32x32.
139  */
140  virtual void addAction( WPropBool toggle, WGEImage::SPtr icon = WGEImage::SPtr() )
141  {
142  WUIQtWidgetBase::addAction( toggle, icon );
143  }
144 protected:
145  /**
146  * Realize the widget. This method blocks until the GUI thread created the widget. Called from within the GUI thread! So you can safely do Qt
147  * stuff.
148  */
149  virtual void realizeImpl();
150 
151  /**
152  * Close the widget. When done, the widget can be safely deleted.
153  */
154  virtual void closeImpl();
155 
156  /**
157  * Cleanup the GUI. Do not delete m_widget, or your content widget. This is done by WUIQtWidgetBase. This method allows you to free resources
158  * that are not automatically freed by the Qt delete mechanism.
159  */
160  virtual void cleanUpGT();
161 private:
162  /**
163  * The prop widget
164  */
165  QWidget* m_propWidget;
166 
167  /**
168  * The properties to show
169  */
170  WPropGroup m_properties;
171 };
172 
173 #endif // WUIQTPROPERTYGROUPWIDGET_H
174 
std::shared_ptr< WGEImage > SPtr
Convenience typedef for a std::shared_ptr< WGEImage >.
Definition: WGEImage.h:48
This class contains the main window and the layout of the widgets within the window.
Definition: WMainWindow.h:66
Widget which is a container for a WPropertyGroup.
Implementation of WUIPropertyGroupWidget.
virtual WPropGroup getPropertyGroup() const
The property group shown by this widget.
virtual void setVisible(bool visible=true)
Hide/show this widget.
virtual void cleanUpGT()
Cleanup the GUI.
virtual QString getTitleQString() const
Title as QString.
virtual void addAction(WPropBool toggle, WGEImage::SPtr icon=WGEImage::SPtr())
Implement WUIWidgetBase::addAction.
virtual bool isVisible() const
Check if the widget is hidden or not.
virtual void close()
Handle shutdown.
std::shared_ptr< WUIQtPropertyGroupWidget > SPtr
Convenience typedef for a std::shared_ptr< WUIQtPropertyGroupWidget >.
virtual void addAction(WPropTrigger trigger, WGEImage::SPtr icon=WGEImage::SPtr())
Implement WUIWidgetBase::addAction.
WPropGroup m_properties
The properties to show.
virtual void closeImpl()
Close the widget.
virtual void show()
Show this widget if not yet visible.
QWidget * m_propWidget
The prop widget.
virtual ~WUIQtPropertyGroupWidget()
Destructor.
virtual void addAction(WPropGroup group, WGEImage::SPtr icon=WGEImage::SPtr())
Implement WUIWidgetBase::addAction.
std::shared_ptr< const WUIQtPropertyGroupWidget > ConstSPtr
Convenience typedef for a std::shared_ptr< const WUIQtPropertyGroupWidget >.
WUIQtPropertyGroupWidget(std::string title, WPropGroup properties, WMainWindow *mainWindow, WUIQtWidgetBase::SPtr parent=WUIQtWidgetBase::SPtr())
Default constructor.
virtual void realizeImpl()
Realize the widget.
Implementation of WUIWidgetBase.
std::shared_ptr< WUIQtWidgetBase > SPtr
Convenience typedef for a std::shared_ptr< WUIQtWidgetBase >.
virtual void addAction(WPropGroup group, WGEImage::SPtr icon=WGEImage::SPtr())
Implement WUIWidgetBase::addAction.