ginebra2/linearflowsnippet.cpp
changeset 5 0f2326c2a325
parent 0 1450b09d0cfd
child 6 1c3b8676e58c
--- a/ginebra2/linearflowsnippet.cpp	Fri May 14 15:40:36 2010 +0300
+++ b/ginebra2/linearflowsnippet.cpp	Wed Jun 23 17:59:43 2010 +0300
@@ -1,20 +1,23 @@
 /*
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, version 2.1 of the License.
 *
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU Lesser General Public License for more details.
 *
-* Contributors:
+* You should have received a copy of the GNU Lesser General Public License
+* along with this program.  If not,
+* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
 *
-* Description: 
+* Description:
 *
 */
-
 #include <QDebug>
 #include <QImage>
 #include <QPainter>
@@ -26,17 +29,17 @@
 #include <QGraphicsDropShadowEffect>
 #include "linearflowsnippet.h"
 
-#define SAFE_DELETE(p) if(p) delete p;
+#define SAFE_DELETE(p) if (p) delete p;
 
 #define SNIPPET_AUTOHIDE_TIMEOUT 5000 //5secs
 
-#define CALL_ON_PREV_PREV_FILM_STRIP(func) if (d->m_centerIndex - 2 >= 0) d->m_films[d->m_centerIndex - 2]->func; else if(d->m_centerIndex == 1) d->m_films[d->m_films.size() - 1]->func; else d->m_films[d->m_films.size() - 2]->func;
-#define CALL_ON_CENTER_FILM_STRIP(func) if (d->m_centerIndex >= 0 && d->m_centerIndex < d->m_films.size()) d->m_films[d->m_centerIndex]->func; else if(d->m_centerIndex < 0) d->m_films[d->m_films.size() + d->m_centerIndex]->func; else d->m_films[(d->m_centerIndex)%d->m_films.size()]->func; 
-#define CALL_ON_PREV_PREV_PREV_FILM_STRIP(func) if (d->m_centerIndex - 3 >= 0) d->m_films[d->m_centerIndex - 3]->func; else if(d->m_centerIndex == 1) d->m_films[d->m_films.size() - 2]->func; else if(d->m_centerIndex == 2) d->m_films[d->m_films.size() - 1]->func; else d->m_films[d->m_films.size() - 3]->func;
-#define CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 3 < d->m_films.size()) d->m_films[d->m_centerIndex + 3]->func; else d->m_films[(d->m_centerIndex + 3)%d->m_films.size()]->func; 
-#define CALL_ON_NEXT_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 2 < d->m_films.size()) d->m_films[d->m_centerIndex + 2]->func; else d->m_films[(d->m_centerIndex + 2)%d->m_films.size()]->func; 
+#define CALL_ON_PREV_PREV_FILM_STRIP(func) if (d->m_centerIndex - 2 >= 0) d->m_films[d->m_centerIndex - 2]->func; else if (d->m_centerIndex == 1) d->m_films[d->m_films.size() - 1]->func; else d->m_films[d->m_films.size() - 2]->func;
+#define CALL_ON_CENTER_FILM_STRIP(func) if (d->m_centerIndex >= 0 && d->m_centerIndex < d->m_films.size()) d->m_films[d->m_centerIndex]->func; else if (d->m_centerIndex < 0) d->m_films[d->m_films.size() + d->m_centerIndex]->func; else d->m_films[(d->m_centerIndex)%d->m_films.size()]->func;
+#define CALL_ON_PREV_PREV_PREV_FILM_STRIP(func) if (d->m_centerIndex - 3 >= 0) d->m_films[d->m_centerIndex - 3]->func; else if (d->m_centerIndex == 1) d->m_films[d->m_films.size() - 2]->func; else if (d->m_centerIndex == 2) d->m_films[d->m_films.size() - 1]->func; else d->m_films[d->m_films.size() - 3]->func;
+#define CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 3 < d->m_films.size()) d->m_films[d->m_centerIndex + 3]->func; else d->m_films[(d->m_centerIndex + 3)%d->m_films.size()]->func;
+#define CALL_ON_NEXT_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 2 < d->m_films.size()) d->m_films[d->m_centerIndex + 2]->func; else d->m_films[(d->m_centerIndex + 2)%d->m_films.size()]->func;
 #define CALL_ON_PREV_FILM_STRIP(func) if (d->m_centerIndex - 1 >= 0) d->m_films[d->m_centerIndex - 1]->func; else d->m_films[d->m_films.size() - 1]->func;
