|
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: caitemmodel.h |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CASTANDARDITEMMODEL_H |
|
19 #define CASTANDARDITEMMODEL_H |
|
20 |
|
21 // System includes |
|
22 #include <QAbstractItemModel> |
|
23 #include <QAbstractItemView> |
|
24 |
|
25 // User includes |
|
26 #include "caclient_global.h" |
|
27 #include "caquery.h" |
|
28 |
|
29 // Forward declarations |
|
30 class CaEntry; |
|
31 class CaItemModelPrivate; |
|
32 CA_CLIENT_TEST_CLASS(TestCaClient) |
|
33 |
|
34 // Class declaration |
|
35 class CACLIENT_EXPORT CaItemModel: public QAbstractItemModel |
|
36 { |
|
37 |
|
38 Q_OBJECT |
|
39 CA_CLIENT_TEST_FRIEND_CLASS(TestCaClient) |
|
40 |
|
41 public: |
|
42 |
|
43 // Data types |
|
44 enum CaItemRole |
|
45 { |
|
46 IdRole = Qt::UserRole + 1, |
|
47 ParentIdRole, |
|
48 TypeRole, |
|
49 FlagsRole, |
|
50 TextRole,//contains title represented as QString, |
|
51 DescriptionRole, // contains item description |
|
52 FullTextRole, //'title description' convinient for operations such as search |
|
53 UninstalRole, //contains progress status as decimal number in QString |
|
54 CollectionTitleRole //contains title represented as QString, |
|
55 |
|
56 }; |
|
57 |
|
58 // Function declarations |
|
59 CaItemModel(const CaQuery &query, QObject *parent = 0); |
|
60 ~CaItemModel(); |
|
61 |
|
62 int columnCount(const QModelIndex &parent = QModelIndex()) const; |
|
63 int rowCount(const QModelIndex &parent = QModelIndex()) const; |
|
64 virtual QModelIndex index(int row, int column = 0, |
|
65 const QModelIndex &parent = QModelIndex()) const; |
|
66 virtual QModelIndex parent(const QModelIndex &index) const; |
|
67 QModelIndex root() const; |
|
68 virtual QVariant data(const QModelIndex &index, int role = |
|
69 Qt::DisplayRole) const; |
|
70 void setAutoUpdate(bool autoUpdate); |
|
71 void setSecondLineVisibility(bool secondLineVisible); |
|
72 bool secondLineVisibility() const; |
|
73 bool isAutoUpdate() const; |
|
74 void setSort(SortAttribute sortAttribute, Qt::SortOrder sortOrder = |
|
75 Qt::AscendingOrder); |
|
76 void setIconSize(const QSizeF &size); |
|
77 QSizeF getIconSize() const; |
|
78 void updateModel(); |
|
79 void setParentId(int parentId); |
|
80 void setFlagsOn(const EntryFlags &onFlags); |
|
81 void setFlagsOff(const EntryFlags &offFlags); |
|
82 QSharedPointer<CaEntry> entry(const QModelIndex &index) const; |
|
83 |
|
84 QList<int> getUninstallingEntriesIds(int componentId); |
|
85 void updateProgress(int id, int valueOfProgress); |
|
86 |
|
87 |
|
88 signals: |
|
89 |
|
90 void scrollTo(int row, QAbstractItemView::ScrollHint hint = |
|
91 QAbstractItemView::EnsureVisible); |
|
92 void empty(bool value); |
|
93 void countChange(); |
|
94 |
|
95 protected: |
|
96 // data |
|
97 |
|
98 CaItemModelPrivate * const m_d; |
|
99 friend class CaItemModelPrivate; |
|
100 |
|
101 }; |
|
102 |
|
103 #endif // CASTANDARDITEMMODEL_H |