memspyui/ui/hb/src/memspythreaddetailindexview.cpp
author hgs
Fri, 14 May 2010 15:15:12 +0300
changeset 26 41ebde60981f
child 31 e7a04a6385be
permissions -rw-r--r--
201019
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
hgs
parents:
diff changeset
     3
 * All rights reserved.
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
 *
hgs
parents:
diff changeset
     9
 * Initial Contributors:
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
 *
hgs
parents:
diff changeset
    12
 * Contributors:
hgs
parents:
diff changeset
    13
 *
hgs
parents:
diff changeset
    14
 * Description:
hgs
parents:
diff changeset
    15
 *  
hgs
parents:
diff changeset
    16
 */
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include <QAction>
hgs
parents:
diff changeset
    19
#include <QStringListModel>
hgs
parents:
diff changeset
    20
#include <HbMenu>
hgs
parents:
diff changeset
    21
hgs
parents:
diff changeset
    22
#include "memspythreaddetailindexview.h"
hgs
parents:
diff changeset
    23
#include "viewmanager.cpp"
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
void MemSpyThreadDetailIndexView::initialize(const QVariantMap& params)
hgs
parents:
diff changeset
    26
{
hgs
parents:
diff changeset
    27
	MemSpyView::initialize(params);
hgs
parents:
diff changeset
    28
	
hgs
parents:
diff changeset
    29
	setTitle(tr("Thread Details"));
hgs
parents:
diff changeset
    30
	
hgs
parents:
diff changeset
    31
	mThreadId = qVariantValue<ThreadId>(params["tid"]);
hgs
parents:
diff changeset
    32
	
hgs
parents:
diff changeset
    33
	QStringList lines = QStringList() << tr("General") << tr("Heap") << tr("Stack") 
hgs
parents:
diff changeset
    34
			<< tr("Chunks") << tr("Code Segments") << tr("Open Files") << tr("Active Objects")
hgs
parents:
diff changeset
    35
			<< tr("Handles to other Threads") << tr("Handles to other Processes") 
hgs
parents:
diff changeset
    36
			<< tr("Servers Running in Thread") << tr("Client <-> Server connections")
hgs
parents:
diff changeset
    37
			<< tr("Semaphores") << tr("References this Thread") << tr("References this Process")
hgs
parents:
diff changeset
    38
			<< tr("Mutexes") << tr("Timers") << tr("Logical DD Channels") 
hgs
parents:
diff changeset
    39
			<< tr("Change Notifiers") << tr("Undertakers") << tr("Logical Device Drivers")
hgs
parents:
diff changeset
    40
			<< tr("Physical Device Drivers");
hgs
parents:
diff changeset
    41
	
hgs
parents:
diff changeset
    42
	mListView.setModel(new QStringListModel(lines, this));
hgs
parents:
diff changeset
    43
	
hgs
parents:
diff changeset
    44
	connect(&mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemClicked(QModelIndex)));
hgs
parents:
diff changeset
    45
}
hgs
parents:
diff changeset
    46
hgs
parents:
diff changeset
    47
