File indexing completed on 2024-04-21 16:32:36

0001 /***************************************************************************
0002                          snumplugin.h  -  description
0003                              -------------------
0004     begin                : Tue Aug 05 2010
0005     copyright            : (C) 2010 by Matteo Azzali
0006     email                : matte.azzali@NOSPAMalice.it
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 SNUM_PLUGIN_H
0019 #define SNUM_PLUGIN_H
0020 
0021 #include "fileplugin.h"
0022 
0023 class SnumPlugin : public FilePlugin
0024 {
0025 public:
0026     explicit SnumPlugin(PluginLoader *loader);
0027 
0028     ~SnumPlugin();
0029 
0030     /**
0031      * @returns the type of the plugin.
0032      */
0033     inline virtual int type() const;
0034 
0035     /**
0036      * This function is the core of your plugin.
0037      *
0038      * It does the actual processing of a file, filename or token depending of the type
0039      * of your plugin.
0040      *
0041      * \see type()
0042      *
0043      * @param b the parent BatchRenamer instance calling this plugin
0044      * @param index the index of the current file (i.e. the first file has index 0,
0045      *              the second file to be renamed has index 1 ....)
0046      * @param filenameOrToken this parameter depends on the type of your plugin.
0047      *                        If type is ePluginType_File, this is the absolute path
0048      *                        or URL to the renamed file.
0049      *                        If type is ePluginType_Filename, this is the filename
0050      *                        (without path) as created by KRename.
0051      *                        If type is ePluginType_Token, this is the contents of a token
0052      *                        in brackets. If your plugin supports the token [example],
0053      *                        KRename will pass the strign "example" to your method.
0054      * @param eCurrentType the current type of plugin that is requested (for plugins that support more than one type)
0055      *
0056      * @returns the result of the function, depending on type().
0057      * @returns QString::null if this plugin has nothing to do.
0058      * @returns A new filename if type is ePluginType_Filename
0059      * @returns the value of the token if type is ePluginType_Token
0060      * @returns an error message or QString::null if type is ePluginType_File
0061      */
0062     virtual QString processFile(BatchRenamer *b, int index, const QString &filenameOrToken, EPluginType eCurrentType);
0063 
0064     /** Returns help descriptions for the supported tokens
0065      *
0066      *  The returned stringlist contains strings that are the tokens
0067      *  and the description separated by ;;
0068      *
0069      *  @returns a stringlist containing help on the supported tokens
0070      */
0071     inline const QStringList &help() const;
0072 
0073     /** Create a user interface for this plugin
0074      *
0075      *  @param parent the parent widget of this plugin
0076      */
0077 
0078 private:
0079     /** Return the number.
0080      *
0081      *  @param unicoded the string which is to be extracted
0082      *
0083      *  @returns the number part of the string, season, or episode or both
0084      */
0085     QString extractnum(const QString &unicoded, int a);
0086 
0087 private:
0088     QStringList m_help;
0089 
0090 };
0091 
0092 inline int SnumPlugin::type() const
0093 {
0094     return ePluginType_Token;
0095 }
0096 
0097 inline const QStringList &SnumPlugin::help() const
0098 {
0099     return m_help;
0100 }
0101 
0102 #endif // SNUM_PLUGIN_H