IEditor Class
class Core::IEditorThe IEditor class provides an interface for editing an open document in Qt Creator. More...
Header: | #include <coreplugin/editormanager/ieditor.h> |
Inherits: | Core::IContext |
Public Functions
IEditor() | |
virtual int | currentColumn() const |
virtual int | currentLine() const |
virtual Core::IDocument * | document() const = 0 |
virtual Core::IEditor * | duplicate() |
bool | duplicateSupported() const |
virtual void | gotoLine(int line, int column = 0, bool centerLine = true) |
virtual bool | isDesignModePreferred() const |
virtual void | restoreState(const QByteArray &state) |
virtual QByteArray | saveState() const |
void | setDuplicateSupported(bool duplicatesSupported) |
virtual QWidget * | toolBar() = 0 |
Detailed Description
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 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.
See also Core::IEditorFactory and Core::EditorManager.
Member Function Documentation
IEditor::IEditor()
Creates an IEditor.
Implementations must create a corresponding document, or share an existing document with another IEditor.
[virtual]
int IEditor::currentColumn() const
Returns the current column in the document, if appropriate. The default implementation returns 0
. Column numbers start at 0
for the first column.
See also currentLine() and gotoLine().
[virtual]
int IEditor::currentLine() const
Returns the current line in the document, if appropriate. The default implementation returns 0
. Line numbers start at 1
for the first line.
See also currentColumn() and gotoLine().
[pure virtual]
Core::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 nullptr
.
[virtual]
Core::IEditor *IEditor::duplicate()
Returns a duplicate of the editor, for example when the user splits the editor view. The default implementation returns nullptr
.
See also duplicateSupported().
bool IEditor::duplicateSupported() const
Returns whether duplication is supported, for example when the user splits the editor view.
See also duplicate() and setDuplicateSupported().
[virtual]
void IEditor::gotoLine(int line, int column = 0, bool centerLine = true)
Goes to line and column in the document. If centerLine is true
, centers the line in the editor.
Line numbers start at 1
for the first line, column numbers start at 0
for the first column.
The default implementation does nothing.
See also currentLine() and currentColumn().
[virtual]
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 false
.
[virtual]
void IEditor::restoreState(const QByteArray &state)
Restores the state of the editor. The default implementation does nothing.
See also saveState().
[virtual]
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.
See also restoreState().
void IEditor::setDuplicateSupported(bool duplicatesSupported)
Sets whether duplication is supported to duplicatesSupported.
The default is false
.
See also duplicate() and duplicateSupported().
[pure virtual]
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.
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.