2 ******************************************************************************
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
7 * @addtogroup GCSPlugins GCS Plugins
9 * @addtogroup CorePlugin Core Plugin
11 * @brief The Core GCS plugin
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include <QtCore/QMap>
33 #include <QtCore/QPointer>
37 #include <coreplugin/minisplitter.h>
52 } // namespace Internal
55 * An item in the sidebar. Has a widget that is displayed in the sidebar and
56 * optionally a list of tool buttons that are added to the toolbar above it.
57 * The window title of the widget is displayed in the combo box.
59 * The SideBarItem takes ownership over the widget.
61 class CORE_EXPORT SideBarItem
{
63 SideBarItem(QWidget
*widget
)
67 virtual ~SideBarItem();
74 /* Should always return a new set of tool buttons.
76 * Workaround since there doesn't seem to be a nice way to remove widgets
77 * that have been added to a QToolBar without either not deleting the
78 * associated QAction or causing the QToolButton to be deleted.
80 virtual QList
<QToolButton
*> createToolBarWidgets()
82 return QList
<QToolButton
*>();
89 class CORE_EXPORT SideBar
: public MiniSplitter
{
93 * The SideBar takes ownership of the SideBarItems.
95 SideBar(QList
<SideBarItem
*> widgetList
,
96 QList
<SideBarItem
*> defaultVisible
);
99 QStringList
availableItems() const;
100 void makeItemAvailable(SideBarItem
*item
);
101 SideBarItem
*item(const QString
&title
);
103 void saveSettings(QSettings
*settings
);
104 void readSettings(QSettings
*settings
);
106 void activateItem(SideBarItem
*item
);
108 void setShortcutMap(const QMap
<QString
, Core::Command
*> &shortcutMap
);
109 QMap
<QString
, Core::Command
*> shortcutMap() const;
112 void splitSubWidget();
113 void closeSubWidget();
114 void updateWidgets();
117 Internal::SideBarWidget
*insertSideBarWidget(int position
,
118 const QString
&title
= QString());
119 void removeSideBarWidget(Internal::SideBarWidget
*widget
);
121 QList
<Internal::SideBarWidget
*> m_widgets
;
123 QMap
<QString
, SideBarItem
*> m_itemMap
;
124 QStringList m_availableItems
;
125 QStringList m_defaultVisible
;
126 QMap
<QString
, Core::Command
*> m_shortcutMap
;
130 class SideBarWidget
: public QWidget
{
133 SideBarWidget(SideBar
*sideBar
, const QString
&title
);
136 QString
currentItemTitle() const;
137 void setCurrentItem(const QString
&title
);
139 void updateAvailableItems();
140 void removeCurrentItem();
142 Core::Command
*command(const QString
&title
) const;
147 void currentWidgetChanged();
150 void setCurrentIndex(int);
153 ComboBox
*m_comboBox
;
154 SideBarItem
*m_currentItem
;
156 QAction
*m_splitAction
;
157 QList
<QAction
*> m_addedToolBarActions
;
159 QToolButton
*m_splitButton
;
160 QToolButton
*m_closeButton
;
163 class ComboBox
: public QComboBox
{
167 ComboBox(SideBarWidget
*sideBarWidget
);
170 bool event(QEvent
*event
);
173 SideBarWidget
*m_sideBarWidget
;
175 } // namespace Internal