-#define CALL_ON_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 1 < d->m_films.size()) d->m_films[d->m_centerIndex + 1]->func; else d->m_films[(d->m_centerIndex + 1)%d->m_films.size()]->func; 
+#define CALL_ON_NEXT_FILM_STRIP(func) if (d->m_centerIndex + 1 < d->m_films.size()) d->m_films[d->m_centerIndex + 1]->func; else d->m_films[(d->m_centerIndex + 1)%d->m_films.size()]->func;
 
 
 #define INVALID_INDEX -1
@@ -179,7 +182,7 @@
 
     void freeze() {m_frozen = true;}
     void updateMovie(FilmstripMovie* movie) {m_movie = movie; m_movieFrame = 0; m_frozen = false;}
-    void updateMovieFrame(int frame) { if(!m_frozen) m_movieFrame = frame;}
+    void updateMovieFrame(int frame) { if (!m_frozen) m_movieFrame = frame;}
     void setName(const QString& name) {m_name = name;}
     QImage& image() {return m_img;}
     QString& name() {return m_name;}
@@ -257,7 +260,7 @@
 
     if (!m_movie)
         return;
-    
+
     QRectF target;
 
     bool needFade = (m_movie->m_movieType == FilmstripMovie::FADE_OUT);
@@ -265,16 +268,16 @@
         target = m_movie->movieClip(0);
     else
         target = m_movie->movieClip(m_movieFrame);
-    
-    if(target.right() > 0 || target.left() < m_filmstripFlowData->m_widgetSize.width()) {
+
+    if (target.right() > 0 || target.left() < m_filmstripFlowData->m_widgetSize.width()) {
         if (needFade)
             painter->setOpacity((ANIMATION_MAX_FRAME - m_movieFrame) / ANIMATION_MAX_FRAME);
 
         painter->fillRect(target.adjusted(-FRAME_WIDTH,-FRAME_WIDTH,FRAME_WIDTH,FRAME_WIDTH), QColor(Qt::gray));
-        
-        if(!m_img.isNull())
+
+        if (!m_img.isNull())
             painter->drawImage(target, m_img);
-    
+
         else {
             painter->save();
             painter->setPen(QColor(Qt::black));
@@ -283,8 +286,8 @@
             painter->restore();
         }
 
-        if (needFade) 
-            painter->setOpacity(1); // restore opacity 
+        if (needFade)
+            painter->setOpacity(1); // restore opacity
     }
 }
 
@@ -322,7 +325,7 @@
 
 // -------------------------------------------------------
 // FilmstripMovieFactory
-FilmstripMovieFactory::~FilmstripMovieFactory() 
+FilmstripMovieFactory::~FilmstripMovieFactory()
 {
     QHashIterator<QString, FilmstripMovie*> i(m_moviesCache);
     while (i.hasNext()) {
@@ -368,7 +371,7 @@
             createRightRightInMovie(movie);
         else if (name == BreakoutLeftLeft)
             createLeftLeftOutMovie(movie);
-        else if (name == BreakoutRightRight)    
+        else if (name == BreakoutRightRight)
             createRightRightOutMovie(movie);
         else if (name == LeftLeftToLeft)
             createLeftLeftToLeftMovie(movie);
@@ -376,7 +379,7 @@
             createLeftToLeftLeftMovie(movie);
         else if (name == RightToRightRight)
             createRightToRightRightMovie(movie);
-        else if(name == RightRightToRight)
+        else if (name == RightRightToRight)
             createRightRightToRightMovie(movie);
 
         m_moviesCache[name] = movie;
@@ -386,7 +389,7 @@
     return movie;
 }
 
-void FilmstripMovieFactory::createLeftLeftInMovie(FilmstripMovie* movie) 
+void FilmstripMovieFactory::createLeftLeftInMovie(FilmstripMovie* movie)
 {
     movie->m_movieClips.clear();
     int cw = m_filmstripFlowData->m_centerWindowSize.width();
@@ -395,8 +398,8 @@
     int w = m_filmstripFlowData->m_widgetSize.width();
     int h = m_filmstripFlowData->m_widgetSize.height();
 
-    qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; 
-    qreal sx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - 2 * sw; 
+    qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space;
+    qreal sx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - 2 * sw;
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME;
 
@@ -416,7 +419,7 @@
     int h = m_filmstripFlowData->m_widgetSize.height();
 
     qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space;
-    qreal sx = ((w + 4 * m_filmstripFlowData->m_space + cw) / 2.0) + sw ; 
+    qreal sx = ((w + 4 * m_filmstripFlowData->m_space + cw) / 2.0) + sw ;
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME;
 
@@ -435,8 +438,8 @@
     int w = m_filmstripFlowData->m_widgetSize.width();
     int h = m_filmstripFlowData->m_widgetSize.height();
 
-    qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; 
-    qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw); 
+    qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space;
+    qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw);
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (sx -cx) / ANIMATION_MAX_FRAME;
 
