Skip to content

Commit

Permalink
Drop global class, change to static member
Browse files Browse the repository at this point in the history
  • Loading branch information
alphaonex86 committed Mar 17, 2013
1 parent 4280165 commit 6390630
Show file tree
Hide file tree
Showing 41 changed files with 328 additions and 514 deletions.
23 changes: 12 additions & 11 deletions CopyEngineManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@
#include <QMessageBox>

#include "CopyEngineManager.h"
#include "LanguagesManager.h"

CopyEngineManager::CopyEngineManager(OptionDialog *optionDialog)
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
connect(languages, &LanguagesManager::newLanguageLoaded, &facilityEngine,&FacilityEngine::retranslate,Qt::DirectConnection);
connect(&LanguagesManager::languagesManager, &LanguagesManager::newLanguageLoaded, &facilityEngine,&FacilityEngine::retranslate,Qt::DirectConnection);
this->optionDialog=optionDialog;
//setup the ui layout
plugins->lockPluginListEdition();
PluginsManager::pluginsManager.lockPluginListEdition();
connect(this,&CopyEngineManager::previouslyPluginAdded, this,&CopyEngineManager::onePluginAdded,Qt::QueuedConnection);
connect(plugins,&PluginsManager::onePluginAdded, this,&CopyEngineManager::onePluginAdded,Qt::QueuedConnection);
connect(&PluginsManager::pluginsManager,&PluginsManager::onePluginAdded, this,&CopyEngineManager::onePluginAdded,Qt::QueuedConnection);
#ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE
connect(plugins,&PluginsManager::onePluginWillBeRemoved, this,&CopyEngineManager::onePluginWillBeRemoved,Qt::DirectConnection);
connect(&PluginsManager::pluginsManager,&PluginsManager::onePluginWillBeRemoved, this,&CopyEngineManager::onePluginWillBeRemoved,Qt::DirectConnection);
#endif
connect(plugins,&PluginsManager::pluginListingIsfinish, this,&CopyEngineManager::allPluginIsloaded,Qt::QueuedConnection);
QList<PluginsAvailable> list=plugins->getPluginsByCategory(PluginType_CopyEngine);
connect(&PluginsManager::pluginsManager,&PluginsManager::pluginListingIsfinish, this,&CopyEngineManager::allPluginIsloaded,Qt::QueuedConnection);
QList<PluginsAvailable> list=PluginsManager::pluginsManager.getPluginsByCategory(PluginType_CopyEngine);
foreach(PluginsAvailable currentPlugin,list)
emit previouslyPluginAdded(currentPlugin);
plugins->unlockPluginListEdition();
PluginsManager::pluginsManager.unlockPluginListEdition();
//load the options
isConnected=false;
}
Expand Down Expand Up @@ -122,8 +123,8 @@ void CopyEngineManager::onePluginAdded(const PluginsAvailable &plugin)
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"plugin: "+newItem.name+" loaded, send options");
//emit newCopyEngineOptions(plugin.path,newItem.name,newItem.optionsWidget);
pluginList << newItem;
connect(languages,&LanguagesManager::newLanguageLoaded,newItem.factory,&PluginInterface_CopyEngineFactory::newLanguageLoaded);
if(plugins->allPluginHaveBeenLoaded())
connect(&LanguagesManager::languagesManager,&LanguagesManager::newLanguageLoaded,newItem.factory,&PluginInterface_CopyEngineFactory::newLanguageLoaded);
if(PluginsManager::pluginsManager.allPluginHaveBeenLoaded())
allPluginIsloaded();
if(isConnected)
emit addCopyEngine(newItem.name,newItem.canDoOnlyCopy);
Expand Down Expand Up @@ -308,7 +309,7 @@ void CopyEngineManager::allPluginIsloaded()
actualList << pluginList.at(index).name;
index++;
}
QStringList preferedList=options->getOptionValue("CopyEngine","List").toStringList();
QStringList preferedList=OptionEngine::optionEngine.getOptionValue("CopyEngine","List").toStringList();
preferedList.removeDuplicates();
actualList.removeDuplicates();
index=0;
Expand All @@ -328,7 +329,7 @@ void CopyEngineManager::allPluginIsloaded()
preferedList << actualList.at(index);
index++;
}
options->setOptionValue("CopyEngine","List",preferedList);
OptionEngine::optionEngine.setOptionValue("CopyEngine","List",preferedList);
QList<CopyEnginePlugin> newPluginList;
index=0;
while(index<preferedList.size())
Expand Down
3 changes: 1 addition & 2 deletions CopyEngineManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <QString>

