OpenWalnut  1.5.0dev
WPropertySelectionWidget.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 WPROPERTYSELECTIONWIDGET_H
26 #define WPROPERTYSELECTIONWIDGET_H
27 
28 #include <string>
29 
30 #include <QComboBox>
31 #include <QListWidget>
32 #include <QHBoxLayout>
33 
34 #include "WPropertyWidget.h"
35 
36 /**
37  * Implements a property widget for WPropSelection.
38  */
40 {
41  Q_OBJECT
42 public:
43  /**
44  * Constructor. Creates a new widget appropriate for the specified property.
45  *
46  * \param property the property to handle
47  * \param parent the parent widget.
48  * \param propertyGrid the grid used to layout the labels and property widgets
49  */
50  WPropertySelectionWidget( WPropSelection property, QGridLayout* propertyGrid, QWidget* parent = 0 );
51 
52  /**
53  * Destructor.
54  */
55  virtual ~WPropertySelectionWidget();
56 
57 protected:
58  /**
59  * Called whenever the widget should update.
60  */
61  virtual void update();
62 
63  /**
64  * The integer property represented by this widget.
65  */
66  WPropSelection m_selectionProperty;
67 
68  /**
69  * The list holding all items
70  */
71  QListWidget* m_list;
72 
73  /**
74  * The combobox holding all items.
75  */
76  QComboBox* m_combo;
77 
78  /**
79  * Layout used to position the label and the checkbox
80  */
81  QGridLayout m_layout;
82 
83  /**
84  * True if a selection update is currently in progress. This is needed as QT does not provide a signal for selection changes which is NOT
85  * called when changed programmatically.
86  */
87  bool m_update;
88 
89 private:
90 public slots:
91 
92  /**
93  * Called whenever the selection in m_list has changed.
94  */
95  void listSelectionChanged();
96 
97  /**
98  * Selection of the combobox has changed.
99  *
100  * \param index the new index
101  */
102  void comboSelectionChanged( int index );
103 };
104 
105 #endif // WPROPERTYSELECTIONWIDGET_H
106 
Implements a property widget for WPropSelection.
WPropSelection m_selectionProperty
The integer property represented by this widget.
QListWidget * m_list
The list holding all items.
WPropertySelectionWidget(WPropSelection property, QGridLayout *propertyGrid, QWidget *parent=0)
Constructor.
virtual ~WPropertySelectionWidget()
Destructor.
QGridLayout m_layout
Layout used to position the label and the checkbox.
QComboBox * m_combo
The combobox holding all items.
void listSelectionChanged()
Called whenever the selection in m_list has changed.
bool m_update
True if a selection update is currently in progress.
virtual void update()
Called whenever the widget should update.
void comboSelectionChanged(int index)
Selection of the combobox has changed.
Class building the base for all widgets representing properties.