| 9 | #include <QtWidgets/QMenu> |
| 10 | |
| 11 | ThreadView::ThreadView(const DebuggerViewParameters& parameters) |
| 12 | : DebuggerView(parameters, MONOSPACE_FONT) |
| 13 | , m_model(new ThreadModel(cpu())) |
| 14 | , m_proxy_model(new QSortFilterProxyModel()) |
| 15 | { |
| 16 | m_ui.setupUi(this); |
| 17 | |
| 18 | m_ui.threadList->setContextMenuPolicy(Qt::CustomContextMenu); |
| 19 | connect(m_ui.threadList, &QTableView::customContextMenuRequested, this, &ThreadView::openContextMenu); |
| 20 | connect(m_ui.threadList, &QTableView::doubleClicked, this, &ThreadView::onDoubleClick); |
| 21 | |
| 22 | m_proxy_model->setSourceModel(m_model); |
| 23 | m_proxy_model->setSortRole(Qt::UserRole); |
| 24 | m_ui.threadList->setModel(m_proxy_model); |
| 25 | m_ui.threadList->setSortingEnabled(true); |
| 26 | m_ui.threadList->sortByColumn(ThreadModel::ThreadColumns::ID, Qt::SortOrder::AscendingOrder); |
| 27 | m_ui.threadList->horizontalHeader()->setSectionsMovable(true); |
| 28 | m_ui.threadList->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); |
| 29 | for (std::size_t i = 0; auto mode : ThreadModel::HeaderResizeModes) |
| 30 | { |
| 31 | m_ui.threadList->horizontalHeader()->setSectionResizeMode(i, mode); |
| 32 | i++; |
| 33 | } |
| 34 | |
| 35 | receiveEvent<DebuggerEvents::Refresh>([this](const DebuggerEvents::Refresh& event) -> bool { |
| 36 | if (!QtHost::IsVMPaused()) |
| 37 | m_model->refreshData(); |
| 38 | return true; |
| 39 | }); |
| 40 | |
| 41 | receiveEvent<DebuggerEvents::VMUpdate>([this](const DebuggerEvents::VMUpdate& event) -> bool { |
| 42 | m_model->refreshData(); |
| 43 | return true; |
| 44 | }); |
| 45 | } |
| 46 | |
| 47 | void ThreadView::openContextMenu(QPoint pos) |
| 48 | { |
nothing calls this directly
no test coverage detected