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

KTextEditor

document.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
00003    Copyright (C) 2005 Dominik Haumann (dhdev@gmx.de) (documentation)
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KDELIBS_KTEXTEDITOR_DOCUMENT_H
00021 #define KDELIBS_KTEXTEDITOR_DOCUMENT_H
00022 
00023 #include <ktexteditor/ktexteditor_export.h>
00024 // the very important KTextEditor::Cursor class
00025 #include <ktexteditor/cursor.h>
00026 #include <ktexteditor/range.h>
00027 
00028 // our main baseclass of the KTextEditor::Document
00029 #include <kparts/part.h>
00030 
00031 // the list of views
00032 #include <QtCore/QList>
00033 #include <QtCore/QMetaType>
00034 
00035 namespace KTextEditor
00036 {
00037 
00038 class Editor;
00039 class View;
00040 
00109 class KTEXTEDITOR_EXPORT Document : public KParts::ReadWritePart
00110 {
00111   Q_OBJECT
00112 
00113   public:
00121     Document ( QObject *parent = 0);
00122 
00126     virtual ~Document ();
00127 
00128   /*
00129    * Methods to create and manage the views of this document and access the
00130    * global editor object.
00131    */
00132   public:
00140     virtual Editor *editor () = 0;
00141 
00147     virtual View *createView ( QWidget *parent ) = 0;
00148 
00152     virtual View* activeView() const = 0;
00153 
00157     virtual const QList<View*> &views() const = 0;
00158 
00159   Q_SIGNALS:
00170     void viewCreated (KTextEditor::Document *document, KTextEditor::View *view);
00171 
00172   /*
00173    * General information about this document and its content.
00174    */
00175   public:
00183     virtual const QString &documentName () const = 0;
00184 
00189     virtual QString mimeType() = 0;
00190 
00191   /*
00192    * SIGNALS
00193    * following signals should be emitted by the editor document.
00194    */
00195   Q_SIGNALS:
00201     void documentNameChanged ( KTextEditor::Document *document );
00202 
00208     void documentUrlChanged ( KTextEditor::Document *document );
00209 
00218     void modifiedChanged ( KTextEditor::Document *document );
00219 
00220   /*
00221    * VERY IMPORTANT: Methods to set and query the current encoding of the
00222    * document
00223    */
00224   public:
00238     virtual bool setEncoding (const QString &encoding) = 0;
00239 
00247     virtual const QString &encoding () const = 0;
00248 
00249   /*
00250    * General file related actions.
00251    * All this actions cause user interaction in some cases.
00252    */
00253   public:
00261     virtual bool documentReload () = 0;
00262 
00269     virtual bool documentSave () = 0;
00270 
00277     virtual bool documentSaveAs () = 0;
00278 
00279  Q_SIGNALS:
00284     void documentSavedOrUploaded(KTextEditor::Document* document,bool saveAs);
00285 
00286  /*
00287   * Methodes to create/end editing sequences.
00288   */
00289  public:
00312     virtual bool startEditing () = 0;
00313 
00320     virtual bool endEditing () = 0;
00321 
00322   /*
00323    * General access to the document's text content.
00324    */
00325   public:
00331     virtual QString text () const = 0;
00332 
00341     virtual QString text ( const Range& range, bool block = false ) const = 0;
00342 
00349     virtual QChar character( const Cursor& position ) const = 0;
00350 
00360     virtual QStringList textLines ( const Range& range, bool block = false ) const = 0;
00361 
00368     virtual QString line ( int line ) const = 0;
00369 
00375     virtual int lines () const = 0;
00376 
00382     virtual Cursor documentEnd() const = 0;
00383 
00388     inline Range documentRange() const { return Range(Cursor::start(), documentEnd()); }
00389 
00396     virtual int totalCharacters() const = 0;
00397 
00401     virtual bool isEmpty() const;
00402 
00410     virtual int lineLength ( int line ) const = 0;
00411 
00417     inline Cursor endOfLine(int line) const { return Cursor(line, lineLength(line)); }
00418 
00425     virtual bool setText ( const QString &text ) = 0;
00426 
00433     virtual bool setText ( const QStringList &text ) = 0;
00434 
00440     virtual bool clear () = 0;
00441 
00450     virtual bool insertText ( const Cursor &position, const QString &text, bool block = false ) = 0;
00451 
00460     virtual bool insertText ( const Cursor &position, const QStringList &text, bool block = false ) = 0;
00461 
00470     virtual bool replaceText ( const Range &range, const QString &text, bool block = false );
00471 
00480     virtual bool replaceText ( const Range &range, const QStringList &text, bool block = false );
00481 
00489     virtual bool removeText ( const Range &range, bool block = false ) = 0;
00490 
00498     virtual bool cursorInText(const Cursor &cursor);
00499 
00512     virtual bool insertLine ( int line, const QString &text ) = 0;
00513 
00526     virtual bool insertLines ( int line, const QStringList &text ) = 0;
00527 
00534     virtual bool removeLine ( int line ) = 0;
00535 
00536   /*
00537    * SIGNALS
00538    * Following signals should be emitted by the document if the text content
00539    * is changed.
00540    */
00541   Q_SIGNALS:
00547     void textChanged(KTextEditor::Document *document);
00548 
00557     void textInserted(KTextEditor::Document *document, const KTextEditor::Range& range);
00558 
00566     void textRemoved(KTextEditor::Document *document, const KTextEditor::Range& range);
00567 
00578     void textChanged(KTextEditor::Document *document, const KTextEditor::Range& oldRange, const KTextEditor::Range& newRange);
00579 
00589     void aboutToClose(KTextEditor::Document *document);
00590 
00600     void aboutToReload(KTextEditor::Document *document);
00601 
00602   /*
00603    * Access to the mode/highlighting subsystem
00604    */
00605   public:
00611     virtual QString mode() const = 0;
00612 
00618     virtual QString highlightingMode() const = 0;
00619 
00625     virtual QStringList modes() const = 0;
00626 
00632     virtual QStringList highlightingModes() const = 0;
00633 
00640     virtual bool setMode(const QString &name) = 0;
00641 
00648     virtual bool setHighlightingMode(const QString &name) = 0;
00649 
00656     virtual QString highlightingModeSection( int index ) const = 0;
00657 
00664     virtual QString modeSection( int index ) const = 0;
00665 
00666   /*
00667    * SIGNALS
00668    * Following signals should be emitted by the document if the mode
00669    * of the document changes
00670    */
00671   Q_SIGNALS:
00679     void modeChanged(KTextEditor::Document *document);
00680 
00688     void highlightingModeChanged(KTextEditor::Document *document);
00689 
00690   private:
00691     class DocumentPrivate* const d;
00692 
00693   public:
00701     void setSuppressOpeningErrorDialogs(bool suppress);
00702     bool suppressOpeningErrorDialogs() const;
00707     bool openingError() const;
00708     QString openingErrorMessage() const;
00709 
00710   protected:
00711     void setOpeningError(bool errors);
00712     void setOpeningErrorMessage(const QString& message);
00713 };
00714 
00715 }
00716 
00717 Q_DECLARE_METATYPE(KTextEditor::Document*)
00718 
00719 #endif
00720 
00721 // kate: space-indent on; indent-width 2; replace-tabs on;
00722 

KTextEditor

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal