|
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: tsmodel.h |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef TSMODEL_H |
|
19 #define TSMODEL_H |
|
20 |
|
21 #include <QAbstractListModel> |
|
22 #include <QList> |
|
23 #include <QSize> |
|
24 #include <QSharedPointer> |
|
25 |
|
26 #include <tstaskmonitor.h> |
|
27 |
|
28 #ifdef Q_OS_SYMBIAN |
|
29 #include <apgcli.h> |
|
30 #endif |
|
31 |
|
32 class CaNotifier; |
|
33 class TsModelItem; |
|
34 |
|
35 class TsModel : public QAbstractListModel |
|
36 { |
|
37 Q_OBJECT |
|
38 |
|
39 public: |
|
40 TsModel(TsTaskMonitor &applicationSrv, |
|
41 QObject &activitySrv, |
|
42 QObject *parent = 0); |
|
43 ~TsModel(); |
|
44 |
|
45 int rowCount(const QModelIndex &parent = QModelIndex()) const; |
|
46 QVariant data(const QModelIndex &index, |
|
47 int role = Qt::DisplayRole) const; |
|
48 int maxRowCount()const; |
|
49 // from QAbstractModel |
|
50 virtual bool insertRows(int row, int count, TsModelItem* item, |
|
51 const QModelIndex & parent = QModelIndex()); |
|
52 virtual bool removeRows(int row, int count, |
|
53 const QModelIndex & parent = QModelIndex()); |
|
54 |
|
55 |
|
56 bool moveRows(int oldPosition, int newPosition, |
|
57 const QModelIndex & parent = QModelIndex()); |
|
58 bool updateRows(int row, TsModelItem* item); |
|
59 void fullUpdate(); |
|
60 |
|
61 public slots: |
|
62 void openApplication(const QModelIndex &index); |
|
63 void closeApplication(const QModelIndex &index); |
|
64 void updateApplications(); |
|
65 void updateActivities(); |
|
66 void entryChanged(TsModelItem *); |
|
67 private: |
|
68 TsModelItem *entry(const QModelIndex &index) const; |
|
69 void getApplications(); |
|
70 void getActivities(); |
|
71 void prepareActivityEntry(QVariantHash &activity); |
|
72 QString getApplicationName(int id); |
|
73 |
|
74 private: |
|
75 /* |
|
76 * List containing result |
|
77 */ |
|
78 QList<TsModelItem *> mEntries; |
|
79 |
|
80 TsTaskMonitor &mApplicationService; |
|
81 |
|
82 /* |
|
83 * Activity Service |
|
84 */ |
|
85 QObject &mActivityService; |
|
86 |
|
87 #ifdef Q_OS_SYMBIAN |
|
88 RApaLsSession iAppArcSession; |
|
89 #endif |
|
90 |
|
91 /* |
|
92 * Maximum number of items (only for running apps + activities) |
|
93 */ |
|
94 int mMaxItems; |
|
95 |
|
96 Q_DISABLE_COPY(TsModel) |
|
97 }; |
|
98 |
|
99 #endif // TSMODEL_H |