summaryrefslogtreecommitdiff
path: root/LocalPluginOptions.cpp
blob: b81e880d53140480325c60b594dcf615cee81858 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/** \file LocalPluginOptions.cpp
\brief To bind the options of the plugin, into unique group options
\author alpha_one_x86
\version 0.3
\date 2010
\licence GPL3, see the file COPYING */

#include "LocalPluginOptions.h"

LocalPluginOptions::LocalPluginOptions(const QString &group)
{
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start(\""+group+"\",[...])");
	groupOptionAdded=false;
	this->group=group;
	options=OptionEngine::getInstance();
	connect(options,SIGNAL(resetOptions()),this,SIGNAL(resetOptions()));
}

LocalPluginOptions::~LocalPluginOptions()
{
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start(\""+group+"\",[...])");
	if(groupOptionAdded)
		options->removeOptionGroup(group);
	else
		ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"option not used");
	OptionEngine::destroyInstanceAtTheLastCall();
}

/// \brief To add option group to options
bool LocalPluginOptions::addOptionGroup(const QList<QPair<QString, QVariant> > &KeysList)
{
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start(\""+group+"\",[...])");
	if(groupOptionAdded)
	{
		ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"Group already added!");
		return false;
	}
	else
	{
		groupOptionAdded=true;
		return options->addOptionGroup(group,KeysList);
	}
}

/// \brief To get option value
QVariant LocalPluginOptions::getOptionValue(const QString &variableName)
{
	return options->getOptionValue(group,variableName);
}

/// \brief To set option value
void LocalPluginOptions::setOptionValue(const QString &variableName,const QVariant &value)
{
	options->setOptionValue(group,variableName,value);
}

/*-> disabled because the value will not externaly changed, then useless notification
void LocalPluginOptions::newOptionValue(QString group,QString variable,QVariant value)
{
	if(group==this->group)
		emit newOptionValue(variable,value);
}*/