• Skip to content
  • Skip to link menu
KDE 4.3 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 
00110 class KTEXTEDITOR_EXPORT Document : public KParts::ReadWritePart
00111 {
00112   Q_OBJECT
00113 
00114   public:
00122     Document ( QObject *parent = 0);
00123 
00127     virtual ~Document ();
00128 
00129   /*
00130    * Methods to create and manage the views of this document and access the
00131    * global editor object.
00132    */
00133   public:
00141     virtual Editor *editor () = 0;
00142 
00148     virtual View *createView ( QWidget *parent ) = 0;
00149 
00153     virtual View* activeView() const = 0;
00154 
00158     virtual const QList<View*> &views() const = 0;
00159 
00160   Q_SIGNALS:
00171     void viewCreated (KTextEditor::Document *document, KTextEditor::View *view);
00172 
00173   /*
00174    * General information about this document and its content.
00175    */
00176   public:
00184     virtual const QString &documentName () const = 0;
00185 
00190     virtual QString mimeType() = 0;
00191 
00192   /*
00193    * SIGNALS
00194    * following signals should be emitted by the editor document.
00195    */
00196   Q_SIGNALS:
00202     void documentNameChanged ( KTextEditor::Document *document );
00203 
00209     void documentUrlChanged ( KTextEditor::Document *document );
00210 
00219     void modifiedChanged ( KTextEditor::Document *document );
00220 
00221   /*
00222    * VERY IMPORTANT: Methods to set and query the current encoding of the
00223    * document
00224    */
00225   public:
00239     virtual bool setEncoding (const QString &encoding) = 0;
00240 
00248     virtual const QString &encoding () const = 0;
00249 
00250   /*
00251    * General file related actions.
00252    * All this actions cause user interaction in some cases.
00253    */
00254   public:
00262     virtual bool documentReload () = 0;
00263 
00270     virtual bool documentSave () = 0;
00271 
00278     virtual bool documentSaveAs () = 0;
00279 
00280  Q_SIGNALS:
00285     void documentSavedOrUploaded(KTextEditor::Document* document,bool saveAs);
00286 
00287  /*
00288   * Methodes to create/end editing sequences.
00289   */
00290  public:
00313     virtual bool startEditing () = 0;
00314 
00321     virtual bool endEditing () = 0;
00322 
00323   /*
00324    * General access to the document's text content.
00325    */
00326   public:
00332     virtual QString text () const = 0;
00333 
00342     virtual QString text ( const Range& range, bool block = false ) const = 0;
00343 
00350     virtual QChar character( const Cursor& position ) const = 0;
00351 
00361     virtual QStringList textLines ( const Range& range, bool block = false ) const = 0;
00362 
00369     virtual QString line ( int line ) const = 0;
00370 
00376     virtual int lines () const = 0;
00377 
00383     virtual Cursor documentEnd() const = 0;
00384 
00389     inline Range documentRange() const { return Range(Cursor::start(), documentEnd()); }
00390 
00397     virtual int totalCharacters() const = 0;
00398 
00402     virtual bool isEmpty() const;
00403 
00411     virtual int lineLength ( int line ) const = 0;
00412 
00418     inline Cursor endOfLine(int line) const { return Cursor(line, lineLength(line)); }
00419 
00426     virtual bool setText ( const QString &text ) = 0;
00427 
00434     virtual bool setText ( const QStringList &text ) = 0;
00435 
00441     virtual bool clear () = 0;
00442 
00451     virtual bool insertText ( const Cursor &position, const QString &text, bool block = false ) = 0;
00452 
00461     virtual bool insertText ( const Cursor &position, const QStringList &text, bool block = false ) = 0;
00462 
00471     virtual bool replaceText ( const Range &range, const QString &text, bool block = false );
00472 
00481     virtual bool replaceText ( const Range &range, const QStringList &text, bool block = false );
00482 
00490     virtual bool removeText ( const Range &range, bool block = false ) = 0;
00491 
00499     virtual bool cursorInText(const Cursor &cursor);
00500 
00513     virtual bool insertLine ( int line, const QString &text ) = 0;
00514 
00527     virtual bool insertLines ( int line, const QStringList &text ) = 0;
00528 
00535     virtual bool removeLine ( int line ) = 0;
00536 
00537   /*
00538    * SIGNALS
00539    * Following signals should be emitted by the document if the text content
00540    * is changed.
00541    */
00542   Q_SIGNALS:
00548     void textChanged(KTextEditor::Document *document);
00549 
00558     void textInserted(KTextEditor::Document *document, const KTextEditor::Range& range);
00559 
00567     void textRemoved(KTextEditor::Document *document, const KTextEditor::Range& range);
00568 
00579     void textChanged(KTextEditor::Document *document, const KTextEditor::Range& oldRange, const KTextEditor::Range& newRange);
00580 
00590     void aboutToClose(KTextEditor::Document *document);
00591 
00601     void aboutToReload(KTextEditor::Document *document);
00602 
00603   /*
00604    * Access to the mode/highlighting subsystem
00605    */
00606   public:
00612     virtual QString mode() const = 0;
00613 
00619     virtual QString highlightingMode() const = 0;
00620 
00626     virtual QStringList modes() const = 0;
00627 
00633     virtual QStringList highlightingModes() const = 0;
00634 
00641     virtual bool setMode(const QString &name) = 0;
00642 
00649     virtual bool setHighlightingMode(const QString &name) = 0;
00650 
00659     virtual QString highlightingModeSection( int index ) const = 0;
00660 
00669     virtual QString modeSection( int index ) const = 0;
00670 
00671   /*
00672    * SIGNALS
00673    * Following signals should be emitted by the document if the mode
00674    * of the document changes
00675    */
00676   Q_SIGNALS:
00684     void modeChanged(KTextEditor::Document *document);
00685 
00693     void highlightingModeChanged(KTextEditor::Document *document);
00694 
00695   private:
00696     class DocumentPrivate* const d;
00697 
00698   public:
00706     void setSuppressOpeningErrorDialogs(bool suppress);
00707     bool suppressOpeningErrorDialogs() const;
00712     bool openingError() const;
00713     QString openingErrorMessage() const;
00714 
00715   protected:
00716     void setOpeningError(bool errors);
00717     void setOpeningErrorMessage(const QString& message);
00718 };
00719 
00720 }
00721 
00722 Q_DECLARE_METATYPE(KTextEditor::Document*)
00723 
00724 #endif
00725 
00726 // kate: space-indent on; indent-width 2; replace-tabs on;
00727 

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
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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