|
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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef GLXMODELWRAPPER_H |
|
19 #define GLXMODELWRAPPER_H |
|
20 |
|
21 #include <QAbstractItemModel> |
|
22 |
|
23 #ifdef BUILD_MODELWRAPPER |
|
24 #define GLX_MODELWRAPPER_EXPORT Q_DECL_EXPORT |
|
25 #else |
|
26 #define GLX_MODELWRAPPER_EXPORT Q_DECL_IMPORT |
|
27 #endif |
|
28 |
|
29 |
|
30 class GLX_MODELWRAPPER_EXPORT GlxModelWrapper : public QAbstractItemModel |
|
31 { |
|
32 Q_OBJECT |
|
33 public : |
|
34 |
|
35 GlxModelWrapper(); |
|
36 ~GlxModelWrapper(); |
|
37 void setModel(QAbstractItemModel *model); |
|
38 void setRoles(int convertrole, int originalrole = Qt::DecorationRole); |
|
39 |
|
40 int rowCount(const QModelIndex &parent = QModelIndex()) const; |
|
41 int columnCount(const QModelIndex &parent = QModelIndex()) const; |
|
42 QModelIndex parent(const QModelIndex &child) const; |
|
43 QVariant data(const QModelIndex &idx, int role) const; |
|
44 bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); |
|
45 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; |
|
46 QModelIndex basemodelindex(int row, int column, const QModelIndex &parent = QModelIndex()) const; |
|
47 void scrollingStarted(); |
|
48 void scrollingEnded(); |
|
49 |
|
50 |
|
51 private: |
|
52 void connectToModel(); |
|
53 void disConnectFromModel(); |
|
54 |
|
55 protected slots: |
|
56 void modelDestroyed(); |
|
57 void dataChangedinModel(QModelIndex startIndex, QModelIndex endIndex); |
|
58 void rowsAboutToBeInserted(const QModelIndex &parent,int start,int end); |
|
59 void rowsInserted(const QModelIndex &parent, int start, int end); |
|
60 void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); |
|
61 void rowsRemoved(const QModelIndex &parent, int start, int end); |
|
62 //These might be needed later. Commenting now |
|
63 /*void columnsAboutToBeInserted(QModelIndex,int,int); |
|
64 void columnsInserted(QModelIndex,int,int); |
|
65 void columnsAboutToBeRemoved(QModelIndex,int,int); |
|
66 void columnsRemoved(QModelIndex,int,int); |
|
67 void rowsMoved(QModelIndex, int, int, QModelIndex, int); |
|
68 void layoutAboutToBeChanged(); |
|
69 void layoutChanged(); |
|
70 void modelReset(); |
|
71 void destroyed();*/ |
|
72 |
|
73 private: |
|
74 |
|
75 void resetTheModel(); |
|
76 |
|
77 QAbstractItemModel *mModel; |
|
78 int mOriginalRole; |
|
79 int mConvertRole; |
|
80 }; |
|
81 |
|
82 #endif /* GLXMODELWRAPPER_H */ |