• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

KTextEditor

  • KTextEditor
  • View
Public Types | Signals | Public Member Functions | List of all members
KTextEditor::View Class Referenceabstract

#include <view.h>

Inheritance diagram for KTextEditor::View:
Inheritance graph
[legend]

Public Types

enum  EditMode { EditInsert = 0, EditOverwrite = 1, EditViMode = 2 }
 

Signals

void contextMenuAboutToShow (KTextEditor::View *view, QMenu *menu)
 
void cursorPositionChanged (KTextEditor::View *view, const KTextEditor::Cursor &newPosition)
 
void focusIn (KTextEditor::View *view)
 
void focusOut (KTextEditor::View *view)
 
void horizontalScrollPositionChanged (KTextEditor::View *view)
 
void informationMessage (KTextEditor::View *view, const QString &message)
 
void mousePositionChanged (KTextEditor::View *view, const KTextEditor::Cursor &newPosition)
 
void selectionChanged (KTextEditor::View *view)
 
void textInserted (KTextEditor::View *view, const KTextEditor::Cursor &position, const QString &text)
 
void verticalScrollPositionChanged (KTextEditor::View *view, const KTextEditor::Cursor &newPos)
 
void viewEditModeChanged (KTextEditor::View *view, enum KTextEditor::View::EditMode mode)
 
void viewModeChanged (KTextEditor::View *view)
 

Public Member Functions

 View (QWidget *parent)
 
virtual ~View ()
 
virtual bool blockSelection () const =0
 
virtual QMenu * contextMenu () const =0
 
virtual Cursor cursorPosition () const =0
 
virtual QPoint cursorPositionCoordinates () const =0
 
virtual Cursor cursorPositionVirtual () const =0
 
virtual QPoint cursorToCoordinate (const KTextEditor::Cursor &cursor) const =0
 
virtual QMenu * defaultContextMenu (QMenu *menu=0L) const =0
 
virtual Document * document () const =0
 
virtual bool insertText (const QString &text)
 
bool isActiveView () const
 
virtual bool mouseTrackingEnabled () const =0
 
virtual bool removeSelection ()=0
 
virtual bool removeSelectionText ()=0
 
virtual bool selection () const =0
 
virtual const Range & selectionRange () const =0
 
virtual QString selectionText () const =0
 
virtual bool setBlockSelection (bool on)=0
 
virtual void setContextMenu (QMenu *menu)=0
 
virtual bool setCursorPosition (Cursor position)=0
 
virtual bool setMouseTrackingEnabled (bool enable)=0
 
virtual bool setSelection (const Range &range)=0
 
virtual bool setSelection (const Cursor &position, int length, bool wrap=true)
 
virtual enum EditMode viewEditMode () const =0
 
virtual QString viewMode () const =0
 
- Public Member Functions inherited from QWidget
 QWidget (QWidget *parent, QFlags< Qt::WindowType > f)
 
 QWidget (QWidget *parent, const char *name, QFlags< Qt::WindowType > f)
 
 ~QWidget ()
 
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 
void activateWindow ()
 
void addAction (QAction *action)
 
void addActions (QList< QAction * > actions)
 
void adjustSize ()
 
bool autoFillBackground () const
 
Qt::BackgroundMode backgroundMode () const
 
QPoint backgroundOffset () const
 
BackgroundOrigin backgroundOrigin () const
 
QPalette::ColorRole backgroundRole () const
 
QSize baseSize () const
 
QString caption () const
 
QWidget * childAt (int x, int y, bool includeThis) const
 
QWidget * childAt (const QPoint &p, bool includeThis) const
 
QWidget * childAt (int x, int y) const
 
QWidget * childAt (const QPoint &p) const
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 
void clearMask ()
 
bool close (bool alsoDelete)
 
bool close ()
 
QColorGroup colorGroup () const
 
void constPolish () const
 
QMargins contentsMargins () const
 
QRect contentsRect () const
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
QCursor cursor () const
 
void customContextMenuRequested (const QPoint &pos)
 
void drawText (const QPoint &p, const QString &s)
 
