File indexing completed on 2025-04-20 05:17:33
0001 // SPDX-License-Identifier: GPL-2.0-or-later 0002 // SPDX-FileCopyrightText: 2008 Dominik Seichter <domseichter@web.de> 0003 0004 #ifndef INCREASE_COUNTER_PLUGIN_H 0005 #define INCREASE_COUNTER_PLUGIN_H 0006 0007 #include <plugin.h> 0008 0009 namespace Ui 0010 { 0011 class IncreaseCounterPluginWidget; 0012 }; 0013 0014 /** This is the abstract interface that has to be implemented 0015 * by all KRename plugins. 0016 */ 0017 class IncreaseCounterPlugin : public QObject, public Plugin 0018 { 0019 0020 Q_OBJECT 0021 0022 public: 0023 explicit IncreaseCounterPlugin(PluginLoader *loader); 0024 ~IncreaseCounterPlugin() override; 0025 0026 /** 0027 * @returns a name of the plugin that can be displayed 0028 * to the user. This name should be internationalized. 0029 */ 0030 const QString name() const override; 0031 0032 /** 0033 * Determines the type of the plugin. 0034 * Different enum values may be or'ed together. 0035 * 0036 * @returns the type of the plugin. 0037 */ 0038 inline int type() const override; 0039 0040 /** 0041 * @returns an icon for this plugin. 0042 */ 0043 const QIcon icon() const override; 0044 0045 /** 0046 * @returns true if this plugins is always enabled 0047 * 0048 * Warning: If you return true here, the user has no possibility to 0049 * disable this plugin. 0050 */ 0051 inline bool enabledByDefault() const override; 0052 0053 /** 0054 * This function is the core of your plugin. 0055 * 0056 * It does the actual processing of a file, filename or token depending of the type 0057 * of your plugin. 0058 * 0059 * \see type() 0060 * 0061 * @param b the parent BatchRenamer instance calling this plugin 0062 * @param index the index of the current file (i.e. the first file has index 0, 0063 * the second file to be renamed has index 1 ....) 0064 * @param filenameOrToken this parameter depends on the type of your plugin. 0065 * If type is ePluginType_File, this is the absolute path 0066 * or URL to the renamed file. 0067 * If type is ePluginType_Filename, this is the filename 0068 * (without path) as created by KRename. 0069 * If type is ePluginType_Token, this is the contents of a token 0070 * in brackets. If your plugin supports the token [example], 0071 * KRename will pass the strign "example" to your method. 0072 * @param eCurrentType the current type of plugin that is requested (for plugins that support more than one type) 0073 * 0074 * @returns the result of the function, depending on type(). 0075 * @returns an empty QString if this plugin has nothing to do. 0076 * @returns A new filename if type is ePluginType_Filename 0077 * @returns the value of the token if type is ePluginType_Token 0078 * @returns an error message or an empty QString if type is ePluginType_File 0079 */ 0080 QString processFile(BatchRenamer *b, int index, const QString &filenameOrToken, EPluginType eCurrentType) override; 0081 0082 /** Get a list of all tokens supported by this plugin. 0083 * 0084 * If the token type != ePluginType_Token you have to return an empty list 0085 * 0086 * @returns a list of all supported tokens. The returned strings will be treated 0087 * as regular expressions to find a plugin which supports a token. 0088 */ 0089 inline const QStringList &supportedTokens() const override; 0090 0091 /** Returns help descriptions for the supported tokens 0092 * 0093 * The returned stringlist contains strings that are the tokens 0094 * and the description separated by ;; 0095 * 0096 * @returns a stringlist containing help on the supported tokens 0097 */ 0098 inline const QStringList &help() const override; 0099 0100 /** Create a user interface for this plugin 0101 * 0102 * @param parent the parent widget of this plugin 0103 */ 0104 void createUI(QWidget *parent) const override; 0105 0106 private Q_SLOTS: 0107 /** 0108 * Called when the user changes the offset through the UI 0109 * 0110 * @param offset the new offset 0111 */ 0112 void slotOffsetChanged(int offset); 0113 0114 private: 0115 Ui::IncreaseCounterPluginWidget *m_widget; 0116 0117 int m_offset; ///< Increase counter by this offset 0118 0119 QStringList m_tmp; ///< Dummy empty list so that we can return a reference for supported tokens and help 0120 QStringList m_users; ///< List of all usernames on the system 0121 QStringList m_groups; ///< List of all groups on the system 0122 }; 0123 0124 inline int IncreaseCounterPlugin::type() const 0125 { 0126 return ePluginType_Filename; 0127 } 0128 0129 inline bool IncreaseCounterPlugin::enabledByDefault() const 0130 { 0131 return false; 0132 } 0133 0134 inline const QStringList &IncreaseCounterPlugin::supportedTokens() const 0135 { 0136 return m_tmp; 0137 } 0138 0139 inline const QStringList &IncreaseCounterPlugin::help() const 0140 { 0141 return m_tmp; 0142 } 0143 0144 #endif // INCREASE_COUNTER_PLUGIN_H 0145