forked from qt-creator/qt-creator
Improve IEditor documentation
Change-Id: I63b1e560c067bb5bf6613dc0f1642b75f8596966 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -26,66 +26,93 @@
|
|||||||
#include "ieditor.h"
|
#include "ieditor.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Core::IEditor
|
\class Core::IEditor
|
||||||
\inheaderfile coreplugin/editormanager/ieditor.h
|
\inheaderfile coreplugin/editormanager/ieditor.h
|
||||||
\inmodule QtCreator
|
\inmodule QtCreator
|
||||||
|
|
||||||
\brief The IEditor class is an interface for providing suitable editors for
|
\brief The IEditor class provides an interface for editing an open document
|
||||||
documents according to their MIME type.
|
in \QC.
|
||||||
|
|
||||||
Classes that implement this interface are for example the editors for
|
IEditor instances are usually created by a corresponding IEditorFactory.
|
||||||
C++ files, UI files, and resource files.
|
|
||||||
|
|
||||||
Whenever a user wants to edit or create a document, the EditorManager
|
An IEditor instance provides an editor widget for a single IDocument via
|
||||||
scans all IEditorFactory interfaces for suitable editors. The selected
|
the IContext::widget() method. If the the editor type supports it, multiple
|
||||||
IEditorFactory is then asked to create an editor, which must implement
|
editors can be opened for the same document. Multiple IEditor instances
|
||||||
this interface.
|
share ownership of the same IDocument instance in that case.
|
||||||
|
|
||||||
\sa Core::IEditorFactory, Core::EditorManager
|
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 Core::IDocument *Core::IEditor::document() const
|
\fn IEditor *IEditor::duplicate()
|
||||||
Returns the document to open in an editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
Returns a duplicate of the editor, for example when the user splits the
|
||||||
\fn Core::IEditor *Core::IEditor::duplicate()
|
editor view. The default implementation returns \c nullptr.
|
||||||
Duplicates the editor.
|
|
||||||
|
|
||||||
\sa duplicateSupported()
|
\sa duplicateSupported()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QByteArray Core::IEditor::saveState() const
|
\fn QByteArray IEditor::saveState() const
|
||||||
Saves the state of the document.
|
|
||||||
|
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 bool Core::IEditor::restoreState(const QByteArray &state)
|
\fn void IEditor::restoreState(const QByteArray &state)
|
||||||
Restores the \a state of the document.
|
|
||||||
|
|
||||||
Returns \c true on success.
|
Restores the \a state of the editor. The default implementation does
|
||||||
|
nothing.
|
||||||
|
|
||||||
|
\sa saveState()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn int Core::IEditor::currentLine() const
|
\fn int IEditor::currentLine() const
|
||||||
Returns the current line in the document.
|
|
||||||
|
Returns the current line in the document, if appropriate. The default
|
||||||
|
implementation returns \c 0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn int Core::IEditor::currentColumn() const
|
\fn int IEditor::currentColumn() const
|
||||||
Returns the current column in the document.
|
|
||||||
|
Returns the current column in the document, if appropriate. The default
|
||||||
|
implementation returns \c 0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void Core::IEditor::gotoLine(int line, int column = 0, bool centerLine = true)
|
\fn void IEditor::gotoLine(int line, int column, bool centerLine)
|
||||||
|
|
||||||
Goes to \a line and \a column in the document. If \a centerLine is
|
Goes to \a line and \a column in the document. If \a centerLine is
|
||||||
\c true, centers the line in the editor.
|
\c true, centers the line in the editor.
|
||||||
|
|
||||||
|
The default implementation does nothing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QWidget Core::IEditor::toolBar()
|
\fn QWidget IEditor::toolBar()
|
||||||
|
|
||||||
Returns the toolbar for the editor.
|
Returns the toolbar for the editor.
|
||||||
|
|
||||||
The editor toolbar is located at the top of the editor view. The editor
|
The editor toolbar is located at the top of the editor view. The editor
|
||||||
@@ -93,22 +120,30 @@
|
|||||||
currently open in the editor.
|
currently open in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \fn bool Core::IEditor::isDesignModePreferred() const
|
/*!
|
||||||
Indicates whether the document should be opened in the Design mode.
|
\fn bool IEditor::isDesignModePreferred() const
|
||||||
Returns \c false unless Design mode is preferred.
|
|
||||||
|
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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
Creates an IEditor.
|
||||||
|
|
||||||
|
Implementations must create a corresponding document, or share an existing
|
||||||
|
document with another IEditor.
|
||||||
*/
|
*/
|
||||||
IEditor::IEditor()
|
IEditor::IEditor()
|
||||||
: m_duplicateSupported(false)
|
: m_duplicateSupported(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns whether duplication is supported.
|
Returns whether duplication is supported, for example when the user splits
|
||||||
|
the editor view.
|
||||||
|
|
||||||
|
\sa duplicate()
|
||||||
|
\sa setDuplicateSupported()
|
||||||
*/
|
*/
|
||||||
bool IEditor::duplicateSupported() const
|
bool IEditor::duplicateSupported() const
|
||||||
{
|
{
|
||||||
@@ -117,6 +152,11 @@ bool IEditor::duplicateSupported() const
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
Sets whether duplication is supported to \a duplicatesSupported.
|
Sets whether duplication is supported to \a duplicatesSupported.
|
||||||
|
|
||||||
|
The default is \c false.
|
||||||
|
|
||||||
|
\sa duplicate()
|
||||||
|
\sa duplicateSupported()
|
||||||
*/
|
*/
|
||||||
void IEditor::setDuplicateSupported(bool duplicatesSupported)
|
void IEditor::setDuplicateSupported(bool duplicatesSupported)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user