void drawText (int x, int y, const QString &s)
 
WId effectiveWinId () const
 
void ensurePolished () const
 
void erase ()
 
void erase (const QRect &rect)
 
void erase (const QRegion &rgn)
 
void erase (int x, int y, int w, int h)
 
Qt::FocusPolicy focusPolicy () const
 
QWidget * focusProxy () const
 
QWidget * focusWidget () const
 
const QFont & font () const
 
QFontInfo fontInfo () const
 
QFontMetrics fontMetrics () const
 
QPalette::ColorRole foregroundRole () const
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRect & geometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 
virtual HDC getDC () const
 
void grabGesture (Qt::GestureType gesture, QFlags< Qt::GestureFlag > flags)
 
void grabKeyboard ()
 
void grabMouse ()
 
void grabMouse (const QCursor &cursor)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context)
 
QGraphicsEffect * graphicsEffect () const
 
QGraphicsProxyWidget * graphicsProxyWidget () const
 
bool hasEditFocus () const
 
bool hasFocus () const
 
bool hasMouse () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int w) const
 
void hide ()
 
const QPixmap * icon () const
 
void iconify ()
 
QString iconText () const
 
QInputContext * inputContext ()
 
Qt::InputMethodHints inputMethodHints () const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
void insertAction (QAction *before, QAction *action)
 
void insertActions (QAction *before, QList< QAction * > actions)
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 
bool isDesktop () const
 
bool isDialog () const
 
bool isEnabled () const
 
bool isEnabledTo (QWidget *ancestor) const
 
bool isEnabledToTLW () const
 
bool isFullScreen () const
 
bool isHidden () const
 
bool isInputMethodEnabled () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isPopup () const
 
bool isShown () const
 
bool isTopLevel () const
 
bool isUpdatesEnabled () const
 
bool isVisible () const
 
bool isVisibleTo (QWidget *ancestor) const
 
bool isVisibleToTLW () const
 
bool isWindow () const
 
bool isWindowModified () const
 
QLayout * layout () const
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
void lower ()
 
Qt::HANDLE macCGHandle () const
 
Qt::HANDLE macQDHandle () const
 
QPoint mapFrom (QWidget *parent, const QPoint &pos) const
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapFromParent (const QPoint &pos) const
 
QPoint mapTo (QWidget *parent, const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QPoint mapToParent (const QPoint &pos) const
 
QRegion mask () const
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
virtual QSize minimumSizeHint () const
 
int minimumWidth () const
 
void move (int x, int y)
 
void move (const QPoint &)
 
QWidget * nativeParentWidget () const
 
QWidget * nextInFocusChain () const
 
QRect normalGeometry () const
 
void overrideWindowFlags (QFlags< Qt::WindowType > flags)
 
bool ownCursor () const
 
bool ownFont () const
 
bool ownPalette () const
 
virtual QPaintEngine * paintEngine () const
 
const QPalette & palette () const
 
QWidget * parentWidget (bool sameWindow) const
 
QWidget * parentWidget () const
 
QPlatformWindow * platformWindow () const
 
QPlatformWindowFormat platformWindowFormat () const
 
void polish ()
 
QPoint pos () const
 
QWidget * previousInFocusChain () const
 
void raise ()
 
void recreate (QWidget *parent, QFlags< Qt::WindowType > f, const QPoint &p, bool showIt)
 
QRect rect () const
 
virtual void releaseDC (HDC hdc) const
 
void releaseKeyboard ()
 
void releaseMouse ()
 
void releaseShortcut (int id)
 
void removeAction (QAction *action)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QFlags< QWidget::RenderFlag > renderFlags)
 
void render (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QFlags< QWidget::RenderFlag > renderFlags)
 
void repaint (int x, int y, int w, int h, bool b)
 
void repaint (const QRegion &rgn, bool b)
 
void repaint ()
 
void repaint (int x, int y, int w, int h)
 
void repaint (const QRegion &rgn)
 
void repaint (bool b)
 
void repaint (const QRect &rect)
 
void repaint (const QRect &r, bool b)
 
