OSDN Git Service

Merge branch 'master' of scm.dev.nokia.troll.no:creator/mainline
[qt-creator-jp/qt-creator-jp.git] / src / plugins / coreplugin / navigationwidget.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** Commercial Usage
10 **
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.
15 **
16 ** GNU Lesser General Public License Usage
17 **
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.
24 **
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
27 **
28 **************************************************************************/
29
30 #ifndef NAVIGATIONWIDGET_H
31 #define NAVIGATIONWIDGET_H
32
33 #include <coreplugin/minisplitter.h>
34
35 #include <QtCore/QHash>
36 #include <QtCore/QScopedPointer>
37
38 QT_BEGIN_NAMESPACE
39 class QSettings;
40 class QShortcut;
41 class QAbstractItemModel;
42 class QStandardItemModel;
43 QT_END_NAMESPACE
44
45 namespace Core {
46 class INavigationWidgetFactory;
47 class IMode;
48 class Command;
49 class NavigationWidget;
50 struct NavigationWidgetPrivate;
51 namespace Internal {
52 class NavigationSubWidget;
53 }
54
55 class CORE_EXPORT NavigationWidgetPlaceHolder : public QWidget
56 {
57     friend class Core::NavigationWidget;
58     Q_OBJECT
59 public:
60     explicit NavigationWidgetPlaceHolder(Core::IMode *mode, QWidget *parent = 0);
61     virtual ~NavigationWidgetPlaceHolder();
62     static NavigationWidgetPlaceHolder* current();
63     void applyStoredSize(int width);
64
65 private slots:
66     void currentModeAboutToChange(Core::IMode *);
67
68 private:
69     Core::IMode *m_mode;
70     static NavigationWidgetPlaceHolder* m_current;
71 };
72
73 class CORE_EXPORT NavigationWidget : public MiniSplitter
74 {
75     Q_OBJECT
76 public:
77     enum FactoryModelRoles {
78         FactoryObjectRole = Qt::UserRole,
79         FactoryIdRole,
80         FactoryPriorityRole
81     };
82
83     explicit NavigationWidget(QAction *toggleSideBarAction);
84     virtual ~NavigationWidget();
85
86     void setFactories(const QList<INavigationWidgetFactory*> factories);
87
88     void saveSettings(QSettings *settings);
89     void restoreSettings(QSettings *settings);
90
91     void activateSubWidget(const QString &factoryId);
92     void closeSubWidgets();
93
94     bool isShown() const;
95     void setShown(bool b);
96
97     bool isSuppressed() const;
98     void setSuppressed(bool b);
99
100     static NavigationWidget* instance();
101
102     int storedWidth();
103
104     // Called from the place holders
105     void placeHolderChanged(NavigationWidgetPlaceHolder *holder);
106
107     QHash<QString, Core::Command*> commandMap() const;
108     QAbstractItemModel *factoryModel() const;
109
110 protected:
111     void resizeEvent(QResizeEvent *);
112
113 private slots:
114     void activateSubWidget();
115     void splitSubWidget();
116     void closeSubWidget();
117
118 private:
119     void updateToggleText();
120     Internal::NavigationSubWidget *insertSubItem(int position, int index);
121     int factoryIndex(const QString &id);
122
123     QScopedPointer<NavigationWidgetPrivate> d;
124 };
125
126 } // namespace Core
127
128 #endif // NAVIGATIONWIDGET_H