HbMenu* MemSpyThreadDetailIndexView::createToolMenu()
hgs
parents:
diff changeset
    48
{
hgs
parents:
diff changeset
    49
	HbMenu* menu = new HbMenu(tr("Thread"));
hgs
parents:
diff changeset
    50
	mPriorityMenu = menu->addMenu("Change Priority");
hgs
parents:
diff changeset
    51
	
hgs
parents:
diff changeset
    52
	mPriorityMenu->addAction(tr("Abs. Very Low"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    53
	mPriorityMenu->addAction(tr("Abs. Low Normal"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    54
	mPriorityMenu->addAction(tr("Abs. Low"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    55
	mPriorityMenu->addAction(tr("Abs. Background Normal"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    56
	mPriorityMenu->addAction(tr("Abs. Background"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    57
	mPriorityMenu->addAction(tr("Abs. Foreground Normal"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    58
	mPriorityMenu->addAction(tr("Abs. Foreground"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    59
	mPriorityMenu->addAction(tr("Abs. High Normal"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    60
	mPriorityMenu->addAction(tr("Abs. High"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    61
	mPriorityMenu->addAction(tr("Abs. Real Time 1"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    62
	mPriorityMenu->addAction(tr("Abs. Real Time 2"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    63
	mPriorityMenu->addAction(tr("Abs. Real Time 3"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    64
	mPriorityMenu->addAction(tr("Abs. Real Time 4"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    65
	mPriorityMenu->addAction(tr("Abs. Real Time 5"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    66
	mPriorityMenu->addAction(tr("Abs. Real Time 6"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    67
	mPriorityMenu->addAction(tr("Abs. Real Time 7"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    68
	mPriorityMenu->addAction(tr("Abs. Real Time 8"), this, SLOT(changePriority()));
hgs
parents:
diff changeset
    69
	
hgs
parents:
diff changeset
    70
	return menu;
hgs
parents:
diff changeset
    71
}
hgs
parents:
diff changeset
    72
	
hgs
parents:
diff changeset
    73
void MemSpyThreadDetailIndexView::changePriority()
hgs
parents:
diff changeset
    74
{
hgs
parents:
diff changeset
    75
	QAction *s = qobject_cast<QAction*>(sender());
hgs
parents:
diff changeset
    76
	int index = mPriorityMenu->actions().indexOf(s);
hgs
parents:
diff changeset
    77
	
hgs
parents:
diff changeset
    78
	ThreadPriority priorities[] = {
hgs
parents:
diff changeset
    79
		ThreadPriorityAbsoluteVeryLow,
hgs
parents:
diff changeset
    80
		ThreadPriorityAbsoluteLowNormal,
hgs
parents:
diff changeset
    81
		ThreadPriorityAbsoluteLow,
hgs
parents:
diff changeset
    82
		ThreadPriorityAbsoluteBackgroundNormal,
hgs
parents:
diff changeset
    83
		ThreadPriorityAbsoluteBackground,
hgs
parents:
diff changeset
    84
		ThreadPriorityAbsoluteForegroundNormal,
hgs
parents:
diff changeset
    85
		ThreadPriorityAbsoluteForeground,
hgs
parents:
diff changeset
    86
		ThreadPriorityAbsoluteHighNormal,
hgs
parents:
diff changeset
    87
		ThreadPriorityAbsoluteHigh,
hgs
parents:
diff changeset
    88
		ThreadPriorityAbsoluteRealTime1,
hgs
parents:
diff changeset
    89
		ThreadPriorityAbsoluteRealTime2,
hgs
parents:
diff changeset
    90
		ThreadPriorityAbsoluteRealTime3,
hgs
parents:
diff changeset
    91
		ThreadPriorityAbsoluteRealTime4,
hgs
parents:
diff changeset
    92
		ThreadPriorityAbsoluteRealTime5,
hgs
parents:
diff changeset
    93
		ThreadPriorityAbsoluteRealTime6,
hgs
parents:
diff changeset
    94
		ThreadPriorityAbsoluteRealTime7, 
hgs
parents:
diff changeset
    95
		ThreadPriorityAbsoluteRealTime8 };
hgs
parents:
diff changeset
    96
	
hgs
parents:
diff changeset
    97
	mEngine.setThreadPriority(mThreadId, priorities[index]);
hgs
parents:
diff changeset
    98
}
hgs
parents:
diff changeset
    99
hgs
parents:
diff changeset
   100
void MemSpyThreadDetailIndexView::itemClicked(const QModelIndex& index)
hgs
parents:
diff changeset
   101
{
hgs
parents:
diff changeset
   102
	ThreadInfoType types[] = { ThreadInfoTypeGeneral, ThreadInfoTypeHeap, 
hgs
parents:
diff changeset
   103
			ThreadInfoTypeStack, ThreadInfoTypeChunk, ThreadInfoTypeCodeSeg, 
hgs
parents:
diff changeset
   104
			ThreadInfoTypeOpenFiles, ThreadInfoTypeActiveObjects, ThreadInfoTypeOwnedThreadHandles,
hgs
parents:
diff changeset
   105
			ThreadInfoTypeOwnedProcessHandles, ThreadInfoTypeServer, ThreadInfoTypeSession, 
hgs
parents:
diff changeset
   106
			ThreadInfoTypeSemaphore, ThreadInfoTypeOtherThreads, ThreadInfoTypeOtherProcesses,
hgs
parents:
diff changeset
   107
			ThreadInfoTypeMutex, ThreadInfoTypeTimer, ThreadInfoTypeChannel,
hgs
parents:
diff changeset
   108
			ThreadInfoTypeChangeNotifier, ThreadInfoTypeUndertaker,
hgs
parents:
diff changeset
   109
			ThreadInfoTypeLDD, ThreadInfoTypePDD };
hgs
parents:
diff changeset
   110
	
hgs
parents:
diff changeset
   111
	QVariantMap map;
hgs
parents:
diff changeset
   112
	map.insert("tid", mThreadId);
hgs
parents:
diff changeset
   113
	map.insert("type", types[index.row()]);
hgs
parents:
diff changeset
   114
	mViewManager.showView(ThreadDetailView, map);
hgs
parents:
diff changeset
   115
}
hgs
parents:
diff changeset
   116