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

Kate

kateedit.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2005 Hamish Rodda <rodda@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #ifndef KATEEDIT_H
00020 #define KATEEDIT_H
00021 
00022 #include <QtCore/QStringList>
00023 #include <QtCore/QObject>
00024 #include <QtCore/QMap>
00025 
00026 #include <ktexteditor/range.h>
00027 
00028 #include "katenamespace.h"
00029 
00030 class KateDocument;
00031 
00037 class KateEditInfo
00038 {
00039   friend class KateEditHistory;
00040 
00041   public:
00042     KateEditInfo(KateDocument* doc, Kate::EditSource source, const KTextEditor::Range& oldRange, const QStringList& oldText, const KTextEditor::Range& newRange, const QStringList& newText);
00043     virtual ~KateEditInfo();
00044 
00045     KateDocument* document() const;
00046 
00048     bool isInsert() const;
00050     bool isRemoval() const;
00052     bool isModification() const;
00053 
00060     bool isEditBoundary() const;
00061 
00067     void setEditBoundary(bool boundary);
00068 
00073     Kate::EditSource editSource() const;
00074 
00077     //bool merge(KateEditInfo* edit) { return false; }
00078 
00084     const KTextEditor::Cursor& start() const { return m_oldRange.start(); }
00085 
00089     const KTextEditor::Range& oldRange() const;
00090 
00096     virtual QString oldTextString(const KTextEditor::Range& range) const;
00097 
00102     virtual QStringList oldText(const KTextEditor::Range& range) const;
00103 
00109     const QStringList& oldText() const;
00110 
00114     const KTextEditor::Range& newRange() const;
00115 
00123     virtual QString newTextString(const KTextEditor::Range& range) const;
00124 
00130     virtual QStringList newText(const KTextEditor::Range& range) const;
00131 
00138     const QStringList& newText() const;
00139 
00140     inline const KTextEditor::Cursor& translate() const { return m_translate; }
00141 
00142     void referenceRevision();
00143     void dereferenceRevision();
00144     bool isReferenced() const;
00145 
00146   private:
00147     KateDocument* m_doc;
00148     Kate::EditSource m_editSource;
00149     bool m_editBoundary;
00150     KTextEditor::Range m_oldRange;
00151     QStringList m_oldText;
00152     KTextEditor::Range m_newRange;
00153     QStringList m_newText;
00154     KTextEditor::Cursor m_translate;
00155     int m_revisionTokenCounter;
00156 };
00157 
00161 class KateEditInfoGroup
00162 {
00163   public:
00164     KateEditInfoGroup();
00165 
00166     KateDocument* doc() const;
00167 
00168     void addEdit(KateEditInfo* edit);
00169     void removeEdit(int indexTo = -1);
00170     KateEditInfo* takeEdit(int indexTo = -1);
00171 
00172     inline const QList<KateEditInfo*>& edits() const { return m_edits; }
00173 
00174     QList<KateEditInfo> summariseEdits(int from = -1, int to = -1, bool destructiveCollapse = false) const;
00175 
00176   private:
00177     QList<KateEditInfo*> m_edits;
00178 };
00179 
00183 class KateEditHistory : public QObject
00184 {
00185   Q_OBJECT
00186 
00187   public:
00188     explicit KateEditHistory(KateDocument* doc);
00189     virtual ~KateEditHistory();
00190 
00191     inline KateEditInfoGroup* buffer() const { return m_buffer; }
00192     //KateEditInfoGroup* redoBuffer() const { return m_redo; }
00193 
00194     int revision();
00195     void releaseRevision(int revision);
00196 
00197     QList<KateEditInfo*> editsBetweenRevisions(int from, int to = -1) const;
00198 
00199     void doEdit(KateEditInfo* edit) { buffer()->addEdit(edit); emit editDone(edit); }
00200 
00201   Q_SIGNALS:
00202     void editDone(KateEditInfo* edit);
00203     //void editUndone(KateEditInfo* edit);
00204 
00205   private:
00206     KateDocument* m_doc;
00207     KateEditInfoGroup* m_buffer;
00208     //KateEditInfoGroup* m_redo;
00209 
00210     QMap<int, KateEditInfo*> m_revisions;
00211     int m_revision;
00212 };
00213 
00214 #endif

Kate

Skip menu "Kate"
  • Main Page
  • 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