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

KTextEditor

  • sources
  • kde-4.12
  • kdelibs
  • interfaces
  • ktexteditor
document.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
3  Copyright (C) 2005 Dominik Haumann (dhdev@gmx.de) (documentation)
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef KDELIBS_KTEXTEDITOR_DOCUMENT_H
22 #define KDELIBS_KTEXTEDITOR_DOCUMENT_H
23 
24 #include <ktexteditor/ktexteditor_export.h>
25 // the very important KTextEditor::Cursor class
26 #include <ktexteditor/cursor.h>
27 #include <ktexteditor/range.h>
28 
29 // our main baseclass of the KTextEditor::Document
30 #include <kparts/part.h>
31 
32 // the list of views
33 #include <QtCore/QList>
34 #include <QtCore/QMetaType>
35 
36 namespace KTextEditor
37 {
38 
39 class Editor;
40 class View;
41 
111 class KTEXTEDITOR_EXPORT Document : public KParts::ReadWritePart
112 {
113  Q_OBJECT
114 
115  public:
123  Document ( QObject *parent = 0);
124 
128  virtual ~Document ();
129 
130  /*
131  * Methods to create and manage the views of this document and access the
132  * global editor object.
133  */
134  public:
142  virtual Editor *editor () = 0;
143 
149  virtual View *createView ( QWidget *parent ) = 0;
150 
154  virtual View* activeView() const = 0;
155 
159  virtual const QList<View*> &views() const = 0;
160 
161  Q_SIGNALS:
172  void viewCreated (KTextEditor::Document *document, KTextEditor::View *view);
173 
174  /*
175  * General information about this document and its content.
176  */
177  public:
185  virtual const QString &documentName () const = 0;
186 
191  virtual QString mimeType() = 0;
192 
193  /*
194  * SIGNALS
195  * following signals should be emitted by the editor document.
196  */
197  Q_SIGNALS:
203  void documentNameChanged ( KTextEditor::Document *document );
204 
210  void documentUrlChanged ( KTextEditor::Document *document );
211 
220  void modifiedChanged ( KTextEditor::Document *document );
221 
225 //warning ADD IN KDE5
226 // void readWriteChanged (KTextEditor::Document *document);
227 
228  /*
229  * VERY IMPORTANT: Methods to set and query the current encoding of the
230  * document
231  */
232  public:
246  virtual bool setEncoding (const QString &encoding) = 0;
247 
255  virtual const QString &encoding () const = 0;
256 
257  /*
258  * General file related actions.
259  * All this actions cause user interaction in some cases.
260  */
261  public:
269  virtual bool documentReload () = 0;
270 
277  virtual bool documentSave () = 0;
278 
285  virtual bool documentSaveAs () = 0;
286 
287  Q_SIGNALS:
292  void documentSavedOrUploaded(KTextEditor::Document* document,bool saveAs);
293 
294  /*
295  * Methodes to create/end editing sequences.
296  */
297  public:
320  virtual bool startEditing () = 0;
321 
328  virtual bool endEditing () = 0;
329 
330  /*
331  * General access to the document's text content.
332  */
333  public:
339  virtual QString text () const = 0;
340 
349  virtual QString text ( const Range& range, bool block = false ) const = 0;
350 
357  virtual QChar character( const Cursor& position ) const = 0;
358 
368  virtual QStringList textLines ( const Range& range, bool block = false ) const = 0;
369 
376  virtual QString line ( int line ) const = 0;
377 
383  virtual int lines () const = 0;
384 
390  virtual Cursor documentEnd() const = 0;
391 
396  inline Range documentRange() const { return Range(Cursor::start(), documentEnd()); }
397 
404  virtual int totalCharacters() const = 0;
405 
409  virtual bool isEmpty() const;
410 
418  virtual int lineLength ( int line ) const = 0;
419 
425  inline Cursor endOfLine(int line) const { return Cursor(line, lineLength(line)); }
426 
433  virtual bool setText ( const QString &text ) = 0;
434 
441  virtual bool setText ( const QStringList &text ) = 0;
442 
448  virtual bool clear () = 0;
449 
458  virtual bool insertText ( const Cursor &position, const QString &text, bool block = false ) = 0;
459 
468  virtual bool insertText ( const Cursor &position, const QStringList &text, bool block = false ) = 0;
469 
478  virtual bool replaceText ( const Range &range, const QString &text, bool block = false );
479 
488  virtual bool replaceText ( const Range &range, const QStringList &text, bool block = false );
489 
497  virtual bool removeText ( const Range &range, bool block = false ) = 0;
498 
506  virtual bool cursorInText(const Cursor &cursor);
507 
520  virtual bool insertLine ( int line, const QString &text ) = 0;
521 
534  virtual bool insertLines ( int line, const QStringList &text ) = 0;
535 
542  virtual bool removeLine ( int line ) = 0;
543 
544  /*
545  * SIGNALS
546  * Following signals should be emitted by the document if the text content
547  * is changed.
548  */
549  Q_SIGNALS:
555  void textChanged(KTextEditor::Document *document);
556 
565  void textInserted(KTextEditor::Document *document, const KTextEditor::Range& range);
566 
574  void textRemoved(KTextEditor::Document *document, const KTextEditor::Range& range);
575 
584  void textRemoved(KTextEditor::Document *document, const KTextEditor::Range& range, const QString& oldText);
585 
596  void textChanged(KTextEditor::Document *document, const KTextEditor::Range& oldRange, const KTextEditor::Range& newRange);
597 
609  void textChanged(KTextEditor::Document *document, const KTextEditor::Range& oldRange, const QString& oldText, const KTextEditor::Range& newRange);
610 
620  void aboutToClose(KTextEditor::Document *document);
621 
631  void aboutToReload(KTextEditor::Document *document);
632 
642  void reloaded(KTextEditor::Document *document);
643 
653  void exclusiveEditStart(KTextEditor::Document *document);
654 
661  void exclusiveEditEnd(KTextEditor::Document *document);
662 
663  /*
664  * Access to the mode/highlighting subsystem
665  */
666  public:
672  virtual QString mode() const = 0;
673 
679  virtual QString highlightingMode() const = 0;
680 
686  virtual QStringList modes() const = 0;
687 
693  virtual QStringList highlightingModes() const = 0;
694 
701  virtual bool setMode(const QString &name) = 0;
702 
709  virtual bool setHighlightingMode(const QString &name) = 0;
710 
719  virtual QString highlightingModeSection( int index ) const = 0;
720 
729  virtual QString modeSection( int index ) const = 0;
730 
731  /*
732  * SIGNALS
733  * Following signals should be emitted by the document if the mode
734  * of the document changes
735  */
736  Q_SIGNALS:
744  void modeChanged(KTextEditor::Document *document);
745 
753  void highlightingModeChanged(KTextEditor::Document *document);
754 
755  private:
756  class DocumentPrivate* const d;
757 
758  public:
766  void setSuppressOpeningErrorDialogs(bool suppress);
767  bool suppressOpeningErrorDialogs() const;
772  bool openingError() const;
773  QString openingErrorMessage() const;
774 
779  bool isOrphaned() const;
780  void setOrphaned(bool value);
781 
782  protected:
783  void setOpeningError(bool errors);
784  void setOpeningErrorMessage(const QString& message);
785 };
786 
787 }
788 
789 Q_DECLARE_METATYPE(KTextEditor::Document*)
790 
791 #endif
792 
793 // kate: space-indent on; indent-width 2; replace-tabs on;
794 
saveAs
KAction * saveAs(const QObject *recvr, const char *slot, QObject *parent)
cursor.h
QWidget
KTextEditor::editor
Editor * editor(const char *libname)
Helper function for the EditorChooser.
Definition: ktexteditor.cpp:173
QString
KTextEditor::Cursor::start
static Cursor start()
Returns a cursor representing the start of any document - i.e., line 0, column 0. ...
Definition: cursor.cpp:57
QObject
KTextEditor::Cursor
An object which represents a position in a Document.
Definition: cursor.h:61
KParts::ReadWritePart
range.h
ktexteditor_export.h
KTextEditor::Document
A KParts derived class representing a text document.
Definition: document.h:111
QStringList
clear
KAction * clear(const QObject *recvr, const char *slot, QObject *parent)
KTextEditor::Document::documentRange
Range documentRange() const
A Range which encompasses the whole document.
Definition: document.h:396
KTextEditor::Range
An object representing a section of text, from one Cursor to another.
Definition: range.h:54
KTextEditor::Editor
Accessor interface for Editor part.
Definition: editor.h:102
KTextEditor::View
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:145
part.h
QList
KTextEditor::Document::endOfLine
Cursor endOfLine(int line) const
Get the end cursor position of line line.
Definition: document.h:425
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:52:20 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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

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