File indexing completed on 2024-12-01 13:50:28
0001 /*************************************************************************** 0002 translitplugin.h - description 0003 ------------------- 0004 begin : Sat Oct 13 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 TRANSLIT_PLUGIN_H 0019 #define TRANSLIT_PLUGIN_H 0020 0021 #include "fileplugin.h" 0022 0023 #include <QHash> 0024 0025 class TranslitPlugin : public FilePlugin 0026 { 0027 public: 0028 explicit TranslitPlugin(PluginLoader *loader); 0029 0030 ~TranslitPlugin(); 0031 0032 /** 0033 * @returns the type of the plugin. 0034 */ 0035 inline virtual int type() const; 0036 0037 /** 0038 * This function is the core of your plugin. 0039 * 0040 * It does the actual processing of a file, filename or token depending of the type 0041 * of your plugin. 0042 * 0043 * \see type() 0044 * 0045 * @param b the parent BatchRenamer instance calling this plugin 0046 * @param index the index of the current file (i.e. the first file has index 0, 0047 * the second file to be renamed has index 1 ....) 0048 * @param filenameOrToken this parameter depends on the type of your plugin. 0049 * If type is ePluginType_File, this is the absolute path 0050 * or URL to the renamed file. 0051 * If type is ePluginType_Filename, this is the filename 0052 * (without path) as created by KRename. 0053 * If type is ePluginType_Token, this is the contents of a token 0054 * in brackets. If your plugin supports the token [example], 0055 * KRename will pass the strign "example" to your method. 0056 * @param eCurrentType the current type of plugin that is requested (for plugins that support more than one type) 0057 * 0058 * @returns the result of the function, depending on type(). 0059 * @returns QString::null if this plugin has nothing to do. 0060 * @returns A new filename if type is ePluginType_Filename 0061 * @returns the value of the token if type is ePluginType_Token 0062 * @returns an error message or QString::null if type is ePluginType_File 0063 */ 0064 virtual QString processFile(BatchRenamer *b, int index, const QString &filenameOrToken, EPluginType eCurrentType); 0065 0066 /** Returns help descriptions for the supported tokens 0067 * 0068 * The returned stringlist contains strings that are the tokens 0069 * and the description separated by ;; 0070 * 0071 * @returns a stringlist containing help on the supported tokens 0072 */ 0073 inline const QStringList &help() const; 0074 0075 /** Create a user interface for this plugin 0076 * 0077 * @param parent the parent widget of this plugin 0078 */ 0079 //virtual void createUI( QWidget* parent ) const; 0080 0081 private: 0082 /** Transliterate a string and return the 0083 * transliterated version. 0084 * 0085 * @param unicoded the string which is to be transliterated 0086 * 0087 * @returns a transliterated copy of the string 0088 */ 0089 QString transliterate(const QString &unicoded); 0090 0091 private: 0092 QStringList m_help; 0093 0094 static const QString s_strUtf8[]; 0095 static const QString s_strEngl[]; 0096 0097 static QHash<QString, QString> s_mapFromUTF8; 0098 }; 0099 0100 inline int TranslitPlugin::type() const 0101 { 0102 //return ePluginType_Filename | ePluginType_Token; 0103 return ePluginType_Token; 0104 } 0105 0106 inline const QStringList &TranslitPlugin::help() const 0107 { 0108 return m_help; 0109 } 0110 0111 #endif // TRANSLIT_PLUGIN_H