1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
37 #include "core_global.h"
38 #include "minisplitter.h"
40 #include <QtCore/QMap>
41 #include <QtCore/QList>
42 #include <QtCore/QScopedPointer>
52 struct SideBarPrivate;
56 } // namespace Internal
59 * An item in the sidebar. Has a widget that is displayed in the sidebar and
60 * optionally a list of tool buttons that are added to the toolbar above it.
61 * The window title of the widget is displayed in the combo box.
63 * The SideBarItem takes ownership over the widget.
65 class CORE_EXPORT SideBarItem : public QObject
69 // id is non-localized string of the item that's used to store the settings.
70 explicit SideBarItem(QWidget *widget, const QString &id);
71 virtual ~SideBarItem();
73 QWidget *widget() const;
75 QString title() const;
77 /* Should always return a new set of tool buttons.
79 * Workaround since there doesn't seem to be a nice way to remove widgets
80 * that have been added to a QToolBar without either not deleting the
81 * associated QAction or causing the QToolButton to be deleted.
83 virtual QList<QToolButton *> createToolBarWidgets();
91 class CORE_EXPORT SideBar : public MiniSplitter
96 * The SideBar takes explicit ownership of the SideBarItems
97 * if you have one SideBar, or shared ownership in case
98 * of multiple SideBars.
100 explicit SideBar(QList< SideBarItem*> widgetList,
101 QList< SideBarItem*> defaultVisible);
104 QStringList availableItemIds() const;
105 QStringList availableItemTitles() const;
106 QStringList unavailableItemIds() const;
107 void makeItemAvailable(SideBarItem *item);
108 void setUnavailableItemIds(const QStringList &itemTitles);
109 QString idForTitle(const QString &itemId) const;
111 SideBarItem *item(const QString &title);
113 bool closeWhenEmpty() const;
114 void setCloseWhenEmpty(bool value);
116 void saveSettings(QSettings *settings, const QString &name);
117 void readSettings(QSettings *settings, const QString &name);
118 void closeAllWidgets();
119 void activateItem(SideBarItem *item);
121 void setShortcutMap(const QMap<QString, Core::Command*> &shortcutMap);
122 QMap<QString, Core::Command*> shortcutMap() const;
125 void availableItemsChanged();
128 void splitSubWidget();
129 void closeSubWidget();
130 void updateWidgets();
133 Internal::SideBarWidget *insertSideBarWidget(int position,
134 const QString &title = QString());
135 void removeSideBarWidget(Internal::SideBarWidget *widget);
137 QScopedPointer<SideBarPrivate> d;