radioapp/radiowidgets/inc/radiocarouselitem.h
author hgs
Fri, 25 Jun 2010 19:09:05 +0300
changeset 34 bc10a61bd7d3
parent 28 075425b8d9a4
child 38 f8c3d4e6102c
permissions -rw-r--r--
201025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#ifndef RADIOCAROUSELITEM_H
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#define RADIOCAROUSELITEM_H
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
// System includes
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <HbWidget>
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <QScopedPointer>
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
// User includes
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
// Forward declarations
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
class RadioStation;
34
hgs
parents: 28
diff changeset
    29
class HbIconItem;
hgs
parents: 28
diff changeset
    30
class HbTextItem;
hgs
parents: 28
diff changeset
    31
class HbRichTextItem;
hgs
parents: 28
diff changeset
    32
class HbTouchArea;
hgs
parents: 28
diff changeset
    33
class RadioCarouselItemObserver;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
// Class declaration
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
class RadioCarouselItem : public HbWidget
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
{
34
hgs
parents: 28
diff changeset
    38
    Q_OBJECT
hgs
parents: 28
diff changeset
    39
    Q_PROPERTY(Appearance appearance READ appearance WRITE setAppearance)
hgs
parents: 28
diff changeset
    40
    Q_ENUMS(Appearance)
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
34
hgs
parents: 28
diff changeset
    42
    friend class RadioStationCarousel;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
public:
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
34
hgs
parents: 28
diff changeset
    46
    enum ItemFlag
hgs
parents: 28
diff changeset
    47
    {
hgs
parents: 28
diff changeset
    48
        NameVisible         = 1 << 0,
hgs
parents: 28
diff changeset
    49
        FavoriteVisible     = 1 << 1,
hgs
parents: 28
diff changeset
    50
        FavoriteTouchable   = 1 << 2,
hgs
parents: 28
diff changeset
    51
        GenreVisible        = 1 << 3,
hgs
parents: 28
diff changeset
    52
        RadiotextVisible    = 1 << 4,
hgs
parents: 28
diff changeset
    53
        RadiotextTouchable  = 1 << 5,
hgs
parents: 28
diff changeset
    54
        UrlVisible          = 1 << 6,
hgs
parents: 28
diff changeset
    55
        UrlTouchable        = 1 << 7,
hgs
parents: 28
diff changeset
    56
hgs
parents: 28
diff changeset
    57
        LastFlagMarker      = 1 << 8,       // Keep this as the last flag
hgs
parents: 28
diff changeset
    58
hgs
parents: 28
diff changeset
    59
        DefaultFlags = NameVisible | FavoriteVisible | FavoriteTouchable | GenreVisible | RadiotextVisible,
hgs
parents: 28
diff changeset
    60
        ManualSeekFlags = NameVisible
hgs
parents: 28
diff changeset
    61
    };
hgs
parents: 28
diff changeset
    62
    Q_DECLARE_FLAGS( CarouselItemFlags, ItemFlag )
hgs
parents: 28
diff changeset
    63
hgs
parents: 28
diff changeset
    64
    enum Appearance { Default, Full, ManualSeek };
hgs
parents: 28
diff changeset
    65
hgs
parents: 28
diff changeset
    66
    RadioCarouselItem( RadioCarouselItemObserver& observer, QGraphicsItem* parent, bool registerCss = false );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    ~RadioCarouselItem();
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
// New functions
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
34
hgs
parents: 28
diff changeset
    71
    void setAppearance( Appearance appearance );
hgs
parents: 28
diff changeset
    72
    Appearance appearance() const;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
34
hgs
parents: 28
diff changeset
    74
    void setSeekLayout( bool seekLayout );
hgs
parents: 28
diff changeset
    75
hgs
parents: 28
diff changeset
    76
    void setStation( const RadioStation& station );
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
    uint frequency() const;
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    void update( const RadioStation* station = NULL );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
    void setFrequency( uint frequency );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
    void cleanRdsData();
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    void setRadioText( const QString& text );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
    enum ItemVisibility{ AllVisible, AllHidden, IconVisible };
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
    void setItemVisibility( ItemVisibility visibility );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    void setIconOpacity( qreal opacity );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
34
hgs
parents: 28
diff changeset
    89
    void createPrimitives();
hgs
parents: 28
diff changeset
    90
hgs
parents: 28
diff changeset
    91
    void drawOffScreen( QPainter& painter );
hgs
parents: 28
diff changeset
    92
hgs
parents: 28
diff changeset
    93
public slots:
hgs
parents: 28
diff changeset
    94
hgs
parents: 28
diff changeset
    95
    void updatePrimitives();
hgs
parents: 28
diff changeset
    96
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
private:
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
34
hgs
parents: 28
diff changeset
    99
    void gestureEvent( QGestureEvent* event );
hgs
parents: 28
diff changeset
   100
hgs
parents: 28
diff changeset
   101
    void setFlags( CarouselItemFlags flags );
hgs
parents: 28
diff changeset
   102
    void clearFlags( CarouselItemFlags flags );
hgs
parents: 28
diff changeset
   103
hgs
parents: 28
diff changeset
   104
    void updateVisibilities();
hgs
parents: 28
diff changeset
   105
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
    void updateFavoriteIcon( bool isFavorite );
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
34
hgs
parents: 28
diff changeset
   108
    void updateLayout();
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
private: // data
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
34
hgs
parents: 28
diff changeset
   112
    RadioCarouselItemObserver&          mObserver;
hgs
parents: 28
diff changeset
   113
hgs
parents: 28
diff changeset
   114
    QScopedPointer<RadioStation>        mStation;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
34
hgs
parents: 28
diff changeset
   116
    HbIconItem*                         mFavoriteItem;
hgs
parents: 28
diff changeset
   117
    HbTextItem*                         mGenreItem;
hgs
parents: 28
diff changeset
   118
    HbTouchArea*                        mFavoriteTouchArea;
hgs
parents: 28
diff changeset
   119
    HbTextItem*                         mNameItem;
hgs
parents: 28
diff changeset
   120
    HbRichTextItem*                     mRadiotextItem;
hgs
parents: 28
diff changeset
   121
    HbTextItem*                         mUrlItem;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
34
hgs
parents: 28
diff changeset
   123
    Appearance                          mAppearance;
hgs
parents: 28
diff changeset
   124
    bool                                mOwnsCss;
hgs
parents: 28
diff changeset
   125
    CarouselItemFlags                   mFlags;
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
};
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
34
hgs
parents: 28
diff changeset
   129
Q_DECLARE_OPERATORS_FOR_FLAGS( RadioCarouselItem::CarouselItemFlags )
hgs
parents: 28
diff changeset
   130
28
075425b8d9a4 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
#endif // RADIOCAROUSELITEM_H