OSDN Git Service

ce64b66998d4e250d192006104074cae2dc2185f
[qt-creator-jp/qt-creator-jp.git] / src / plugins / coreplugin / editortoolbar.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
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
14 ** this package.
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 ** 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.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef FAKETOOLBAR_H
35 #define FAKETOOLBAR_H
36
37 #include "core_global.h"
38
39 #include <QtCore/QScopedPointer>
40
41 #include <utils/styledbar.h>
42
43 namespace Core {
44     class IEditor;
45
46 struct EditorToolBarPrivate;
47
48 /**
49   * Fakes an IEditor-like toolbar for design mode widgets such as Qt Designer and Bauhaus.
50   * Creates a combobox for open files and lock and close buttons on the right.
51   */
52 class CORE_EXPORT EditorToolBar : public Utils::StyledBar
53 {
54     Q_OBJECT
55     Q_DISABLE_COPY(EditorToolBar)
56 public:
57     explicit EditorToolBar(QWidget *parent = 0);
58     virtual ~EditorToolBar();
59
60     enum ToolbarCreationFlags { FlagsNone = 0, FlagsStandalone = 1 };
61
62     /**
63       * Adds an editor whose state is listened to, so that the toolbar can be kept up to date
64       * with regards to locked status and tooltips.
65       */
66     void addEditor(IEditor *editor);
67
68     /**
69       * Sets the editor and adds its custom toolbar to the widget.
70       */
71     void setCurrentEditor(IEditor *editor);
72
73     void setToolbarCreationFlags(ToolbarCreationFlags flags);
74
75     /**
76       * Adds a toolbar to the widget and sets invisible by default.
77       */
78     void addCenterToolBar(QWidget *toolBar);
79
80     void setNavigationVisible(bool isVisible);
81     void setCanGoBack(bool canGoBack);
82     void setCanGoForward(bool canGoForward);
83     void removeToolbarForEditor(IEditor *editor);
84
85 public slots:
86     void updateEditorStatus(IEditor *editor);
87
88 signals:
89     void closeClicked();
90     void goBackClicked();
91     void goForwardClicked();
92     void listSelectionActivated(int row);
93
94 private slots:
95     void updateEditorListSelection(Core::IEditor *newSelection);
96     void changeActiveEditor(int row);
97     void listContextMenu(QPoint);
98     void makeEditorWritable();
99
100     void checkEditorStatus();
101     void closeView();
102     void updateActionShortcuts();
103
104 private:
105     void updateToolBar(QWidget *toolBar);
106     IEditor *currentEditor() const;
107
108     QScopedPointer<EditorToolBarPrivate> d;
109 };
110
111 } // namespace Core
112
113 #endif // FAKETOOLBAR_H