void reparent (QWidget *parent, QFlags< Qt::WindowType > f, const QPoint &p, bool showIt)
 
void reparent (QWidget *parent, const QPoint &p, bool showIt)
 
void resize (int w, int h)
 
void resize (const QSize &)
 
bool restoreGeometry (const QByteArray &geometry)
 
QByteArray saveGeometry () const
 
void scroll (int dx, int dy)
 
void scroll (int dx, int dy, const QRect &r)
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setActiveWindow ()
 
void setAttribute (Qt::WidgetAttribute attribute, bool on)
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundColor (const QColor &color)
 
void setBackgroundMode (Qt::BackgroundMode widgetBackground, Qt::BackgroundMode paletteBackground)
 
void setBackgroundOrigin (BackgroundOrigin background)
 
void setBackgroundPixmap (const QPixmap &pixmap)
 
void setBackgroundRole (QPalette::ColorRole role)
 
void setBaseSize (const QSize &)
 
void setBaseSize (int basew, int baseh)
 
void setCaption (const QString &c)
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContentsMargins (const QMargins &margins)
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setDisabled (bool disable)
 
void setEditFocus (bool enable)
 
void setEnabled (bool)
 
void setEraseColor (const QColor &color)
 
void setErasePixmap (const QPixmap &pixmap)
 
void setFixedHeight (int h)
 
void setFixedSize (const QSize &s)
 
void setFixedSize (int w, int h)
 
void setFixedWidth (int w)
 
void setFocus (Qt::FocusReason reason)
 
void setFocus ()
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *w)
 
void setFont (const QFont &)
 
void setFont (const QFont &f, bool b)
 
void setForegroundRole (QPalette::ColorRole role)
 
void setGeometry (int x, int y, int w, int h)
 
void setGeometry (const QRect &)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 
void setHidden (bool hidden)
 
void setIcon (const QPixmap &i)
 
void setIconText (const QString &it)
 
void setInputContext (QInputContext *context)
 
void setInputMethodEnabled (bool enabled)
 
void setInputMethodHints (QFlags< Qt::InputMethodHint > hints)
 
void setKeyCompression (bool b)
 
void setLayout (QLayout *layout)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &bitmap)
 
void setMask (const QRegion &region)
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (int minw, int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 
void setPalette (const QPalette &p, bool b)
 
void setPaletteBackgroundColor (const QColor &color)
 
void setPaletteBackgroundPixmap (const QPixmap &pixmap)
 
void setPaletteForegroundColor (const QColor &color)
 
void setParent (QWidget *parent)
 
void setParent (QWidget *parent, QFlags< Qt::WindowType > f)
 
void setPlatformWindow (QPlatformWindow *window)
 
void setPlatformWindowFormat (const QPlatformWindowFormat &format)
 
void setShortcutAutoRepeat (int id, bool enable)
 
void setShortcutEnabled (int id, bool enable)
 
void setShown (bool shown)
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 
void setSizePolicy (QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
void setSizePolicy (QSizePolicy)
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *style)
 
QStyle * setStyle (const QString &style)
 
void setStyleSheet (const QString &styleSheet)
 
void setToolTip (const QString &)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 
virtual void setVisible (bool visible)
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (QFlags< Qt::WindowType > type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowModified (bool)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &role)
 
void setWindowState (QFlags< Qt::WindowState > windowState)
 
void setWindowSurface (QWindowSurface *surface)
 
void setWindowTitle (const QString &)
 
void show ()
 
void showFullScreen ()
 
void showMaximized ()
 
void showMinimized ()
 
void showNormal ()
 
QSize size () const
 
virtual QSize sizeHint () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *w)
 
QString statusTip () const
 
QStyle * style () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute attribute) const
 
QString toolTip () const
 
QWidget * topLevelWidget () const
 
bool underMouse () const
 
void ungrabGesture (Qt::GestureType gesture)
 
void unsetCursor ()
 
void unsetFont ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void unsetPalette ()
 
void update (const QRect &rect)
 
void update (const QRegion &rgn)
 
