Kate
katescriptmanager.h
Go to the documentation of this file.
00001 // This file is part of the KDE libraries 00002 // Copyright (C) 2008 Paul Giannaros <paul@giannaros.org> 00003 // Copyright (C) 2009 Dominik Haumann <dhaumann kde org> 00004 // Copyright (C) 2010 Joseph Wenninger <jowenn@kde.org> 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) version 3. 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 #ifndef KATE_SCRIPT_MANAGER_H 00022 #define KATE_SCRIPT_MANAGER_H 00023 00024 #include <ktexteditor/commandinterface.h> 00025 #include <ktexteditor/cursor.h> 00026 00027 #include <kdebug.h> 00028 00029 #include <QVector> 00030 00031 #include "katescript.h" 00032 #include "kateindentscript.h" 00033 #include "katecommandlinescript.h" 00034 #include "katetemplatescript.h" 00035 00036 class QString; 00037 00038 00043 class KateScriptManager : public QObject, public KTextEditor::Command 00044 { 00045 Q_OBJECT 00046 00047 public: 00048 KateScriptManager(); 00049 virtual ~KateScriptManager(); 00050 00052 const QVector<KateCommandLineScript*> &commandLineScripts() { return m_commandLineScripts; } 00053 00060 KateIndentScript *indenter(const QString &language); 00061 00062 // 00063 // KTextEditor::Command 00064 // 00065 public: 00073 bool exec(KTextEditor::View *view, const QString &cmd, QString &errorMsg); 00074 00082 bool help(KTextEditor::View *view, const QString &cmd, QString &msg); 00083 00088 const QStringList &cmds(); 00089 00090 // 00091 // Helper methods 00092 // 00093 public: 00101 void collect(const QString& resourceFile, 00102 const QString& directory, 00103 bool force = false); 00104 00109 static bool parseMetaInformation(const QString& url, QHash<QString, QString> &pairs); 00110 00111 public: 00112 KateIndentScript *indentationScript (const QString &scriptname) { return m_indentationScriptMap.value(scriptname); } 00113 00114 int indentationScriptCount () { return m_indentationScripts.size(); } 00115 KateIndentScript *indentationScriptByIndex (int index) { return m_indentationScripts[index]; } 00116 00117 public: 00119 void reload(); 00120 00121 Q_SIGNALS: 00123 void reloaded(); 00124 00125 private: 00127 QVector<KateCommandLineScript*> m_commandLineScripts; 00128 00130 QList<KateIndentScript*> m_indentationScripts; 00131 00133 QHash<QString, KateIndentScript*> m_indentationScriptMap; 00134 00136 QHash<QString, QVector<KateIndentScript*> > m_languageToIndenters; 00137 00138 00139 // 00140 // Template handling 00141 // 00142 public: 00144 KTextEditor::TemplateScript* registerTemplateScript (QObject* owner, const QString& script); 00146 void unregisterTemplateScript(KTextEditor::TemplateScript* templateScript); 00147 00148 KateTemplateScript* templateScript(KTextEditor::TemplateScript* templateScript); 00149 00150 public Q_SLOTS: 00151 void slotTemplateScriptOwnerDestroyed(QObject* owner); 00152 00153 private: 00154 QMultiMap<QObject*, KTextEditor::TemplateScript*> m_ownerScript; 00155 QList<KTextEditor::TemplateScript*> m_templateScripts; 00156 }; 00157 00158 00159 00160 #endif 00161 00162 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE 4.6 API Reference