- void Backbone::selectedDictionaries(QList<CommonDictInterface* > activeDicts) {
- foreach(CommonDictInterface* dict, _dicts.keys())
- if(activeDicts.contains(dict))
- _dicts[dict] = 1;
- else
- _dicts[dict] = 0;
+void Backbone::selectedDictionaries(QList<CommonDictInterface* > activeDicts) {
+ foreach(CommonDictInterface* dict, _dicts.keys())
+ if(activeDicts.contains(dict))
+ _dicts[dict] = 1;
+ else
+ _dicts[dict] = 0;
+ dictUpdated();
}
+void Backbone::addDictionary(CommonDictInterface *dict, bool active) {
+ addInternalDictionary(dict,active);
+ dictUpdated();
+}
+
+
- void Backbone::addDictionary(CommonDictInterface* dict, bool active) {
+ void Backbone::addInternalDictionary(CommonDictInterface* dict, bool active) {
dict->setHash(_dicts.size()+1);
_dicts[dict] = active;
connect(dict, SIGNAL(settingsChanged()), this, SLOT(dictUpdated()));
QDir confDir(_configPath);
if(!confDir.exists())
qDebug() << "Configuration file dosn't exists (" << _configPath << ")";
+ return;
QSettings set(_configPath + "/mdictionary.config", QSettings::IniFormat);
_pluginPath = set.value("general/plugin_path", _pluginPath).toString();
_historyLen = set.value("general/history_length", 10).toInt();
QDir confDir(_configPath);
if(!confDir.exists())
qDebug() << confDir.mkpath(_configPath);
+
QSettings set(_configPath + "/mdictionary.config", QSettings::IniFormat);
- _pluginPath = set.value("general/path", _pluginPath).toString();
QStringList dicts = set.childGroups();
foreach(QString dict, dicts) {
if(!dict.contains("dictionary_"))
QStringList items = set.childKeys();
foreach(QString item, items)
plugSet->setValue(item, set.value(item, "").toString());
- addDictionary(plug->getNew(plugSet), set.value("active",1).toBool());
+ bool active = set.value("active",1).toBool();
set.endGroup();
+ addInternalDictionary(plug->getNew(plugSet), active);
}
}
void Backbone::dictUpdated() {
- qDebug() << "UPDATE";
QDir confDir(_configPath);
if(!confDir.exists())
qDebug() << confDir.mkpath(_configPath);
void Backbone::saveState(QSettings* set, Settings* plugSet, bool active
, uint hash) {
+ if(!set || !plugSet)
+ return;
QString section;
- section.append("dictionary_%1").arg(hash);
+ section.append(QString("dictionary_%1").arg(hash));
QList<QString> keys = plugSet->keys();
foreach(QString key, keys)
set->setValue(section + "/" + key, plugSet->value(key));
set->setValue(section + "/active", active);
-
}
//saving dictionaries state
/*! adds new dictionary and activate it
\param dict dictionary to be added
+ \param active decides whether searches are perfomed in given dictionaries
*/
void addDictionary(CommonDictInterface* dict, bool active = 1);
void loadDicts();
void saveState(QSettings*, Settings*, bool, uint);
CommonDictInterface* plugin(QString type); //< search for given type plugin
+ void addInternalDictionary(CommonDictInterface*, bool);
//void writeConfig(QString key, QString value);
};