|
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 #ifndef DATAPROVIDERHELPER_H |
|
18 #define DATAPROVIDERHELPER_H |
|
19 |
|
20 #include <hgwidgets/hgdataprovidermodel.h> |
|
21 #include <QList> |
|
22 #include <QPair> |
|
23 |
|
24 class DataProviderHelper : public HgDataProviderModel, public HgDataProviderModelObserver |
|
25 { |
|
26 Q_OBJECT |
|
27 |
|
28 public: |
|
29 DataProviderHelper(int size =1200, QObject *parent = 0); |
|
30 ~DataProviderHelper(); |
|
31 |
|
32 //from HgDataProviderModel |
|
33 virtual void doReleaseData(QList<int> list, bool silent); |
|
34 virtual void doRequestData(QList<int> list, bool silent); |
|
35 virtual QVariant defaultIcon() const; |
|
36 virtual void doResetModel(); |
|
37 |
|
38 //from QAbstractItemModel |
|
39 virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); |
|
40 virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles); |
|
41 |
|
42 //for testing |
|
43 void testClearCache(); |
|
44 void testNewItem(QList< QPair< QVariant, int > >* list, bool silent); |
|
45 void testNewItem(QPair< QVariant, int > item, bool silent); |
|
46 bool testUpdate(int pos, QList< QPair< QVariant, int > >* list, bool silent); |
|
47 bool testUpdate(int pos, QVariant obj, int role, bool silent ); |
|
48 void testRemoveItems(int pos, int size = 1); |
|
49 void testRemoveItem(int pos); |
|
50 void testInsertItem(int pos, QPair< QVariant, int > item, bool silent); |
|
51 |
|
52 QList< QPair< int, int > > getObserverDataUpdated(); |
|
53 |
|
54 QList< QPair< int, int > > getSignalDataUpdated(); |
|
55 QList< QPair< int, int > > getSignalRowsAboutToBeInserted(); |
|
56 QList< QPair< int, int > > getSignalRowsInserted(); |
|
57 QList< QPair< int, int > > getSignalRowsAboutToBeRemoved(); |
|
58 QList< QPair< int, int > > getSignalRowsRemoved(); |
|
59 bool getSignalAboutToBeReset(); |
|
60 bool getSignalReset(); |
|
61 |
|
62 QList<int> getLastRelease(); |
|
63 QList<int> getLastRequest(); |
|
64 |
|
65 void testReleasePixmap(int idx); |
|
66 QVariant testCreateIcon(int index, QPixmap aPixmap); |
|
67 |
|
68 void testEmitDataChanged(QModelIndex from,QModelIndex to); |
|
69 void testEmitHeaderDataChanged(Qt::Orientation orientation, int first, int last); |
|
70 void testEmitRowsInsert(QModelIndex parent,int from,int to); |
|
71 void testEmitColumnsInsert(QModelIndex parent,int from,int to); |
|
72 void testEmitRowsRemove(QModelIndex parent,int from,int to); |
|
73 void testEmitColumnsRemove(QModelIndex parent,int from,int to); |
|
74 void testEmitLayoutAboutToBeChanged(); |
|
75 void testEmitLayoutChanged(); |
|
76 void testEmitModelAboutToBeReset(); |
|
77 void testEmitModelReset(); |
|
78 |
|
79 //from HgDataProviderModelObserver |
|
80 public: |
|
81 virtual void dataUpdated(int from, int to); |
|
82 |
|
83 private slots: |
|
84 void slotDataUpdated(QModelIndex,QModelIndex); |
|
85 void slotRowsAboutToBeInserted(QModelIndex,int,int); |
|
86 void slotRowsInserted(QModelIndex,int,int); |
|
87 void slotRowsAboutToBeRemoved(QModelIndex,int,int); |
|
88 void slotRowsRemoved(QModelIndex,int,int); |
|
89 void slotModelAboutToBeReset(); |
|
90 void slotModelReset(); |
|
91 |
|
92 private: |
|
93 QVariant mDefaultIcon; |
|
94 QList< QPair< int, int > > mObserverDataUpdated; |
|
95 |
|
96 QList< QPair< int, int > > mSignalDataUpdated; |
|
97 QList< QPair< int, int > > mSignalRowsAboutToBeInserted; |
|
98 QList< QPair< int, int > > mSignalRowsInserted; |
|
99 QList< QPair< int, int > > mSignalRowsAboutToBeRemoved; |
|
100 QList< QPair< int, int > > mSignalRowsRemoved; |
|
101 bool mSignalAboutToBeReset; |
|
102 bool mSignalReset; |
|
103 QList<int> mLastRelease; |
|
104 QList<int> mLastRequest; |
|
105 |
|
106 }; |
|
107 |
|
108 #endif // DATAPROVIDERHELPER_H |