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

KTextEditor

  • 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 
222  /*
223  * VERY IMPORTANT: Methods to set and query the current encoding of the
224  * document
225  */
226  public:
240  virtual bool setEncoding (const QString &encoding) = 0;
241 
249  virtual const QString &encoding () const = 0;
250 
251  /*
252  * General file related actions.
253  * All this actions cause user interaction in some cases.
254  */
255  public:
263  virtual bool documentReload () = 0;
264 
271  virtual bool documentSave () = 0;
272 
279  virtual bool documentSaveAs () = 0;
280 
281  Q_SIGNALS:
286  void documentSavedOrUploaded(KTextEditor::Document* document,bool saveAs);
287 
288  /*
289  * Methodes to create/end editing sequences.
290  */
291  public:
314  virtual bool startEditing () = 0;
315 
322  virtual bool endEditing () = 0;
323 
324  /*
325  * General access to the document's text content.
326  */
327  public:
333  virtual QString text () const = 0;
334 
343  virtual QString text ( const Range& range, bool block = false ) const = 0;
344 
351  virtual QChar character( const Cursor& position ) const = 0;
352 
362  virtual QStringList textLines ( const Range& range, bool block = false ) const = 0;
363 
370  virtual QString line ( int line ) const = 0;
371 
377  virtual int lines () const = 0;
378 
384  virtual Cursor documentEnd() const = 0;
385 
390  inline Range documentRange() const { return Range(Cursor::start(), documentEnd()); }
391 
398  virtual int totalCharacters() const = 0;
399 
403  virtual bool isEmpty() const;
404 
412  virtual int lineLength ( int line ) const = 0;
413 
419  inline Cursor endOfLine(int line) const { return Cursor(line, lineLength(line)); }
420 
427  virtual bool setText ( const QString &text ) = 0;
428 
435  virtual bool setText ( const QStringList &text ) = 0;
436 
442  virtual bool clear () = 0;
443 
452  virtual bool insertText ( const Cursor &position, const QString &text, bool block = false ) = 0;
453 
462  virtual bool insertText ( const Cursor &position, const QStringList &text, bool block = false ) = 0;
463 
472  virtual bool replaceText ( const Range &range, const QString &text, bool block = false );
473 
482  virtual bool replaceText ( const Range &range, const QStringList &text, bool block = false );
483 
491  virtual bool removeText ( const Range &range, bool block = false ) = 0;
492 
500  virtual bool cursorInText(const Cursor &cursor);
501 
514  virtual bool insertLine ( int line, const QString &text ) = 0;
515 
528  virtual bool insertLines ( int line, const QStringList &text ) = 0;
529 
536  virtual bool removeLine ( int line ) = 0;
537 
538  /*
539  * SIGNALS
540  * Following signals should be emitted by the document if the text content
541  * is changed.
542  */
543  Q_SIGNALS:
549  void textChanged(KTextEditor::Document *document);
550 
559  void textInserted(KTextEditor::Document *document, const KTextEditor::Range& range);
560 
568  void textRemoved(KTextEditor::Document *document, const KTextEditor::Range& range);
569 
578  void textRemoved(KTextEditor::Document *document, const KTextEditor::Range& range, const QString& oldText);
579 
590  void textChanged(KTextEditor::Document *document, const KTextEditor::Range& oldRange, const KTextEditor::Range& newRange);
591 
603  void textChanged(KTextEditor::Document *document, const KTextEditor::Range& oldRange, const QString& oldText, const KTextEditor::Range& newRange);
604 
614  void aboutToClose(KTextEditor::Document *document);
615 
625  void aboutToReload(KTextEditor::Document *document);
626 
636  void reloaded(KTextEditor::Document *document);
637 
647  void exclusiveEditStart(KTextEditor::Document *document);
648 
655  void exclusiveEditEnd(KTextEditor::Document *document);
656 
657  /*
658  * Access to the mode/highlighting subsystem
659  */
660  public:
666  virtual QString mode() const = 0;
667 
673  virtual QString highlightingMode() const = 0;
674 
680  virtual QStringList modes() const = 0;
681 
687  virtual QStringList highlightingModes() const = 0;
688 
695  virtual bool setMode(const QString &name) = 0;
696 
703  virtual bool setHighlightingMode(const QString &name) = 0;
704 
713  virtual QString highlightingModeSection( int index ) const = 0;
714 
723  virtual QString modeSection( int index ) const = 0;
724 
725  /*
726  * SIGNALS
727  * Following signals should be emitted by the document if the mode
728  * of the document changes
729  */
730  Q_SIGNALS:
738  void modeChanged(KTextEditor::Document *document);
739 
747  void highlightingModeChanged(KTextEditor::Document *document);
748 
749  private:
750  class DocumentPrivate* const d;
751 
752  public:
760  void setSuppressOpeningErrorDialogs(bool suppress);
761  bool suppressOpeningErrorDialogs() const;
766  bool openingError() const;
767  QString openingErrorMessage() const;
768 
769  protected:
770  void setOpeningError(bool errors);
771  void setOpeningErrorMessage(const QString& message);
772 };
773 
774 }
775 
776 Q_DECLARE_METATYPE(KTextEditor::Document*)
777 
778 #endif
779 
780 // kate: space-indent on; indent-width 2; replace-tabs on;
781 
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Fri Dec 7 2012 16:20:21 by doxygen 1.8.1 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-4.8.5 API Reference

Skip menu "kdelibs-4.8.5 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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