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

List:       kde-commits
Subject:    [calligra/stage-singlecanvas-aakriti] /: Now used a QMap for all
From:       Aakriti Gupta <aakriti.a.gupta () gmail ! com>
Date:       2011-07-31 20:39:25
Message-ID: 20110731203925.0DC69A60BB () git ! kde ! org
[Download RAW message or body]

Git commit cbe643497878c0e69126e791285ffa88f2180181 by Aakriti Gupta.
Committed on 29/07/2011 at 15:09.
Pushed by aakritigupta into branch 'stage-singlecanvas-aakriti'.

Now used a QMap for all the animation attributes and their values.

M  +2    -2    filters/libsvg/SvgWriter_generic.cpp
M  +32   -77   plugins/presentationviewportshape/PresentationViewPortShape.cpp
M  +4    -10   plugins/presentationviewportshape/PresentationViewPortShape.h

http://commits.kde.org/calligra/cbe643497878c0e69126e791285ffa88f2180181

diff --git a/filters/libsvg/SvgWriter_generic.cpp \
b/filters/libsvg/SvgWriter_generic.cpp index 3c0ee72..e0cb018 100644
--- a/filters/libsvg/SvgWriter_generic.cpp
+++ b/filters/libsvg/SvgWriter_generic.cpp
@@ -262,8 +262,8 @@ void SvgWriter_generic::saveViewPort(KoShape* shape)
     *m_body << " height=\"" << size.height() << "pt\"";
 
     *m_body << "/>" << endl;
-    saveAppData(shape);//TODO Make the PVPShape save all the animation data too \
                instead of adding it as custom data.
-                       //IMPORTANT   
+    
+    m_appData.append(viewport->toString()); //Saving animation data
 }
 
 void SvgWriter_generic::saveShape(KoShape * shape)
diff --git a/plugins/presentationviewportshape/PresentationViewPortShape.cpp \
b/plugins/presentationviewportshape/PresentationViewPortShape.cpp index \
                d2965e5..1ac516f 100644
--- a/plugins/presentationviewportshape/PresentationViewPortShape.cpp
+++ b/plugins/presentationviewportshape/PresentationViewPortShape.cpp
@@ -21,12 +21,14 @@
 #include <KoPathPoint.h>
 #include <qpainter.h>
 #include <KoShapeBackground.h>
+#include <KoXmlReader.h>
 
 PresentationViewPortShape::PresentationViewPortShape() : m_noOfPoints(8)
 {
     setShapeId(PresentationViewPortShapeId);
     m_adjMatrix = createAdjMatrix();
     setName("ViewPort");//TODO remove this?
+    initializeAnimationProperties();
 }
 
 
@@ -85,88 +87,46 @@ void PresentationViewPortShape::parseAnimationProperties(const \
KoXmlElement& e)  
 void PresentationViewPortShape::initializeAnimationProperties()
 {
-    m_attributes.append("title");
-    m_attributes.append("refid");
-    m_attributes.append("transition-profile");
-    m_attributes.append("hide");
-    m_attributes.append("clip");
-    m_attributes.append("timeout-enable");
-    m_attributes.append("sequence");
-    m_attributes.append("transition-zoom-percent");
-    m_attributes.append("timeout-ms");
-    m_attributes.append("transition-duration-ms");
-        
-    setDefaultValues();
+    //Initializing the map with default values of all attributes
+    m_animationAttributes.insert("title", "No title");
+    m_animationAttributes.insert("refid", "null");
+    m_animationAttributes.insert("transition-profile", "linear");
+    m_animationAttributes.insert("hide", "true");
+    m_animationAttributes.insert("clip", "true");
+    m_animationAttributes.insert("timeout-enable", "false");
+    m_animationAttributes.insert("sequence", QString("%1").arg(0));
+    m_animationAttributes.insert("transition-zoom-percent", QString("%1").arg(1));
+    m_animationAttributes.insert("transition-duration-ms", QString("%1").arg(5000));
+    m_animationAttributes.insert("timeout-ms", QString("%1").arg(1000));
 }
 
-static void printIndentation(QTextStream *stream, unsigned int indent)
-//void SvgWriter_generic::printIndentation(QTextStream* stream, unsigned int indent)
+static void printIndentation(QString& stream, unsigned int indent)
 {
     static const QString INDENT("  ");
-    for (unsigned int i = 0; i < indent;++i)
-    *stream << INDENT;
-}
-
-void PresentationViewPortShape::setDefaultValues()
-{
-    m_title = "No Title";
-    m_refId = "No Ref ID"; 
-    m_transitionProfile = "linear";
-    m_hide = true;
-    m_clip = true;
-    m_timeoutEnable = false;
-
-    m_sequence = 0;
-    m_transitionZoomPercent = 1;
-    m_transitionDurationMs = 1000; 
-    m_timeoutMs = 5000;    
+    for (unsigned int i = 0; i < indent;++i){
+        stream.append(INDENT);
+    }
 }
 
