Kate
katetemplatehandler.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 _KATE_TEMPLATE_HANDLER_H_
00020 #define _KATE_TEMPLATE_HANDLER_H_
00021
00022 #include "katesmartrange.h"
00023 #include <QtCore/QPointer>
00024 #include <QtCore/QObject>
00025 #include <QtCore/QMap>
00026 #include <QtCore/QHash>
00027 #include <QtCore/QString>
00028 #include <QtCore/QList>
00029
00030 class KateDocument;
00031 class KateUndoManager;
00032
00033 namespace KTextEditor {
00034 class SmartRange;
00035 }
00036
00060 class KateTemplateHandler: public QObject
00061 {
00062 Q_OBJECT
00063 public:
00070 KateTemplateHandler(KateDocument *doc, const KTextEditor::Cursor& position,
00071 const QString &templateString, const QMap<QString, QString> &initialValues,
00072 KateUndoManager* undoManager);
00073
00077 virtual ~KateTemplateHandler();
00078
00079 protected:
00095 virtual bool eventFilter(QObject* object, QEvent* event);
00096
00097 private:
00101 void insertText(const KTextEditor::Cursor& position, const QString& text);
00102
00110 void handleTemplateString(const KTextEditor::Cursor &position, QString templateString,
00111 const QMap<QString, QString> &initialValues);
00112
00119 void setupEventHandler(KTextEditor::View* view);
00120
00126 void jumpToPreviousRange();
00127
00133 void jumpToNextRange();
00134
00138 void setCurrentRange(KTextEditor::SmartRange* range);
00139
00146 void syncMirroredRanges(KTextEditor::SmartRange* range);
00147
00155 void cleanupAndExit();
00156
00161 void jumpToFinalCursorPosition();
00162
00163 private Q_SLOTS:
00167 void slotViewCreated(KTextEditor::Document* document, KTextEditor::View* view);
00168
00175 void slotTextChanged(KTextEditor::Document* document, const KTextEditor::Range& oldRange);
00176
00180 void setEditWithUndo(const bool &enabled);
00181
00182 private:
00184 KateDocument *m_doc;
00194 QList<KTextEditor::SmartRange*> m_templateRanges;
00197 KTextEditor::SmartRange* m_wholeTemplateRange;
00199 KTextEditor::SmartCursor* m_finalCursorPosition;
00201 KTextEditor::Cursor m_lastCaretPosition;
00205 QList<KTextEditor::SmartRange*> m_uneditedRanges;
00208 QList<KTextEditor::SmartRange*> m_AllRangesSorted;
00210 bool m_isMirroring;
00212 bool m_editWithUndo;
00214 bool m_jumping;
00215 };
00216
00217 #endif
00218
00219