memspyui/ui/hb/src/memspythreaddetailview.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 "memspythreaddetailview.h"
       
    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 qMax(mThreadInfo.count(), 1);
       
    39 }
       
    40 	
       
    41 QVariant MemSpyThreadDetailModel::data(const QModelIndex &index, int role) const
       
    42 {
       
    43 	if (role == Qt::DisplayRole) {
       
    44 	    
       
    45 	    if (mThreadInfo.count()) {
       
    46             QStringList lines;
       
    47             lines << mThreadInfo.at(index.row())->caption();
       
    48             lines << mThreadInfo.at(index.row())->value();
       
    49             return lines;
       
    50 	    }
       
    51 	    
       
    52 	    return tr("(no items found)");
       
    53 	}
       
    54 	
       
    55 	if (role == Qt::TextAlignmentRole && mThreadInfo.count() == 0) {
       
    56 	    
       
    57 	    return Qt::AlignHCenter;
       
    58 	}
       
    59 	
       
    60 	return QVariant();
       
    61 }
       
    62 
       
    63 void MemSpyThreadDetailView::initialize(const QVariantMap& params)
       
    64 {
       
    65     mProcessName = params["pname"].toString();
       
    66     mThreadName = params["tname"].toString();
       
    67     
       
    68     // TODO: Remove duplicates with memspythreaddetailindexview
       
    69     QMap<int, QString> titleMap;
       
    70     titleMap[ThreadInfoTypeGeneral] = tr("General");
       
    71     titleMap[ThreadInfoTypeHeap] = tr("Heap");
       
    72     titleMap[ThreadInfoTypeStack] = tr("Stack");
       
    73     titleMap[ThreadInfoTypeChunk] = tr("Chunks");
       
    74     titleMap[ThreadInfoTypeCodeSeg] = tr("Code Segments"); 
       
    75     titleMap[ThreadInfoTypeOpenFiles] = tr("Open Files");
       
    76     titleMap[ThreadInfoTypeActiveObjects] = tr("Active Objects");
       
    77     titleMap[ThreadInfoTypeOwnedThreadHandles] = tr("Handles to other Threads");
       
    78     titleMap[ThreadInfoTypeOwnedProcessHandles] = tr("Handles to other Processes");
       
    79     titleMap[ThreadInfoTypeServer] = tr("Servers Running in Thread");
       
    80     titleMap[ThreadInfoTypeSession] = tr("Client <-> Server connections");
       
    81     titleMap[ThreadInfoTypeSemaphore] = tr("Semaphores");
       
    82     titleMap[ThreadInfoTypeOtherThreads] = tr("References this Thread");
       
    83     titleMap[ThreadInfoTypeOtherProcesses] = tr("References this Process");
       
    84     titleMap[ThreadInfoTypeMutex] = tr("Mutexes");
       
    85     titleMap[ThreadInfoTypeTimer] = tr("Timers");
       
    86     titleMap[ThreadInfoTypeChannel] = tr("Logical DD Channels");
       
    87     titleMap[ThreadInfoTypeChangeNotifier] = tr("Change Notifiers"); 
       
    88     titleMap[ThreadInfoTypeUndertaker] = tr("Undertakers");
       
    89     titleMap[ThreadInfoTypeLDD] = tr("Logical Device Drivers");
       
    90     titleMap[ThreadInfoTypePDD] = tr("Physical Device Drivers");
       
    91     
       
    92     setTitle(titleMap.value(params["type"].toInt()));
       
    93     
       
    94 	MemSpyView::initialize(params);
       
    95 	
       
    96 	ThreadId threadId = qVariantValue<ThreadId>(params["tid"]);
       
    97 	ThreadInfoType type = static_cast<ThreadInfoType>(qVariantValue<int>(params["type"]));
       
    98 	
       
    99 	mListView.setModel(new MemSpyThreadDetailModel(mEngine, threadId, type, this));
       
   100 }
       
   101 
       
   102 bool MemSpyThreadDetailView::isBreadCrumbVisible() const
       
   103 {
       
   104     return true;
       
   105 }
       
   106 
       
   107 QString MemSpyThreadDetailView::getBreadCrumbText() const
       
   108 {
       
   109     return tr("Processes > %1 > Threads > %2").arg(mProcessName).arg(mThreadName);
       
   110 }