aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cppcodemodelsettings.h
blob: 9bf2b6862db7567350adc7607af0173544189958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "cppeditor_global.h"

#include <utils/store.h>

namespace ProjectExplorer { class Project; }
namespace Utils {
class FilePath;
class QtcSettings;
}

namespace CppEditor {
enum class UsePrecompiledHeaders;

class CPPEDITOR_EXPORT CppCodeModelSettings
{
public:
    enum PCHUsage {
        PchUse_None = 1,
        PchUse_BuildSystem = 2
    };

    CppCodeModelSettings() = default;
    CppCodeModelSettings(const Utils::Store &store) { fromMap(store); }

    friend bool operator==(const CppCodeModelSettings &s1, const CppCodeModelSettings &s2);
    friend bool operator!=(const CppCodeModelSettings &s1, const CppCodeModelSettings &s2)
    {
        return !(s1 == s2);
    }

    Utils::Store toMap() const;
    void fromMap(const Utils::Store &store);

    static CppCodeModelSettings settingsForProject(const ProjectExplorer::Project *project);
    static CppCodeModelSettings settingsForProject(const Utils::FilePath &projectFile);
    static CppCodeModelSettings settingsForFile(const Utils::FilePath &file);
    static bool hasCustomSettings(const ProjectExplorer::Project *project);
    static void setSettingsForProject(ProjectExplorer::Project *project,
                                      const CppCodeModelSettings &settings);

    static const CppCodeModelSettings &global() { return globalInstance(); }
    static void setGlobal(const CppCodeModelSettings &settings);

    static PCHUsage pchUsageForProject(const ProjectExplorer::Project *project);
    UsePrecompiledHeaders usePrecompiledHeaders() const;
    static UsePrecompiledHeaders usePrecompiledHeaders(const ProjectExplorer::Project *project);

    int effectiveIndexerFileSizeLimitInMb() const;

    static bool categorizeFindReferences();
    static void setCategorizeFindReferences(bool categorize);

    QString ignorePattern;
    PCHUsage pchUsage = PchUse_BuildSystem;
    int indexerFileSizeLimitInMb = 5;
    bool interpretAmbigiousHeadersAsC = false;
    bool skipIndexingBigFiles = true;
    bool useBuiltinPreprocessor = true;
    bool ignoreFiles = false;
    bool enableIndexing = true;
    bool m_categorizeFindReferences = false; // Ephemeral!

private:
    CppCodeModelSettings(Utils::QtcSettings *s) { fromSettings(s); }
    static CppCodeModelSettings &globalInstance();

    void toSettings(Utils::QtcSettings *s);
    void fromSettings(Utils::QtcSettings *s);
};

namespace Internal {
void setupCppCodeModelSettingsPage();
void setupCppCodeModelProjectSettingsPanel();
} // namespace Internal

} // namespace CppEditor