@@ -456,7 +459,7 @@
     int h = m_filmstripFlowData->m_widgetSize.height();
 
     qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space;
-    qreal sx = ((w + 4 * m_filmstripFlowData->m_space + cw) / 2.0) + sw ; 
+    qreal sx = ((w + 4 * m_filmstripFlowData->m_space + cw) / 2.0) + sw ;
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (sx - cx) / ANIMATION_MAX_FRAME;
 
@@ -476,15 +479,15 @@
     int h = m_filmstripFlowData->m_widgetSize.height();
 
     qreal step = ANIMATION_MAX_FRAME;
-    qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; 
+    qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space;
     qreal cy = m_filmstripFlowData->m_centerTopSpace;
-    qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw); 
+    qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw);
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (cx - sx) / step;
     qreal stepy = (cy - sy) / step;
     qreal stepx2 = stepx + (cw - sw) / step;
     qreal stepy2 = stepy + (ch - sh) / step;
- 
+
     QRectF startRect = QRectF(sx, sy, sw, sh);
     QRectF endRect = QRectF(cx, cy, cw, ch);
 
@@ -502,15 +505,15 @@
     int h = m_filmstripFlowData->m_widgetSize.height();
 
     qreal step = ANIMATION_MAX_FRAME;
-    qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space; 
+    qreal cx = ((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw + m_filmstripFlowData->m_space;
     qreal cy = m_filmstripFlowData->m_centerTopSpace;
-    qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw); 
+    qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - (2 *sw);
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (sx - cx) / step;
     qreal stepy = (sy - cy) / step;
     qreal stepx2 = stepx + (sw - cw) / step;
     qreal stepy2 = stepy + (sh - ch) / step;
- 
+
     QRectF startRect = QRectF(cx, cy, cw, ch);
     QRectF endRect = QRectF(sx, sy, sw, sh);
     addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2);
@@ -529,17 +532,17 @@
     qreal step = ANIMATION_MAX_FRAME;
     qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space;
     qreal cy = m_filmstripFlowData->m_centerTopSpace;
