OSDN Git Service

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