• Skip to content
  • Skip to link menu
KDE 4.1 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  /*
00280   * Methodes to create/end editing sequences.
00281   */
00282  public:
00305     virtual bool startEditing () = 0;
00306 
00313     virtual bool endEditing () = 0;
00314 
00315   /*
00316    * General access to the document's text content.
00317    */
00318   public:
00324     virtual QString text () const = 0;
00325 
00334     virtual QString text ( const Range& range, bool block = false ) const = 0;
00335 
00342     virtual QChar character( const Cursor& position ) const = 0;
00343 
00353     virtual QStringList textLines ( const Range& range, bool block = false ) const = 0;
00354 
00361     virtual QString line ( int line ) const = 0;
00362 
00368     virtual int lines () const = 0;
00369 
00375     virtual Cursor documentEnd() const = 0;
00376 
00381     inline Range documentRange() const { return Range(Cursor::start(), documentEnd()); }
00382 
00389     virtual int totalCharacters() const = 0;
00390 
00394     virtual bool isEmpty() const;
00395 
00403     virtual int lineLength ( int line ) const = 0;
00404 
00410     inline Cursor endOfLine(int line) const { return Cursor(line, lineLength(line)); }
00411 
00418     virtual bool setText ( const QString &text ) = 0;
00419 
00426     virtual bool setText ( const QStringList &text ) = 0;
00427 
00433     virtual bool clear () = 0;
00434 
00443     virtual bool insertText ( const Cursor &position, const QString &text, bool block = false ) = 0;
00444 
00453     virtual bool insertText ( const Cursor &position, const QStringList &text, bool block = false ) = 0;
00454 
00463     virtual bool replaceText ( const Range &range, const QString &text, bool block = false );
00464 
00473     virtual bool replaceText ( const Range &range, const QStringList &text, bool block = false );
00474 
00482     virtual bool removeText ( const Range &range, bool block = false ) = 0;
00483 
00491     virtual bool cursorInText(const Cursor &cursor);
00492 
00505     virtual bool insertLine ( int line, const QString &text ) = 0;
00506 
00519     virtual bool insertLines ( int line, const QStringList &text ) = 0;
00520 
00527     virtual bool removeLine ( int line ) = 0;
00528 
00529   /*
00530    * SIGNALS
00531    * Following signals should be emitted by the document if the text content
00532    * is changed.
00533    */
00534   Q_SIGNALS:
00540     void textChanged(KTextEditor::Document *document);
00541 
00550     void textInserted(KTextEditor::Document *document, const KTextEditor::Range& range);
00551 
00559     void textRemoved(KTextEditor::Document *document, const KTextEditor::Range& range);
00560 
00571     void textChanged(KTextEditor::Document *document, const KTextEditor::Range& oldRange, const KTextEditor::Range& newRange);
00572 
00582     void aboutToClose(KTextEditor::Document *document);
00583 
00593     void aboutToReload(KTextEditor::Document *document);
00594 
00595   /*
00596    * Access to the mode/highlighting subsystem
00597    */
00598   public:
00604     virtual QString mode() const = 0;
00605 
00611     virtual QString highlightingMode() const = 0;
00612 
00618     virtual QStringList modes() const = 0;
00619 
00625     virtual QStringList highlightingModes() const = 0;
00626 
00633     virtual bool setMode(const QString &name) = 0;
00634 
00641     virtual bool setHighlightingMode(const QString &name) = 0;
00642 
00649     virtual QString highlightingModeSection( int index ) const = 0;
00650 
00657     virtual QString modeSection( int index ) const = 0;
00658 
00659   /*
00660    * SIGNALS
00661    * Following signals should be emitted by the document if the mode
00662    * of the document changes
00663    */
00664   Q_SIGNALS:
00672     void modeChanged(KTextEditor::Document *document);
00673 
00681     void highlightingModeChanged(KTextEditor::Document *document);
00682 
00683   private:
00684     class DocumentPrivate* const d;
00685 
00686   public:
00694     void setSuppressOpeningErrorDialogs(bool suppress);
00695     bool suppressOpeningErrorDialogs() const;
00700     bool openingError() const;
00701     QString openingErrorMessage() const;
00702 
00703   protected:
00704     void setOpeningError(bool errors);
00705     void setOpeningErrorMessage(const QString& message);
00706 };
00707 
00708 }
00709 
00710 Q_DECLARE_METATYPE(KTextEditor::Document*)
00711 
00712 #endif
00713 
00714 // kate: space-indent on; indent-width 2; replace-tabs on;
00715 

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