aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cursorineditor.h
blob: 46dd4b2b2ace13a05be0da96468fbeb9b55b6420 (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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <utils/fileutils.h>
#include <utils/link.h>

#include <QTextCursor>

#include <functional>

namespace TextEditor { class TextDocument; }

namespace CppEditor {
class CppEditorWidget;

// TODO: Move to a better place.
using RenameCallback = std::function<void(const QString &, const Utils::Links &, int)>;

class CursorInEditor
{
public:
    CursorInEditor(const QTextCursor &cursor, const Utils::FilePath &filePath,
                 CppEditorWidget *editorWidget = nullptr,
                 TextEditor::TextDocument *textDocument = nullptr)
        : m_cursor(cursor)
        , m_filePath(filePath)
        , m_editorWidget(editorWidget)
        , m_textDocument(textDocument)
    {}
    CppEditorWidget *editorWidget() const { return m_editorWidget; }
    TextEditor::TextDocument *textDocument() const { return m_textDocument; }
    const QTextCursor &cursor() const { return m_cursor; }
    const Utils::FilePath &filePath() const { return m_filePath; }
private:
    QTextCursor m_cursor;
    Utils::FilePath m_filePath;
    CppEditorWidget *m_editorWidget = nullptr;
    TextEditor::TextDocument * const m_textDocument;
};

} // namespace CppEditor