kateexternaltools.h
00001 /* 00002 This file is part of the Kate text editor of the KDE project. 00003 It describes a "external tools" action for kate and provides a dialog 00004 page to configure that. 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 version 2 as published by the Free Software Foundation. 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 Copyright (C) 2004, Anders Lund <anders@alweb.dk> 00022 */ 00023 00024 #ifndef _KATE_EXTERNAL_TOOLS_H_ 00025 #define _KATE_EXTERNAL_TOOLS_H_ 00026 00027 #include <kaction.h> 00028 #include <kdialogbase.h> 00029 #include <kate/document.h> 00030 #include <kmacroexpander.h> 00031 #include <tqpixmap.h> 00032 00054 class KateExternalToolsMenuAction : public KActionMenu 00055 { 00056 friend class KateExternalToolAction; 00057 00058 Q_OBJECT 00059 public: 00060 KateExternalToolsMenuAction( const TQString &text=TQString::null, TQObject *parent=0, const char* name=0, class KateMainWindow *mw=0 ); 00061 ~KateExternalToolsMenuAction() {}; 00062 00066 void reload(); 00067 00068 class KActionCollection *actionCollection() { return m_actionCollection; } 00069 00070 private slots: 00071 void slotDocumentChanged(); 00072 00073 private: 00074 class KActionCollection *m_actionCollection; 00075 class KateMainWindow *mainwindow; // for the actions to access view/doc managers 00076 }; 00077 00081 class KateExternalToolAction : public KAction, public KWordMacroExpander 00082 { 00083 Q_OBJECT 00084 public: 00085 KateExternalToolAction( TQObject *parent, const char *name, class KateExternalTool *t ); 00086 ~KateExternalToolAction(); 00087 protected: 00088 virtual bool expandMacro( const TQString &str, TQStringList &ret ); 00089 00090 private slots: 00091 void slotRun(); 00092 00093 public: 00094 class KateExternalTool *tool; 00095 }; 00096 00100 class KateExternalTool 00101 { 00102 public: 00103 KateExternalTool( const TQString &name=TQString::null, 00104 const TQString &command=TQString::null, 00105 const TQString &icon=TQString::null, 00106 const TQString &tryexec=TQString::null, 00107 const TQStringList &mimetypes=TQStringList(), 00108 const TQString &acname=TQString::null, 00109 const TQString &cmdname=TQString::null, 00110 int save=0 ); 00111 ~KateExternalTool() {}; 00112 00113 TQString name; 00114 TQString command; 00115 TQString icon; 00116 TQString tryexec; 00117 TQStringList mimetypes; 00118 bool hasexec; 00119 TQString acname; 00120 TQString cmdname; 00121 int save; 00122 00126 bool valid( const TQString &mimetype ) const; 00132 bool checkExec(); 00133 00134 private: 00135 TQString m_exec; 00136 }; 00137 00143 class KateExternalToolsConfigWidget : public Kate::ConfigPage 00144 { 00145 Q_OBJECT 00146 public: 00147 KateExternalToolsConfigWidget( TQWidget *parent, const char* name); 00148 virtual ~KateExternalToolsConfigWidget(); 00149 00150 virtual void apply(); 00151 virtual void reload(); 00152 virtual void reset() { reload(); } // sigh 00153 virtual void defaults() { reload(); } // double sigh 00154 00155 private slots: 00156 void slotNew(); 00157 void slotEdit(); 00158 void slotRemove(); 00159 void slotInsertSeparator(); 00160 00161 void slotMoveUp(); 00162 void slotMoveDown(); 00163 00164 void slotSelectionChanged(); 00165 00166 private: 00167 TQPixmap blankIcon(); 00168 00169 TQStringList m_removed; 00170 00171 class KListBox *lbTools; 00172 class TQPushButton *btnNew, *btnRemove, *btnEdit, *btnMoveUp, *btnMoveDwn; 00173 00174 class KConfig *config; 00175 00176 bool m_changed; 00177 }; 00178 00182 class KateExternalToolsCommand : public Kate::Command { 00183 public: 00184 KateExternalToolsCommand (); 00185 virtual ~KateExternalToolsCommand () {}; 00186 static KateExternalToolsCommand *self(); 00187 void reload(); 00188 public: 00189 virtual TQStringList cmds (); 00190 virtual bool exec (Kate::View *view, const TQString &cmd, TQString &msg); 00191 virtual bool help (Kate::View *view, const TQString &cmd, TQString &msg); 00192 private: 00193 static KateExternalToolsCommand *s_self; 00194 TQStringList m_list; 00195 TQMap<TQString,TQString> m_map; 00196 bool m_inited; 00197 }; 00198 00202 class KateExternalToolServiceEditor : public KDialogBase 00203 { 00204 Q_OBJECT 00205 00206 public: 00207 00208 KateExternalToolServiceEditor( KateExternalTool *tool=0, 00209 TQWidget *parent=0, const char *name=0 ); 00210 00211 class TQLineEdit *leName, *leExecutable, *leMimetypes,*leCmdLine; 00212 class TQTextEdit *teCommand; 00213 class KIconButton *btnIcon; 00214 class TQComboBox *cmbSave; 00215 00216 private slots: 00220 void slotOk(); 00224 void showMTDlg(); 00225 00226 private: 00227 KateExternalTool *tool; 00228 }; 00229 #endif //_KATE_EXTERNAL_TOOLS_H_