ginebra2/linearflowsnippet.h
branchGCC_SURGE
changeset 8 2e16851ffecd
parent 5 0f2326c2a325
equal deleted inserted replaced
2:bf4420e9fa4d 8:2e16851ffecd
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
     4 *
     9 * Initial Contributors:
     5 * This program is free software: you can redistribute it and/or modify
    10 * Nokia Corporation - initial contribution.
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
    11 *
     8 *
    12 * Contributors:
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
    13 *
    13 *
    14 * Description: 
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not,
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
    15 *
    19 *
    16 */
    20 */
    17 
       
    18 
    21 
    19 #ifndef LINEARFLOWSNIPPET_H
    22 #ifndef LINEARFLOWSNIPPET_H
    20 #define LINEARFLOWSNIPPET_H
    23 #define LINEARFLOWSNIPPET_H
    21 
    24 
    22 #include <QTime>
    25 #include <QTime>
    23 #include <QImage>
    26 #include <QImage>
    24 #include <QWidget>
    27 #include <QWidget>
    25 #include <QGraphicsWidget>
    28 #include <QGraphicsWidget>
    26 #include <QGraphicsItem>
    29 #include <QGraphicsItem>
       
    30 #include "ChromeItem.h"
    27 
    31 
    28 class DragPoint
    32 class DragPoint
    29     {
    33     {
    30     public:
    34     public:
    31         QPoint iPoint;
    35         QPoint iPoint;
    38 class FilmstripFlowPrivate;
    42 class FilmstripFlowPrivate;
    39 class FilmstripMovieFactory;
    43 class FilmstripMovieFactory;
    40 
    44 
    41 /*!
    45 /*!
    42   Class GraphicsFilmstripFlow
    46   Class GraphicsFilmstripFlow
    43  */ 
    47  */
    44 class LinearFlowSnippet: public QGraphicsWidget
    48 class LinearFlowSnippet: public ChromeItem
    45 {
    49 {
    46 Q_OBJECT
    50 Q_OBJECT
    47 friend class Filmstrip;
    51 friend class Filmstrip;
    48 friend class FilmstripMovieFactory;
    52 friend class FilmstripMovieFactory;
    49 
    53 
    50 public:
    54 public:
    51     /*!
    55     /*!
    52     Creates a new FilmstripFlow widget.
    56     Creates a new FilmstripFlow widget.
    53     */  
    57     */
    54     LinearFlowSnippet(QGraphicsWidget* parent = 0);
    58     LinearFlowSnippet(QGraphicsWidget* parent = 0);
    55 
    59 
    56     /*!
    60     /*!
    57     Destroys the widget.
    61     Destroys the widget.
    58     */
    62     */
    63     */
    67     */
    64     void init(QString displayMode, QString titleName);
    68     void init(QString displayMode, QString titleName);
    65 
    69 
    66     //! Clear all slides
    70     //! Clear all slides
    67     void clear();
    71     void clear();
    68     
    72 
    69     //! Add a slide to the flow
    73     //! Add a slide to the flow
    70     void addSlide(const QImage& image);
    74     void addSlide(const QImage& image);
    71 
    75 
    72     //! Add a slide to the flow with title
    76     //! Add a slide to the flow with title
    73     void addSlide(const QImage& image, const QString& title);
    77     void addSlide(const QImage& image, const QString& title);
    74 
    78 
    75     //! Set the center of the flow
    79     //! Set the center of the flow
    76     void setCenterIndex(int i);
    80     void setCenterIndex(int i);
    77 
    81 
    78     //! Show the previous item 
    82     //! Show the previous item
    79     void showPrevious();
    83     void showPrevious();
    80 
    84 
    81     //! Show the next item
    85     //! Show the next item
    82     void showNext();
    86     void showNext();
    83 
    87 
    97     QRect centralRect() const;
   101     QRect centralRect() const;
    98 
   102 
    99     //! show the ith slide
   103     //! show the ith slide
   100     void showSlide(int) {}
   104     void showSlide(int) {}
   101 
   105 
   102     //! inserts filmstrip at index position i. 
   106     //! inserts filmstrip at index position i.
   103     void insert(int i, const QImage& image, const QString& title);
   107     void insert(int i, const QImage& image, const QString& title);
   104 
   108 
   105     //! removes filmstrip at index position i.
   109     //! removes filmstrip at index position i.
   106     void removeAt (int i);
   110     void removeAt (int i);
   107 
   111 
   114     //! prepare start-animation
   118     //! prepare start-animation
   115     void prepareStartAnimation();
   119     void prepareStartAnimation();
   116 
   120 
   117     //! run start-animation
   121     //! run start-animation
   118     void runStartAnimation();
   122     void runStartAnimation();
   119     
   123 
   120     //! run end-animation
   124     //! run end-animation
   121     void runEndAnimation();
   125     void runEndAnimation();
   122 
   126 
   123     bool isFlick();
   127     bool isFlick();
   124     
   128 
   125     QPoint speed();
   129     QPoint speed();
   126     
   130 
   127     QPoint currentPos();
   131     QPoint currentPos();
   128     
   132 
   129     QPoint previousPos();
   133     QPoint previousPos();
   130     
   134 
   131     qreal dragTime() const;
   135     qreal dragTime() const;
   132 
   136 
   133     void startFlickScroll();
   137     void startFlickScroll();
   134 
   138 
   135 signals:
   139 signals:
   136     void removed(int index);
   140     void removed(int index);
   137     void endAnimationCplt();
   141     void endAnimationCplt();
   138     void centerIndexChanged(int index);
   142     void centerIndexChanged(int index);
   139     void ok(int index);
   143     void ok(int index);
   140     void cancel();
   144     void cancel();
   141     void mouseEvent(QEvent::Type type);
       
   142 protected:
   145 protected:
   143     void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); 
   146     void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
   144     void resizeEvent(QGraphicsSceneResizeEvent* event); 
   147     void resizeEvent(QGraphicsSceneResizeEvent* event);
   145     void moveEvent(QGraphicsSceneMoveEvent* event);
   148     void moveEvent(QGraphicsSceneMoveEvent* event);
   146     void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
   149     void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
   147     void mousePressEvent(QGraphicsSceneMouseEvent* event);
   150     void mousePressEvent(QGraphicsSceneMouseEvent* event);
   148     void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
   151     void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
   149     void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
   152     void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
   150 
   153 
   151 private slots:
   154 private slots:
   152     void stopMovie();
   155     void stopMovie();
   153     void playMovie(int frame);
   156     void playMovie(int frame);
   154     void closeAnimation();
   157     void closeAnimation();
   155     
   158 
   156 private:
   159 private:
   157     void scroll();
   160     void scroll();
   158     void adjustFilmstripSize(QSize& s);
   161     void adjustFilmstripSize(QSize& s);
   159     void showInsertOnRight();
   162     void showInsertOnRight();
   160     void showInsertOnLeft();
   163     void showInsertOnLeft();