aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/abstracteditorsupport.h
blob: 0f8a8d179b0ef220b7b17d28216e91fec9f9443c (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
// 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/filepath.h>

#include <QObject>

namespace ProjectExplorer { class Project; }

namespace CppEditor {

class CPPEDITOR_EXPORT AbstractEditorSupport : public QObject
{
    Q_OBJECT

public:
    explicit AbstractEditorSupport(QObject *parent = nullptr);
    ~AbstractEditorSupport() override;

    /// \returns the contents, encoded as UTF-8
    virtual QByteArray contents() const = 0;
    virtual Utils::FilePath filePath() const = 0;
    virtual Utils::FilePath sourceFilePath() const = 0;

    void updateDocument();
    void notifyAboutUpdatedContents() const;
    unsigned revision() const { return m_revision; }

    static QString licenseTemplate(ProjectExplorer::Project *project,
                                   const Utils::FilePath &filePath = {},
                                   const QString &className = {});
    static bool usePragmaOnce(ProjectExplorer::Project *project);

private:
    unsigned m_revision;
};

} // CppEditor