[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdevplatform/plugins/snippet
From:       Robert Gruber <rgruber () users ! sourceforge ! net>
Date:       2009-05-01 16:24:18
Message-ID: 1241195058.260002.16785.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 962171 by rgruber:

Added Snippet repositories get saved now uppon closing KDevelop.
So the user will find the snippet tree filled with the same repositories
when he starts the KDevelop session the next time.


 M  +8 -1      snippetplugin.cpp  
 M  +22 -0     snippetstore.cpp  
 M  +4 -2      snippetstore.h  


--- trunk/KDE/kdevplatform/plugins/snippet/snippetplugin.cpp #962170:962171
@@ -25,6 +25,8 @@
 
 #include "snippetview.h"
 #include "snippetcompletionmodel.h"
+#include <interfaces/isession.h>
+#include "snippetstore.h"
 
 K_PLUGIN_FACTORY(SnippetFactory, registerPlugin<SnippetPlugin>(); )
 K_EXPORT_PLUGIN(SnippetFactory(KAboutData("kdevsnippet","kdevsnippet", \
ki18n("Snippets"), "0.1", ki18n("Support for managing and using code snippets"), \
KAboutData::License_GPL))) @@ -60,15 +62,20 @@
     m_factory = new SnippetViewFactory(this);
     core()->uiController()->addToolView(i18n("Snippets"), m_factory);
     connect( core()->partController(), SIGNAL(partAdded(KParts::Part*)), this, \
SLOT(documentLoaded(KParts::Part*)) ); +
+    // load the repositories from the last run
+    SnippetStore::instance()->load(core()->activeSession()->config()->group("Snippets"));
  }
 
 SnippetPlugin::~SnippetPlugin()
 {
-    kDebug(9500) ;
 }
 
 void SnippetPlugin::unload()
 {
+    // Save the currently configured repositories
+    SnippetStore::instance()->save(core()->activeSession()->config()->group("Snippets"));
 +
     core()->uiController()->removeToolView(m_factory);
 }
 
--- trunk/KDE/kdevplatform/plugins/snippet/snippetstore.cpp #962170:962171
@@ -77,4 +77,26 @@
     }
 }
 
+void SnippetStore::load(KConfigGroup config)
+{
+    if (config.hasGroup("repos")) {
+        KConfigGroup repoGroup = config.group("repos");
+        QStringList keys = repoGroup.keyList();
+        foreach(QString key, keys) {
+            createNewRepository(0, key, repoGroup.readEntry(key));
+        }
+    }
+}
+
+void SnippetStore::save(KConfigGroup config)
+{
+    // remove all old repos that might have changed
+    config.group("repos").deleteGroup();
+    config.sync();
+
+    foreach(SnippetRepository* repo, repos_) {
+        config.group("repos").writeEntry(repo->text(), repo->getLocation());
+    }
+}
+
 #include "snippetstore.moc"
--- trunk/KDE/kdevplatform/plugins/snippet/snippetstore.h #962170:962171
@@ -11,10 +11,9 @@
 #ifndef __SNIPPETSTORE_H__
 #define __SNIPPETSTORE_H__
 
-#include <QObject>
-
 #include <QList>
 #include <QStandardItemModel>
+#include <kconfiggroup.h>
 
 class SnippetRepository;
 
@@ -50,6 +49,9 @@
      */
     void remove(SnippetRepository* repo);
 
+    void load(KConfigGroup config);
+    void save(KConfigGroup config);
+
 private:
     SnippetStore();
     virtual Qt::ItemFlags flags (const QModelIndex & index) const;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic