"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/pluginloader.cpp" between
krename-4.0.9.tar.gz and krename-4.90.90.tar.gz

About: KRename is a batch file-renamer (KDE).

pluginloader.cpp  (krename-4.0.9):pluginloader.cpp  (krename-4.90.90)
skipping to change at line 25 skipping to change at line 25
* * * *
***************************************************************************/ ***************************************************************************/
#include "pluginloader.h" #include "pluginloader.h"
#include "krenameimpl.h" #include "krenameimpl.h"
#include "plugin.h" #include "plugin.h"
#include "datetimeplugin.h" #include "datetimeplugin.h"
#include "dirsortplugin.h" #include "dirsortplugin.h"
#ifdef WITH_EXIV2
#include "exiv2plugin.h"
#endif // WITH_EXIV2
#include "fileplugin.h" #include "fileplugin.h"
#include "increasecounterplugin.h" #include "increasecounterplugin.h"
#include "permissionsplugin.h" #include "permissionsplugin.h"
#include "scriptplugin.h" #include "scriptplugin.h"
#include "systemplugin.h" #include "systemplugin.h"
#ifdef WITH_TAGLIB
# include "taglibplugin.h"
#endif // WITH_TAGLIB
#ifdef WITH_PODOFO
# include "podofoplugin.h"
#endif // WITH_TAGLIB
#ifdef WITH_FREETYPE
# include "fontplugin.h"
#endif // WITH_FREETYPE
#include "translitplugin.h" #include "translitplugin.h"
#include "snumplugin.h" #include "snumplugin.h"
#include "../config-krename.h"
#include <kservice.h> #include <kservice.h>
PluginLoader* PluginLoader::s_instance = NULL; #include <../config-krename.h>;
PluginLoader* PluginLoader::Instance() #if HAVE_TAGLIB
# include "taglibplugin.h"
#endif // HAVE_TAGLIB
#if HAVE_EXIV2
#include "exiv2plugin.h"
#endif // HAVE_EXIV2
#if HAVE_PODOFO
# include "podofoplugin.h"
#endif // HAVE_PODOFO
#if HAVE_FREETYPE
# include "fontplugin.h"
#endif // HAVE_FREETYPE
PluginLoader *PluginLoader::s_instance = nullptr;
PluginLoader *PluginLoader::Instance()
{ {
if( !s_instance ) if (!s_instance) {
s_instance = new PluginLoader(); s_instance = new PluginLoader();
}
return s_instance; return s_instance;
} }
PluginLoader::PluginLoader() PluginLoader::PluginLoader()
{ {
this->load(); this->load();
} }
PluginLoader::~PluginLoader() PluginLoader::~PluginLoader()
{ {
this->clear(); this->clear();
} }
Plugin* PluginLoader::findPlugin( const QString & token ) Plugin *PluginLoader::findPlugin(const QString &token)
{ {
QString lower = token.toLower(); QString lower = token.toLower();
// first search in the cache // first search in the cache
Plugin* p = m_tokenCache[lower]; Plugin *p = m_tokenCache[lower];
if( p ) if (p) {
return p; return p;
}
// now search in all tokens // now search in all tokens
QMap<QString,Plugin*>::const_iterator it = m_tokenMap.begin(); QMap<QString, Plugin *>::const_iterator it = m_tokenMap.constBegin();
while( it != m_tokenMap.end() ) while (it != m_tokenMap.constEnd()) {
{ if (QRegExp(it.key()).exactMatch(lower)) {
if( QRegExp( it.key() ).exactMatch( lower ) )
{
// we found a plugin // we found a plugin
// put the token into the cache for quick access // put the token into the cache for quick access
p = it.value(); p = it.value();
m_tokenCache[lower] = p; m_tokenCache[lower] = p;
return p; return p;
} }
++it; ++it;
} }
// add typos to the cache, too: // add typos to the cache, too:
// So that we find immediately that this key is not supported. // So that we find immediately that this key is not supported.
m_tokenCache.insert( lower, NULL ); m_tokenCache.insert(lower, nullptr);
return NULL; return nullptr;
} }
Plugin* PluginLoader::findPluginByName( const QString & name ) Plugin *PluginLoader::findPluginByName(const QString &name)
{ {
QList<Plugin*>::iterator it = m_plugins.begin(); QList<Plugin *>::iterator it = m_plugins.begin();
while( it != m_plugins.end() ) while (it != m_plugins.end()) {
{ if ((*it)->name() == name) {
if( (*it)->name() == name )
return *it; return *it;
}
++it; ++it;
} }
return NULL; return nullptr;
} }
void PluginLoader::clear() void PluginLoader::clear()
{ {
QList<Plugin*>::iterator it = m_plugins.begin(); QList<Plugin *>::iterator it = m_plugins.begin();
while( it != m_plugins.end() ) while (it != m_plugins.end()) {
{
delete *it; delete *it;
++it; ++it;
} }
m_plugins.clear(); m_plugins.clear();
m_tokenMap.clear(); m_tokenMap.clear();
m_tokenCache.clear(); m_tokenCache.clear();
} }
void PluginLoader::load() void PluginLoader::load()
{ {
#ifndef _WIN32 #ifndef Q_OS_WIN
m_plugins.append( new DateTimePlugin( this ) ); m_plugins.append(new DateTimePlugin(this));
#endif // _WIN32 #endif
m_plugins.append( new DirSortPlugin( this ) ); m_plugins.append(new DirSortPlugin(this));
#ifdef WITH_EXIV2 #if HAVE_EXIV2
m_plugins.append( new Exiv2Plugin( this ) ); m_plugins.append(new Exiv2Plugin(this));
#endif // WITH_EXIV2 #endif // HAVE_EXIV2
#ifdef WITH_FREETYPE #if HAVE_FREETYPE
m_plugins.append( new FontPlugin( this ) ); m_plugins.append(new FontPlugin(this));
#endif // WITH_FREETYPE #endif // HAVE_FREETYPE
m_plugins.append( new IncreaseCounterPlugin( this ) ); m_plugins.append(new IncreaseCounterPlugin(this));
#ifndef _WIN32 #ifndef Q_OS_WIN
m_plugins.append( new PermissionsPlugin( this ) ); m_plugins.append(new PermissionsPlugin(this));
#endif // _WIN32 #endif
m_plugins.append( new ScriptPlugin( this ) ); m_plugins.append(new ScriptPlugin(this));
m_plugins.append( new SystemPlugin( this ) ); m_plugins.append(new SystemPlugin(this));
#ifdef WITH_TAGLIB #if HAVE_TAGLIB
m_plugins.append( new TagLibPlugin( this ) ); m_plugins.append(new TagLibPlugin(this));
#endif // WITH_TAGLIB #endif // HAVE_TAGLIB
#ifdef WITH_PODOFO #if HAVE_PODOFO
m_plugins.append( new PodofoPlugin( this ) ); m_plugins.append(new PodofoPlugin(this));
#endif // WITH_TAGLIB #endif // HAVE_PODOFO
m_plugins.append( new TranslitPlugin( this ) ); m_plugins.append(new TranslitPlugin(this));
m_plugins.append( new SnumPlugin( this ) ); m_plugins.append(new SnumPlugin(this));
//this->loadFilePlugins(); //this->loadFilePlugins();
// Fill the token map // Fill the token map
QList<Plugin*>::iterator it = m_plugins.begin(); QList<Plugin *>::iterator it = m_plugins.begin();
while( it != m_plugins.end() ) while (it != m_plugins.end()) {
{ if (((*it)->type() & ePluginType_Token)) {
if( ((*it)->type() & ePluginType_Token) ) const QStringList &tokens = (*it)->supportedTokens();
{
const QStringList & tokens = (*it)->supportedTokens();
QStringList::const_iterator itList = tokens.begin(); QStringList::const_iterator itList = tokens.begin();
while( itList != tokens.end() ) while (itList != tokens.end()) {
{ m_tokenMap.insert((*itList).toLower(), *it);
m_tokenMap.insert( (*itList).toLower(), *it );
++itList; ++itList;
} }
} }
++it; ++it;
} }
} }
void PluginLoader::registerForUpdates( KRenameImpl* krename ) void PluginLoader::registerForUpdates(KRenameImpl *krename)
{ {
m_observers.prepend( krename ); m_observers.prepend(krename);
} }
void PluginLoader::deregisterForUpdates( KRenameImpl* krename ) void PluginLoader::deregisterForUpdates(KRenameImpl *krename)
{ {
m_observers.removeOne( krename ); m_observers.removeOne(krename);
} }
void PluginLoader::sendUpdatePreview() void PluginLoader::sendUpdatePreview()
{ {
QList<KRenameImpl*>::iterator it = m_observers.begin(); QList<KRenameImpl *>::iterator it = m_observers.begin();
while( it != m_observers.end() ) while (it != m_observers.end()) {
{ (*it)->slotUpdatePreview();
(*it)->slotUpdatePreview();
++it; ++it;
} }
} }
void PluginLoader::loadConfig( KConfigGroup & group ) void PluginLoader::loadConfig(KConfigGroup &group)
{ {
QList<Plugin*>::const_iterator it = m_plugins.begin(); QList<Plugin *>::const_iterator it = m_plugins.constBegin();
while( it != m_plugins.end() ) while (it != m_plugins.constEnd()) {
{ (*it)->loadConfig(group);
(*it)->loadConfig( group );
++it; ++it;
} }
} }
void PluginLoader::saveConfig( KConfigGroup & group ) void PluginLoader::saveConfig(KConfigGroup &group)
{ {
QList<Plugin*>::const_iterator it = m_plugins.begin(); QList<Plugin *>::const_iterator it = m_plugins.constBegin();
while( it != m_plugins.end() ) while (it != m_plugins.constEnd()) {
{ (*it)->saveConfig(group);
(*it)->saveConfig( group );
++it; ++it;
} }
} }
 End of changes. 33 change blocks. 
89 lines changed or deleted 83 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)