1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
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 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
28 **************************************************************************/
30 #ifndef NAVIGATIONWIDGET_H
31 #define NAVIGATIONWIDGET_H
33 #include <coreplugin/minisplitter.h>
35 #include <QtCore/QHash>
36 #include <QtCore/QScopedPointer>
41 class QAbstractItemModel;
42 class QStandardItemModel;
46 class INavigationWidgetFactory;
49 class NavigationWidget;
50 struct NavigationWidgetPrivate;
52 class NavigationSubWidget;
55 class CORE_EXPORT NavigationWidgetPlaceHolder : public QWidget
57 friend class Core::NavigationWidget;
60 explicit NavigationWidgetPlaceHolder(Core::IMode *mode, QWidget *parent = 0);
61 virtual ~NavigationWidgetPlaceHolder();
62 static NavigationWidgetPlaceHolder* current();
63 void applyStoredSize(int width);
66 void currentModeAboutToChange(Core::IMode *);
70 static NavigationWidgetPlaceHolder* m_current;
73 class CORE_EXPORT NavigationWidget : public MiniSplitter
77 enum FactoryModelRoles {
78 FactoryObjectRole = Qt::UserRole,
83 explicit NavigationWidget(QAction *toggleSideBarAction);
84 virtual ~NavigationWidget();
86 void setFactories(const QList<INavigationWidgetFactory*> factories);
88 void saveSettings(QSettings *settings);
89 void restoreSettings(QSettings *settings);
91 void activateSubWidget(const QString &factoryId);
92 void closeSubWidgets();
95 void setShown(bool b);
97 bool isSuppressed() const;
98 void setSuppressed(bool b);
100 static NavigationWidget* instance();
104 // Called from the place holders
105 void placeHolderChanged(NavigationWidgetPlaceHolder *holder);
107 QHash<QString, Core::Command*> commandMap() const;
108 QAbstractItemModel *factoryModel() const;
111 void resizeEvent(QResizeEvent *);
114 void activateSubWidget();
115 void splitSubWidget();
116 void closeSubWidget();
119 void updateToggleText();
120 Internal::NavigationSubWidget *insertSubItem(int position, int index);
121 int factoryIndex(const QString &id);
123 QScopedPointer<NavigationWidgetPrivate> d;
128 #endif // NAVIGATIONWIDGET_H