void update (int x, int y, int w, int h)
 
void update ()
 
void updateGeometry ()
 
bool updatesEnabled () const
 
QRect visibleRect () const
 
QRegion visibleRegion () const
 
QString whatsThis () const
 
int width () const
 
QWidget * window () const
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 
QIcon windowIcon () const
 
QString windowIconText () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 
Qt::WindowStates windowState () const
 
QWindowSurface * windowSurface () const
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 
WId winId () const
 
int x () const
 
const QX11Info & x11Info () const
 
Qt::HANDLE x11PictureHandle () const
 
int y () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 
- Public Member Functions inherited from QPaintDevice
virtual  ~QPaintDevice ()
 
int colorCount () const
 
int depth () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
int numColors () const
 
virtual QPaintEngine * paintEngine () const =0
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 
int x11Cells () const
 
Qt::HANDLE x11Colormap () const
 
bool x11DefaultColormap () const
 
bool x11DefaultVisual () const
 
int x11Depth () const
 
Display * x11Display () const
 
int x11Screen () const
 
void * x11Visual () const
 

Additional Inherited Members

- Static Public Member Functions inherited from QWidget
QWidget * find (WId id)
 
QWidget * keyboardGrabber ()
 
QWidget * mouseGrabber ()
 
void setTabOrder (QWidget *first, QWidget *second)
 
QWidgetMapper * wmapper ()
 
- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Static Public Member Functions inherited from QPaintDevice
int x11AppCells (int screen)
 
Qt::HANDLE x11AppColormap (int screen)
 
bool x11AppDefaultColormap (int screen)
 
bool x11AppDefaultVisual (int screen)
 
int x11AppDepth (int screen)
 
Display * x11AppDisplay ()
 
int x11AppDpiX (int screen)
 
int x11AppDpiY (int screen)
 
Qt::HANDLE x11AppRootWindow (int screen)
 
int x11AppScreen ()
 
void * x11AppVisual (int screen)
 
void x11SetAppDpiX (int dpi, int screen)
 
void x11SetAppDpiY (int dpi, int screen)
 
- Public Attributes inherited from QWidget
typedef RenderFlags
 
- Protected Member Functions inherited from QWidget
virtual void actionEvent (QActionEvent *event)
 
virtual void changeEvent (QEvent *event)
 
virtual void closeEvent (QCloseEvent *event)
 
virtual void contextMenuEvent (QContextMenuEvent *event)
 
void create (WId window, bool initializeWindow, bool destroyOldWindow)
 
void destroy (bool destroyWindow, bool destroySubWindows)
 
virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
virtual void enterEvent (QEvent *event)
 
virtual bool event (QEvent *event)
 
virtual void focusInEvent (QFocusEvent *event)
 
bool focusNextChild ()
 
virtual bool focusNextPrevChild (bool next)
 
virtual void focusOutEvent (QFocusEvent *event)
 
bool focusPreviousChild ()
 
virtual void hideEvent (QHideEvent *event)
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void languageChange ()
 
virtual void leaveEvent (QEvent *event)
 
virtual bool macEvent (EventHandlerCallRef caller, EventRef event)
 
virtual int metric (PaintDeviceMetric m) const
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void moveEvent (QMoveEvent *event)
 
virtual void paintEvent (QPaintEvent *event)
 
virtual bool qwsEvent (QWSEvent *event)
 
void resetInputContext ()
 
virtual void resizeEvent (QResizeEvent *event)
 
virtual void showEvent (QShowEvent *event)
 
virtual void tabletEvent (QTabletEvent *event)
 
void updateMicroFocus ()
 
virtual void wheelEvent (QWheelEvent *event)
 
virtual bool winEvent (MSG *message, long *result)
 
virtual bool x11Event (XEvent *event)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Member Functions inherited from QPaintDevice
 QPaintDevice ()
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 toolTip
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 

Detailed Description

A text widget with KXMLGUIClient that represents a Document.

Topics:

  • Introduction
  • Merging the View's GUI
  • Text Selection
  • Cursor Positions
  • Mouse Tracking
  • Edit Modes
  • View Extension Interfaces

