scriptplugin.h (krename-4.0.9) | : | scriptplugin.h (krename-4.90.90) | ||
---|---|---|---|---|
skipping to change at line 18 | skipping to change at line 18 | |||
/*************************************************************************** | /*************************************************************************** | |||
* * | * * | |||
* This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | |||
* it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | |||
* the Free Software Foundation; either version 2 of the License, or * | * the Free Software Foundation; either version 2 of the License, or * | |||
* (at your option) any later version. * | * (at your option) any later version. * | |||
* * | * * | |||
***************************************************************************/ | ***************************************************************************/ | |||
#ifndef _SCRIPT_PLUGIN_H_ | #ifndef SCRIPT_PLUGIN_H | |||
#define _SCRIPT_PLUGIN_H_ | #define SCRIPT_PLUGIN_H | |||
#include "plugin.h" | #include "plugin.h" | |||
class QMenu; | class QMenu; | |||
class KJSInterpreter; | class KJSInterpreter; | |||
class KRenameFile; | class KRenameFile; | |||
namespace Ui { | namespace Ui | |||
class ScriptPluginWidget; | { | |||
class ScriptPluginWidget; | ||||
}; | }; | |||
class ScriptPlugin : public QObject, public Plugin { | class ScriptPlugin : public QObject, public Plugin | |||
Q_OBJECT | { | |||
public: | Q_OBJECT | |||
public: | ||||
/** Create a new ScriptPlugin from | /** Create a new ScriptPlugin from | |||
* | * | |||
*/ | */ | |||
ScriptPlugin( PluginLoader* loader ); | explicit ScriptPlugin(PluginLoader *loader); | |||
virtual ~ScriptPlugin(); | virtual ~ScriptPlugin(); | |||
/** | /** | |||
* @returns a name of the plugin that can be displayed | * @returns a name of the plugin that can be displayed | |||
* to the user. This name should be internationalized. | * to the user. This name should be internationalized. | |||
*/ | */ | |||
inline virtual const QString name() const; | inline virtual const QString name() const; | |||
/** | /** | |||
skipping to change at line 93 | skipping to change at line 95 | |||
* in brackets. If your plugin supports the token [ex ample], | * in brackets. If your plugin supports the token [ex ample], | |||
* KRename will pass the strign "example" to your met hod. | * KRename will pass the strign "example" to your met hod. | |||
* @param eCurrentType the current type of plugin that is requested (for plu gins that support more than one type) | * @param eCurrentType the current type of plugin that is requested (for plu gins that support more than one type) | |||
* | * | |||
* @returns the result of the function, depending on type(). | * @returns the result of the function, depending on type(). | |||
* @returns QString::null if this plugin has nothing to do. | * @returns QString::null if this plugin has nothing to do. | |||
* @returns A new filename if type is ePluginType_Filename | * @returns A new filename if type is ePluginType_Filename | |||
* @returns the value of the token if type is ePluginType_Token | * @returns the value of the token if type is ePluginType_Token | |||
* @returns an error message or QString::null if type is ePluginType_File | * @returns an error message or QString::null if type is ePluginType_File | |||
*/ | */ | |||
virtual QString processFile( BatchRenamer* b, int index, const QString & fil enameOrToken, EPluginType eCurrentType ); | virtual QString processFile(BatchRenamer *b, int index, const QString &filen ameOrToken, EPluginType eCurrentType); | |||
/** Get a list of all tokens supported by this plugin. | /** Get a list of all tokens supported by this plugin. | |||
* | * | |||
* If the token type != ePluginType_Token you have to return an empty list | * If the token type != ePluginType_Token you have to return an empty list | |||
* | * | |||
* @returns a list of all supported tokens. | * @returns a list of all supported tokens. | |||
*/ | */ | |||
inline virtual const QStringList & supportedTokens() const; | inline virtual const QStringList &supportedTokens() const; | |||
/** Returns help descriptions for the supported tokens | /** Returns help descriptions for the supported tokens | |||
* | * | |||
* The returned stringlist contains strings that are the tokens | * The returned stringlist contains strings that are the tokens | |||
* and the description separated by ;; | * and the description separated by ;; | |||
* | * | |||
* @returns a stringlist containing help on the supported tokens | * @returns a stringlist containing help on the supported tokens | |||
*/ | */ | |||
inline virtual const QStringList & help() const; | inline virtual const QStringList &help() const; | |||
/** Create a user interface for this plugin | /** Create a user interface for this plugin | |||
* | * | |||
* @param parent the parent widget of this plugin | * @param parent the parent widget of this plugin | |||
* | * | |||
* This is implemented here for all FilePlugin based classed | * This is implemented here for all FilePlugin based classed | |||
*/ | */ | |||
void createUI( QWidget* parent ) const; | void createUI(QWidget *parent) const; | |||
/** Load the plugin configuration. | /** Load the plugin configuration. | |||
* | * | |||
* Called when plugins should load their configuration. | * Called when plugins should load their configuration. | |||
* | * | |||
* @param group config group where the configuration should be read from | * @param group config group where the configuration should be read from | |||
*/ | */ | |||
virtual void loadConfig( KConfigGroup & group ); | virtual void loadConfig(KConfigGroup &group); | |||
/** Save the plugin configuration. | /** Save the plugin configuration. | |||
* | * | |||
* Called when plugins should save their configuration. | * Called when plugins should save their configuration. | |||
* | * | |||
* @param group config group where the configuration should be stored | * @param group config group where the configuration should be stored | |||
*/ | */ | |||
virtual void saveConfig( KConfigGroup & group ) const; | virtual void saveConfig(KConfigGroup &group) const; | |||
protected: | protected: | |||
/** | /** | |||
* Adds a token to the list of supported tokens | * Adds a token to the list of supported tokens | |||
* | * | |||
* @param token will be a supported token from now on | * @param token will be a supported token from now on | |||
* | * | |||
* @see supports | * @see supports | |||
*/ | */ | |||
inline void addSupportedToken( const QString & token ) { m_keys.append( toke | inline void addSupportedToken(const QString &token) | |||
n ); } | { | |||
m_keys.append(token); | ||||
} | ||||
/** | /** | |||
* Set all KRename internal variables on the internal | * Set all KRename internal variables on the internal | |||
* Interpreter object. | * Interpreter object. | |||
* | * | |||
* @param file the KRenameFile where the values can be retrieved | * @param file the KRenameFile where the values can be retrieved | |||
* @param index index of the current file | * @param index index of the current file | |||
*/ | */ | |||
void initKRenameVars( const KRenameFile & file, int index ); | void initKRenameVars(const KRenameFile &file, int index); | |||
/** | /** | |||
* Insert a variable in the definitions textfield | * Insert a variable in the definitions textfield | |||
* at the current cursor position | * at the current cursor position | |||
* | * | |||
* @param name variable name | * @param name variable name | |||
*/ | */ | |||
void insertVariable( const char* name ); | void insertVariable(const char *name); | |||
private slots: | private Q_SLOTS: | |||
void slotEnableControls(); | void slotEnableControls(); | |||
void slotAdd(); | void slotAdd(); | |||
void slotRemove(); | void slotRemove(); | |||
void slotSave(); | void slotSave(); | |||
void slotLoad(); | void slotLoad(); | |||
void slotTest(); | void slotTest(); | |||
void slotInsertIndex(); | void slotInsertIndex(); | |||
void slotInsertUrl(); | void slotInsertUrl(); | |||
void slotInsertFilename(); | void slotInsertFilename(); | |||
void slotInsertExtension(); | void slotInsertExtension(); | |||
void slotInsertDirectory(); | void slotInsertDirectory(); | |||
private: | private: | |||
QString m_name; | QString m_name; | |||
QString m_icon; | QString m_icon; | |||
QStringList m_keys; | QStringList m_keys; | |||
QStringList m_help; | QStringList m_help; | |||
KJSInterpreter* m_interpreter; | KJSInterpreter *m_interpreter; | |||
QWidget* m_parent; | QWidget *m_parent; | |||
QMenu* m_menu; | QMenu *m_menu; | |||
Ui::ScriptPluginWidget* m_widget; | Ui::ScriptPluginWidget *m_widget; | |||
static const char* s_pszFileDialogLocation; ///< Static URL for KFileDialog | static const char *s_pszFileDialogLocation; ///< Static URL for KFileDialog | |||
static const char* s_pszVarNameIndex; | static const char *s_pszVarNameIndex; | |||
static const char* s_pszVarNameUrl; | static const char *s_pszVarNameUrl; | |||
static const char* s_pszVarNameFilename; | static const char *s_pszVarNameFilename; | |||
static const char* s_pszVarNameExtension; | static const char *s_pszVarNameExtension; | |||
static const char* s_pszVarNameDirectory; | static const char *s_pszVarNameDirectory; | |||
}; | }; | |||
inline const QString ScriptPlugin::name() const | inline const QString ScriptPlugin::name() const | |||
{ | { | |||
return m_name; | return m_name; | |||
} | } | |||
inline bool ScriptPlugin::alwaysEnabled() const | inline bool ScriptPlugin::alwaysEnabled() const | |||
{ | { | |||
return true; | return true; | |||
} | } | |||
inline int ScriptPlugin::type() const | inline int ScriptPlugin::type() const | |||
{ | { | |||
return ePluginType_Token; | return ePluginType_Token; | |||
} | } | |||
inline const QStringList & ScriptPlugin::supportedTokens() const | inline const QStringList &ScriptPlugin::supportedTokens() const | |||
{ | { | |||
return m_keys; | return m_keys; | |||
} | } | |||
inline const QStringList & ScriptPlugin::help() const | inline const QStringList &ScriptPlugin::help() const | |||
{ | { | |||
return m_help; | return m_help; | |||
} | } | |||
#endif // _FILE_PLUGIN_H_ | #endif // FILE_PLUGIN_H | |||
End of changes. 20 change blocks. | ||||
35 lines changed or deleted | 39 lines changed or added |