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

List:       kde-commits
Subject:    KDE/kdelibs/kross/ui
From:       Sebastian Sauer <mail () dipe ! org>
Date:       2008-03-08 13:38:10
Message-ID: 1204983490.297391.27485.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 783522 by sebsauer:

* delete the d-pointer again
* dox++, whitespaces--, include moc, etc.

@Paulo: Would you agree if we relicense that file to LGPLv2+ (if yes, please just \
change+commit, thx)? I ask cause whole of kross/kdelibs is LGPL rather then GPL what \
                allows to use kdelibs also in commercial products.
CC_MAIL: moura@kdewebdev.org



 M  +29 -33    plugin.cpp  
 M  +18 -7     plugin.h  


--- trunk/KDE/kdelibs/kross/ui/plugin.cpp #783521:783522
@@ -29,15 +29,25 @@
 #include <kross/core/actioncollection.h>
 #include <kio/netaccess.h>
 
-namespace Kross
-{
+using namespace Kross;
 
+/// \internal d-pointer class
 class ScriptingPlugin::ScriptingPluginPrivate
 {
 public:
-    QDomElement getMenuFromName(QString const& name, const QDomDocument& document);
-    
     QString userActionsFile;
+
+    QDomElement menuFromName(QString const& name, const QDomDocument& document)
+    {
+        QDomElement menuBar = \
document.documentElement().firstChildElement("MenuBar"); +        QDomElement menu = \
menuBar.firstChildElement("Menu"); +        for(; !menu.isNull(); menu = \
menu.nextSiblingElement("Menu")) { +            if(menu.attribute("name") == name) {
+                return menu;
+            }
+        }
+        return QDomElement();
+    }
 };
 
 ScriptingPlugin::ScriptingPlugin(QObject* parent)
@@ -49,21 +59,22 @@
 
 ScriptingPlugin::~ScriptingPlugin()
 {
+    delete d;
 }
 
 void ScriptingPlugin::setDOMDocument(const QDomDocument &document, bool merge)
 {
-    QDomDocument doc = buildDomDocument(document);    
+    QDomDocument doc = buildDomDocument(document);
     KXMLGUIClient::setDOMDocument(doc, merge);
 }
 
 QDomDocument ScriptingPlugin::buildDomDocument(const QDomDocument& document)
 {
     QStringList allActionFiles = KGlobal::dirs()->findAllResources("appdata", \
                "scripts/*.rc");
-    
+
     Kross::Manager::self().setProperty("configfile", d->userActionsFile);
     Kross::Manager::self().setProperty("configfiles", allActionFiles);
-    
+
     if(KIO::NetAccess::exists(KUrl(d->userActionsFile), KIO::NetAccess::SourceSide, \
                0)) {
         Kross::Manager::self().actionCollection()->readXmlFile(d->userActionsFile);
     }
@@ -82,16 +93,15 @@
 void ScriptingPlugin::buildDomDocument(QDomDocument& document,
     Kross::ActionCollection* collection)
 {
-    QDomElement menuElement = d->getMenuFromName(collection->name(), document);
+    QDomElement menuElement = d->menuFromName(collection->name(), document);
 
-    foreach(Kross::Action* action, collection->actions()) 
-{
+    foreach(Kross::Action* action, collection->actions()) {
         // Create and append new Menu element if doesn't exist
         if(menuElement.isNull()) {
             menuElement = document.createElement("Menu");
-            menuElement.setAttribute("name", collection->name());            
+            menuElement.setAttribute("name", collection->name());
             menuElement.setAttribute("noMerge", "0");
-            
+
             QDomElement textElement = document.createElement("text");
             textElement.appendChild(document.createTextNode(collection->text()));
             menuElement.appendChild(textElement);
@@ -101,7 +111,7 @@
                 document.documentElement().firstChildElement("MenuBar").appendChild(menuElement);
  }
             else {
-                QDomElement parentMenuElement = \
d->getMenuFromName(parentCollection->name(), document); +                QDomElement \
parentMenuElement = d->menuFromName(parentCollection->name(), document);  
                 if(!parentMenuElement.isNull()) {
                     parentMenuElement.appendChild(menuElement);
@@ -111,13 +121,13 @@
                 }
             }
         }
-            
+
         // Create and append new Action element
         QDomElement newActionElement = document.createElement("Action");
         newActionElement.setAttribute("name", action->name());
 
         menuElement.appendChild(newActionElement);
-    
+
         actionCollection()->addAction(action->name(), action);
     }
 
@@ -129,35 +139,21 @@
     }
 }
 
-QDomElement ScriptingPlugin::ScriptingPluginPrivate::getMenuFromName(QString const& \
                name, 
-        const QDomDocument& document)
-{
-    QDomElement menuBar = document.documentElement().firstChildElement("MenuBar");
-    QDomElement menu = menuBar.firstChildElement("Menu");
-    for(; !menu.isNull(); menu = menu.nextSiblingElement("Menu")) {
-        if(menu.attribute("name") == name) {
-            return menu;
-        }
-    }
-    
-    return QDomElement();
-}
-
 void ScriptingPlugin::slotEditScriptActions()
 {
     if(!KIO::NetAccess::exists(KUrl(d->userActionsFile), KIO::NetAccess::SourceSide, \
0)) {  KUrl dir = KUrl(d->userActionsFile).directory();
         KIO::NetAccess::mkdir(dir, 0);
-    
+
         QFile f(d->userActionsFile);
         if(f.open(QIODevice::WriteOnly)) {
-            
+
             bool collectionEmpty = true;
             if(!Kross::Manager::self().actionCollection()->actions().empty()
                 || !Kross::Manager::self().actionCollection()->collections().empty()) \
{  collectionEmpty = false;
             }
-            
+
             if( !collectionEmpty ) {
                 if( Kross::Manager::self().actionCollection()->writeXml(&f) ) {
                     kDebug() << "Successfully saved file: " << d->userActionsFile;
@@ -199,4 +195,4 @@
     KIO::NetAccess::del(KUrl(d->userActionsFile), 0);
 }
 
-}
+#include "plugin.moc"
--- trunk/KDE/kdelibs/kross/ui/plugin.h #783521:783522
@@ -31,7 +31,6 @@
 
 class QWidget;
 
-
 namespace Kross
 {
 
@@ -64,22 +63,34 @@
 {
     Q_OBJECT
 public:
-    ScriptingPlugin(QObject* parent = 0);
-    ~ScriptingPlugin();
 
-    /** 
-     * Re-implement in order to load additional kross scripting rc files
+    /**
+     * Constructor.
+     *
+     * \param parent The parent QObject this QObject is child of.
      */
+    explicit ScriptingPlugin(QObject* parent = 0);
+
+    /**
+     * Destructor.
+     */
+    virtual ~ScriptingPlugin();
+
+    /**
+     * Re-implement in order to load additional kross scripting rc files.
+     */
     virtual void setDOMDocument (const QDomDocument &document, bool merge = false);
 
 protected Q_SLOTS:
+
     /**
      * This slot will open/create a scriptactions.rc file at \
                $KDEHOME/share/apps/application/scripts/
-     * which will overide other kross rc files. This allows a user to extend \
existing menus with new actions +     * which will overide other kross rc files. This \
                allows a user to extend existing menus with new actions.
      */
     virtual void slotEditScriptActions();
+
     /**
-     * Deletes the user rc file, which has the effect of falling back to the default \
script actions (if any) +     * Deletes the user rc file, which has the effect of \
                falling back to the default script actions (if any).
      */
     virtual void slotResetScriptActions();
 


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

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