Introduction

The View class represents a single view of a KTextEditor::Document, get the document on which the view operates with document(). A view provides both the graphical representation of the text and the KXMLGUIClient for the actions. The view itself does not provide text manipulation, use the methods from the Document instead. The only method to insert text is insertText(), which inserts the given text at the current cursor position and emits the signal textInserted().

Usually a view is created by using Document::createView(). Furthermore a view can have a context menu. Set it with setContextMenu() and get it with contextMenu().

Merging the View's GUI

A View is derived from the class KXMLGUIClient, so its GUI elements (like menu entries and toolbar items) can be merged into the application's GUI (or into a KXMLGUIFactory) by calling

// view is of type KTextEditor::View*
mainWindow()->guiFactory()->addClient( view );

You can add only one view as client, so if you have several views, you first have to remove the current view, and then add the new one, like this

mainWindow()->guiFactory()->removeClient( currentView );
mainWindow()->guiFactory()->addClient( newView );

Text Selection

As the view is a graphical text editor it provides normal and block text selection. You can check with selection() whether a selection exists. removeSelection() will remove the selection without removing the text, whereas removeSelectionText() also removes both, the selection and the selected text. Use selectionText() to get the selected text and setSelection() to specify the selected textrange. The signal selectionChanged() is emitted whenever the selecteion changed.

Cursor Positions

A view has one Cursor which represents a line/column tuple. Two different kinds of cursor positions are supported: first is the real cursor position where a tab character only counts one character. Second is the virtual cursor position, where a tab character counts as many spaces as defined. Get the real position with cursorPosition() and the virtual position with cursorPositionVirtual(). Set the real cursor position with setCursorPosition(). You can even get the screen coordinates of the current cursor position in pixel by using cursorPositionCoordinates(). The signal cursorPositionChanged() is emitted whenever the cursor position changed.

Mouse Tracking

It is possible to get notified via the signal mousePositionChanged() for mouse move events, if mouseTrackingEnabled() returns true. Mouse tracking can be turned on/off by calling setMouseTrackingEnabled(). If an editor implementation does not support mouse tracking, mouseTrackingEnabled() will always return false.

Edit Modes

A view supports several edit modes (EditMode). Common edit modes are insert-mode (INS) and overwrite-mode (OVR). Which edit modes the editor supports depends on the implementation, another well-known mode is the command-mode for example in vim and yzis. The getter viewMode() returns a string like INS or OVR and is represented in the user interface for example in the status bar. Further you can get the edit mode as enum by using viewEditMode(). Whenever the edit mode changed the signals viewModeChanged() and viewEditModeChanged() are emitted.

View Extension Interfaces

A simple view represents the text of a Document and provides a text cursor, text selection, edit modes etc. Advanced concepts like code completion and text hints are defined in the extension interfaces. An KTextEditor implementation does not need to support all the extensions. To implement the interfaces multiple inheritance is used.

More information about interfaces for the view can be found in View Extension Interfaces.

See also
KTextEditor::Document, KTextEditor::TemplateInterface, KTextEditor::CodeCompletionInterface, KTextEditor::SessionConfigInterface, KTextEditor::TemplateInterface, KXMLGUIClient
Author
Christoph Cullmann <cullm.nosp@m.ann@.nosp@m.kde.o.nosp@m.rg>

Definition at line 145 of file view.h.

Member Enumeration Documentation

enum KTextEditor::View::EditMode

Possible edit modes.

These correspond to various modes the text editor might be in.

Enumerator
EditInsert 

Insert mode.

Characters will be added.

EditOverwrite 

Overwrite mode.

Characters will be replaced.

EditViMode 

Vi mode.

The view will behave like the editor vi(m)

Since
4.11

Definition at line 205 of file view.h.

Constructor & Destructor Documentation

View::View ( QWidget *  parent)

Constructor.

Create a view attached to the widget parent.

Parameters
parentparent widget
See also
Document::createView()

Definition at line 198 of file ktexteditor.cpp.

