ginebra/graphicsitemflipper.h
changeset 5 0f2326c2a325
parent 1 b0dd75e285d2
child 6 1c3b8676e58c
equal deleted inserted replaced
1:b0dd75e285d2 5:0f2326c2a325
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     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 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef GRAPHICSITEMFLIPPER_H
       
    20 #define GRAPHICSITEMFLIPPER_H
       
    21 
       
    22 #include <QtGui>
       
    23 
       
    24 // Implements a "flipping" animation between two QGraphicsItems.  The source
       
    25 // item should be hidden after start() is called and the target item should be 
       
    26 // shown in response to the finished() signal.  
       
    27 class GraphicsItemFlipper : public QObject {
       
    28   Q_OBJECT
       
    29 
       
    30 public:
       
    31     GraphicsItemFlipper(QGraphicsItem *parent, QGraphicsScene *scene, int duration = 500, uint updateInterval = 10, int zValue = 0);
       
    32     ~GraphicsItemFlipper();
       
    33 
       
    34     void start(QGraphicsView *view, QGraphicsWidget *sourceWidget, QGraphicsWidget *targetWidget, bool forward = true);
       
    35 
       
    36 signals:
       
    37     void starting();
       
    38     void finished();
       
    39 
       
    40 protected:
       
    41     void getPixmaps(QGraphicsView *view, QGraphicsWidget *sourceWidget, QGraphicsWidget *targetWidget);
       
    42 
       
    43 protected slots:
       
    44     void updateFlipStep(qreal value);
       
    45     void onFinished();
       
    46 
       
    47 protected:
       
    48     QGraphicsPixmapItem *m_pixmapItem;
       
    49     QPixmap *m_sourcePixmap;
       
    50     QPixmap *m_targetPixmap;
       
    51     QRectF m_sourceRect;
       
    52     QRectF m_targetRect;
       
    53     QTimeLine m_timeLine;
       
    54 };
       
    55 
       
    56 #endif // GRAPHICSITEMFLIPPER_H