Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SideArea.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 
51 
52 #ifndef SIDE_AREA_
53 #define SIDE_AREA_
54 
55 //=============================================================================
56 //
57 // CLASS SideElement
58 //
59 //=============================================================================
60 
61 //== INCLUDES =================================================================
62 
63 #include <QIcon>
64 #include <QWidget>
65 #include <QString>
66 #include <QSettings>
67 
68 //== FORWARDDECLARATIONS ======================================================
69 
70 class QVBoxLayout;
71 
72 class SideElement;
73 
80 class SideArea : public QWidget {
81  public:
82 
86  SideArea (QWidget *_parent = 0);
87 
95  void addItem (QObject const * const _plugin, QWidget *_w, QString _name,
96  QIcon* _icon = 0, QWidget *_headerAreaWidget = 0);
97 
99  void clear ();
100 
101  //expand all elements
102  void expandAll();
103 
104  void expand(QWidget *sideElementWidget, bool expand);
105 
107  void saveState (QSettings &_settings);
108 
110  void saveViewModeState(const QString& _viewMode);
111 
113  void restoreState (QSettings &_settings);
114 
116  void restoreViewModeState(const QString& _viewMode);
117 
119  void setElementActive(QString _name, bool _active);
120 
122  void moveItemToPosition(const QString& _name, int _position);
123 
125  void moveItemToPosition(QObject const * const _plugin, const QString& _name, int _position);
126 
128  int getNumberOfWidgets() const;
129 
131  const QList<const QObject *>& plugins();
132 
134  const QStringList& names();
135 
136  // position of the last added item
137  int lastPos_;
138 
139  private:
140  // elements
141  QVector<SideElement *> items_;
142 
143  // plugins in side area
144  QList<const QObject *> plugins_;
145 
146  // item names
147  QStringList itemNames_;
148 
149  // saves active state of each SideElement in each view
150  QMap<QString, bool> sideElementState_;
151 
152  // main layout
153  QVBoxLayout *layout_;
154 };
155 
156 //=============================================================================
157 //=============================================================================
158 #endif // SIDE_AREA_ defined
159 //=============================================================================
160 
const QList< const QObject * > & plugins()
Get plugins in side area.
Definition: SideArea.cc:230
void moveItemToPosition(const QString &_name, int _position)
Move a toolbox widget to a given position.
Definition: SideArea.cc:90
void setElementActive(QString _name, bool _active)
set the active state of given element
Definition: SideArea.cc:218
SideArea(QWidget *_parent=0)
Definition: SideArea.cc:60
void saveState(QSettings &_settings)
returns the current state
Definition: SideArea.cc:178
int getNumberOfWidgets() const
Get number of widgets.
Definition: SideArea.cc:138
void saveViewModeState(const QString &_viewMode)
saves the active state of _viewMode
Definition: SideArea.cc:202
const QStringList & names()
Get item names.
Definition: SideArea.cc:236
void restoreViewModeState(const QString &_viewMode)
restores the active state of _viewMode
Definition: SideArea.cc:210
void clear()
clears the whole tool widget area
Definition: SideArea.cc:144
void addItem(QObject const *const _plugin, QWidget *_w, QString _name, QIcon *_icon=0, QWidget *_headerAreaWidget=0)
Definition: SideArea.cc:78
void restoreState(QSettings &_settings)
restores the state
Definition: SideArea.cc:190