View::~View ( )
virtual

Virtual destructor.

Definition at line 203 of file ktexteditor.cpp.

Member Function Documentation

virtual bool KTextEditor::View::blockSelection ( ) const
pure virtual

Get the status of the selection mode.

true indicates that block selection mode is on. If this is true, selections applied via the SelectionInterface are handled as block selections and the Copy&Paste functions work on rectangular blocks of text rather than normal.

Returns
true, if block selection mode is enabled, otherwise false
See also
setBlockSelection()
virtual QMenu* KTextEditor::View::contextMenu ( ) const
pure virtual

Get the context menu for this view.

The return value can be NULL if no context menu object was set and kxmlgui is not initialized yet. If there is no user set menu, the kxmlgui menu is returned. Do not delete this menu, if if it is the xmlgui menu.

Returns
context menu object
See also
setContextMenu()
void KTextEditor::View::contextMenuAboutToShow ( KTextEditor::View *  view,
QMenu *  menu 
)
signal

Signal which is emitted immediately prior to showing the current context menu.

virtual Cursor KTextEditor::View::cursorPosition ( ) const
pure virtual

Get the view's current cursor position.

A TAB character is handeled as only one character.

Returns
current cursor position
See also
setCursorPosition()
void KTextEditor::View::cursorPositionChanged ( KTextEditor::View *  view,
const KTextEditor::Cursor &  newPosition 
)
signal

This signal is emitted whenever the view's cursor position changed.

Parameters
viewview which emitted the signal
newPositionnew position of the cursor (Kate will pass the real cursor potition, not the virtual)
See also
cursorPosition(), cursorPositionVirtual()
virtual QPoint KTextEditor::View::cursorPositionCoordinates ( ) const
pure virtual

Get the coordinates (x/y) of the cursor position in pixels.

The returned coordinates are relative to the View. If global screen coordinates are required, e.g. for showing a QToolTip, conversion as follows is required:

QPoint viewCoordinates = view->cursorPositionCoordinates();
QPoint globalCoorinates = view->mapToGlobal(viewCoordinates);
Returns
cursor screen coordinates
virtual Cursor KTextEditor::View::cursorPositionVirtual ( ) const
pure virtual

Get the current virtual cursor position, virtual means the tabulator character (TAB) counts multiple characters, as configured by the user (e.g.

one TAB is 8 spaces). The virtual cursor position provides access to the user visible values of the current cursor position.

Returns
virtual cursor position
See also
cursorPosition()
virtual QPoint KTextEditor::View::cursorToCoordinate ( const KTextEditor::Cursor &  cursor) const
pure virtual

Get the screen coordinates (x, y) of the supplied cursor relative to the view widget in pixels.

Thus, 0,0 represents the top left hand of the view widget.

Parameters
cursorcursor to determine coordinate for.
Returns
cursor screen coordinates relative to the view widget
virtual QMenu* KTextEditor::View::defaultContextMenu ( QMenu *  menu = 0L) const
pure virtual

Populate menu with default text editor actions.

If menu is null, a menu will be created with the view as its parent.

Note
to use this menu, you will next need to call setContextMenu(), as this does not assign the new context menu.
Warning
This contains only basic options from the editor component (katepart). Plugins are not merged/integrated into it! If you want to be a better citizen and take full advantage of KTextEditor plugins do something like:
KXMLGUIClient* client = view;
// search parent XmlGuiClient
while (client->parentClient()) {
client = client->parentClient();
}
if (client->factory()) {
QList<QWidget*> conts = client->factory()->containers("menu");
foreach (QWidget *w, conts) {
if (w->objectName() == "ktexteditor_popup") {
// do something with the menu (ie adding an onshow handler)
break;
}
}
}
or simply use the aboutToShow, aboutToHide signals !!!!!
Parameters
menuthe menu to be populated, or null to create a new menu.
Returns
the menu, whether created or passed initially
virtual Document* KTextEditor::View::document ( ) const
pure virtual

Get the view's document, that means the view is a view of the returned document.

