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 RADIOSTATIONFILTERMODEL_H_ |
|
19 #define RADIOSTATIONFILTERMODEL_H_ |
|
20 |
|
21 // System includes |
|
22 #include <QSortFilterProxyModel> |
|
23 #include <QMap> |
|
24 |
|
25 // User includes |
|
26 #include "radiouiengineexport.h" |
|
27 #include "radiostation.h" |
|
28 |
|
29 // Forward declarations |
|
30 class RadioUiEngine; |
|
31 |
|
32 class UI_ENGINE_DLL_EXPORT RadioStationFilterModel : public QSortFilterProxyModel |
|
33 { |
|
34 public: |
|
35 |
|
36 RadioStationFilterModel( RadioUiEngine& uiEngine, QObject* parent = 0 ); |
|
37 |
|
38 ~RadioStationFilterModel(); |
|
39 |
|
40 // from QAbstractItemModel |
|
41 |
|
42 int rowCount( const QModelIndex& parent = QModelIndex() ) const; |
|
43 QModelIndex index( int row, int column, |
|
44 const QModelIndex &parent = QModelIndex() ) const; |
|
45 QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; |
|
46 |
|
47 // New functions |
|
48 |
|
49 void setTypeFilter( RadioStation::Type filter ); |
|
50 |
|
51 /*! |
|
52 * Returns the model index corresponding to the given frequency |
|
53 */ |
|
54 QModelIndex modelIndexFromFrequency( uint frequency ); |
|
55 |
|
56 void setCyclic( bool cyclic ); |
|
57 |
|
58 bool hasLooped( const QModelIndex& index ) const; |
|
59 |
|
60 QModelIndex realIndex( const QModelIndex& shadowIndex ) const; |
|
61 |
|
62 bool isEqual( const QModelIndex& first, const QModelIndex& second ) const; |
|
63 |
|
64 private: |
|
65 |
|
66 // from base class QSortFilterProxyModel |
|
67 |
|
68 bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const; |
|
69 |
|
70 private: // data |
|
71 |
|
72 RadioUiEngine& mUiEngine; |
|
73 |
|
74 RadioStation::Type mFilter; |
|
75 |
|
76 bool mIsCyclic; |
|
77 |
|
78 QMap<QModelIndex,QModelIndex> mShadowIndexes; |
|
79 |
|
80 }; |
|
81 |
|
82 #endif // RADIOSTATIONFILTERMODEL_H_ |
|