• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Kate

katetemplatehandler.h

Go to the documentation of this file.
00001 /*  This file is part of the KDE libraries and the Kate part.
00002  *
00003  *  Copyright (C) 2004,2010 Joseph Wenninger <jowenn@kde.org>
00004  *  Copyright (C) 2009 Milian Wolff <mail@milianw.de>
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Library General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Library General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Library General Public License
00017  *  along with this library; see the file COPYING.LIB.  If not, write to
00018  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  *  Boston, MA 02110-1301, USA.
00020  */
00021 
00022 #ifndef _KATE_TEMPLATE_HANDLER_H_
00023 #define _KATE_TEMPLATE_HANDLER_H_
00024 
00025 #include <QtCore/QPointer>
00026 #include <QtCore/QObject>
00027 #include <QtCore/QMap>
00028 #include <QtCore/QHash>
00029 #include <QtCore/QString>
00030 #include <QtCore/QList>
00031 #include <QtCore/QRegExp>
00032 
00033 class KateDocument;
00034 
00035 class KateView;
00036 
00037 class KateUndoManager;
00038 
00039 class KateTemplateScript;
00040 
00041 namespace KTextEditor
00042 {
00043 
00044 class MovingCursor;
00045 
00046 class MovingRange;
00047 }
00048 
00073 class KateTemplateHandler: public QObject
00074 {
00075   Q_OBJECT
00076 
00077 public:
00084   KateTemplateHandler(KateView *view,
00085                       const KTextEditor::Cursor& position,
00086                       const QString &templateString,
00087                       const QMap<QString, QString> &initialValues,
00088                       KateUndoManager* undoManager,
00089                       KateTemplateScript* templateScript);
00090 
00094   virtual ~KateTemplateHandler();
00095 
00096 protected:
00112   virtual bool eventFilter(QObject* object, QEvent* event);
00113 
00114 private:
00118   void insertText(const KTextEditor::Cursor& position, const QString& text);
00119 
00126   void handleTemplateString(const QMap<QString, QString> &initialValues);
00127 
00134   void setupEventHandler(KTextEditor::View* view);
00135 
00141   void jumpToPreviousRange();
00142 
00148   void jumpToNextRange();
00149 
00153   void setCurrentRange(KTextEditor::MovingRange* range);
00154 
00161   void syncMirroredRanges(KTextEditor::MovingRange* range);
00162 
00163 public:
00164 
00165   class MirrorBehaviour
00166   {
00167 
00168   public:
00169     MirrorBehaviour(); //clone
00170     MirrorBehaviour(const QString &regexp, const QString &replacement, const QString &flags);   //regexp
00171     MirrorBehaviour(KateTemplateScript* templateScript, const QString& functionName, KateTemplateHandler* handler);   //scripted
00172     ~MirrorBehaviour();
00173     QString getMirrorString(const QString &source);
00174 
00175   private:
00176     enum Behaviour {
00177       Clone = 0,
00178       Regexp = 1,
00179       Scripted = 2
00180     };
00181     Behaviour m_behaviour;
00182     QString m_search;
00183     QString m_replace;
00184     QRegExp m_expr;
00185     bool m_global;
00186     KateTemplateScript* m_templateScript;
00187     QString m_functionName;
00188     KateTemplateHandler *m_handler;
00189   };
00190 
00191 private:
00192 
00193   QHash<KTextEditor::MovingRange*, MirrorBehaviour> m_mirrorBehaviour;
00194 
00195 
00200   void jumpToFinalCursorPosition();
00201 
00202   KateDocument *doc();
00203 
00204 private Q_SLOTS:
00212   void cleanupAndExit();
00213 
00219   void slotTemplateInserted(KTextEditor::Document* document, const KTextEditor::Range& range);
00223   void slotViewCreated(KTextEditor::Document* document, KTextEditor::View* view);
00230   void slotTextChanged(KTextEditor::Document* document, const KTextEditor::Range& oldRange);
00231 
00235   void setEditWithUndo(const bool &enabled);
00236 
00237 public:
00238   KateView* view();
00239 
00240 private:
00242   KateView *m_view;
00244   KateUndoManager *const m_undoManager;
00254   QList<KTextEditor::MovingRange*> m_templateRanges;
00255 
00257   QMap<KTextEditor::MovingRange*, QList<KTextEditor::MovingRange*> > m_templateRangesChildren;
00258   QMap<KTextEditor::MovingRange*, KTextEditor::MovingRange*> m_templateRangesChildToParent;
00259 
00262   KTextEditor::MovingRange *m_wholeTemplateRange;
00264   KTextEditor::MovingCursor *m_finalCursorPosition;
00266   KTextEditor::Cursor m_lastCaretPosition;
00270   QList<KTextEditor::MovingRange*> m_uneditedRanges;
00272   QList<KTextEditor::MovingRange*> m_masterRanges;
00274   bool m_isMirroring;
00276   bool m_editWithUndo;
00278   bool m_jumping;
00280   KateTemplateScript* m_templateScript;
00281 
00282   QList<KTextEditor::MovingRange*> m_spacersMovingRanges;
00283 
00284   bool m_initialRemodify;
00285 };
00286 
00287 
00288 #endif
00289 
00290 // kate: indent-mode cstyle; space-indent on; indent-width 2; replace-tabs on;  replace-tabs on;  replace-tabs on;  replace-tabs on;

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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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