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

List:       kde-commits
Subject:    koffice/krita/image
From:       Cyrille Berger <cyb () lepi ! org>
Date:       2007-08-01 0:20:09
Message-ID: 1185927609.819790.25708.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 694886 by berger:

add a better identification of layers and start unserializing polylines

 M  +32 -7     kis_recorded_action.cc  
 M  +4 -0      kis_recorded_action.h  
 M  +5 -2      kis_recorded_paint_actions.cc  


--- trunk/koffice/krita/image/kis_recorded_action.cc #694885:694886
@@ -22,6 +22,10 @@
 #include <QDomElement>
 #include <QString>
 
+#include <kis_image.h>
+#include <kis_layer.h>
+#include <kis_group_layer.h>
+
 struct KisRecordedAction::Private {
     QString name;
     QString id;
@@ -54,15 +58,18 @@
     elt.setAttribute( "id", id() );
 }
 
-
-/*
-
-void KisRecordedAction::fromXML(QDomElement elt)
+QString KisRecordedAction::layerToIndexPath(KisLayerSP _layer)
 {
-    d->name = elt.attribute("name","");
-    Q_ASSERT(d->id == elt.attribute( "id", ""));
+    QString path;
+    KisLayerSP layer = _layer;
+    KisLayerSP parent = 0;
+    while((parent = layer->parentLayer()))
+    {
+        path = "\\" + layer->index() + path;
+        layer = parent;
+    }
+    return path;
 }
-*/
 
 struct KisRecordedActionFactory::Private {
     QString id;
@@ -82,3 +89,21 @@
 {
     return d->id;
 }
+
+KisLayerSP KisRecordedActionFactory::indexPathToLayer(KisImageSP img, QString path)
+{
+    QStringList indexes = path.split("\\");
+    KisLayerSP current = (img->rootLayer()->at(indexes[0].toUInt()));
+    for(int i = 1; i < indexes.size(); i++)
+    {
+        KisGroupLayerSP groupCurrent = dynamic_cast<KisGroupLayer*>(current.data());
+        if(groupCurrent)
+        {
+            current = groupCurrent->at(indexes[i].toUInt());
+        } else
+        {
+            break;
+        }
+    }
+    return current;
+}
--- trunk/koffice/krita/image/kis_recorded_action.h #694885:694886
@@ -35,6 +35,8 @@
     public:
         QString id();
         QString name();
+    protected:
+        static QString layerToIndexPath(KisLayerSP);
     private:
         struct Private;
         Private* const d;
@@ -46,6 +48,8 @@
         virtual ~KisRecordedActionFactory();
         virtual KisRecordedAction* fromXML(KisImageSP img, const QDomElement& elt) \
=0;  QString id();
+    protected:
+        static KisLayerSP indexPathToLayer(KisImageSP img, QString);
     private:
         struct Private;
         Private* const d;
--- trunk/koffice/krita/image/kis_recorded_paint_actions.cc #694885:694886
@@ -74,7 +74,7 @@
 
 void KisRecordedPolyLinePaintAction::toXML(QDomDocument& doc, QDomElement& elt)
 {
-    elt.setAttribute("layer", d->layer->id());
+    elt.setAttribute("layer", KisRecordedAction::layerToIndexPath(d->layer));
     elt.setAttribute("paintop", d->paintOpId);
     QDomElement ressourceElt = doc.createElement( "Brush");
     d->brush->toXML(doc, ressourceElt);
@@ -101,6 +101,9 @@
 
 KisRecordedAction* KisRecordedPolyLinePaintActionFactory::fromXML(KisImageSP img, \
const QDomElement& elt)  {
-    
+    QString name = elt.attribute("name");
+    KisLayerSP layer = KisRecordedActionFactory::indexPathToLayer(img, \
elt.attribute("layer")); +    QString paintOpId = elt.attribute("paintop");
+//     QString brush = 
     return 0;
 }


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

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