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