-    qreal sx = (((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0) + sw; 
+    qreal sx = (((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0) + sw;
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (sx - cx) / step;
     qreal stepy = (sy - cy) / step;
     qreal stepx2 = stepx + (sw - cw) / step;
     qreal stepy2 = stepy + (sh - ch) / step;
-  
+
     QRectF startRect = QRectF(cx, cy, cw, ch);
     QRectF endRect = QRectF(sx, sy, sw, sh);
     addRectByFrame(movie, startRect, endRect, stepx, stepy, stepx2, stepy2);
-   
+
 }
 
 void FilmstripMovieFactory::createRightRightToRightMovie(FilmstripMovie* movie)
@@ -555,13 +558,13 @@
     qreal step = ANIMATION_MAX_FRAME;
     qreal cx = (w + 4 * m_filmstripFlowData->m_space + cw) / 2.0 - m_filmstripFlowData->m_space;
     qreal cy = m_filmstripFlowData->m_centerTopSpace;
-    qreal sx = ((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0 + sw; 
+    qreal sx = ((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0 + sw;
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (cx - sx) / step;
     qreal stepy = (cy - sy) / step;
     qreal stepx2 = stepx + (cw - sw) / step;
     qreal stepy2 = stepy + (ch - sh) / step;
- 
+
     QRectF startRect = QRectF(sx, sy, sw, sh);
     QRectF endRect = QRectF(cx, cy, cw, ch);
 
@@ -623,7 +626,7 @@
     qreal step = ANIMATION_MAX_FRAME;
     qreal cx = (w - cw) / 2.0;
     qreal cy = m_filmstripFlowData->m_centerTopSpace;
-    qreal sx = ((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0 - m_filmstripFlowData->m_space; 
+    qreal sx = ((w + 4 * m_filmstripFlowData->m_space) + cw) / 2.0 - m_filmstripFlowData->m_space;
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (cx - sx) / step;
     qreal stepy = (cy - sy) / step;
@@ -649,7 +652,7 @@
     qreal step = ANIMATION_MAX_FRAME;
     qreal cx = (w - cw) / 2.0;
     qreal cy = m_filmstripFlowData->m_centerTopSpace;
-    qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - sw + m_filmstripFlowData->m_space; 
+    qreal sx = (((w - 4 * m_filmstripFlowData->m_space) - cw) / 2.0) - sw + m_filmstripFlowData->m_space;
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (sx - cx) / step;
     qreal stepy = (sy - cy) / step;
@@ -699,7 +702,7 @@
     qreal sx = (w * (1 - 2 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw;
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (sx -cx) / ANIMATION_MAX_FRAME;
- 
+
     QRectF startRect = QRectF(sx, sy, sw, sh);
     QRectF endRect = QRectF(2 * sx - cx , sy, sw, sh);
 
@@ -716,10 +719,10 @@
     int h = m_filmstripFlowData->m_widgetSize.height();
 
     qreal cx = (w - cw) / 2.0;
-    qreal sx = (w * (1 - 2 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw; 
+    qreal sx = (w * (1 - 2 * m_filmstripFlowData->m_space) - cw) / 2.0 - sw;
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME;
-    
+
     QRectF startRect = QRectF(2 * sx - cx , sy, sw, sh);
     QRectF endRect = QRectF(sx, sy, sw, sh);
 
@@ -736,7 +739,7 @@
     int h = m_filmstripFlowData->m_widgetSize.height();
 
     qreal cx = (w - cw) / 2.0;
-    qreal sx = (w * (1 + 2 * m_filmstripFlowData->m_space) + cw) / 2.0; 
+    qreal sx = (w * (1 + 2 * m_filmstripFlowData->m_space) + cw) / 2.0;
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (sx - cx) / ANIMATION_MAX_FRAME;
 
@@ -755,7 +758,7 @@
     int h = m_filmstripFlowData->m_widgetSize.height();
 
     qreal cx = (w - cw) / 2.0;
-    qreal sx = (w * (1 + 2 * m_filmstripFlowData->m_space) + cw) / 2.0; 
+    qreal sx = (w * (1 + 2 * m_filmstripFlowData->m_space) + cw) / 2.0;
     qreal sy = m_filmstripFlowData->m_sideTopSpace;
     qreal stepx = (cx - sx) / ANIMATION_MAX_FRAME;
 
@@ -777,7 +780,7 @@
 
     QRectF startRect = QRectF(cx, cy, cw, ch);
     movie->m_movieClips.append(startRect);
-    
+
     movie->m_movieType = FilmstripMovie::FADE_OUT;
 }
 
@@ -797,7 +800,7 @@
     qreal stepy = - cy / step;
     qreal stepx2 = - stepx;
     qreal stepy2 = (h - cy - ch) / step;
- 
+
     QRectF startRect = QRectF(cx, cy, cw, ch);
     QRectF endRect = QRectF(0, 0, w, h);
 
@@ -884,43 +887,43 @@
         createLeftLeftInMovie(movie);
     }
 
-    
+
     i = m_moviesCache.find(BreakinRightRight);
     if (i != m_moviesCache.end()) {
         FilmstripMovie* movie =  m_moviesCache.value(BreakinRightRight);
         createRightRightInMovie(movie);
     }
-    
+
     i = m_moviesCache.find(BreakoutLeftLeft);
     if (i != m_moviesCache.end()) {
         FilmstripMovie* movie =  m_moviesCache.value(BreakoutLeftLeft);
         createLeftLeftOutMovie(movie);
     }
-    
+
     i = m_moviesCache.find(BreakoutRightRight);
     if (i != m_moviesCache.end()) {
         FilmstripMovie* movie =  m_moviesCache.value(BreakoutRightRight);
         createRightRightOutMovie(movie);
     }
-    
+
     i = m_moviesCache.find(LeftLeftToLeft);
     if (i != m_moviesCache.end()) {
         FilmstripMovie* movie =  m_moviesCache.value(LeftLeftToLeft);
         createLeftLeftToLeftMovie(movie);
-    } 
-    
+    }
+
     i = m_moviesCache.find(LeftToLeftLeft);
     if (i != m_moviesCache.end()) {
         FilmstripMovie* movie =  m_moviesCache.value(LeftToLeftLeft);
         createLeftToLeftLeftMovie(movie);
-    } 
-    
+    }
+
     i = m_moviesCache.find(RightToRightRight);
     if (i != m_moviesCache.end()) {
         FilmstripMovie* movie =  m_moviesCache.value(RightToRightRight);
         createRightToRightRightMovie(movie);
-    } 
-    
+    }
+
     i = m_moviesCache.find(RightRightToRight);
     if (i != m_moviesCache.end()) {
         FilmstripMovie* movie =  m_moviesCache.value(RightRightToRight);
@@ -932,8 +935,8 @@
 // LinearFlowSnippet.
 /*!
   Creates a new LinearFlowSnippet.
-*/  
-LinearFlowSnippet::LinearFlowSnippet(QGraphicsWidget* parent): QGraphicsWidget(parent), d(new FilmstripFlowPrivate())
+*/
+LinearFlowSnippet::LinearFlowSnippet(QGraphicsWidget* parent): ChromeItem(NULL, parent), d(new FilmstripFlowPrivate())
 {
     setParent(parent);
     m_scrolled = false;
@@ -987,29 +990,29 @@
 /*!
   Set center index
 */
-void LinearFlowSnippet::setCenterIndex(int i) 
+void LinearFlowSnippet::setCenterIndex(int i)
 {
     Q_ASSERT(d);
     if (!d->m_films.size())
         return;
-    
-    if(d->m_centerIndex == i)
+
+    if (d->m_centerIndex == i)
         return;
 
-    if(i < 0)
+    if (i < 0)
         i = (d->m_films.size() + i);
-    else if(d->m_centerIndex >= d->m_films.size() - 1)
+    else if (d->m_centerIndex >= d->m_films.size() - 1)
         i = i % d->m_films.size();
 
     d->m_centerIndex = i;
-  
+
     CALL_ON_PREV_PREV_PREV_FILM_STRIP(updateMovie(NULL));
     CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(updateMovie(NULL));
     d->m_films[d->m_centerIndex]->updateMovie(d->m_movieFactory.createMovie(CenterToRight));
     CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToCenter)));
-    CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftLeftToLeft))); 
+    CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftLeftToLeft)));
     CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToRightRight)));
