1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
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
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 ** 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.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef EDITORCONFIGURATION_H
35 #define EDITORCONFIGURATION_H
37 #include "projectexplorer_export.h"
39 #include <QtCore/QObject>
40 #include <QtCore/QVariantMap>
41 #include <QtCore/QScopedPointer>
43 namespace TextEditor {
45 class BaseTextEditorWidget;
47 class StorageSettings;
48 class BehaviorSettings;
49 class ExtraEncodingSettings;
52 namespace ProjectExplorer {
54 struct EditorConfigurationPrivate;
56 class PROJECTEXPLORER_EXPORT EditorConfiguration : public QObject
61 EditorConfiguration();
62 ~EditorConfiguration();
64 bool useGlobalSettings() const;
65 void cloneGlobalSettings();
67 // The default codec is returned in the case the project doesn't override it.
68 QTextCodec *textCodec() const;
70 const TextEditor::TabSettings &tabSettings() const;
71 const TextEditor::StorageSettings &storageSettings() const;
72 const TextEditor::BehaviorSettings &behaviorSettings() const;
73 const TextEditor::ExtraEncodingSettings &extraEncodingSettings() const;
75 void apply(TextEditor::ITextEditor *textEditor) const;
77 QVariantMap toMap() const;
78 void fromMap(const QVariantMap &map);
81 void tabSettingsChanged(const TextEditor::TabSettings &);
82 void storageSettingsChanged(const TextEditor::StorageSettings &);
83 void behaviorSettingsChanged(const TextEditor::BehaviorSettings &);
84 void extraEncodingSettingsChanged(const TextEditor::ExtraEncodingSettings &);
87 void setUseGlobalSettings(bool use);
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);
99 void setCleanWhiteSpace(bool cleanWhiteSpace);
100 void setInEntireDocument(bool entireDocument);
101 void setAddFinalNewLine(bool newLine);
102 void setCleanIndentation(bool cleanIndentation);
104 void setMouseNavigation(bool mouseNavigation);
105 void setScrollWheelZooming(bool scrollZooming);
107 void setUtf8BomSettings(int index);
109 void setTextCodec(QTextCodec *textCodec);
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;
118 void emitTabSettingsChanged();
119 void emitStorageSettingsChanged();
120 void emitBehaviorSettingsChanged();
121 void emitExtraEncodingSettingsChanged();
123 QScopedPointer<EditorConfigurationPrivate> m_d;
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);
134 #endif // EDITORCONFIGURATION_H