Returns
the view's document
void KTextEditor::View::focusIn ( KTextEditor::View *  view)
signal

This signal is emitted whenever the view gets the focus.

Parameters
viewview which gets focus
See also
focusOut()
void KTextEditor::View::focusOut ( KTextEditor::View *  view)
signal

This signal is emitted whenever the view loses the focus.

Parameters
viewview which lost focus
See also
focusIn()
void KTextEditor::View::horizontalScrollPositionChanged ( KTextEditor::View *  view)
signal

This signal should be emitted whenever the view is scrolled horizontally.

Parameters
viewview which emitted the signal
void KTextEditor::View::informationMessage ( KTextEditor::View *  view,
const QString &  message 
)
signal

This signal is emitted whenever the view wants to display a information message.

The message can be displayed in the status bar for example.

Parameters
viewview which sends out information
messageinformation message
bool View::insertText ( const QString &  text)
virtual

This is a convenience function which inserts text at the view's current cursor position.

You do not necessarily need to reimplement it, except you want to do some special things.

Parameters
textText to be inserted
Returns
true on success of insertion, otherwise false
See also
textInserted()

Definition at line 140 of file ktexteditor.cpp.

bool View::isActiveView ( ) const

Check whether this view is the document's active view.

This is equal to the code:

document()->activeView() == view

Definition at line 116 of file ktexteditor.cpp.

void KTextEditor::View::mousePositionChanged ( KTextEditor::View *  view,
const KTextEditor::Cursor &  newPosition 
)
signal

This signal is emitted whenever the position of the mouse changes over this view.

If the mouse moves off the view, an invalid cursor position should be emitted, i.e. Cursor::invalid().

Note
If mouseTrackingEnabled() returns false, this signal is never emitted.
Parameters
viewview which emitted the signal
newPositionnew position of the mouse or Cursor::invalid(), if the mouse moved out of the view.
See also
mouseTrackingEnabled()
virtual bool KTextEditor::View::mouseTrackingEnabled ( ) const
pure virtual

Check, whether mouse tracking is enabled.

Mouse tracking is required to have the signal mousePositionChanged() emitted.

Returns
true, if mouse tracking is enabled, otherwise false
See also
setMouseTrackingEnabled(), mousePositionChanged()
virtual bool KTextEditor::View::removeSelection ( )
pure virtual

Remove the view's current selection, without deleting the selected text.

Returns
true on success, otherwise false
See also
removeSelectionText()
virtual bool KTextEditor::View::removeSelectionText ( )
pure virtual

Remove the view's current selection including the selected text.

Returns
true on success, otherwise false
See also
removeSelection()
virtual bool KTextEditor::View::selection ( ) const
pure virtual

Query the view whether it has selected text, i.e.

whether a selection exists.

Returns
true if a text selection exists, otherwise false
See also
setSelection(), selectionRange()
void KTextEditor::View::selectionChanged ( KTextEditor::View *  view)
signal

This signal is emitted whenever the view's selection changes.

Note
If the mode switches from block selection to normal selection or vice versa this signal should also be emitted.
Parameters
viewview in which the selection changed
See also
selection(), selectionRange(), selectionText()
virtual const Range& KTextEditor::View::selectionRange ( ) const
pure virtual

Get the range occupied by the current selection.

Returns
selection range, valid only if a selection currently exists.
See also
setSelection()
virtual QString KTextEditor::View::selectionText ( ) const
pure virtual

Get the view's selected text.

Returns
the selected text
See also
setSelection()
virtual bool KTextEditor::View::setBlockSelection ( bool  on)
pure virtual

Set block selection mode to state on.

Parameters
onif true, block selection mode is turned on, otherwise off
Returns
true on success, otherwise false
See also
blockSelection()
virtual void KTextEditor::View::setContextMenu ( QMenu *  menu)
pure virtual

Set a context menu for this view to menu.

