void Backbone::init() {
_searchLimit = 10;
_interval = 250; //msec
+ _pluginPath = "/usr/lib/mdictionary/";
loadPlugins();
+
if(!connect(&_timer, SIGNAL(timeout()), this, SLOT(translation())))
qDebug() << "Timer signal not connected";
}
void Backbone::search(QString word) {
- //TODO add running searches in new threads
_timer.stop();
_result.clear();
_innerResult.clear();
_dicts[dict] = 1;
}
+ void Backbone::removeDictionary(CommonDictInterface *dict) {
+ _dicts.remove(dict);
+
+ }
+
void Backbone::quit() {
void Backbone::loadPlugins() {
- QPluginLoader loader("xdxf.so");
- if(!loader.load()) {
- qDebug()<<loader.errorString();
+ QDir plug(QDir::toNativeSeparators(_pluginPath));
+ if(!plug.exists()) {
+ qDebug() << plug.absolutePath() << " folder dosen't exists";
return;
}
- QObject *pl = loader.instance();
+ QStringList nameFilter;
+ nameFilter << "*.so";
+ plug.setFilter(QDir::Files);
+ QStringList files = plug.entryList(nameFilter);
+ qDebug() << files;
+
- qDebug()<<"loaded";
- CommonDictInterface *plugin = qobject_cast<CommonDictInterface*>(pl);
- _plugins.append(plugin);
- addDictionary(plugin->getNew(0)); //TODO change 0 to real settings
+ foreach(QString file, files) {
+ QPluginLoader loader(plug.absoluteFilePath(file));
+ if(!loader.load()) {
+ qDebug()<< file << " " << loader.errorString();
+ continue;
+ }
+ QObject *pl = loader.instance();
+
+ CommonDictInterface *plugin = qobject_cast<CommonDictInterface*>(pl);
+ _plugins.append(plugin);
+ addDictionary(plugin->getNew(0)); //TODO change 0 to real settings
+ }
}