Developer Documentation
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
45
46#ifndef SIDE_AREA_
47#define SIDE_AREA_
48
49//=============================================================================
50//
51// CLASS SideElement
52//
53//=============================================================================
54
55//== INCLUDES =================================================================
56
57#include <QIcon>
58#include <QWidget>
59#include <QString>
60#include <QSettings>
61
62//== FORWARDDECLARATIONS ======================================================
63
64class QVBoxLayout;
65
66class SideElement;
67
74class SideArea : public QWidget {
75 public:
76
80 explicit SideArea (QWidget *_parent = 0);
81
89 void addItem (QObject const * const _plugin, QWidget *_w, QString _name,
90 QIcon* _icon = 0, QWidget *_headerAreaWidget = 0);
91
93 void clear ();
94
95 //expand all elements
96 void expandAll();
97
98 void expand(QWidget *sideElementWidget, bool expand);
99
101 void saveState (QSettings &_settings);
102
104 void saveViewModeState(const QString& _viewMode);
105
107 void restoreState (QSettings &_settings);
108
110 void restoreViewModeState(const QString& _viewMode);
111
113 void setElementActive(const QString &_name, bool _active);
114
116 void moveItemToPosition(const QString& _name, int _position);
117
119 void moveItemToPosition(QObject const * const _plugin, const QString& _name, int _position);
120
122 int getNumberOfWidgets() const;
123
125 const QList<const QObject *>& plugins();
126
128 const QStringList& names();
129
130 // position of the last added item
131 int lastPos_;
132
133 private:
134 // elements
135 QVector<SideElement *> items_;
136
137 // plugins in side area
138 QList<const QObject *> plugins_;
139
140 // item names
141 QStringList itemNames_;
142
143 // saves active state of each SideElement in each view
144 QMap<QString, bool> sideElementState_;
145
146 // main layout
147 QVBoxLayout *layout_;
148};
149
150//=============================================================================
151//=============================================================================
152#endif // SIDE_AREA_ defined
153//=============================================================================
154
void moveItemToPosition(const QString &_name, int _position)
Move a toolbox widget to a given position.
Definition: SideArea.cc:84
SideArea(QWidget *_parent=0)
Definition: SideArea.cc:54
int getNumberOfWidgets() const
Get number of widgets.
Definition: SideArea.cc:132
const QList< const QObject * > & plugins()
Get plugins in side area.
Definition: SideArea.cc:224
const QStringList & names()
Get item names.
Definition: SideArea.cc:230
void restoreViewModeState(const QString &_viewMode)
restores the active state of _viewMode
Definition: SideArea.cc:204
void addItem(QObject const *const _plugin, QWidget *_w, QString _name, QIcon *_icon=0, QWidget *_headerAreaWidget=0)
Definition: SideArea.cc:72
void setElementActive(const QString &_name, bool _active)
set the active state of given element
Definition: SideArea.cc:212
void clear()
clears the whole tool widget area
Definition: SideArea.cc:138
void saveViewModeState(const QString &_viewMode)
saves the active state of _viewMode
Definition: SideArea.cc:196
void restoreState(QSettings &_settings)
restores the state
Definition: SideArea.cc:184
void saveState(QSettings &_settings)
returns the current state
Definition: SideArea.cc:172