-    CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutRightRight))); 
+    CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutRightRight)));
 
     emit centerIndexChanged(i);
 }
@@ -1037,7 +1040,7 @@
 
 /*!
   Inserts filmstrip at index position i.
-  If i is 0, the filmstrip is prepended to the film list. 
+  If i is 0, the filmstrip is prepended to the film list.
   If i is size(), the value is appended to the film list.
 */
 void LinearFlowSnippet::insert(int i, const QImage& image, const QString& title)
@@ -1048,7 +1051,7 @@
     Filmstrip* filmstrip = new Filmstrip(image, d);
     filmstrip->setName(title);
     d->m_films.insert(i, filmstrip);
-    
+
     if (isVisible()) {
         Q_ASSERT(d->m_movieTimer.state() != QTimeLine::Running);
         if (i == d->m_centerIndex + 1)  // insert on right
@@ -1072,7 +1075,7 @@
         if (d->m_movieTimer.state() == QTimeLine::Running)
             return;
 
-        d->m_films[d->m_centerIndex]->updateMovie(d->m_movieFactory.createMovie(FadeOut)); // move center slide to left            
+        d->m_films[d->m_centerIndex]->updateMovie(d->m_movieFactory.createMovie(FadeOut)); // move center slide to left
         CALL_ON_PREV_FILM_STRIP(freeze()); // no movement for left slide
         CALL_ON_NEXT_FILM_STRIP(freeze()); // no movement for right slide
 
@@ -1091,7 +1094,7 @@
 /*!
   Return the index of the current center slide
 */
-int LinearFlowSnippet::centerIndex() const 
+int LinearFlowSnippet::centerIndex() const
 {
     Q_ASSERT(d);
     return d->m_centerIndex;
@@ -1099,7 +1102,7 @@
 
 /*! Clear all slides
 */
-void LinearFlowSnippet::clear() 
+void LinearFlowSnippet::clear()
 {
     Q_ASSERT(d);
     d->clear();
@@ -1111,7 +1114,7 @@
     d->m_bgColor = c;
 }
 
-int LinearFlowSnippet::slideCount() const 
+int LinearFlowSnippet::slideCount() const
 {
     return d ? d->m_films.size() : 0;
 }
@@ -1125,14 +1128,14 @@
 }
 
 //! return true if slide animation is ongoing
-bool LinearFlowSnippet::slideAnimationOngoing() const 
+bool LinearFlowSnippet::slideAnimationOngoing() const
 {
     Q_ASSERT(d);
     return d->m_movieTimer.state() == QTimeLine::Running;
 }
 
 //! return center slide's rect
-QRect LinearFlowSnippet::centralRect() const 
+QRect LinearFlowSnippet::centralRect() const
 {
     Q_ASSERT(d);
     int cw = d->m_centerWindowSize.width();
@@ -1148,9 +1151,9 @@
 //! prepare start-animation
 void LinearFlowSnippet::prepareStartAnimation()
 {
-    CALL_ON_PREV_PREV_PREV_FILM_STRIP(updateMovie(NULL)); 
-    CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(updateMovie(NULL)); 
-    CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinLeftLeft))); 
+    CALL_ON_PREV_PREV_PREV_FILM_STRIP(updateMovie(NULL));
+    CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(updateMovie(NULL));
+    CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinLeftLeft)));
     CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToCenter)));
     CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinRightRight)));
     CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftLeftToLeft)));
@@ -1172,13 +1175,13 @@
     Q_ASSERT(d);
     if (d->m_movieTimer.state() == QTimeLine::Running)
         return;
-    
+
     CALL_ON_PREV_PREV_PREV_FILM_STRIP(freeze());
     CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(freeze());
     CALL_ON_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutLeftLeft)));
     CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToLeftLeft)));
     CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(CenterToLeft)));
-    CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToRightRight))); 
+    CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToRightRight)));
     CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutRightRight)));
 
     QObject::disconnect(&d->m_movieTimer, SIGNAL(finished()), this, SLOT(stopMovie()));
@@ -1207,7 +1210,7 @@
     SAFE_DELETE(d->m_titleBuffer);
     int w = s.width();
     int h = s.height() * FILM_HEIGHT;
-    
+
     qreal ix;
     qreal ratio = ((qreal) w) / h;
 
@@ -1229,8 +1232,8 @@
     d->m_centerWindowSize = QSize(WIDTH * L_CENTER_WIDTH_P_C, h * L_CENTER_HEIGHT_P_C);
     d->m_centerTopSpace = h * L_CENTER_TOP_SPACE_P_C;
     d->m_sideTopSpace = h * L_SIDE_TOP_SPACE_P_C ;
-    
-    if( m_displayMode == "Portrait") {
+
+    if ( m_displayMode == "Portrait") {
         d->m_space = ((qreal)w - ( P_MAX_SLIDE - 1) * (qreal)d->m_sideWindowSize.width() -  (qreal)d->m_centerWindowSize.width())/(P_MAX_SLIDE + 1);
     }
     else {
@@ -1245,27 +1248,27 @@
     }
     d->m_movieFactory.updateAllMovie();
 
-    if(d->m_centerIndex != -1)  {
-        if(m_displayMode == "Portrait")
+    if (d->m_centerIndex != -1)  {
+        if (m_displayMode == "Portrait")
             setCenterIndex(d->m_centerIndex - 1);
         else
             setCenterIndex(d->m_centerIndex + 1);
     }
 }
 
-//! insert a new filmstrip on current's right 
+//! insert a new filmstrip on current's right
 void LinearFlowSnippet::showInsertOnRight()
 {
     Q_ASSERT(d);
     d->m_incIndex = 1;
     d->m_films[d->m_centerIndex]->updateMovie(d->m_movieFactory.createMovie(CenterToLeft)); // move center slide to left
-        
+
     CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutLeft))); // move left slide out
     CALL_ON_NEXT_NEXT_FILM_STRIP(freeze());// no movement for right slide
     d->m_movieTimer.start();
 }
 
-//! insert a new filmstrip on current's right 
+//! insert a new filmstrip on current's right
 void LinearFlowSnippet::showInsertOnLeft()
 {
     //FIXME
@@ -1273,11 +1276,11 @@
     qDebug() << "showInsertOnLeft is not implemented.";
 }
 
-//! Show the previous item 
+//! Show the previous item
 void LinearFlowSnippet::showPrevious()
 {
     Q_ASSERT(d);
-   
+
     d->m_incIndex = -1;
     CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(CenterToRight)));
     CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToCenter)));
@@ -1287,7 +1290,7 @@
 
     CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakoutRightRight)));
     CALL_ON_PREV_PREV_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinLeftLeft)));
-    
+
     d->m_movieTimer.start();
 }
 
@@ -1295,7 +1298,7 @@
 void LinearFlowSnippet::showNext()
 {
     Q_ASSERT(d);
-   
+
     d->m_incIndex = 1;
     CALL_ON_CENTER_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(CenterToLeft)));
     CALL_ON_PREV_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(LeftToLeftLeft)));
@@ -1309,10 +1312,10 @@
 
 void LinearFlowSnippet::scroll()
 {
-    if(d->m_movieTimer.state() == QTimeLine::Running)
+    if (d->m_movieTimer.state() == QTimeLine::Running)
         return;
-    
-    if(d->m_lastMoveEventPos.x() < (size().width() - d->m_centerWindowSize.width())/ 2) {
+
+    if (d->m_lastMoveEventPos.x() < (size().width() - d->m_centerWindowSize.width())/ 2) {
         showPrevious();
     }
     else if (d->m_lastMoveEventPos.x() > (size().width() + d->m_centerWindowSize.width())/ 2) {
@@ -1348,10 +1351,10 @@
 
     if (newIndex >= 0 && newIndex < d->m_films.size())
         setCenterIndex(newIndex);
-    
+
     update();
 
-    if(m_countFlicks) {
+    if (m_countFlicks) {
         startFlickScroll();
     }
 }
@@ -1360,8 +1363,8 @@
 {
     Filmstrip* f = d->m_films.at(d->m_centerIndex);
 
-    if (d->m_centerIndex == 0) { 
-        d->m_incIndex = 0;      
+    if (d->m_centerIndex == 0) {
+        d->m_incIndex = 0;
         CALL_ON_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(RightToCenter)));
         CALL_ON_NEXT_NEXT_FILM_STRIP(updateMovie(d->m_movieFactory.createMovie(BreakinRight)));
         d->m_films.removeAt(d->m_centerIndex);
@@ -1387,7 +1390,7 @@
 {
     if (!d->m_closeIcon)
         return false;
-    
+
     int iw = d->m_closeIcon->size().width() / 2;
     QPoint p = d->m_lastMoveEventPos - (d->m_closeIconPos + QPoint(iw, iw));
     return (p.manhattanLength() < iw + CLOSE_ICON_ADJUST_SIZE) ? true : false;
@@ -1407,18 +1410,18 @@
 
 void LinearFlowSnippet::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
 {
-    //qDebug() << "!!!!!!!!!!!!!!!!move event" << this->size();   
-    if( qAbs(qAbs(event->pos().toPoint().x()) - qAbs(d->m_lastMoveEventPos.x())) > 20)
+    //qDebug() << "!!!!!!!!!!!!!!!!move event" << this->size();
+    if ( qAbs(qAbs(event->pos().toPoint().x()) - qAbs(d->m_lastMoveEventPos.x())) > 20)
     {
-        if( event->pos().toPoint().x() < event->lastPos().toPoint().x())
+        if ( event->pos().toPoint().x() < event->lastPos().toPoint().x())
             showNext();
         else
             showPrevious();
         d->m_lastMoveEventPos = event->pos().toPoint();
 
         QTime now(QTime::currentTime());
-   	    m_lastMoveEventTime.setHMS(now.hour(),now.minute(), now.second(), now.msec());
-    
+        m_lastMoveEventTime.setHMS(now.hour(),now.minute(), now.second(), now.msec());
+
         DragPoint dragPoint;
         dragPoint.iPoint = d->m_lastMoveEventPos;
         dragPoint.iTime = QTime::currentTime();
@@ -1426,25 +1429,25 @@
 
         while (m_dragPoints.size() > 4)
             m_dragPoints.removeFirst();
-        
+
         m_scrolled= true;
     }
 }
 
-bool LinearFlowSnippet::isFlick() 
+bool LinearFlowSnippet::isFlick()
 {
     bool flick = false;
     QPoint moveSpeed = speed();
     int xSpeed = moveSpeed.x();
     int ySpeed = moveSpeed.y();
-     
-    flick = (qAbs(xSpeed) > THRESHOLD_FLICK_SPEED || 
+
+    flick = (qAbs(xSpeed) > THRESHOLD_FLICK_SPEED ||
              qAbs(ySpeed) > THRESHOLD_FLICK_SPEED);
- 
+
     return flick;
 }
 
-QPoint LinearFlowSnippet::speed() 
+QPoint LinearFlowSnippet::speed()
 {
     // Speed is only evaluated at the end of the swipe
     QPoint dragSpeed(0,0);
@@ -1469,7 +1472,7 @@
 
 qreal LinearFlowSnippet::dragTime() const
 {
-    if(m_dragPoints.isEmpty())
+    if (m_dragPoints.isEmpty())
         return 0.0;
     else
         return  m_dragPoints[0].iTime.msecsTo(m_dragPoints[m_dragPoints.size()-1].iTime);
@@ -1492,7 +1495,7 @@
 void LinearFlowSnippet::mousePressEvent(QGraphicsSceneMouseEvent* event)
 {
     emit mouseEvent( event->type());
-    if(m_countFlicks)
+    if (m_countFlicks)
         m_countFlicks = 0;
     d->m_movieTimer.setDuration(ANIMATION_DURATION);
     m_dragPoints.clear();
@@ -1500,16 +1503,16 @@
     dragPoint.iPoint = event->pos().toPoint();
     dragPoint.iTime = QTime::currentTime();
     m_dragPoints.append(dragPoint);
-    m_scrolled = false; 
+    m_scrolled = false;
     m_lastMoveEventTime.setHMS(0,0,0,0);
     d->m_lastMoveEventPos = event->pos().toPoint();
 }
 
 void LinearFlowSnippet::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
-{    
+{
     emit mouseEvent( event->type());
     //check whether strip is scrolled
-    if(!m_scrolled) {
+    if (!m_scrolled) {
         QPoint releasePoint = event->pos().toPoint();
 
         int cw = d->m_centerWindowSize.width();
@@ -1527,15 +1530,15 @@
         int pageIndex;
 
         //check for leftleft film
-        if((releasePoint.x() >= leftLeftPageX) && (releasePoint.x() <= (leftLeftPageX + sw)) && 
+        if ((releasePoint.x() >= leftLeftPageX) && (releasePoint.x() <= (leftLeftPageX + sw)) &&
             (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) {
 
             pageIndex = d->m_centerIndex - 2;
 
         }
-    
+
         //check for left film
-        else if((releasePoint.x() >= leftPageX) && (releasePoint.x() <= (leftPageX + sw)) && 
+        else if ((releasePoint.x() >= leftPageX) && (releasePoint.x() <= (leftPageX + sw)) &&
                     (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) {
 
             pageIndex = d->m_centerIndex - 1;
@@ -1543,19 +1546,19 @@
         }
 
         //check for center film
-        else if((releasePoint.x() >= centerPageX) && (releasePoint.x() <= (centerPageX + cw)) && 
+        else if ((releasePoint.x() >= centerPageX) && (releasePoint.x() <= (centerPageX + cw)) &&
                     (releasePoint.y() >= (d->m_centerTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_centerTopSpace + ch + d->m_widgetSize.height() * TITLE_HEIGHT))) {
             pageIndex = d->m_centerIndex;
         }
 
         //check for right film
-        else if((releasePoint.x() >= rightPageX) && (releasePoint.x() <= (rightPageX + sw)) && 
+        else if ((releasePoint.x() >= rightPageX) && (releasePoint.x() <= (rightPageX + sw)) &&
                     (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) {
             pageIndex = d->m_centerIndex + 1;
         }
 
         //check for right right film
-        else if((releasePoint.x() >= rightRightPageX) && (releasePoint.x() <= (rightRightPageX + sw)) && 
+        else if ((releasePoint.x() >= rightRightPageX) && (releasePoint.x() <= (rightRightPageX + sw)) &&
                     (releasePoint.y() >= (d->m_sideTopSpace+ d->m_widgetSize.height() * TITLE_HEIGHT)) && (releasePoint.y() <= (d->m_sideTopSpace + sh + d->m_widgetSize.height() * TITLE_HEIGHT))) {
             pageIndex = d->m_centerIndex + 2;
         }
@@ -1564,14 +1567,14 @@
         else  {
             return;
         }
-        if( pageIndex < 0)
+        if ( pageIndex < 0)
             pageIndex = d->m_films.size() + pageIndex;
         else if (pageIndex >= d->m_films.size())
             pageIndex = (pageIndex) % d->m_films.size();
 
         emit ok(pageIndex);
     }
- 
+
     else  {
         int msecs = 0;
         if (!m_lastMoveEventTime.isNull()) {
@@ -1580,8 +1583,8 @@
             msecs = m_lastMoveEventTime.msecsTo(now);
             m_lastMoveEventTime.setHMS(0,0,0,0);
         }
-        if((msecs>0) && (msecs < THRESHOLD_FLICK_TIME)) {
-            if( isFlick()) {
+        if ((msecs>0) && (msecs < THRESHOLD_FLICK_TIME)) {
+            if ( isFlick()) {
                 m_countFlicks = qBound (-MAX_FLICK_SPEED,speed().x(),+MAX_FLICK_SPEED)/((m_displayMode == "portrait") ? 200 : 100);
                 startFlickScroll();
             }
@@ -1590,9 +1593,9 @@
 }
 
 void LinearFlowSnippet::startFlickScroll()
-{ 
+{
     d->m_movieTimer.setDuration(qAbs(ANIMATION_DURATION / m_countFlicks));
-    if(m_countFlicks < 0) {
+    if (m_countFlicks < 0) {
         showNext();
         m_countFlicks++;
     }
@@ -1613,7 +1616,7 @@
     d->m_buffer->fill(d->m_bgColor);
 
     if (d->m_films.size() > 0 && d->m_centerIndex != INVALID_INDEX) {
-        
+
         QPainter bufPaint(d->m_buffer);
         // draw center film strip
         CALL_ON_CENTER_FILM_STRIP(paint(&bufPaint));
@@ -1632,7 +1635,7 @@
 
         // draw right right film strip
         CALL_ON_NEXT_NEXT_FILM_STRIP(paint(&bufPaint));
-        
+
         // draw right right film strip
         CALL_ON_NEXT_NEXT_NEXT_FILM_STRIP(paint(&bufPaint));
 
@@ -1644,7 +1647,7 @@
                 painter->drawImage(d->m_closeIconPos, *(d->m_closeIcon));
         }
     }
-    else 
+    else
         painter->drawImage(QPoint(0,d->m_widgetSize.height() * TITLE_HEIGHT), *(d->m_buffer));
 }