Fixed #6304: xdxf plugin deletes cache files when beign removed from app
authorBartosz Szatkowski <bulislaw@linux.com>
Mon, 30 Aug 2010 08:12:39 +0000 (10:12 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Mon, 30 Aug 2010 08:13:30 +0000 (10:13 +0200)
trunk/src/base/backbone/backbone.cpp
trunk/src/includes/CommonDictInterface.h
trunk/src/plugins/xdxf/src/xdxfplugin.cpp
trunk/src/plugins/xdxf/src/xdxfplugin.h

index d7ca916..80ede84 100644 (file)
@@ -255,6 +255,7 @@ void Backbone::addDictionary(CommonDictInterface *dict, bool active) {
 
  void Backbone::removeDictionary(CommonDictInterface *dict) {
      _dicts.remove(dict);
+     dict->clean();
      delete dict;
      dictUpdated();
 
index f4af85d..712f68c 100644 (file)
@@ -89,8 +89,14 @@ class CommonDictInterface : public QObject, public AccentsNormalizer {
     //! returns plugin icon
     virtual QIcon* icon() = 0;
 
+    //! returns empty translation object (to be fetch later) for given key
     virtual Translation* getTranslationFor(QString key) {return 0;}
 
+    /*! plugin should delete any files (eg. cache) that has created and be ready
+        to be deleted
+        */
+    virtual void clean() {};
+
  public Q_SLOTS:
     /*! performs search in dictionary
         \param  word word to search in dictionary
index ae9f35e..78a5905 100644 (file)
@@ -567,4 +567,11 @@ bool XdxfPlugin::makeCache(QString dir) {
     return true;
 }
 
+
+
+void XdxfPlugin::clean() {
+    if(settings()->value("cached") == "true")
+        QFile(settings()->value("cache_path")).remove();
+}
+
 Q_EXPORT_PLUGIN2(xdxf, XdxfPlugin)
index 964b827..a763327 100644 (file)
@@ -100,6 +100,11 @@ public:
     //! returns plugin icon
     virtual QIcon* icon();
 
+    /*! plugin should delete any files (eg. cache) that has created and be ready
+        to be deleted
+        */
+    virtual void clean();
+
 public Q_SLOTS:
     /*! performs search in dictionary
       \param  word word to search in dictionary