Note
any previously assigned menu is not deleted. If you are finished with the previous menu, you may delete it.
Warning
Use this with care! Plugin xml gui clients are not merged into this menu!
!!!!!! DON'T USE THIS FUNCTION, UNLESS YOU ARE SURE YOU DON'T WANT PLUGINS TO WORK !!!!!!
Parameters
menunew context menu object for this view
See also
contextMenu()
virtual bool KTextEditor::View::setCursorPosition ( Cursor  position)
pure virtual

Set the view's new cursor to position.

A TAB character is handeled as only on character.

Parameters
positionnew cursor position
Returns
true on success, otherwise false
See also
cursorPosition()
virtual bool KTextEditor::View::setMouseTrackingEnabled ( bool  enable)
pure virtual

Try to enable or disable mouse tracking according to enable.

The return value contains the state of mouse tracking after the request. Mouse tracking is required to have the mousePositionChanged() signal emitted.

Note
Implementation Notes: An implementation is not forced to support this, and should always return false if it does not have support.
Parameters
enableif true, try to enable mouse tracking, otherwise disable it.
Returns
the current state of mouse tracking
See also
mouseTrackingEnabled(), mousePositionChanged()
virtual bool KTextEditor::View::setSelection ( const Range &  range)
pure virtual

Set the view's selection to the range selection.

The old selection will be discarded.

Parameters
rangethe range of the new selection
Returns
true on success, otherwise false (e.g. when the cursor range is invalid)
See also
selectionRange(), selection()
bool View::setSelection ( const Cursor &  position,
int  length,
bool  wrap = true 
)
virtual

This is an overloaded member function, provided for convenience, it differs from the above function only in what argument(s) it accepts.

An existing old selection will be discarded. If possible you should reimplement the default implementation with a more efficient one.

Parameters
positionstart or end position of the selection, depending on the length parameter
lengthif >0 position defines the start of the selection, if <0 position specifies the end
wrapif false the selection does not wrap lines and reaches only to start/end of the cursors line. Default: true. Warning: true was never implemented in KDE 4.
See also
selectionRange(), selection()
Todo:
remove in KDE5 in favour of Range based setSelection()

Definition at line 122 of file ktexteditor.cpp.

void KTextEditor::View::textInserted ( KTextEditor::View *  view,
const KTextEditor::Cursor &  position,
const QString &  text 
)
signal

This signal is emitted from view whenever the users inserts text at position, that means the user typed/pasted text.

Parameters
viewview in which the text was inserted
positionposition where the text was inserted
textthe text the user has typed into the editor
See also
insertText()
void KTextEditor::View::verticalScrollPositionChanged ( KTextEditor::View *  view,
const KTextEditor::Cursor &  newPos 
)
signal

This signal should be emitted whenever the view is scrolled vertically.

Parameters
viewview which emitted the signal
newPosthe new scroll position
virtual enum EditMode KTextEditor::View::viewEditMode ( ) const
pure virtual

Get the view's current edit mode.

The current mode can be insert mode, replace mode or any other the editor supports, e.g. a vim like command mode. If in doubt return EditInsert.

Returns
the current edit mode of this view
See also
viewEditModeChanged()
void KTextEditor::View::viewEditModeChanged ( KTextEditor::View *  view,
enum KTextEditor::View::EditMode  mode 
)
signal

This signal is emitted whenever the view's edit mode changed from either EditInsert to EditOverwrite or vice versa.

Parameters
viewview which changed its edit mode
modenew edit mode
See also
viewEditMode()
virtual QString KTextEditor::View::viewMode ( ) const
pure virtual

Get the current view mode/state.

This can be used to visually indicate the view's current mode, for example INSERT mode, OVERWRITE mode or COMMAND mode - or whatever other edit modes are supported. The string should be translated (i18n), as this is a user aimed representation of the view state, which should be shown in the GUI, for example in the status bar. This string may be rich-text.

Returns
See also
viewModeChanged()
void KTextEditor::View::viewModeChanged ( KTextEditor::View *  view)
signal

This signal is emitted whenever the view mode of view changes.

Parameters
viewthe view which changed its mode
See also
viewMode()

The documentation for this class was generated from the following files:
  • view.h
  • ktexteditor.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:48 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KTextEditor

Skip menu "KTextEditor"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal