aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/coreplugin/editormanager/ieditor.cpp
blob: 476f0a75a5977e98f60efe039f19d8939e533058 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#include "ieditor.h"

/*!
    \class Core::IEditor
    \inheaderfile coreplugin/editormanager/ieditor.h
    \inmodule QtCreator

    \brief The IEditor class provides an interface for editing an open document
    in \QC.

    IEditor instances are usually created by a corresponding IEditorFactory.

    An IEditor instance provides an editor widget for a single IDocument via
    the IContext::widget() method. If the the editor type supports it, multiple
    editors can be opened for the same document. Multiple IEditor instances
    share ownership of the same IDocument instance in that case.

    The IEditor::toolBar() is integrated into the toolbar above the editor
    widget, next to the document drop down.

    \sa Core::IEditorFactory, Core::EditorManager
*/

namespace Core {

/*!
    \fn IDocument *IEditor::document() const

    Returns the document that is edited by this editor. The editor owns the
    document. If the editor supports splitting, all editors created with
    duplicate() share ownership of the document.

    This must never return \c nullptr.
*/

/*!
    \fn IEditor *IEditor::duplicate()

    Returns a duplicate of the editor, for example when the user splits the
    editor view. The default implementation returns \c nullptr.

    \sa duplicateSupported()
*/

/*!
    \fn QByteArray IEditor::saveState() const

    Returns the state of the editor, like scroll and cursor position, as a
    QByteArray. This is used for restoring the state for example after the
    document was closed (manually or automatically) and re-opened later. The
    default implementation returns an empty QByteArray.

    \sa restoreState()
*/

/*!
    \fn void IEditor::restoreState(const QByteArray &state)

    Restores the \a state of the editor. The default implementation does
    nothing.

    \sa saveState()
*/

/*!
    \fn int IEditor::currentLine() const

    Returns the current line in the document, if appropriate. The default
    implementation returns \c 0. Line numbers start at \c 1 for the first line.

    \sa currentColumn()
    \sa gotoLine()
*/

/*!
    \fn int IEditor::currentColumn() const

    Returns the current column in the document, if appropriate. The default
    implementation returns \c 0. Column numbers start at \c 0 for the first
    column.

    \sa currentLine()
    \sa gotoLine()
*/

/*!
    \fn void IEditor::gotoLine(int line, int column, bool centerLine)

    Goes to \a line and \a column in the document. If \a centerLine is
    \c true, centers the line in the editor.

    Line numbers start at \c 1 for the first line, column numbers start at \c 0
    for the first column.

    The default implementation does nothing.

    \sa currentLine()
    \sa currentColumn()
*/

/*!
    \fn QWidget IEditor::toolBar()

    Returns the toolbar for the editor.

    The editor toolbar is located at the top of the editor view. The editor
    toolbar is context sensitive and shows items relevant to the document
    currently open in the editor.
*/

/*!
    \fn bool IEditor::isDesignModePreferred() const

    Returns whether the document should be opened in the Design mode by
    default. This requires design mode to support that document type. The
    default implementation returns \c false.
*/

/*!
    Creates an IEditor.

    Implementations must create a corresponding document, or share an existing
    document with another IEditor.
*/
IEditor::IEditor()
    : m_duplicateSupported(false)
{}

/*!
    Returns whether duplication is supported, for example when the user splits
    the editor view.

    \sa duplicate()
    \sa setDuplicateSupported()
*/
bool IEditor::duplicateSupported() const
{
    return m_duplicateSupported;
}

/*!
    Sets whether duplication is supported to \a duplicatesSupported.

    The default is \c false.

    \sa duplicate()
    \sa duplicateSupported()
*/
void IEditor::setDuplicateSupported(bool duplicatesSupported)
{
    m_duplicateSupported = duplicatesSupported;
}

} // namespace Core