KRename – powerful batch renamer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pluginloader.h 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /***************************************************************************
  2. pluginloader.h - description
  3. -------------------
  4. begin : Sun Dec 30 2001
  5. copyright : (C) 2001 by Dominik Seichter
  6. email : domseichter@web.de
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #ifndef PLUGINLOADER_H
  17. #define PLUGINLOADER_H
  18. // Own includes
  19. #include "batchrenamer.h"
  20. #include "plugin.h"
  21. #include <tqmap.h>
  22. #include <tqptrlist.h>
  23. class TQCheckBox;
  24. class TQVBoxLayout;
  25. class TQString;
  26. class TQWidget;
  27. #define NUM_INTERNAL_PLUGINS 8
  28. enum pluginType {
  29. TYPE_BRACKET = 2, // Plugin argument is in brackets like [artist] or [1-2]
  30. TYPE_TOKEN = 4, // Plugin has its own reserved token like ,& or /
  31. TYPE_FINAL_FILE = 8, // Plugin does something with the final file
  32. // i.e. that is not changing its name but its permission or similar!
  33. TYPE_FINAL_FILENAME = 16 // Plugin changes the final filename before renaming
  34. };
  35. class PluginLoader {
  36. public:
  37. // For RedHat :)
  38. struct PluginLibrary {
  39. Plugin *plugin;
  40. bool usePlugin;
  41. /* access this member only
  42. * from within KRenameImpl
  43. * when the GUI is already constructed!
  44. */
  45. TQCheckBox* check;
  46. };
  47. static PluginLoader* instance();
  48. void loadPlugins( bool fileplugins );
  49. TQPtrList<PluginLoader::PluginLibrary> libs;
  50. Plugin* findPlugin( const TQString & token );
  51. inline bool filePluginsLoaded() const;
  52. void clearCache();
  53. private:
  54. PluginLoader();
  55. ~PluginLoader();
  56. void addPlugin( Plugin* plugin );
  57. void loadFilePlugins();
  58. private:
  59. Plugin* m_internal_plugins[NUM_INTERNAL_PLUGINS];
  60. static PluginLoader* m_plugin;
  61. TQMap<TQString,Plugin*> m_bracket_map;
  62. TQMap<TQString,Plugin*> m_bracket_cache;
  63. bool m_loaded;
  64. bool m_file;
  65. };
  66. bool PluginLoader::filePluginsLoaded() const
  67. {
  68. return m_file;
  69. }
  70. #endif