|
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 |
|
18 #include "memspyecominterfaceview.h" |
|
19 #include "viewmanager.h" |
|
20 |
|
21 MemSpyEComInterfaceModel::MemSpyEComInterfaceModel(EngineWrapper &engine, int categoryId, QObject *parent) : |
|
22 QAbstractListModel(parent), |
|
23 mCategoryId(categoryId), |
|
24 mEngine(engine), |
|
25 mData(engine.getEComInterfaces(categoryId)) |
|
26 { |
|
27 } |
|
28 |
|
29 MemSpyEComInterfaceModel::~MemSpyEComInterfaceModel() |
|
30 { |
|
31 qDeleteAll(mData); |
|
32 } |
|
33 |
|
34 int MemSpyEComInterfaceModel::rowCount(const QModelIndex &parent) const |
|
35 { |
|
36 Q_UNUSED(parent); |
|
37 return mData.count(); |
|
38 } |
|
39 |
|
40 QVariant MemSpyEComInterfaceModel::data(const QModelIndex &index, int role) const |
|
41 { |
|
42 if (role == Qt::DisplayRole) { |
|
43 const MemSpyEComInterface* interface = mData.at(index.row()); |
|
44 |
|
45 QStringList lines; |
|
46 lines << interface->name(); |
|
47 lines << QString("%1 implementation(s)").arg(interface->implementationCount()); |
|
48 |
|
49 return lines; |
|
50 } |
|
51 |
|
52 if (role == Qt::UserRole) |
|
53 return mData.at(index.row())->id(); |
|
54 |
|
55 return QVariant(); |
|
56 } |
|
57 |
|
58 void MemSpyEComInterfaceModel::refresh() |
|
59 { |
|
60 beginResetModel(); |
|
61 QList<MemSpyEComInterface*> data = mEngine.getEComInterfaces(mCategoryId); |
|
62 qDeleteAll(mData); |
|
63 mData = data; |
|
64 endResetModel(); |
|
65 } |
|
66 |
|
67 |
|
68 void MemSpyEComInterfaceView::initialize(const QVariantMap& params) |
|
69 { |
|
70 setTitle(tr("ECom Interfaces")); |
|
71 |
|
72 mParentId = params["pid"].toInt(); |
|
73 mParentName = params["pname"].toString(); |
|
74 |
|
75 MemSpyView::initialize(params); |
|
76 |
|
77 mModel = new MemSpyEComInterfaceModel(mEngine, mParentId, this); |
|
78 mListView.setModel(mModel); |
|
79 |
|
80 connect(&mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemClicked(QModelIndex))); |
|
81 } |
|
82 |
|
83 void MemSpyEComInterfaceView::itemClicked(const QModelIndex& index) |
|
84 { |
|
85 QVariantMap map; |
|
86 map.insert("pid", index.data(Qt::UserRole)); |
|
87 map.insert("pname", index.data(Qt::DisplayRole).toStringList().at(0)); |
|
88 mViewManager.showView(EComImplementationView, map); |
|
89 } |
|
90 |
|
91 void MemSpyEComInterfaceView::refresh() |
|
92 { |
|
93 mModel->refresh(); |
|
94 } |