@@ -29,6 +29,7 @@ enum class Tag : quint8
29
29
Processes,
30
30
Threads,
31
31
Tracepoints,
32
+ Favorites,
32
33
LAST_TAG,
33
34
};
34
35
const auto DATATAG_SHIFT = sizeof (Tag) * 8 ;
@@ -83,6 +84,7 @@ int EventModel::rowCount(const QModelIndex& parent) const
83
84
case Tag::Cpus:
84
85
case Tag::Threads:
85
86
case Tag::Tracepoints:
87
+ case Tag::Favorites:
86
88
return 0 ;
87
89
break ;
88
90
case Tag::Processes:
@@ -95,11 +97,13 @@ int EventModel::rowCount(const QModelIndex& parent) const
95
97
return m_processes.size ();
96
98
case 2 :
97
99
return m_data.tracepoints .size ();
100
+ case 3 :
101
+ return m_favourites.size ();
98
102
default :
99
103
Q_ASSERT (false );
100
104
}
101
105
case Tag::Root:
102
- return m_data. tracepoints . isEmpty () ? 2 : 3 ;
106
+ return 4 ;
103
107
case Tag::LAST_TAG:
104
108
Q_ASSERT (false );
105
109
};
@@ -166,6 +170,8 @@ QVariant EventModel::data(const QModelIndex& index, int role) const
166
170
return tr (" Processes" );
167
171
case 2 :
168
172
return tr (" Tracepoints" );
173
+ case 3 :
174
+ return tr (" Favorites" );
169
175
}
170
176
} else if (role == Qt::ToolTipRole) {
171
177
if (index.row () == 0 ) {
@@ -175,6 +181,8 @@ QVariant EventModel::data(const QModelIndex& index, int role) const
175
181
return tr (" Event timelines for the individual threads and processes." );
176
182
} else if (index.row () == 2 ) {
177
183
return tr (" Event timelines for tracepoints" );
184
+ } else if (index.row () == 3 ) {
185
+ return tr (" A list of favourites to group important events" );
178
186
}
179
187
} else if (role == SortRole) {
180
188
return index.row ();
@@ -244,6 +252,10 @@ QVariant EventModel::data(const QModelIndex& index, int role) const
244
252
} else if (tag == Tag::Tracepoints) {
245
253
tracepoint = &m_data.tracepoints [index.row ()];
246
254
Q_ASSERT (tracepoint);
255
+ } else if (tag == Tag::Favorites) {
256
+ auto & favourite = m_favourites[index.row ()];
257
+ auto res = data (favourite, role);
258
+ return res;
247
259
}
248
260
249
261
if (role == ThreadStartRole) {
@@ -467,17 +479,21 @@ QModelIndex EventModel::index(int row, int column, const QModelIndex& parent) co
467
479
case Tag::Cpus:
468
480
case Tag::Tracepoints:
469
481
case Tag::Threads:
482
+ case Tag::Favorites:
470
483
break ;
471
484
case Tag::Root: // root has the 1st level children: Overview
472
485
return createIndex (row, column, static_cast <quintptr>(Tag::Overview));
473
486
case Tag::Overview: // 2nd level children: Cpus and the Processes
474
- if (parent.row () == 0 )
487
+ if (parent.row () == 0 ) {
475
488
return createIndex (row, column, static_cast <quintptr>(Tag::Cpus));
476
- else if (parent.row () == 1 )
489
+ } else if (parent.row () == 1 ) {
477
490
return createIndex (row, column, static_cast <quintptr>(Tag::Processes));
478
- else {
491
+ } else if (parent. row () == 2 ) {
479
492
return createIndex (row, column, static_cast <quintptr>(Tag::Tracepoints));
493
+ } else if (parent.row () == 3 ) {
494
+ return createIndex (row, column, static_cast <quintptr>(Tag::Favorites));
480
495
}
496
+ break ;
481
497
case Tag::Processes: // 3rd level children: Threads
482
498
return createIndex (row, column, combineDataTag (Tag::Threads, parent.row ()));
483
499
}
@@ -497,14 +513,24 @@ QModelIndex EventModel::parent(const QModelIndex& child) const
497
513
return createIndex (0 , 0 , static_cast <quintptr>(Tag::Overview));
498
514
case Tag::Processes:
499
515
return createIndex (1 , 0 , static_cast <quintptr>(Tag::Overview));
500
- case Tag::Tracepoints: {
516
+ case Tag::Tracepoints:
501
517
return createIndex (2 , 0 , static_cast <qintptr>(Tag::Overview));
502
- }
503
- case Tag::Threads: {
518
+ case Tag::Favorites:
519
+ return createIndex (3 , 0 , static_cast <qintptr>(Tag::Overview));
520
+ case Tag::Threads:
504
521
const auto parentRow = tagData (child.internalId ());
505
522
return createIndex (parentRow, 0 , static_cast <quintptr>(Tag::Processes));
506
523
}
507
- }
508
524
509
525
return {};
510
526
}
527
+
528
+ void EventModel::addToFavourites (const QModelIndex& index)
529
+ {
530
+ int position = m_favourites.size ();
531
+ beginInsertRows (createIndex (3 , 0 ), position, position + 1 );
532
+ m_favourites.push_back (index);
533
+ endInsertRows ();
534
+ beginResetModel ();
535
+ endResetModel ();
536
+ }
0 commit comments