plugin.h (krename-4.0.9) | : | plugin.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 _PLUGIN_H_ | #ifndef PLUGIN_H | |||
#define _PLUGIN_H_ | #define PLUGIN_H | |||
#include <QPixmap> | #include <QPixmap> | |||
#include <QString> | #include <QString> | |||
#include <KConfigGroup> | ||||
#include <KSharedConfig> | ||||
class BatchRenamer; | class BatchRenamer; | |||
class KConfigGroup; | class KConfigGroup; | |||
class PluginLoader; | class PluginLoader; | |||
/** An enum to determine the correct plugin type. | /** An enum to determine the correct plugin type. | |||
* | * | |||
* A plugin may be of different types at a time. | * A plugin may be of different types at a time. | |||
*/ | */ | |||
enum EPluginType { | enum EPluginType { | |||
ePluginType_Token = 0x01, ///< A plugin that handles a token in brackets [ ] | ePluginType_Token = 0x01, ///< A plugin that handles a token in brackets [ ] | |||
ePluginType_Filename = 0x02, ///< A plugin that transforms the complete fin al filename | ePluginType_Filename = 0x02, ///< A plugin that transforms the complete fin al filename | |||
ePluginType_File = 0x04 ///< A plugin that changes the finally renamed file | ePluginType_File = 0x04 ///< A plugin that changes the finally renamed file | |||
}; | }; | |||
/** This is the abstract interface that has to be implemented | /** This is the abstract interface that has to be implemented | |||
* by all KRename plugins. | * by all KRename plugins. | |||
*/ | */ | |||
class Plugin { | class Plugin | |||
public: | { | |||
Plugin( PluginLoader* loader ); | public: | |||
explicit Plugin(PluginLoader *loader); | ||||
virtual ~Plugin(); | virtual ~Plugin(); | |||
/** | /** | |||
* Creates a help entry for the QStringList returned by help, | * Creates a help entry for the QStringList returned by help, | |||
* adds correct separator and brackets where necessary. | * adds correct separator and brackets where necessary. | |||
* | * | |||
* \param token the token ([ brackets ] will be added to surround it) | * \param token the token ([ brackets ] will be added to surround it) | |||
* \help help for the token | * \help help for the token | |||
* | * | |||
* \see help() | * \see help() | |||
*/ | */ | |||
static QString createHelpEntry( const QString & token, const QString & help ); | static QString createHelpEntry(const QString &token, const QString &help); | |||
/** | /** | |||
* @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. | |||
*/ | */ | |||
virtual const QString name() const = 0; | virtual const QString name() const = 0; | |||
/** | /** | |||
* Determines the type of the plugin. | * Determines the type of the plugin. | |||
* Different enum values may be or'ed together. | * Different enum values may be or'ed together. | |||
skipping to change at line 83 | skipping to change at line 87 | |||
*/ | */ | |||
virtual const QPixmap icon() const = 0; | virtual const QPixmap icon() const = 0; | |||
/** Set the enabled state of a plugin | /** Set the enabled state of a plugin | |||
* so that it can be used. | * so that it can be used. | |||
* | * | |||
* \param b the enabled state of the plugin. | * \param b the enabled state of the plugin. | |||
* | * | |||
* This has no effect if alwaysEnabled returns true | * This has no effect if alwaysEnabled returns true | |||
*/ | */ | |||
inline void setEnabled( bool b ); | inline void setEnabled(bool b); | |||
/** | /** | |||
* @returns true if this plugin is enabled. | * @returns true if this plugin is enabled. | |||
* Only use it if it is enabled. | * Only use it if it is enabled. | |||
*/ | */ | |||
inline bool isEnabled() const; | inline bool isEnabled() const; | |||
/** | /** | |||
* @returns true if this plugins is always enabled | * @returns true if this plugins is always enabled | |||
* | * | |||
skipping to change at line 126 | skipping to change at line 130 | |||
* 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 ) = 0; | virtual QString processFile(BatchRenamer *b, int index, const QString &filen ameOrToken, EPluginType eCurrentType) = 0; | |||
/** 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. The returned strings will be tr eated | * @returns a list of all supported tokens. The returned strings will be tr eated | |||
* as regular expressions to find a plugin which supports a token. | * as regular expressions to find a plugin which supports a token. | |||
*/ | */ | |||
virtual const QStringList & supportedTokens() const = 0; | virtual const QStringList &supportedTokens() const = 0; | |||
/** 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 | |||
*/ | */ | |||
virtual const QStringList & help() const = 0; | virtual const QStringList &help() const = 0; | |||
/** 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 | |||
*/ | */ | |||
virtual void createUI( QWidget* parent ) const = 0; | virtual void createUI(QWidget *parent) const = 0; | |||
/** 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; | |||
/* | /* | |||
virtual bool checkError() = 0; | virtual bool checkError() = 0; | |||
virtual void drawInterface( QWidget* w, QVBoxLayout* l ) = 0; | virtual void drawInterface( QWidget* w, QVBoxLayout* l ) = 0; | |||
virtual void fillStructure() { } | virtual void fillStructure() { } | |||
virtual QString processFile( BatchRenamer* b, int i, QString token, int mode ) = 0; | virtual QString processFile( BatchRenamer* b, int i, QString token, int mode ) = 0; | |||
virtual void finished() { } | virtual void finished() { } | |||
virtual void addHelp( HelpDialogData* data ); | virtual void addHelp( HelpDialogData* data ); | |||
virtual void removeHelp( HelpDialogData* data ); | virtual void removeHelp( HelpDialogData* data ); | |||
virtual void clearCache(); | virtual void clearCache(); | |||
virtual const QPixmap getIcon() const; | virtual const QPixmap getIcon() const; | |||
virtual const QStringList getKeys() const; | virtual const QStringList getKeys() const; | |||
*/ | */ | |||
protected: | protected: | |||
PluginLoader* m_pluginLoader; | PluginLoader *m_pluginLoader; | |||
private: | private: | |||
bool m_enabled; | bool m_enabled; | |||
}; | }; | |||
inline void Plugin::setEnabled( bool b ) | inline void Plugin::setEnabled(bool b) | |||
{ | { | |||
m_enabled = b; | m_enabled = b; | |||
} | } | |||
inline bool Plugin::isEnabled() const | inline bool Plugin::isEnabled() const | |||
{ | { | |||
return this->alwaysEnabled() || m_enabled; | return this->alwaysEnabled() || m_enabled; | |||
} | } | |||
#endif // _PLUGIN_H_ | #endif // PLUGIN_H | |||
End of changes. 15 change blocks. | ||||
17 lines changed or deleted | 21 lines changed or added |