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

Kate

katesmartmanager.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 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 #include "kateedit.h"
00030 
00031 class KateDocument;
00032 class KateSmartCursor;
00033 class KateSmartRange;
00034 class KateSmartGroup;
00035 
00042 class KateSmartManager : public QObject
00043 {
00044   Q_OBJECT
00045 
00046   public:
00047     explicit KateSmartManager(KateDocument* parent);
00048     virtual ~KateSmartManager();
00049 
00050     KateDocument* doc() const;
00051 
00063     inline bool isClearing() const { return m_clearing; }
00064     void clear(bool includingInternal);
00065 
00066     int currentRevision() const;
00067     void releaseRevision(int revision) const;
00068     void useRevision(int revision = -1);
00069     KTextEditor::Cursor translateFromRevision(const KTextEditor::Cursor& cursor, KTextEditor::SmartCursor::InsertBehavior insertBehavior = KTextEditor::SmartCursor::StayOnInsert) const;
00070     KTextEditor::Range translateFromRevision(const KTextEditor::Range& range, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::ExpandLeft | KTextEditor::SmartRange::ExpandRight) const;
00071 
00072     KateSmartCursor* newSmartCursor(const KTextEditor::Cursor& position = KTextEditor::Cursor(), KTextEditor::SmartCursor::InsertBehavior insertBehavior = KTextEditor::SmartCursor::MoveOnInsert, bool internal = true);
00073     void deleteCursors(bool includingInternal);
00074 
00075     KateSmartRange* newSmartRange(const KTextEditor::Range& range = KTextEditor::Range(), KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::DoNotExpand, bool internal = true);
00076     KateSmartRange* newSmartRange(KateSmartCursor* start, KateSmartCursor* end, KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = KTextEditor::SmartRange::DoNotExpand, bool internal = true);
00077     void unbindSmartRange(KTextEditor::SmartRange* range);
00078     void deleteRanges(bool includingInternal);
00079 
00080     void rangeGotParent(KateSmartRange* range);
00081     void rangeLostParent(KateSmartRange* range);
00083     void rangeDeleted(KateSmartRange* range);
00084 
00085     KateSmartGroup* groupForLine(int line) const;
00086 
00087   Q_SIGNALS:
00088     void signalRangeDeleted(KateSmartRange* range);
00089 
00090   private Q_SLOTS:
00091     void slotTextChanged(KateEditInfo* edit);
00092     void verifyCorrect() const;
00093 
00094   private:
00095     KateSmartRange* feedbackRange(const KateEditInfo& edit, KateSmartRange* range);
00096     int usingRevision() const;
00097 
00098     void debugOutput() const;
00099 
00100     KateSmartGroup* m_firstGroup;
00101     QSet<KateSmartRange*> m_topRanges;
00102     KateSmartGroup* m_invalidGroup;
00103     bool m_clearing;
00104     QThreadStorage<int*> m_usingRevision;
00105     struct KateTranslationDebugger;
00106     KateTranslationDebugger* m_currentKateTranslationDebugger;
00107 };
00108 
00117 class KateSmartGroup
00118 {
00119   public:
00120     KateSmartGroup(int startLine, int endLine, KateSmartGroup* previous, KateSmartGroup* next);
00121 
00122     inline int startLine() const { return m_startLine; }
00123     inline int newStartLine() const { return m_newStartLine; }
00124     inline int endLine() const { return m_endLine; }
00125     inline int newEndLine() const { return m_newEndLine; }
00126     inline void setEndLine(int endLine) { m_newEndLine = m_endLine = endLine; }
00127     inline void setNewEndLine(int endLine) { m_newEndLine = endLine; }
00128     inline int length() const { return m_endLine - m_startLine + 1; }
00129     inline bool containsLine(int line) const { return line >= m_newStartLine && line <= m_newEndLine; }
00130 
00131     inline KateSmartGroup* previous() const { return m_previous; }
00132     inline void setPrevious(KateSmartGroup* previous) { m_previous = previous; }
00133 
00134     inline KateSmartGroup* next() const { return m_next; }
00135     inline void setNext(KateSmartGroup* next) { m_next = next; }
00136 
00137     void addCursor(KateSmartCursor* cursor);
00138     void changeCursorFeedback(KateSmartCursor* cursor);
00139     void removeCursor(KateSmartCursor* cursor);
00140     // Cursors requiring position change feedback
00141     const QSet<KateSmartCursor*>& feedbackCursors() const;
00142     // Cursors not requiring feedback
00143     const QSet<KateSmartCursor*>& normalCursors() const;
00144 
00145     // Cursor movement!
00151     void joined(KateSmartCursor* cursor);
00152 
00158     void leaving(KateSmartCursor* cursor);
00159 
00160     // Merge with the next Smart Group, because this group became too small.
00161     void merge();
00162 
00163     // First pass for translation
00164     void translateChanged(const KateEditInfo& edit);
00165     void translateShifted(const KateEditInfo& edit);
00166 
00167     // Second pass for finalizing the translation
00168     void translatedChanged(const KateEditInfo& edit);
00169     void translatedShifted(const KateEditInfo& edit);
00170 
00171     // Third pass, when all translations are complete
00172     void translatedChanged2(const KateEditInfo& edit);
00173     
00174     void deleteCursors(bool includingInternal);
00175     void deleteCursorsInternal(QSet<KateSmartCursor*>& set);
00176 
00177     void debugOutput() const;
00178 
00179   private:
00180     int m_startLine, m_newStartLine, m_endLine, m_newEndLine;
00181     KateSmartGroup* m_next;
00182     KateSmartGroup* m_previous;
00183 
00184     QSet<KateSmartCursor*> m_feedbackCursors;
00185     QSet<KateSmartCursor*> m_normalCursors;
00186 };
00187 
00188 #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
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
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