Kate
katesmartmanager.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef KATESMARTMANAGER_H
00020 #define KATESMARTMANAGER_H
00021
00022 #include <QtCore/QObject>
00023 #include <QtCore/QSet>
00024 #include <QtCore/QLinkedList>
00025 #include <QtCore/QThreadStorage>
00026
00027 #include <ktexteditor/smartrange.h>
00028
00029 class KateEditInfo;
00030 class KateDocument;
00031 class KateSmartCursor;
00032 class KateSmartRange;
00033 class KateSmartGroup;
00034
00041 class KateSmartManager : public QObject
00042 {
00043 Q_OBJECT
00044
00045 public:
00046 explicit KateSmartManager(KateDocument* parent);
00047 virtual ~KateSmartManager();
00048
00049 KateDocument* doc() const;
00050
00062 inline bool isClearing() const { return m_clearing; }
00063 void clear(bool includingInternal);
00064
00065 int currentRevision() const;
00066 void releaseRevision(int revision) const;
00067 void useRevision(int revision = -1);
00068 KTextEditor::Cursor translateFromRevision(const KTextEditor::Cursor& cursor, KTextEditor::SmartCursor::InsertBehavior insertBehavior = KTextEditor::SmartCursor::StayOnInsert) const;
00069 KTextEditor::Range translateFromRevision(const KTextEditor::Range& range, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::ExpandLeft | KTextEditor::SmartRange::ExpandRight) const;
00070
00071 KateSmartCursor* newSmartCursor(const KTextEditor::Cursor& position = KTextEditor::Cursor(), KTextEditor::SmartCursor::InsertBehavior insertBehavior = KTextEditor::SmartCursor::MoveOnInsert, bool internal = true);
00072 void deleteCursors(bool includingInternal);
00073
00074 KateSmartRange* newSmartRange(const KTextEditor::Range& range = KTextEditor::Range(), KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::DoNotExpand, bool internal = true);
00075 KateSmartRange* newSmartRange(KateSmartCursor* start, KateSmartCursor* end, KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::DoNotExpand, bool internal = true);
00076 void unbindSmartRange(KTextEditor::SmartRange* range);
00077 void deleteRanges(bool includingInternal);
00078
00079 void rangeGotParent(KateSmartRange* range);
00080 void rangeLostParent(KateSmartRange* range);
00082 void rangeDeleted(KateSmartRange* range);
00083
00084 KateSmartGroup* groupForLine(int line) const;
00085
00086 Q_SIGNALS:
00087 void signalRangeDeleted(KateSmartRange* range);
00088
00089 private Q_SLOTS:
00090 void slotTextChanged(KateEditInfo* edit);
00091 void verifyCorrect() const;
00092
00093 private:
00094 KateSmartRange* feedbackRange(const KateEditInfo& edit, KateSmartRange* range);
00095 int usingRevision() const;
00096
00097 void debugOutput() const;
00098
00099 KateSmartGroup* m_firstGroup;
00100 QSet<KateSmartRange*> m_topRanges;
00101 KateSmartGroup* m_invalidGroup;
00102 bool m_clearing;
00103 QThreadStorage<int*> m_usingRevision;
00104 struct KateTranslationDebugger;
00105 KateTranslationDebugger* m_currentKateTranslationDebugger;
00106 };
00107
00116 class KateSmartGroup
00117 {
00118 public:
00119 KateSmartGroup(int startLine, int endLine, KateSmartGroup* previous, KateSmartGroup* next);
00120
00121 inline int startLine() const { return m_startLine; }
00122 inline int newStartLine() const { return m_newStartLine; }
00123 inline int endLine() const { return m_endLine; }
00124 inline int newEndLine() const { return m_newEndLine; }
00125 inline void setEndLine(int endLine) { m_newEndLine = m_endLine = endLine; }
00126 inline void setNewEndLine(int endLine) { m_newEndLine = endLine; }
00127 inline int length() const { return m_endLine - m_startLine + 1; }
00128 inline bool containsLine(int line) const { return line >= m_newStartLine && line <= m_newEndLine; }
00129
00130 inline KateSmartGroup* previous() const { return m_previous; }
00131 inline void setPrevious(KateSmartGroup* previous) { m_previous = previous; }
00132
00133 inline KateSmartGroup* next() const { return m_next; }
00134 inline void setNext(KateSmartGroup* next) { m_next = next; }
00135
00136 void addCursor(KateSmartCursor* cursor);
00137 void changeCursorFeedback(KateSmartCursor* cursor);
00138 void removeCursor(KateSmartCursor* cursor);
00139
00140 const QSet<KateSmartCursor*>& feedbackCursors() const;
00141
00142 const QSet<KateSmartCursor*>& normalCursors() const;
00143
00144
00150 void joined(KateSmartCursor* cursor);
00151
00157 void leaving(KateSmartCursor* cursor);
00158
00159
00160 void merge();
00161
00162
00163 void translateChanged(const KateEditInfo& edit);
00164 void translateShifted(const KateEditInfo& edit);
00165
00166
00167 void translatedChanged(const KateEditInfo& edit);
00168 void translatedShifted(const KateEditInfo& edit);
00169
00170
00171 void translatedChanged2(const KateEditInfo& edit);
00172
00173 void deleteCursors(bool includingInternal);
00174 void deleteCursorsInternal(QSet<KateSmartCursor*>& set);
00175
00176 void debugOutput() const;
00177
00178 private:
00179 int m_startLine, m_newStartLine, m_endLine, m_newEndLine;
00180 KateSmartGroup* m_next;
00181 KateSmartGroup* m_previous;
00182
00183 QSet<KateSmartCursor*> m_feedbackCursors;
00184 QSet<KateSmartCursor*> m_normalCursors;
00185 };
00186
00187 #endif