|
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 |
|
24 // User includes |
|
25 #include "radiouiengineexport.h" |
|
26 #include "radiohistoryitem.h" |
|
27 |
|
28 // Forward declarations |
|
29 class RadioHistoryModelPrivate; |
|
30 class RadioUiEngine; |
|
31 class RadioStation; |
|
32 |
|
33 class UI_ENGINE_DLL_EXPORT RadioHistoryModel : public QAbstractListModel |
|
34 { |
|
35 Q_OBJECT |
|
36 Q_DECLARE_PRIVATE_D( d_ptr, RadioHistoryModel ) |
|
37 Q_DISABLE_COPY( RadioHistoryModel ) |
|
38 |
|
39 friend class RadioUiEngine; |
|
40 friend class RadioStationModelPrivate; |
|
41 friend class TestRadioUiEngine; |
|
42 |
|
43 public: |
|
44 |
|
45 enum HistoryRole |
|
46 { |
|
47 HistoryItemRole = Qt::UserRole + 100, |
|
48 SetFavoriteRole |
|
49 }; |
|
50 |
|
51 // from base class QAbstractListModel |
|
52 |
|
53 Qt::ItemFlags flags ( const QModelIndex& index ) const; |
|
54 int rowCount( const QModelIndex& parent = QModelIndex() ) const; |
|
55 QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; |
|
56 bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ); |
|
57 |
|
58 // New functions |
|
59 |
|
60 bool isCurrentSongRecognized() const; |
|
61 void setShowDetails( bool showDetails ); |
|
62 |
|
63 signals: |
|
64 |
|
65 void itemAdded(); |
|
66 void currentSongReset(); |
|
67 |
|
68 public slots: |
|
69 |
|
70 void resetCurrentSong(); |
|
71 void setFavorite(); |
|
72 void removeAll(); |
|
73 |
|
74 private: |
|
75 |
|
76 explicit RadioHistoryModel( RadioUiEngine& uiEngine ); |
|
77 |
|
78 ~RadioHistoryModel(); |
|
79 |
|
80 void addItem( const QString& artist, const QString& title, const RadioStation& station ); |
|
81 |
|
82 void clearRadioTextPlus(); |
|
83 void addRadioTextPlus( int rtClass, const QString& rtItem, const RadioStation& station ); |
|
84 |
|
85 int findItem( const QString& artist, const QString& title, RadioHistoryItem& item ); |
|
86 |
|
87 void updateItem( int index, const RadioHistoryItem& item, bool prepend = false ); |
|
88 |
|
89 private: // data |
|
90 |
|
91 /** |
|
92 * Unmodifiable pointer to the private implementation |
|
93 */ |
|
94 RadioHistoryModelPrivate* const d_ptr; |
|
95 |
|
96 }; |
|
97 |
|
98 #endif // RADIOHISTORYMODEL_H |