• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • 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 as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KDELIBS_KTEXTEDITOR_DOCUMENT_H
00022 #define KDELIBS_KTEXTEDITOR_DOCUMENT_H
00023 
00024 #include <ktexteditor/ktexteditor_export.h>
00025 // the very important KTextEditor::Cursor class
00026 #include <ktexteditor/cursor.h>
00027 #include <ktexteditor/range.h>
00028 
00029 // our main baseclass of the KTextEditor::Document
00030 #include <kparts/part.h>
00031 
00032 // the list of views
00033 #include <QtCore/QList>
00034 #include <QtCore/QMetaType>
00035 
00036 namespace KTextEditor
00037 {
00038 
00039 class Editor;
00040 class View;
00041 
00111 class KTEXTEDITOR_EXPORT Document : public KParts::ReadWritePart
00112 {
00113   Q_OBJECT
00114 
00115   public:
00123     Document ( QObject *parent = 0);
00124 
00128     virtual ~Document ();
00129 
00130   /*
00131    * Methods to create and manage the views of this document and access the
00132    * global editor object.
00133    */
00134   public:
00142     virtual Editor *editor () = 0;
00143 
00149     virtual View *createView ( QWidget *parent ) = 0;
00150 
00154     virtual View* activeView() const = 0;
00155 
00159     virtual const QList<View*> &views() const = 0;
00160 
00161   Q_SIGNALS:
00172     void viewCreated (KTextEditor::Document *document, KTextEditor::View *view);
00173 
00174   /*
00175    * General information about this document and its content.
00176    */
00177   public:
00185     virtual const QString &documentName () const = 0;
00186 
00191     virtual QString mimeType() = 0;
00192 
00193   /*
00194    * SIGNALS
00195    * following signals should be emitted by the editor document.
00196    */
00197   Q_SIGNALS:
00203     void documentNameChanged ( KTextEditor::Document *document );
00204 
00210     void documentUrlChanged ( KTextEditor::Document *document );
00211 
00220     void modifiedChanged ( KTextEditor::Document *document );
00221 
00222   /*
00223    * VERY IMPORTANT: Methods to set and query the current encoding of the
00224    * document
00225    */
00226   public:
00240     virtual bool setEncoding (const QString &encoding) = 0;
00241 
00249     virtual const QString &encoding () const = 0;
00250 
00251   /*
00252    * General file related actions.
00253    * All this actions cause user interaction in some cases.
00254    */
00255   public:
00263     virtual bool documentReload () = 0;
00264 
00271     virtual bool documentSave () = 0;
00272 
00279     virtual bool documentSaveAs () = 0;
00280 
00281  Q_SIGNALS:
00286     void documentSavedOrUploaded(KTextEditor::Document* document,bool saveAs);
00287 
00288  /*
00289   * Methodes to create/end editing sequences.
00290   */
00291  public:
00314     virtual bool startEditing () = 0;
00315 
00322     virtual bool endEditing () = 0;
00323 
00324   /*
00325    * General access to the document's text content.
00326    */
00327   public:
00333     virtual QString text () const = 0;
00334 
00343     virtual QString text ( const Range& range, bool block = false ) const = 0;
00344 
00351     virtual QChar character( const Cursor& position ) const = 0;
00352 
00362     virtual QStringList textLines ( const Range& range, bool block = false ) const = 0;
00363 
00370     virtual QString line ( int line ) const = 0;
00371 
00377     virtual int lines () const = 0;
00378 
00384     virtual Cursor documentEnd() const = 0;
00385 
00390     inline Range documentRange() const { return Range(Cursor::start(), documentEnd()); }
00391 
00398     virtual int totalCharacters() const = 0;
00399 
00403     virtual bool isEmpty() const;
00404 
00412     virtual int lineLength ( int line ) const = 0;
00413 
00419     inline Cursor endOfLine(int line) const { return Cursor(line, lineLength(line)); }
00420 
00427     virtual bool setText ( const QString &text ) = 0;
00428 
00435     virtual bool setText ( const QStringList &text ) = 0;
00436 
00442     virtual bool clear () = 0;
00443 
00452     virtual bool insertText ( const Cursor &position, const QString &text, bool block = false ) = 0;
00453 
00462     virtual bool insertText ( const Cursor &position, const QStringList &text, bool block = false ) = 0;
00463 
00472     virtual bool replaceText ( const Range &range, const QString &text, bool block = false );
00473 
00482     virtual bool replaceText ( const Range &range, const QStringList &text, bool block = false );
00483 
00491     virtual bool removeText ( const Range &range, bool block = false ) = 0;
00492 
00500     virtual bool cursorInText(const Cursor &cursor);
00501 
00514     virtual bool insertLine ( int line, const QString &text ) = 0;
00515 
00528     virtual bool insertLines ( int line, const QStringList &text ) = 0;
00529 
00536     virtual bool removeLine ( int line ) = 0;
00537 
00538   /*
00539    * SIGNALS
00540    * Following signals should be emitted by the document if the text content
00541    * is changed.
00542    */
00543   Q_SIGNALS:
00549     void textChanged(KTextEditor::Document *document);
00550 
00559     void textInserted(KTextEditor::Document *document, const KTextEditor::Range& range);
00560 
00568     void textRemoved(KTextEditor::Document *document, const KTextEditor::Range& range);
00569 
00578     void textRemoved(KTextEditor::Document *document, const KTextEditor::Range& range, const QString& oldText);
00579     
00590     void textChanged(KTextEditor::Document *document, const KTextEditor::Range& oldRange, const KTextEditor::Range& newRange);
00591 
00603     void textChanged(KTextEditor::Document *document, const KTextEditor::Range& oldRange, const QString& oldText, const KTextEditor::Range& newRange);
00604     
00614     void aboutToClose(KTextEditor::Document *document);
00615 
00625     void aboutToReload(KTextEditor::Document *document);
00626 
00636     void reloaded(KTextEditor::Document *document);
00637 
00647     void exclusiveEditStart(KTextEditor::Document *document);
00648 
00655     void exclusiveEditEnd(KTextEditor::Document *document);
00656 
00657   /*
00658    * Access to the mode/highlighting subsystem
00659    */
00660   public:
00666     virtual QString mode() const = 0;
00667 
00673     virtual QString highlightingMode() const = 0;
00674 
00680     virtual QStringList modes() const = 0;
00681 
00687     virtual QStringList highlightingModes() const = 0;
00688 
00695     virtual bool setMode(const QString &name) = 0;
00696 
00703     virtual bool setHighlightingMode(const QString &name) = 0;
00704 
00713     virtual QString highlightingModeSection( int index ) const = 0;
00714 
00723     virtual QString modeSection( int index ) const = 0;
00724 
00725   /*
00726    * SIGNALS
00727    * Following signals should be emitted by the document if the mode
00728    * of the document changes
00729    */
00730   Q_SIGNALS:
00738     void modeChanged(KTextEditor::Document *document);
00739 
00747     void highlightingModeChanged(KTextEditor::Document *document);
00748 
00749   private:
00750     class DocumentPrivate* const d;
00751 
00752   public:
00760     void setSuppressOpeningErrorDialogs(bool suppress);
00761     bool suppressOpeningErrorDialogs() const;
00766     bool openingError() const;
00767     QString openingErrorMessage() const;
00768 
00769   protected:
00770     void setOpeningError(bool errors);
00771     void setOpeningErrorMessage(const QString& message);
00772 };
00773 
00774 }
00775 
00776 Q_DECLARE_METATYPE(KTextEditor::Document*)
00777 
00778 #endif
00779 
00780 // kate: space-indent on; indent-width 2; replace-tabs on;
00781 

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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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