1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
36 #include "core_global.h"
37 #include "minisplitter.h"
39 #include <QtCore/QMap>
40 #include <QtCore/QList>
41 #include <QtCore/QScopedPointer>
51 struct SideBarPrivate;
55 } // namespace Internal
58 * An item in the sidebar. Has a widget that is displayed in the sidebar and
59 * optionally a list of tool buttons that are added to the toolbar above it.
60 * The window title of the widget is displayed in the combo box.
62 * The SideBarItem takes ownership over the widget.
64 class CORE_EXPORT SideBarItem : public QObject
68 // id is non-localized string of the item that's used to store the settings.
69 explicit SideBarItem(QWidget *widget, const QString &id);
70 virtual ~SideBarItem();
72 QWidget *widget() const;
74 QString title() const;
76 /* Should always return a new set of tool buttons.
78 * Workaround since there doesn't seem to be a nice way to remove widgets
79 * that have been added to a QToolBar without either not deleting the
80 * associated QAction or causing the QToolButton to be deleted.
82 virtual QList<QToolButton *> createToolBarWidgets();
90 class CORE_EXPORT SideBar : public MiniSplitter
95 * The SideBar takes explicit ownership of the SideBarItems
96 * if you have one SideBar, or shared ownership in case
97 * of multiple SideBars.
99 explicit SideBar(QList< SideBarItem*> widgetList,
100 QList< SideBarItem*> defaultVisible);
103 QStringList availableItemIds() const;
104 QStringList availableItemTitles() const;
105 QStringList unavailableItemIds() const;
106 void makeItemAvailable(SideBarItem *item);
107 void setUnavailableItemIds(const QStringList &itemTitles);
108 QString idForTitle(const QString &itemId) const;
110 SideBarItem *item(const QString &title);
112 bool closeWhenEmpty() const;
113 void setCloseWhenEmpty(bool value);
115 void saveSettings(QSettings *settings, const QString &name);
116 void readSettings(QSettings *settings, const QString &name);
117 void closeAllWidgets();
118 void activateItem(SideBarItem *item);
120 void setShortcutMap(const QMap<QString, Core::Command*> &shortcutMap);
121 QMap<QString, Core::Command*> shortcutMap() const;
124 void availableItemsChanged();
127 void splitSubWidget();
128 void closeSubWidget();
129 void updateWidgets();
132 Internal::SideBarWidget *insertSideBarWidget(int position,
133 const QString &title = QString());
134 void removeSideBarWidget(Internal::SideBarWidget *widget);
136 QScopedPointer<SideBarPrivate> d;