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 #include <QtCore/QMutex> 00026 00027 #include <ktexteditor/range.h> 00028 00029 #include "katenamespace.h" 00030 00031 class KateDocument; 00032 00038 class KateEditInfo 00039 { 00040 public: 00041 KateEditInfo(Kate::EditSource source, const KTextEditor::Range& oldRange, const QStringList& oldText, const KTextEditor::Range& newRange, const QStringList& newText); 00042 virtual ~KateEditInfo(); 00043 00045 bool isRemoval() const; 00046 00051 Kate::EditSource editSource() const; 00052 00058 const KTextEditor::Cursor& start() const { return m_oldRange.start(); } 00059 00063 const KTextEditor::Range& oldRange() const; 00064 00069 virtual QStringList oldText(const KTextEditor::Range& range) const; 00070 00075 const QStringList& oldText() const; 00076 00080 const KTextEditor::Range& newRange() const; 00081 00086 virtual QStringList newText(const KTextEditor::Range& range) const; 00087 00093 const QStringList& newText() const; 00094 00095 inline const KTextEditor::Cursor& translate() const { return m_translate; } 00096 00097 void referenceRevision(); 00098 void dereferenceRevision(); 00099 bool isReferenced() const; 00100 00101 private: 00102 Kate::EditSource m_editSource; 00103 KTextEditor::Range m_oldRange; 00104 QStringList m_oldText; 00105 KTextEditor::Range m_newRange; 00106 QStringList m_newText; 00107 KTextEditor::Cursor m_translate; 00108 int m_revisionTokenCounter; 00109 }; 00110 00116 class KateEditHistory : public QObject 00117 { 00118 Q_OBJECT 00119 00120 public: 00121 explicit KateEditHistory(KateDocument* doc); 00122 virtual ~KateEditHistory(); 00123 00124 int revision(); 00125 void releaseRevision(int revision); 00126 00127 QList<KateEditInfo*> editsBetweenRevisions(int from, int to = -1) const; 00128 00129 void doEdit(KateEditInfo* edit); 00130 00131 Q_SIGNALS: 00132 void editDone(KateEditInfo* edit); 00133 00134 private: 00135 QList<KateEditInfo*> m_edits; 00136 mutable QMutex m_mutex; 00137 00138 QMap<int, KateEditInfo*> m_revisions; 00139 int m_revision; 00140 }; 00141 00142 #endif