33 } |
33 } |
34 |
34 |
35 int MemSpyThreadDetailModel::rowCount(const QModelIndex &parent) const |
35 int MemSpyThreadDetailModel::rowCount(const QModelIndex &parent) const |
36 { |
36 { |
37 Q_UNUSED(parent); |
37 Q_UNUSED(parent); |
38 return mThreadInfo.count(); |
38 return qMax(mThreadInfo.count(), 1); |
39 } |
39 } |
40 |
40 |
41 QVariant MemSpyThreadDetailModel::data(const QModelIndex &index, int role) const |
41 QVariant MemSpyThreadDetailModel::data(const QModelIndex &index, int role) const |
42 { |
42 { |
43 if (role == Qt::DisplayRole) { |
43 if (role == Qt::DisplayRole) { |
44 QStringList lines; |
44 |
45 lines << mThreadInfo.at(index.row())->caption(); |
45 if (mThreadInfo.count()) { |
46 lines << mThreadInfo.at(index.row())->value(); |
46 QStringList lines; |
47 return 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; |
48 } |
58 } |
49 |
59 |
50 return QVariant(); |
60 return QVariant(); |
51 } |
61 } |
52 |
62 |
53 void MemSpyThreadDetailView::initialize(const QVariantMap& params) |
63 void MemSpyThreadDetailView::initialize(const QVariantMap& params) |
54 { |
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 |
55 MemSpyView::initialize(params); |
94 MemSpyView::initialize(params); |
56 |
|
57 setTitle(tr("Thread Details")); |
|
58 |
95 |
59 ThreadId threadId = qVariantValue<ThreadId>(params["tid"]); |
96 ThreadId threadId = qVariantValue<ThreadId>(params["tid"]); |
60 ThreadInfoType type = static_cast<ThreadInfoType>(qVariantValue<int>(params["type"])); |
97 ThreadInfoType type = static_cast<ThreadInfoType>(qVariantValue<int>(params["type"])); |
61 |
98 |
62 mListView.setModel(new MemSpyThreadDetailModel(mEngine, threadId, type, this)); |
99 mListView.setModel(new MemSpyThreadDetailModel(mEngine, threadId, type, this)); |
63 } |
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 } |