| 1394 | } |
| 1395 | |
| 1396 | void ShaderViewer::UpdateBookmarkMenu(QMenu *menu, QAction *nextAction, QAction *prevAction, |
| 1397 | QAction *clearAction) |
| 1398 | { |
| 1399 | // setup permanent actions |
| 1400 | const bool hasBookmarks = HasBookmarks(); |
| 1401 | nextAction->setEnabled(hasBookmarks); |
| 1402 | prevAction->setEnabled(hasBookmarks); |
| 1403 | clearAction->setEnabled(hasBookmarks); |
| 1404 | |
| 1405 | // remove current bookmark list |
| 1406 | QList<QAction *> actions = menu->actions(); |
| 1407 | for(auto itAction = actions.rbegin(); itAction != actions.rend() && !(*itAction)->isSeparator(); |
| 1408 | ++itAction) |
| 1409 | menu->removeAction(*itAction); |
| 1410 | |
| 1411 | // populate bookmark list |
| 1412 | ScintillaEdit *cur = currentScintilla(); |
| 1413 | if(!cur) |
| 1414 | return; |
| 1415 | |
| 1416 | auto itBookmarks = m_Bookmarks.find(cur); |
| 1417 | if(itBookmarks == m_Bookmarks.end()) |
| 1418 | return; |
| 1419 | |
| 1420 | QString filename; |
| 1421 | if(cur == m_DisassemblyView) |
| 1422 | filename = m_DisassemblyFrame->windowTitle(); |
| 1423 | else |
| 1424 | filename = cur->windowTitle(); |
| 1425 | |
| 1426 | int numAddedBookmarks = 0; |
| 1427 | for(sptr_t lineNumber : *itBookmarks) |
| 1428 | { |
| 1429 | QString textLine = QString::fromUtf8(cur->getLine(lineNumber)).simplified(); |
| 1430 | if(textLine.size() > BOOKMARK_MAX_MENU_ENTRY_LENGTH) |
| 1431 | { |
| 1432 | textLine.chop(textLine.size() - BOOKMARK_MAX_MENU_ENTRY_LENGTH); |
| 1433 | textLine.append(lit("...")); |
| 1434 | } |
| 1435 | else if(textLine.isEmpty()) |
| 1436 | { |
| 1437 | textLine = lit("(empty)"); |
| 1438 | } |
| 1439 | |
| 1440 | QString name = QFormatStr("%1:%2 - %3").arg(filename).arg(lineNumber + 1).arg(textLine); |
| 1441 | QAction *action = new QAction(name, menu); |
| 1442 | QObject::connect(action, &QAction::triggered, [cur, lineNumber]() { cur->gotoLine(lineNumber); }); |
| 1443 | menu->addAction(action); |
| 1444 | |
| 1445 | if(++numAddedBookmarks >= BOOKMARK_MAX_MENU_ENTRY_COUNT) |
| 1446 | break; |
| 1447 | } |
| 1448 | } |
| 1449 | |
| 1450 | QAction *ShaderViewer::MakeExecuteAction(QString name, const QIcon &icon, QString tooltip, |
| 1451 | QKeySequence shortcut) |
nothing calls this directly
no test coverage detected