OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / projectexplorer / editorconfiguration.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 (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef EDITORCONFIGURATION_H
34 #define EDITORCONFIGURATION_H
35
36 #include "projectexplorer_export.h"
37
38 #include <QtCore/QObject>
39 #include <QtCore/QVariantMap>
40 #include <QtCore/QScopedPointer>
41
42 namespace TextEditor {
43 class ITextEditor;
44 class BaseTextEditorWidget;
45 class TabSettings;
46 class StorageSettings;
47 class BehaviorSettings;
48 class ExtraEncodingSettings;
49 }
50
51 namespace ProjectExplorer {
52
53 struct EditorConfigurationPrivate;
54
55 class PROJECTEXPLORER_EXPORT EditorConfiguration : public QObject
56 {
57     Q_OBJECT
58
59 public:
60     EditorConfiguration();
61     ~EditorConfiguration();
62
63     bool useGlobalSettings() const;
64     void cloneGlobalSettings();
65
66     // The default codec is returned in the case the project doesn't override it.
67     QTextCodec *textCodec() const;
68
69     const TextEditor::TabSettings &tabSettings() const;
70     const TextEditor::StorageSettings &storageSettings() const;
71     const TextEditor::BehaviorSettings &behaviorSettings() const;
72     const TextEditor::ExtraEncodingSettings &extraEncodingSettings() const;
73
74     void apply(TextEditor::ITextEditor *textEditor) const;
75
76     QVariantMap toMap() const;
77     void fromMap(const QVariantMap &map);
78
79 signals:
80     void tabSettingsChanged(const TextEditor::TabSettings &);
81     void storageSettingsChanged(const TextEditor::StorageSettings &);
82     void behaviorSettingsChanged(const TextEditor::BehaviorSettings &);
83     void extraEncodingSettingsChanged(const TextEditor::ExtraEncodingSettings &);
84
85 private slots:
86     void setUseGlobalSettings(bool use);
87
88     void setInsertSpaces(bool spaces);
89     void setAutoInsertSpaces(bool autoSpaces);
90     void setAutoIndent(bool autoIndent);
91     void setSmartBackSpace(bool smartBackSpace);
92     void setTabSize(int size);
93     void setIndentSize(int size);
94     void setIndentBlocksBehavior(int index);
95     void setTabKeyBehavior(int index);
96     void setContinuationAlignBehavior(int index);
97
98     void setCleanWhiteSpace(bool cleanWhiteSpace);
99     void setInEntireDocument(bool entireDocument);
100     void setAddFinalNewLine(bool newLine);
101     void setCleanIndentation(bool cleanIndentation);
102
103     void setMouseNavigation(bool mouseNavigation);
104     void setScrollWheelZooming(bool scrollZooming);
105
106     void setUtf8BomSettings(int index);
107
108     void setTextCodec(QTextCodec *textCodec);
109
110 private:
111     void switchSettings(TextEditor::BaseTextEditorWidget *baseTextEditor) const;
112     template <class NewSenderT, class OldSenderT>
113     void switchSettings_helper(const NewSenderT *newSender,
114                                const OldSenderT *oldSender,
115                                TextEditor::BaseTextEditorWidget *baseTextEditor) const;
116
117     void emitTabSettingsChanged();
118     void emitStorageSettingsChanged();
119     void emitBehaviorSettingsChanged();
120     void emitExtraEncodingSettingsChanged();
121
122     QScopedPointer<EditorConfigurationPrivate> m_d;
123 };
124
125 // Return the editor settings in the case it's not null. Otherwise, try to find the project
126 // the file belongs to and return the project settings. If the file doesn't belong to any
127 // project return the global settings.
128 PROJECTEXPLORER_EXPORT const TextEditor::TabSettings &actualTabSettings(
129     const QString &fileName, const TextEditor::BaseTextEditorWidget *baseTextEditor);
130
131 } // ProjectExplorer
132
133 #endif // EDITORCONFIGURATION_H