| 161 | } |
| 162 | |
| 163 | void ProjectTreeView::contextMenuEvent(QContextMenuEvent *event) |
| 164 | { |
| 165 | QModelIndex index = indexAt(event->pos()); |
| 166 | auto item = d->model->itemForIndex(index); |
| 167 | if (!item) |
| 168 | return; |
| 169 | |
| 170 | QMenu menu; |
| 171 | if (d->viewType == UnitTest) |
| 172 | d->createUTActoins(&menu, item); |
| 173 | |
| 174 | if (!item->itemNode->isFileNodeType()) { |
| 175 | menu.addSeparator(); |
| 176 | if (isExpanded(index)) |
| 177 | menu.addAction(tr("Collapse"), this, std::bind(&ProjectTreeView::collapse, this, index)); |
| 178 | else |
| 179 | menu.addAction(tr("Expand"), this, std::bind(&ProjectTreeView::expand, this, index)); |
| 180 | menu.addAction(tr("Collapse All"), this, &ProjectTreeView::collapseAll); |
| 181 | menu.addAction(tr("Expand All"), this, &ProjectTreeView::expandAll); |
| 182 | } |
| 183 | |
| 184 | if (!menu.actions().isEmpty()) |
| 185 | menu.exec(QCursor::pos()); |
| 186 | } |
nothing calls this directly
no test coverage detected