|
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: Videolist sort filter proxy stub implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef VIDEOPROXYMODELGENERIC_H |
|
19 #define VIDEOPROXYMODELGENERIC_H |
|
20 |
|
21 #include <qsortfilterproxymodel.h> |
|
22 #include <QString> |
|
23 #include <QList> |
|
24 #include <mpxitemid.h> |
|
25 |
|
26 class VideoProxyModelGeneric : public QSortFilterProxyModel |
|
27 { |
|
28 Q_OBJECT |
|
29 |
|
30 public: |
|
31 |
|
32 /** |
|
33 * Contructor. |
|
34 * |
|
35 * @param parent parent of this widget |
|
36 */ |
|
37 VideoProxyModelGeneric(QObject *parent=0); |
|
38 |
|
39 /** |
|
40 * Destructor. |
|
41 * |
|
42 */ |
|
43 virtual ~VideoProxyModelGeneric(); |
|
44 |
|
45 public: |
|
46 |
|
47 /** |
|
48 * Method checks that model exists and asks for mpx id from |
|
49 * given object. |
|
50 * |
|
51 * @param index index of the item. |
|
52 * @return int mpx id if succeeds, -1 in case of error |
|
53 * |
|
54 */ |
|
55 TMPXItemId getMediaIdAtIndex(QModelIndex index); |
|
56 |
|
57 /** |
|
58 * Returns filepath. |
|
59 * |
|
60 * @param mediaId id for the item, only iId1 is used. |
|
61 * @returns file path for the item. |
|
62 */ |
|
63 QString getMediaFilePathForId(TMPXItemId mediaId); |
|
64 |
|
65 /** |
|
66 * Return to collection level |
|
67 * |
|
68 */ |
|
69 void back(); |
|
70 |
|
71 /** |
|
72 * Return source model. |
|
73 * |
|
74 */ |
|
75 VideoProxyModelGeneric* sourceModel(); |
|
76 |
|
77 public: // Simplified data access. |
|
78 /** |
|
79 * Return count of filenames. |
|
80 * |
|
81 */ |
|
82 int rowCount(const QModelIndex & parent = QModelIndex()) const; |
|
83 |
|
84 /** |
|
85 * Return specified index. |
|
86 * |
|
87 */ |
|
88 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; |
|
89 |
|
90 /** |
|
91 * Returns copy of the given index. |
|
92 * |
|
93 */ |
|
94 QModelIndex mapToSource(const QModelIndex &proxyIndex) const; |
|
95 |
|
96 signals: |
|
97 |
|
98 /** |
|
99 * Signals that the model is ready, ie. that all data has been |
|
100 * loaded from myvideoscollection. |
|
101 */ |
|
102 void modelReady(); |
|
103 |
|
104 /** |
|
105 * notifies that model's physical data structure has changed: |
|
106 * - item inserted |
|
107 * - item removed |
|
108 */ |
|
109 void modelChanged(); |
|
110 |
|
111 public: // Test helper methods. |
|
112 |
|
113 static void reset(); |
|
114 |
|
115 void appendData(QString fileName); |
|
116 |
|
117 protected: // from QSortFilterProxyModel |
|
118 |
|
119 /** |
|
120 * Compares items based in the role setted before sorting. |
|
121 * |
|
122 */ |
|
123 bool lessThan ( const QModelIndex & left, const QModelIndex & right ) const; |
|
124 |
|
125 public: |
|
126 |
|
127 // Incremented at rowCount calls. |
|
128 static int mRowCountCallCount; |
|
129 |
|
130 // If true index() returns invalid indexes. |
|
131 static bool mReturnInvalidIndexes; |
|
132 |
|
133 // Model items. |
|
134 QList<QString> mFileNames; |
|
135 }; |
|
136 |
|
137 #endif // VIDEOPROXYMODELGENERIC_H |