File indexing completed on 2022-11-29 20:25:18

0001 /***************************************************************************
0002                        systemplugin.h  -  description
0003                              -------------------
0004     begin                : Thu Oct 11 2007
0005     copyright            : (C) 2007 by Dominik Seichter
0006     email                : domseichter@web.de
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either version 2 of the License, or     *
0014  *   (at your option) any later version.                                   *
0015  *                                                                         *
0016  ***************************************************************************/
0017 
0018 #ifndef SYSTEM_PLUGIN_H
0019 #define SYSTEM_PLUGIN_H
0020 
0021 #include "fileplugin.h"
0022 
0023 class SystemPlugin : public FilePlugin
0024 {
0025 public:
0026     /** Create a new SystemPlugin
0027      */
0028     explicit SystemPlugin(PluginLoader *loader);
0029 
0030     virtual ~SystemPlugin();
0031 
0032     /**
0033      * @returns a name of the plugin that can be displayed
0034      *          to the user. This name should be internationalized.
0035      */
0036     inline virtual const QString name() const;
0037 
0038     /**
0039      * @returns the type of the plugin.
0040      */
0041     inline int type() const;
0042 
0043     /**
0044      * This function is the core of your plugin.
0045      *
0046      * It does the actual processing of a file, filename or token depending of the type
0047      * of your plugin.
0048      *
0049      * \see type()
0050      *
0051      * @param b the parent BatchRenamer instance calling this plugin
0052      * @param index the index of the current file (i.e. the first file has index 0,
0053      *              the second file to be renamed has index 1 ....)
0054      * @param filenameOrToken this parameter depends on the type of your plugin.
0055      *                        If type is ePluginType_File, this is the absolute path
0056      *                        or URL to the renamed file.
0057      *                        If type is ePluginType_Filename, this is the filename
0058      *                        (without path) as created by KRename.
0059      *                        If type is ePluginType_Token, this is the contents of a token
0060      *                        in brackets. If your plugin supports the token [example],
0061      *                        KRename will pass the strign "example" to your method.
0062      * @param eCurrentType the current type of plugin that is requested (for plugins that support more than one type)
0063      *
0064      * @returns the result of the function, depending on type().
0065      * @returns QString::null if this plugin has nothing to do.
0066      * @returns A new filename if type is ePluginType_Filename
0067      * @returns the value of the token if type is ePluginType_Token
0068      * @returns an error message or QString::null if type is ePluginType_File
0069      */
0070     virtual QString processFile(BatchRenamer *b, int index, const QString &filenameOrToken, EPluginType eCurrentType);
0071 
0072     /** Returns help descriptions for the supported tokens
0073      *
0074      *  The returned stringlist contains strings that are the tokens
0075      *  and the description separated by ;;
0076      *
0077      *  @returns a stringlist containing help on the supported tokens
0078      */
0079     inline virtual const QStringList &help() const;
0080 
0081 private:
0082     const QString time(time_t time, const QString &format);
0083 
0084 private:
0085     QStringList m_help;
0086 
0087 };
0088 
0089 inline const QString SystemPlugin::name() const
0090 {
0091     return m_name;
0092 }
0093 
0094 inline int SystemPlugin::type() const
0095 {
0096     return ePluginType_Token;
0097 }
0098 
0099 inline const QStringList &SystemPlugin::help() const
0100 {
0101     return m_help;
0102 }
0103 
0104 #endif // SYSTEM_PLUGIN_H