#include "Environment.h"
#include "GlobalClass.h"
#include "LocalPluginOptions.h"
#include "OptionDialog.h"
#include "interface/PluginInterface_CopyEngine.h"
Expand All @@ -24,7 +23,7 @@ namespace Ui {
}

/** \brief Manage copy engine plugins and their instance */
class CopyEngineManager : public QObject, public GlobalClass
class CopyEngineManager : public QObject
{
Q_OBJECT
public:
Expand Down
23 changes: 12 additions & 11 deletions CopyListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
\licence GPL3, see the file COPYING */

#include "CopyListener.h"
#include "LanguagesManager.h"

#include <QRegularExpression>
#include <QMessageBox>
Expand All @@ -19,19 +20,19 @@ CopyListener::CopyListener(OptionDialog *optionDialog)
tryListen=false;
QList<QPair<QString, QVariant> > KeysList;
KeysList.append(qMakePair(QString("CatchCopyAsDefault"),QVariant(true)));
options->addOptionGroup("CopyListener",KeysList);
plugins->lockPluginListEdition();
QList<PluginsAvailable> list=plugins->getPluginsByCategory(PluginType_Listener);
OptionEngine::optionEngine.addOptionGroup("CopyListener",KeysList);
PluginsManager::pluginsManager.lockPluginListEdition();
QList<PluginsAvailable> list=PluginsManager::pluginsManager.getPluginsByCategory(PluginType_Listener);
connect(this,&CopyListener::previouslyPluginAdded, this,&CopyListener::onePluginAdded,Qt::QueuedConnection);
connect(plugins,&PluginsManager::onePluginAdded, this,&CopyListener::onePluginAdded,Qt::QueuedConnection);
connect(&PluginsManager::pluginsManager,&PluginsManager::onePluginAdded, this,&CopyListener::onePluginAdded,Qt::QueuedConnection);
#ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE
connect(plugins,&PluginsManager::onePluginWillBeRemoved, this,&CopyListener::onePluginWillBeRemoved,Qt::DirectConnection);
connect(&PluginsManager::pluginsManager,&PluginsManager::onePluginWillBeRemoved, this,&CopyListener::onePluginWillBeRemoved,Qt::DirectConnection);
#endif
connect(plugins,&PluginsManager::pluginListingIsfinish, this,&CopyListener::allPluginIsloaded,Qt::QueuedConnection);
connect(&PluginsManager::pluginsManager,&PluginsManager::pluginListingIsfinish, this,&CopyListener::allPluginIsloaded,Qt::QueuedConnection);
connect(pluginLoader,&PluginLoader::pluginLoaderReady, this,&CopyListener::pluginLoaderReady);
foreach(PluginsAvailable currentPlugin,list)
emit previouslyPluginAdded(currentPlugin);
plugins->unlockPluginListEdition();
PluginsManager::pluginsManager.unlockPluginListEdition();
last_state=Ultracopier::NotListening;
last_have_plugin=false;
last_inWaitOfReply=false;
Expand All @@ -41,7 +42,7 @@ CopyListener::~CopyListener()
{
stopIt=true;
#ifndef ULTRACOPIER_PLUGIN_ALL_IN_ONE
QList<PluginsAvailable> list=plugins->getPluginsByCategory(PluginType_Listener);
QList<PluginsAvailable> list=PluginsManager::pluginsManager.getPluginsByCategory(PluginType_Listener);
foreach(PluginsAvailable currentPlugin,list)
onePluginWillBeRemoved(currentPlugin);
#endif
Expand All @@ -50,7 +51,7 @@ CopyListener::~CopyListener()

void CopyListener::resendState()
{
if(plugins->allPluginHaveBeenLoaded())
if(PluginsManager::pluginsManager.allPluginHaveBeenLoaded())
{
sendState(true);
pluginLoader->resendState();
Expand Down Expand Up @@ -129,7 +130,7 @@ void CopyListener::onePluginAdded(const PluginsAvailable &plugin)
newPluginListener.options=new LocalPluginOptions("Listener-"+plugin.name);
newPluginListener.listenInterface->setResources(newPluginListener.options,plugin.writablePath,plugin.path,ULTRACOPIER_VERSION_PORTABLE_BOOL);
optionDialog->addPluginOptionWidget(PluginType_Listener,plugin.name,newPluginListener.listenInterface->options());
connect(languages,&LanguagesManager::newLanguageLoaded,newPluginListener.listenInterface,&PluginInterface_Listener::newLanguageLoaded);
connect(&LanguagesManager::languagesManager,&LanguagesManager::newLanguageLoaded,newPluginListener.listenInterface,&PluginInterface_Listener::newLanguageLoaded);
pluginList << newPluginListener;
connect(pluginList.last().listenInterface,&PluginInterface_Listener::newState,this,&CopyListener::newState);
if(tryListen)
Expand Down Expand Up @@ -392,7 +393,7 @@ void CopyListener::allPluginIsloaded()

void CopyListener::reloadClientList()
{
if(!plugins->allPluginHaveBeenLoaded())
if(!PluginsManager::pluginsManager.allPluginHaveBeenLoaded())
return;
QStringList clients;
int indexPlugin=0;
Expand Down
3 changes: 1 addition & 2 deletions CopyListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@

#include "interface/PluginInterface_Listener.h"
#include "Environment.h"
#include "GlobalClass.h"
#include "PluginLoader.h"
#include "OptionDialog.h"

/** \brief to load all the listener and parse all event */
class CopyListener : public QObject, public GlobalClass
class CopyListener : public QObject
{
Q_OBJECT
public:
Expand Down
15 changes: 8 additions & 7 deletions Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QtPlugin>

#include "Core.h"
#include "ThemesManager.h"

Core::Core(CopyEngineManager *copyEngineList)
{
Expand All @@ -18,8 +19,8 @@ Core::Core(CopyEngineManager *copyEngineList)
forUpateInformation.setInterval(ULTRACOPIER_TIME_INTERFACE_UPDATE);
loadInterface();
//connect(&copyEngineList, &CopyEngineManager::newCanDoOnlyCopy, this, &Core::newCanDoOnlyCopy);
connect(themes, &ThemesManager::theThemeNeedBeUnloaded, this, &Core::unloadInterface);
connect(themes, &ThemesManager::theThemeIsReloaded, this, &Core::loadInterface, Qt::QueuedConnection);
connect(&ThemesManager::themesManager, &ThemesManager::theThemeNeedBeUnloaded, this, &Core::unloadInterface);
connect(&ThemesManager::themesManager, &ThemesManager::theThemeIsReloaded, this, &Core::loadInterface, Qt::QueuedConnection);
connect(&forUpateInformation, &QTimer::timeout, this, &Core::periodicSynchronization);
}

Expand Down Expand Up @@ -54,7 +55,7 @@ void Core::newCopy(const quint32 &orderId,const QStringList &protocolsUsedForThe
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start: "+sources.join(";")+", dest: "+destination);
//search to group the window
int GroupWindowWhen=options->getOptionValue("Ultracopier","GroupWindowWhen").toInt();
int GroupWindowWhen=OptionEngine::optionEngine.getOptionValue("Ultracopier","GroupWindowWhen").toInt();
bool haveSameSource=false,haveSameDestination=false;
if(GroupWindowWhen!=0)
{
Expand Down Expand Up @@ -120,7 +121,7 @@ void Core::newMove(const quint32 &orderId,const QStringList &protocolsUsedForThe
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start: "+sources.join(";")+", dest: "+destination);
//search to group the window
int GroupWindowWhen=options->getOptionValue("Ultracopier","GroupWindowWhen").toInt();
int GroupWindowWhen=OptionEngine::optionEngine.getOptionValue("Ultracopier","GroupWindowWhen").toInt();
bool haveSameSource=false,haveSameDestination=false;
if(GroupWindowWhen!=0)
{
Expand Down Expand Up @@ -179,7 +180,7 @@ void Core::addWindowCopyMove(const Ultracopier::CopyMode &mode,const QString &na
QMessageBox::critical(NULL,tr("Error"),tr("Unable to get a copy engine instance"));
return;
}
ActionOnManualOpen ActionOnManualOpen_value=(ActionOnManualOpen)options->getOptionValue("Ultracopier","ActionOnManualOpen").toInt();
ActionOnManualOpen ActionOnManualOpen_value=(ActionOnManualOpen)OptionEngine::optionEngine.getOptionValue("Ultracopier","ActionOnManualOpen").toInt();
if(ActionOnManualOpen_value!=ActionOnManualOpen_Nothing)
{
if(ActionOnManualOpen_value==ActionOnManualOpen_Folder)
Expand Down Expand Up @@ -252,7 +253,7 @@ void Core::loadInterface()
loop_size=copyList.size();
while(index<loop_size)
{
copyList[index].interface=themes->getThemesInstance();
copyList[index].interface=ThemesManager::themesManager.getThemesInstance();
if(copyList[index].interface==NULL)
{
copyInstanceCanceledByIndex(index);
Expand Down Expand Up @@ -347,7 +348,7 @@ int Core::connectCopyEngine(const Ultracopier::CopyMode &mode,bool ignoreMode,co
newItem.engine=returnInformations.engine;
if(newItem.engine!=NULL)
{
PluginInterface_Themes *theme=themes->getThemesInstance();
PluginInterface_Themes *theme=ThemesManager::themesManager.getThemesInstance();
if(theme!=NULL)
{
newItem.id=incrementId();
Expand Down
3 changes: 1 addition & 2 deletions Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
#include "Environment.h"
#include "StructEnumDefinition.h"
#include "CopyEngineManager.h"
#include "GlobalClass.h"
#include "LogThread.h"
#include "interface/PluginInterface_CopyEngine.h"
#include "interface/PluginInterface_Themes.h"

/** \brief Define the class definition for core, the Copy of each copy/move window
This class provide a core for dispatch the event of signal/slot, it checks too if not other instance is running */
class Core : public QObject, public GlobalClass
class Core : public QObject
{
Q_OBJECT
public:
Expand Down
12 changes: 4 additions & 8 deletions DebugEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ DebugEngine::DebugEngine()
if(removeTheLockFile())
{
//Ask to the user
QMessageBox::StandardButton reply = QMessageBox::question(NULL,"Save the previous report","Ultracopier seam have crashed, do you want save the previous report for report it to the forum?",QMessageBox::Yes|QMessageBox::No,QMessageBox::No);
/*QMessageBox::StandardButton reply = QMessageBox::question(NULL,"Save the previous report","Ultracopier seam have crashed, do you want save the previous report for report it to the forum?",QMessageBox::Yes|QMessageBox::No,QMessageBox::No);
if(reply==QMessageBox::Yes)
saveBugReport();
saveBugReport();*/
}
else
puts(qPrintable(logFile.fileName()+" unable to open it as read"));
Expand Down Expand Up @@ -217,7 +217,6 @@ bool DebugEngine::removeTheLockFile()

void DebugEngine::addDebugInformationStatic(const Ultracopier::DebugLevel &level,const QString& function,const QString& text,const QString& file,const int& ligne,const QString& location)
{
DebugEngine *debug_engine_instance=DebugEngine::getInstance();
DebugLevel_custom tempLevel=DebugLevel_custom_Information;
switch(level)
{
Expand All @@ -236,15 +235,12 @@ void DebugEngine::addDebugInformationStatic(const Ultracopier::DebugLevel &level
default:
tempLevel=DebugLevel_custom_Notice;
}
debug_engine_instance->addDebugInformation(tempLevel,function,text,file,ligne,location);
DebugEngine::destroyInstanceAtTheLastCall();
DebugEngine::debugEngine.addDebugInformation(tempLevel,function,text,file,ligne,location);
}

void DebugEngine::addDebugNote(const QString& text)
{
DebugEngine *debug_engine_instance=DebugEngine::getInstance();
debug_engine_instance->addDebugInformation(DebugLevel_custom_UserNote,"",text,"",-1,"Core");
DebugEngine::destroyInstanceAtTheLastCall();
DebugEngine::debugEngine.addDebugInformation(DebugLevel_custom_UserNote,"",text,"",-1,"Core");
}

/// \brief For add message info, this function is thread safe
Expand Down
5 changes: 2 additions & 3 deletions DebugEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "PlatformMacro.h"
#include "StructEnumDefinition.h"
#include "StructEnumDefinition_UltracopierSpecific.h"
#include "Singleton.h"

#ifdef ULTRACOPIER_DEBUG

Expand Down Expand Up @@ -64,10 +63,9 @@ private slots:
/** \brief Define the class for the debug
This class provide all needed for the debug mode of ultracopier */
class DebugEngine : public QObject, public Singleton<DebugEngine>
class DebugEngine : public QObject
{
Q_OBJECT
friend class Singleton<DebugEngine>;
public:
/** \brief Get the html text info for re-show it
\note This function is thread safe */
Expand All @@ -86,6 +84,7 @@ class DebugEngine : public QObject, public Singleton<DebugEngine>
\note This function is reentrant */
static void addDebugInformationStatic(const Ultracopier::DebugLevel &level,const QString& function,const QString& text,const QString& file="",const int& ligne=-1,const QString& location="Core");
static void addDebugNote(const QString& text);
static DebugEngine debugEngine;
public slots:
/** \brief ask to the user where save the bug report
\warning This function can be only call by the graphical thread */
Expand Down
2 changes: 0 additions & 2 deletions DebugModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

// Model

DebugModel DebugModel::debugModel;

DebugModel::DebugModel()
{
displayed = false;
Expand Down
Loading

0 comments on commit 6390630

Please sign in to comment.