diff options
Diffstat (limited to 'SessionLoader.cpp')
-rw-r--r-- | SessionLoader.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/SessionLoader.cpp b/SessionLoader.cpp index 21cca9b..1266e2f 100644 --- a/SessionLoader.cpp +++ b/SessionLoader.cpp @@ -5,11 +5,12 @@ #include "SessionLoader.h" #include "LanguagesManager.h" +#include "cpp11addition.h" #ifndef ULTRACOPIER_VERSION_PORTABLE SessionLoader::SessionLoader(OptionDialog *optionDialog) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); this->optionDialog=optionDialog; //load the options connect(OptionEngine::optionEngine,&OptionEngine::newOptionValue, this, &SessionLoader::newOptionValue,Qt::QueuedConnection); @@ -20,26 +21,25 @@ SessionLoader::SessionLoader(OptionDialog *optionDialog) #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE connect(PluginsManager::pluginsManager,&PluginsManager::onePluginWillBeRemoved, this,&SessionLoader::onePluginWillBeRemoved,Qt::DirectConnection); #endif - QList<PluginsAvailable> list=PluginsManager::pluginsManager->getPluginsByCategory(PluginType_SessionLoader); + std::vector<PluginsAvailable> list=PluginsManager::pluginsManager->getPluginsByCategory(PluginType_SessionLoader); foreach(PluginsAvailable currentPlugin,list) emit previouslyPluginAdded(currentPlugin); PluginsManager::pluginsManager->unlockPluginListEdition(); - shouldEnabled=OptionEngine::optionEngine->getOptionValue(QStringLiteral("SessionLoader"),QStringLiteral("LoadAtSessionStarting")).toBool(); + shouldEnabled=stringtobool(OptionEngine::optionEngine->getOptionValue("SessionLoader","LoadAtSessionStarting")); } SessionLoader::~SessionLoader() { #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE_DIRECT - int index=0; - const int &loop_size=pluginList.size(); - while(index<loop_size) + unsigned int index=0; + while(index<pluginList.size()) { if(pluginList.at(index).pluginLoader!=NULL) { if(!pluginList.at(index).pluginLoader->isLoaded() || pluginList.at(index).pluginLoader->unload()) { delete pluginList.at(index).options; - pluginList.removeAt(index); + pluginList.erase(pluginList.begin()+index); } } index++; @@ -52,10 +52,10 @@ void SessionLoader::onePluginAdded(const PluginsAvailable &plugin) #ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE_DIRECT if(plugin.category!=PluginType_SessionLoader) return; - int index=0; + unsigned int index=0; LocalPlugin newEntry; - QString pluginPath=plugin.path+PluginsManager::getResolvedPluginName(QStringLiteral("sessionLoader")); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("try load: ")+pluginPath); + std::string pluginPath=plugin.path+PluginsManager::getResolvedPluginName("sessionLoader"); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"try load: "+pluginPath); #ifdef ULTRACOPIER_PLUGIN_ALL_IN_ONE PluginInterface_SessionLoader *sessionLoader; @@ -72,23 +72,23 @@ void SessionLoader::onePluginAdded(const PluginsAvailable &plugin) } if(index==objectList.size()) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("static session loader not found")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"static session loader not found"); return; } newEntry.pluginLoader=NULL; #else - QPluginLoader *pluginLoader= new QPluginLoader(pluginPath); + QPluginLoader *pluginLoader= new QPluginLoader(QString::fromStdString(pluginPath)); newEntry.pluginLoader=pluginLoader; QObject *pluginInstance = pluginLoader->instance(); if(!pluginInstance) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("unable to load the plugin: ")+pluginLoader->errorString()); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to load the plugin: "+pluginLoader->errorString().toStdString()); return; } PluginInterface_SessionLoader *sessionLoader = qobject_cast<PluginInterface_SessionLoader *>(pluginInstance); if(!sessionLoader) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("unable to cast the plugin: ")+pluginLoader->errorString()); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to cast the plugin: "+pluginLoader->errorString().toStdString()); return; } //check if found @@ -97,7 +97,7 @@ void SessionLoader::onePluginAdded(const PluginsAvailable &plugin) { if(pluginList.at(index).sessionLoaderInterface==sessionLoader) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Plugin already found")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Plugin already found"); pluginLoader->unload(); return; } @@ -107,14 +107,14 @@ void SessionLoader::onePluginAdded(const PluginsAvailable &plugin) #ifdef ULTRACOPIER_DEBUG connect(sessionLoader,&PluginInterface_SessionLoader::debugInformation,this,&SessionLoader::debugInformation); #endif // ULTRACOPIER_DEBUG - newEntry.options=new LocalPluginOptions(QStringLiteral("SessionLoader-")+plugin.name); + newEntry.options=new LocalPluginOptions("SessionLoader-"+plugin.name); newEntry.sessionLoaderInterface=sessionLoader; newEntry.path=plugin.path; newEntry.sessionLoaderInterface->setResources(newEntry.options,plugin.writablePath,plugin.path,ULTRACOPIER_VERSION_PORTABLE_BOOL); newEntry.sessionLoaderInterface->setEnabled(shouldEnabled); optionDialog->addPluginOptionWidget(PluginType_SessionLoader,plugin.name,newEntry.sessionLoaderInterface->options()); connect(LanguagesManager::languagesManager,&LanguagesManager::newLanguageLoaded,newEntry.sessionLoaderInterface,&PluginInterface_SessionLoader::newLanguageLoaded); - pluginList << newEntry; + pluginList.push_back(newEntry); #else Q_UNUSED(plugin); return; @@ -126,8 +126,8 @@ void SessionLoader::onePluginWillBeRemoved(const PluginsAvailable &plugin) { if(plugin.category!=PluginType_SessionLoader) return; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start")); - int index=0; + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); + unsigned int index=0; while(index<pluginList.size()) { if(plugin.path==pluginList.at(index).path) @@ -137,7 +137,7 @@ void SessionLoader::onePluginWillBeRemoved(const PluginsAvailable &plugin) if(!pluginList.at(index).pluginLoader->isLoaded() || pluginList.at(index).pluginLoader->unload()) { delete pluginList.at(index).options; - pluginList.removeAt(index); + pluginList.erase(pluginList.begin()+index); } } break; @@ -147,13 +147,13 @@ void SessionLoader::onePluginWillBeRemoved(const PluginsAvailable &plugin) } #endif -void SessionLoader::newOptionValue(const QString &groupName,const QString &variableName,const QVariant &value) +void SessionLoader::newOptionValue(const std::string &groupName,const std::string &variableName,const std::string &value) { - if(groupName==QStringLiteral("SessionLoader") && variableName==QStringLiteral("LoadAtSessionStarting")) + if(groupName=="SessionLoader" && variableName=="LoadAtSessionStarting") { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start, value: %1").arg(value.toBool())); - shouldEnabled=value.toBool(); - int index=0; + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start, value: "+value); + shouldEnabled=stringtobool(value); + unsigned int index=0; while(index<pluginList.size()) { pluginList.at(index).sessionLoaderInterface->setEnabled(shouldEnabled); @@ -163,9 +163,9 @@ void SessionLoader::newOptionValue(const QString &groupName,const QString &varia } #ifdef ULTRACOPIER_DEBUG -void SessionLoader::debugInformation(const Ultracopier::DebugLevel &level,const QString& fonction,const QString& text,const QString& file,const int& ligne) +void SessionLoader::debugInformation(const Ultracopier::DebugLevel &level,const std::string& fonction,const std::string& text,const std::string& file,const int& ligne) { - DebugEngine::addDebugInformationStatic(level,fonction,text,file,ligne,QStringLiteral("Session loader plugin")); + DebugEngine::addDebugInformationStatic(level,fonction,text,file,ligne,"Session loader plugin"); } #endif // ULTRACOPIER_DEBUG #endif // !defined(ULTRACOPIER_PLUGIN_ALL_IN_ONE) || !defined(ULTRACOPIER_VERSION_PORTABLE) |