19 #include <QStringListModel> |
19 #include <QStringListModel> |
20 #include <HbMenu> |
20 #include <HbMenu> |
21 |
21 |
22 #include "memspythreaddetailview.h" |
22 #include "memspythreaddetailview.h" |
23 |
23 |
|
24 MemSpyThreadDetailModel::MemSpyThreadDetailModel(EngineWrapper &engine, ThreadId threadId, ThreadInfoType type, QObject *parent) : |
|
25 QAbstractListModel(parent), |
|
26 mThreadInfo(engine.getThreadInfo(threadId, type)) |
|
27 { |
|
28 } |
|
29 |
|
30 MemSpyThreadDetailModel::~MemSpyThreadDetailModel() |
|
31 { |
|
32 qDeleteAll(mThreadInfo); |
|
33 } |
|
34 |
|
35 int MemSpyThreadDetailModel::rowCount(const QModelIndex &parent) const |
|
36 { |
|
37 Q_UNUSED(parent); |
|
38 return mThreadInfo.count(); |
|
39 } |
|
40 |
|
41 QVariant MemSpyThreadDetailModel::data(const QModelIndex &index, int role) const |
|
42 { |
|
43 if (role == Qt::DisplayRole) { |
|
44 QStringList lines; |
|
45 lines << mThreadInfo.at(index.row())->caption(); |
|
46 lines << mThreadInfo.at(index.row())->value(); |
|
47 return lines; |
|
48 } |
|
49 |
|
50 return QVariant(); |
|
51 } |
|
52 |
24 void MemSpyThreadDetailView::initialize(const QVariantMap& params) |
53 void MemSpyThreadDetailView::initialize(const QVariantMap& params) |
25 { |
54 { |
26 MemSpyView::initialize(params); |
55 MemSpyView::initialize(params); |
27 |
56 |
28 setTitle(tr("Thread Details")); |
57 setTitle(tr("Thread Details")); |
29 |
58 |
30 mThreadId = qVariantValue<ThreadId>(params["tid"]); |
59 ThreadId threadId = qVariantValue<ThreadId>(params["tid"]); |
|
60 ThreadInfoType type = static_cast<ThreadInfoType>(qVariantValue<int>(params["type"])); |
31 |
61 |
32 QStringList lines = QStringList() << tr("General") << tr("Heap") << tr("Stack") |
62 mListView.setModel(new MemSpyThreadDetailModel(mEngine, threadId, type, this)); |
33 << tr("Chunks") << tr("Code Segments") << tr("Open Files") << tr("Active Objects") |
|
34 << tr("Handles to other Threads") << tr("Handles to other Processes") |
|
35 << tr("Servers Running in Thread") << tr("Client <-> Server connections") |
|
36 << tr("Semaphores") << tr("References this Thread") << tr("References this Process") |
|
37 << tr("Mutexes") << tr("Timers") << tr("Logical DD Channels") |
|
38 << tr("Change Notifiers") << tr("Undertakers") << tr("Logical Device Drivers") |
|
39 << tr("Physical Device Drivers") << tr("Memory Tracking"); |
|
40 |
|
41 mListView.setModel(new QStringListModel(lines, this)); |
|
42 } |
63 } |
43 |
|
44 HbMenu* MemSpyThreadDetailView::createToolMenu() |
|
45 { |
|
46 HbMenu* menu = new HbMenu(tr("Thread")); |
|
47 mPriorityMenu = menu->addMenu("Change Priority"); |
|
48 |
|
49 mPriorityMenu->addAction(tr("Abs. Very Low"), this, SLOT(changePriority())); |
|
50 mPriorityMenu->addAction(tr("Abs. Low Normal"), this, SLOT(changePriority())); |
|
51 mPriorityMenu->addAction(tr("Abs. Low"), this, SLOT(changePriority())); |
|
52 mPriorityMenu->addAction(tr("Abs. Background Normal"), this, SLOT(changePriority())); |
|
53 mPriorityMenu->addAction(tr("Abs. Background"), this, SLOT(changePriority())); |
|
54 mPriorityMenu->addAction(tr("Abs. Foreground Normal"), this, SLOT(changePriority())); |
|
55 mPriorityMenu->addAction(tr("Abs. Foreground"), this, SLOT(changePriority())); |
|
56 mPriorityMenu->addAction(tr("Abs. High Normal"), this, SLOT(changePriority())); |
|
57 mPriorityMenu->addAction(tr("Abs. High"), this, SLOT(changePriority())); |
|
58 mPriorityMenu->addAction(tr("Abs. Real Time 1"), this, SLOT(changePriority())); |
|
59 mPriorityMenu->addAction(tr("Abs. Real Time 2"), this, SLOT(changePriority())); |
|
60 mPriorityMenu->addAction(tr("Abs. Real Time 3"), this, SLOT(changePriority())); |
|
61 mPriorityMenu->addAction(tr("Abs. Real Time 4"), this, SLOT(changePriority())); |
|
62 mPriorityMenu->addAction(tr("Abs. Real Time 5"), this, SLOT(changePriority())); |
|
63 mPriorityMenu->addAction(tr("Abs. Real Time 6"), this, SLOT(changePriority())); |
|
64 mPriorityMenu->addAction(tr("Abs. Real Time 7"), this, SLOT(changePriority())); |
|
65 mPriorityMenu->addAction(tr("Abs. Real Time 8"), this, SLOT(changePriority())); |
|
66 |
|
67 return menu; |
|
68 } |
|
69 |
|
70 void MemSpyThreadDetailView::changePriority() |
|
71 { |
|
72 QAction *s = qobject_cast<QAction*>(sender()); |
|
73 int index = mPriorityMenu->actions().indexOf(s); |
|
74 |
|
75 ThreadPriority priorities[] = { |
|
76 ThreadPriorityAbsoluteVeryLow, |
|
77 ThreadPriorityAbsoluteLowNormal, |
|
78 ThreadPriorityAbsoluteLow, |
|
79 ThreadPriorityAbsoluteBackgroundNormal, |
|
80 ThreadPriorityAbsoluteBackground, |
|
81 ThreadPriorityAbsoluteForegroundNormal, |
|
82 ThreadPriorityAbsoluteForeground, |
|
83 ThreadPriorityAbsoluteHighNormal, |
|
84 ThreadPriorityAbsoluteHigh, |
|
85 ThreadPriorityAbsoluteRealTime1, |
|
86 ThreadPriorityAbsoluteRealTime2, |
|
87 ThreadPriorityAbsoluteRealTime3, |
|
88 ThreadPriorityAbsoluteRealTime4, |
|
89 ThreadPriorityAbsoluteRealTime5, |
|
90 ThreadPriorityAbsoluteRealTime6, |
|
91 ThreadPriorityAbsoluteRealTime7, |
|
92 ThreadPriorityAbsoluteRealTime8 }; |
|
93 |
|
94 mEngine.setThreadPriority(mThreadId, priorities[index]); |
|
95 } |
|
96 |
|