radioapp/radiouiengine/inc/radiohistorymodel.h
branchRCL_3
changeset 20 93c594350b9a
parent 19 cce62ebc198e
equal deleted inserted replaced
19:cce62ebc198e 20:93c594350b9a
     1 /*
       
     2 * Copyright (c) 2009 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 #ifndef RADIOHISTORYMODEL_H
       
    19 #define RADIOHISTORYMODEL_H
       
    20 
       
    21 // System includes
       
    22 #include <QAbstractListModel>
       
    23 #include <QScopedPointer>
       
    24 
       
    25 // User includes
       
    26 #include "radiouiengineexport.h"
       
    27 #include "radiohistoryitem.h"
       
    28 
       
    29 // Forward declarations
       
    30 class RadioHistoryModelPrivate;
       
    31 class RadioUiEngine;
       
    32 class RadioStation;
       
    33 class QIcon;
       
    34 class RadioHistoryItem;
       
    35 
       
    36 class UI_ENGINE_DLL_EXPORT RadioHistoryModel : public QAbstractListModel
       
    37 {
       
    38     Q_OBJECT
       
    39     Q_DECLARE_PRIVATE_D( d_ptr.data(), RadioHistoryModel )
       
    40     Q_DISABLE_COPY( RadioHistoryModel )
       
    41 
       
    42     friend class RadioUiEngine;
       
    43     friend class RadioUiEnginePrivate;
       
    44     friend class RadioStationModelPrivate;
       
    45 
       
    46     friend class RadioHistoryView;  // TEMPORARY TEST CODE, REMOVE
       
    47 
       
    48 public:
       
    49 
       
    50     ~RadioHistoryModel();
       
    51 
       
    52     enum HistoryRole
       
    53     {
       
    54         HistoryItemRole = Qt::UserRole + 100,
       
    55         SetFavoriteRole
       
    56     };
       
    57 
       
    58 // from base class QAbstractListModel
       
    59 
       
    60     int rowCount( const QModelIndex& parent = QModelIndex() ) const;
       
    61     QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
       
    62 
       
    63 // New functions
       
    64 
       
    65     /*!
       
    66      * Sets the icons to be used in the list
       
    67      */
       
    68     void setIcons( const QIcon& nonTaggedIcon, const QIcon& taggedIcon );
       
    69 
       
    70     bool isCurrentSongRecognized() const;
       
    71     void setShowDetails( bool showDetails );
       
    72     void setShowTagged( bool showTagged );
       
    73     void toggleTagging( const RadioHistoryItem& item, const int row );
       
    74 
       
    75     RadioHistoryItem itemAtIndex( const QModelIndex& index ) const;
       
    76 
       
    77     void removeAll( bool removeTagged );
       
    78 
       
    79 signals:
       
    80 
       
    81     void itemAdded();
       
    82     void currentSongReset();
       
    83 
       
    84 public slots:
       
    85 
       
    86     void resetCurrentSong();
       
    87 
       
    88 private:
       
    89 
       
    90     explicit RadioHistoryModel( RadioUiEngine& uiEngine );
       
    91 
       
    92     void addItem( const QString& artist, const QString& title, const RadioStation& station );
       
    93 
       
    94     void clearRadioTextPlus();
       
    95     void addRadioTextPlus( int rtClass, const QString& rtItem, const RadioStation& station );
       
    96 
       
    97     void reportChangedData( int start, int end = -1 );
       
    98 
       
    99     void emitItemAdded();
       
   100 
       
   101 private: // data
       
   102 
       
   103     /**
       
   104      * Unmodifiable pointer to the private implementation
       
   105      */
       
   106     const QScopedPointer<RadioHistoryModelPrivate> d_ptr;
       
   107 
       
   108 };
       
   109 
       
   110 #endif // RADIOHISTORYMODEL_H