Kate
katecommandlinescript.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) 2009 Dominik Haumann <dhaumann kde org> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KATE_COMMANDLINE_SCRIPT_H 00022 #define KATE_COMMANDLINE_SCRIPT_H 00023 00024 #include "katescript.h" 00025 #include "kateview.h" 00026 00027 #include <QtCore/QPair> 00028 #include <ktexteditor/commandinterface.h> 00029 00030 class KateScriptDocument; 00031 00032 class KateCommandLineScriptHeader 00033 { 00034 public: 00035 KateCommandLineScriptHeader() 00036 {} 00037 00038 inline void setFunctions(const QStringList& functions) 00039 { m_functions = functions; } 00040 inline const QStringList& functions() const 00041 { return m_functions; } 00042 00043 private: 00044 QStringList m_functions; 00045 }; 00046 00047 class ScriptActionInfo 00048 { 00049 public: 00050 ScriptActionInfo() {} 00051 00052 inline bool isValid() const { return !(m_command.isEmpty() || m_text.isEmpty()); } 00053 00054 inline void setCommand(const QString& command) { m_command = command; } 00055 inline QString command() const { return m_command; } 00056 inline void setText(const QString& text) { m_text = text; } 00057 inline QString text() const { return m_text; } 00058 inline void setIcon(const QString& icon) { m_icon = icon; } 00059 inline QString icon() const { return m_icon; } 00060 inline void setCategory(const QString& category) { m_category = category; } 00061 inline QString category() const { return m_category; } 00062 inline void setInteractive(bool interactive) { m_interactive = interactive; } 00063 inline bool interactive() const { return m_interactive; } 00064 inline void setShortcut(const QString& shortcut) { m_shortcut = shortcut; } 00065 inline QString shortcut() const { return m_shortcut; } 00066 00067 private: 00068 QString m_command; 00069 QString m_text; 00070 QString m_icon; 00071 QString m_category; 00072 bool m_interactive; 00073 QString m_shortcut; 00074 }; 00075 00080 class KateCommandLineScript : public KateScript, public KTextEditor::Command 00081 { 00082 public: 00083 KateCommandLineScript(const QString &url, const KateCommandLineScriptHeader &header); 00084 virtual ~KateCommandLineScript(); 00085 00086 const KateCommandLineScriptHeader& commandHeader(); 00087 00088 bool callFunction(const QString& cmd, const QStringList args, QString &errorMessage); 00089 00090 ScriptActionInfo actionInfo(const QString& cmd); 00091 00092 // 00093 // KTextEditor::Command interface 00094 // 00095 public: 00096 virtual const QStringList &cmds (); 00097 virtual bool exec (KTextEditor::View *view, const QString &cmd, QString &msg); 00098 virtual bool help (KTextEditor::View *view, const QString &cmd, QString &msg); 00099 00100 private: 00101 KateCommandLineScriptHeader m_commandHeader; 00102 }; 00103 00104 #endif 00105 00106 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE 4.6 API Reference