Merged with master
authorBartosz Szatkowski <bulislaw@linux.com>
Mon, 9 Aug 2010 08:13:04 +0000 (10:13 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Mon, 9 Aug 2010 08:13:04 +0000 (10:13 +0200)
debian/mdictionary.substvars
trunk/src/base/backbone/backbone.cpp
trunk/src/base/backbone/backbone.h
trunk/src/plugins/xdxf/src/xdxfplugin.cpp
trunk/src/src.pro
trunk/tests/mDictionaryTests/CommonDictInterfaceMock.h
trunk/tests/mDictionaryTests/tst_Backbone.cpp

index abbeeb5..1c10018 100644 (file)
@@ -1 +1,2 @@
-shlibs:Depends=libc6 (>= 2.5.0-1), libgcc1 (>= 1:4.2.1), libqt4-core (>= 4.6.2~git20100401), libqt4-gui (>= 4.6.2~git20100401), libqt4-xml (>= 4.6.2~git20100401), libstdc++6 (>= 4.2.1)
+shlibs:Depends=libc6 (>= 2.1.3), libc6 (>= 2.3.6-6~), libgcc1 (>= 1:4.1.1), libqt4-xml (>= 4:4.5.3), libqtcore4 (>= 4:4.6.1), libqtgui4 (>= 4:4.5.3), libstdc++6 (>= 4.1.1)
+misc:Depends=
index 5487791..d57f179 100644 (file)
@@ -29,22 +29,20 @@ void Backbone::init() {
    _interval = 250; //msec
    if(!_pluginPath.size())
        _pluginPath = "/usr/lib/mdictionary/";
+
+   if(!_configPath.size())
+       _configPath = "~/mdictrc";
    loadPlugins();
 
    if(!connect(&_timer, SIGNAL(timeout()), this, SLOT(translation())))
        qDebug() << "Timer signal not connected";
 }
 
-Backbone::Backbone(QObject *parent)
-    : QObject(parent)
-{
-    init();
-}
-
-Backbone::Backbone(QString pluginPath, QObject *parent)
+Backbone::Backbone(QString pluginPath, QString configPath, QObject *parent)
     : QObject(parent)
 {
     _pluginPath = pluginPath;
+    _configPath = configPath;
     init();
 }
 
@@ -197,24 +195,28 @@ void Backbone::translation() {
     }
 }
 
+QStringList Backbone::getFilesFromDir(QString dir, QStringList nameFilter) {
+    QDir plug(QDir::toNativeSeparators(dir));
+    if(!plug.exists()) {
+        qDebug() << plug.absolutePath() << " folder dosen't exists";
+        return QStringList();
+    }
+    plug.setFilter(QDir::Files);
+    QStringList list = plug.entryList(nameFilter);
 
+    for(int i = 0; i < list.size(); i++)
+        list[i] = plug.absoluteFilePath(list.at(i));
+    return list;
+}
 
 
 void Backbone::loadPlugins() {
-    QDir plug(QDir::toNativeSeparators(_pluginPath));
-    if(!plug.exists()) {
-        qDebug() << plug.absolutePath() << " folder dosen't exists";
-        return;
-    }
     QStringList nameFilter;
     nameFilter << "*.so";
-    plug.setFilter(QDir::Files);
-    QStringList files = plug.entryList(nameFilter);
-    qDebug() << files;
-
+    QStringList files = getFilesFromDir(_pluginPath, nameFilter);
 
     foreach(QString file, files) {
-        QPluginLoader loader(plug.absoluteFilePath(file));
+        QPluginLoader loader(file);
         if(!loader.load()) {
             qDebug()<< file << " " << loader.errorString();
             continue;
@@ -228,4 +230,7 @@ void Backbone::loadPlugins() {
 }
 
 
+void Backbone::loadDict() {
+
+}
 
index 0ee15cf..4302e26 100644 (file)
@@ -53,9 +53,9 @@ class Backbone : public QObject
     Q_OBJECT
 
 public:
-    Backbone(QObject *parent = 0);
-    //! \param pluginPath path to plugins
-    Backbone(QString pluginPath, QObject *parent = 0);
+    /*!\param pluginPath path to plugins (leave blank for default)
+      \param configPath path to folder with configuration files*/
+    Backbone(QString pluginPath="", QString configPath="", QObject *parent = 0);
     ~Backbone();
     Backbone(const Backbone& b);
 
@@ -125,7 +125,6 @@ Q_SIGNALS:
 
 
 private:
-    void loadPlugins(); //< locate and load plugins
     QHash<CommonDictInterface*, bool> _dicts;
     QList<CommonDictInterface*> _plugins;
     QList<QFuture<QList<Translation*> > > _innerResult;
@@ -136,8 +135,13 @@ private:
     QTime _time;
     int _interval; //Search fetching timer.timeout interval in msec
     QString _pluginPath;
+    QString _configPath;
 
     void init();
+    QStringList getFilesFromDir(QString dir, QStringList nameFilter);
+    void loadPlugins(); //< locate and load plugins
+    void loadDict();
+    //void writeConfig(QString key, QString value);
 
 };
 
index a90164d..47c269d 100644 (file)
@@ -32,11 +32,11 @@ XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
                     _type(tr("xdxf")), _infoNote(tr("")) {
     _settings = new Settings();
     _dictDialog = new XdxfDictDialog(this);
-    _settings->setValue("Type","xdxf");
+    _settings->setValue("type","xdxf");
     if(isCached())
-        _settings->setValue("Cached","true");
+        _settings->setValue("cached","true");
     else
-        _settings->setValue("Cached","false");
+        _settings->setValue("cached","false");
     setPath("/usr/lib/mdictionary/dict.xdxf");
     stopped = false;
 }
index 1d0fa3e..25f3dfd 100644 (file)
@@ -1,5 +1,5 @@
 TEMPLATE=subdirs
-SUBDIRS = plugins
+SUBDIRS = plugins base
 
 check.target = check
 check.CONFIG = recursive
index c627190..ad2fbbc 100644 (file)
@@ -51,7 +51,7 @@ public:
     uint hash() const { return _hash;}
     void setHash(uint h) {_hash = h;}
     void stop() {stopped = 1;}
-    QString search(QString key) {}
+    QString search(QString key) {return "";}
     QList<Translation*> searchWordList(QString word, int limit) {
         qDebug() << "search " << this->thread()->currentThreadId();
         stopped = 0;
@@ -67,8 +67,8 @@ public:
 
         return list;
     }
-    DictDialog* dictDialog() {}
-    Settings* settings() {}
+    DictDialog* dictDialog() {return 0;}
+    Settings* settings() {return 0;}
 
 };
 
index 57b9233..43f2ec4 100644 (file)
@@ -105,7 +105,7 @@ void BackboneTest::removeDictionaryTest() {
         back->removeDictionary(dict[i]);
 
     QVERIFY2(back->getDictionaries().contains(dict[total-1]) == 1,
-             "Deletet wrong dictionaries");
+             "Deleted wrong dictionaries");
 
 }