-void PresentationViewPortShape::writeToStream(QTextStream* stream)
+QString PresentationViewPortShape::toString()
 {
-        unsigned indent = 1;
-    //QTextStream * stream;
-    
+    unsigned indent = 1;
+    QString stream;
+    QString ns("calligra:");
+        
     printIndentation(stream, indent++);
-    *stream << "<calligra:frame" << endl;
-       
-    printIndentation(stream, indent);
-    *stream << "calligra:" << "title=\"" << title() << "\"" << endl;
-    printIndentation(stream, indent);
-    *stream << "calligra:" << "refid=\"" << refId() << "\"" << endl;
-    printIndentation(stream, indent);
-    *stream << "calligra:" << "transition-profile=\"" << transitionProfile() << "\"" \
                << endl;
-    printIndentation(stream, indent);
-    *stream << "calligra:" << "hide=\"";
-    if(isHide())
-      *stream << "true";
-    else
-     *stream << "false";
-    *stream << "\"" << endl;
-     
-    printIndentation(stream, indent);
-    *stream << "calligra:" << "clip=\"";
-    if(isClip())
-      *stream << "true";
-    else
-      *stream << "false";
-    *stream << "\"" << endl;
+    stream.append("<calligra:frame");
+    stream.append("\n");
     
-    printIndentation(stream, indent);
-    *stream << "calligra:" << "timeout-enable=\"" << isEnableTimeout() << "\"" << \
                endl;
-    printIndentation(stream, indent);
-    *stream << "calligra:" << "sequence=\"" << sequence() << "\"" << endl;
-    printIndentation(stream, indent);
-    *stream << "calligra:" << "transition-zoom-percent=\"" << zoomPercent() << "\"" \
                << endl;
-    printIndentation(stream, indent);
-    *stream << "calligra:" << "timeout-ms=\"" << timeout() << "\"" << endl;
-    printIndentation(stream, indent);
-    *stream << "calligra:" << "transition-duration-ms=\"" << transitionDuration() << \
                "\"" << endl;
-              
-    //*stream << "/>" << endl; because transform needs to be added
-
+    foreach(QString key, m_animationAttributes.keys()){
+      printIndentation(stream, indent);
+      stream.append(ns).append(key).append("=\"").append(m_animationAttributes.value(key)).append("\"");
 +      stream.append("\n");
+    }
+    stream.append("/>\n");
+    
+    return stream;
 }
-
 QVector< QVector < int > > PresentationViewPortShape::createAdjMatrix()
 {
   m_noOfPoints = 8;
@@ -385,11 +345,6 @@ int PresentationViewPortShape::transitionDuration() const
     return m_transitionDurationMs;
 }
           
-QList< QString > PresentationViewPortShape::attributes() const
-{
-    return m_attributes;
-}
-
 //TODO: What will be done in this?
 // Neccessary to write to and from an ODF
 bool PresentationViewPortShape::loadOdf(const KoXmlElement& element, \
                KoShapeLoadingContext& context)
diff --git a/plugins/presentationviewportshape/PresentationViewPortShape.h \
b/plugins/presentationviewportshape/PresentationViewPortShape.h index \
                536bd78..55bf050 100644
--- a/plugins/presentationviewportshape/PresentationViewPortShape.h
+++ b/plugins/presentationviewportshape/PresentationViewPortShape.h
@@ -62,11 +62,12 @@ public:
     /**
      * Sets the default values for all frame attrbutes
      */
-    void setDefaultValues();
+    //void setDefaultValues();
     /**
      * @param stream QTextStream to which all frame data is written in specific \
                format.
      */
-    void writeToStream(QTextStream * stream);
+    //QTextStream* writeToStream();
+    QString toString();
     
     void setTitle(const QString& title);
     void setRefId(const QString& refId); 
@@ -95,10 +96,6 @@ public:
     int transitionDuration() const;
      
      
-    /**
-     * @return m_attributes 
-     */
-    QList<QString> attributes() const; 
     
 private:     
     void setListOfPoints(QList<QPointF> points);
@@ -128,10 +125,7 @@ private:
      int m_transitionDurationMs;
      int m_timeoutMs;
         
-     /**
-      * @brief m_attributes List of all attributes a frame can have
-      */
-     QList<QString> m_attributes;
+     QMap<QString, QString> m_animationAttributes;
   
 };
 #endif


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

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