memspyui/ui/hb/src/memspythreaddetailindexview.cpp
branchRCL_3
changeset 21 b3cee849fa46
equal deleted inserted replaced
20:48060abbbeaf 21:b3cee849fa46
       
     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 <QAction>
       
    19 #include <QStringListModel>
       
    20 #include <HbMenu>
       
    21 
       
    22 #include "memspythreaddetailindexview.h"
       
    23 #include "viewmanager.cpp"
       
    24 
       
    25 void MemSpyThreadDetailIndexView::initialize(const QVariantMap& params)
       
    26 {
       
    27 	setTitle(tr("Details"));
       
    28 	
       
    29 	mProcessName = params["pname"].toString();
       
    30 	mThreadName = params["tname"].toString();
       
    31 	
       
    32 	MemSpyView::initialize(params);
       
    33 	
       
    34 	mThreadId = qVariantValue<ThreadId>(params["tid"]);
       
    35 	
       
    36 	QStringList lines = QStringList() << tr("General") << tr("Heap") << tr("Stack") 
       
    37 			<< tr("Chunks") << tr("Code Segments") << tr("Open Files") << tr("Active Objects")
       
    38 			<< tr("Handles to other Threads") << tr("Handles to other Processes") 
       
    39 			<< tr("Servers Running in Thread") << tr("Client <-> Server connections")
       
    40 			<< tr("Semaphores") << tr("References this Thread") << tr("References this Process")
       
    41 			<< tr("Mutexes") << tr("Timers") << tr("Logical DD Channels") 
       
    42 			<< tr("Change Notifiers") << tr("Undertakers") << tr("Logical Device Drivers")
       
    43 			<< tr("Physical Device Drivers");
       
    44 	
       
    45 	mListView.setModel(new QStringListModel(lines, this));
       
    46 	
       
    47 	connect(&mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemClicked(QModelIndex)));
       
    48 }
       
    49 
       
    50 HbMenu* MemSpyThreadDetailIndexView::createToolMenu()
       
    51 {
       
    52 	HbMenu* menu = new HbMenu(tr("Thread"));
       
    53 	mPriorityMenu = menu->addMenu("Change Priority");
       
    54 	
       
    55 	mPriorityMenu->addAction(tr("Abs. Very Low"), this, SLOT(changePriority()));
       
    56 	mPriorityMenu->addAction(tr("Abs. Low Normal"), this, SLOT(changePriority()));
       
    57 	mPriorityMenu->addAction(tr("Abs. Low"), this, SLOT(changePriority()));
       
    58 	mPriorityMenu->addAction(tr("Abs. Background Normal"), this, SLOT(changePriority()));
       
    59 	mPriorityMenu->addAction(tr("Abs. Background"), this, SLOT(changePriority()));
       
    60 	mPriorityMenu->addAction(tr("Abs. Foreground Normal"), this, SLOT(changePriority()));
       
    61 	mPriorityMenu->addAction(tr("Abs. Foreground"), this, SLOT(changePriority()));
       
    62 	mPriorityMenu->addAction(tr("Abs. High Normal"), this, SLOT(changePriority()));
       
    63 	mPriorityMenu->addAction(tr("Abs. High"), this, SLOT(changePriority()));
       
    64 	mPriorityMenu->addAction(tr("Abs. Real Time 1"), this, SLOT(changePriority()));
       
    65 	mPriorityMenu->addAction(tr("Abs. Real Time 2"), this, SLOT(changePriority()));
       
    66 	mPriorityMenu->addAction(tr("Abs. Real Time 3"), this, SLOT(changePriority()));
       
    67 	mPriorityMenu->addAction(tr("Abs. Real Time 4"), this, SLOT(changePriority()));
       
    68 	mPriorityMenu->addAction(tr("Abs. Real Time 5"), this, SLOT(changePriority()));
       
    69 	mPriorityMenu->addAction(tr("Abs. Real Time 6"), this, SLOT(changePriority()));
       
    70 	mPriorityMenu->addAction(tr("Abs. Real Time 7"), this, SLOT(changePriority()));
       
    71 	mPriorityMenu->addAction(tr("Abs. Real Time 8"), this, SLOT(changePriority()));
       
    72 	
       
    73 	return menu;
       
    74 }
       
    75 
       
    76 bool MemSpyThreadDetailIndexView::isBreadCrumbVisible() const
       
    77 {
       
    78     return true;
       
    79 }
       
    80 
       
    81 QString MemSpyThreadDetailIndexView::getBreadCrumbText() const
       
    82 {
       
    83     return tr("Processes > %1 > Threads > %2").arg(mProcessName).arg(mThreadName);
       
    84 }
       
    85 
       
    86 void MemSpyThreadDetailIndexView::changePriority()
       
    87 {
       
    88 	QAction *s = qobject_cast<QAction*>(sender());
       
    89 	int index = mPriorityMenu->actions().indexOf(s);
       
    90 	
       
    91 	ThreadPriority priorities[] = {
       
    92 		ThreadPriorityAbsoluteVeryLow,
       
    93 		ThreadPriorityAbsoluteLowNormal,
       
    94 		ThreadPriorityAbsoluteLow,
       
    95 		ThreadPriorityAbsoluteBackgroundNormal,
       
    96 		ThreadPriorityAbsoluteBackground,
       
    97 		ThreadPriorityAbsoluteForegroundNormal,
       
    98 		ThreadPriorityAbsoluteForeground,
       
    99 		ThreadPriorityAbsoluteHighNormal,
       
   100 		ThreadPriorityAbsoluteHigh,
       
   101 		ThreadPriorityAbsoluteRealTime1,
       
   102 		ThreadPriorityAbsoluteRealTime2,
       
   103 		ThreadPriorityAbsoluteRealTime3,
       
   104 		ThreadPriorityAbsoluteRealTime4,
       
   105 		ThreadPriorityAbsoluteRealTime5,
       
   106 		ThreadPriorityAbsoluteRealTime6,
       
   107 		ThreadPriorityAbsoluteRealTime7, 
       
   108 		ThreadPriorityAbsoluteRealTime8 };
       
   109 	
       
   110 	mEngine.setThreadPriority(mThreadId, priorities[index]);
       
   111 }
       
   112 
       
   113 void MemSpyThreadDetailIndexView::itemClicked(const QModelIndex& index)
       
   114 {
       
   115 	ThreadInfoType types[] = { ThreadInfoTypeGeneral, ThreadInfoTypeHeap, 
       
   116 			ThreadInfoTypeStack, ThreadInfoTypeChunk, ThreadInfoTypeCodeSeg, 
       
   117 			ThreadInfoTypeOpenFiles, ThreadInfoTypeActiveObjects, ThreadInfoTypeOwnedThreadHandles,
       
   118 			ThreadInfoTypeOwnedProcessHandles, ThreadInfoTypeServer, ThreadInfoTypeSession, 
       
   119 			ThreadInfoTypeSemaphore, ThreadInfoTypeOtherThreads, ThreadInfoTypeOtherProcesses,
       
   120 			ThreadInfoTypeMutex, ThreadInfoTypeTimer, ThreadInfoTypeChannel,
       
   121 			ThreadInfoTypeChangeNotifier, ThreadInfoTypeUndertaker,
       
   122 			ThreadInfoTypeLDD, ThreadInfoTypePDD };
       
   123 	
       
   124 	QVariantMap map;
       
   125 	map.insert("tid", mThreadId);
       
   126 	map.insert("type", types[index.row()]);
       
   127 	map.insert("pname", mProcessName);
       
   128 	map.insert("tname", mThreadName);
       
   129 	mViewManager.showView(ThreadDetailView, map);
       
   130 }
       
   131