MCPcopy Create free account
hub / github.com/KDE/labplot / showExtendedContextMenu

Method showExtendedContextMenu

src/frontend/spreadsheet/SearchReplaceWidget.cpp:1516–1616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1514};
1515
1516void SearchReplaceWidget::showExtendedContextMenu(bool replace, const QPoint& pos) {
1517 // create the original menu
1518 QLineEdit* lineEdit;
1519 if (replace)
1520 lineEdit = uiSearchReplace.cbReplaceText->lineEdit();
1521 else
1522 lineEdit = uiSearchReplace.cbValueText->lineEdit();
1523
1524 auto* const contextMenu = lineEdit->createStandardContextMenu();
1525 if (!contextMenu)
1526 return;
1527
1528 // the extension should only be available for regex
1529 const auto opText = static_cast<OperatorText>(uiSearchReplace.cbOperatorText->currentData().toInt());
1530 if (opText != OperatorText::RegEx) {
1531 contextMenu->exec(lineEdit->mapToGlobal(pos));
1532 return;
1533 }
1534
1535 // create the extension sub-menu
1536 AddMenuManager addMenuManager(contextMenu, 37);
1537 if (!replace) {
1538 addMenuManager.addEntry(QStringLiteral("^"), QString(), i18n("Beginning of line"));
1539 addMenuManager.addEntry(QStringLiteral("$"), QString(), i18n("End of line"));
1540 addMenuManager.addSeparator();
1541 addMenuManager.addEntry(QStringLiteral("."), QString(), i18n("Match any character excluding new line (by default)"));
1542 addMenuManager.addEntry(QStringLiteral("+"), QString(), i18n("One or more occurrences"));
1543 addMenuManager.addEntry(QStringLiteral("*"), QString(), i18n("Zero or more occurrences"));
1544 addMenuManager.addEntry(QStringLiteral("?"), QString(), i18n("Zero or one occurrences"));
1545 addMenuManager.addEntry(QStringLiteral("{a"), QStringLiteral(",b}"), i18n("<a> through <b> occurrences"), QStringLiteral("{"), QStringLiteral(",}"));
1546 addMenuManager.addSeparator();
1547 addMenuManager.addEntry(QStringLiteral("("), QStringLiteral(")"), i18n("Group, capturing"));
1548 addMenuManager.addEntry(QStringLiteral("|"), QString(), i18n("Or"));
1549 addMenuManager.addEntry(QStringLiteral("["), QStringLiteral("]"), i18n("Set of characters"));
1550 addMenuManager.addEntry(QStringLiteral("[^"), QStringLiteral("]"), i18n("Negative set of characters"));
1551 addMenuManager.addSeparator();
1552 } else {
1553 addMenuManager.addEntry(QStringLiteral("\\0"), QString(), i18n("Whole match reference"));
1554 addMenuManager.addSeparator();
1555 const QString pattern = uiSearchReplace.cbReplace->currentText();
1556 const auto& capturePatterns = this->capturePatterns(pattern);
1557
1558 const int captureCount = capturePatterns.count();
1559 for (int i = 1; i <= 9; i++) {
1560 const QString number = QString::number(i);
1561 const QString& captureDetails =
1562 (i <= captureCount) ? QLatin1String(" = (") + QStringView(capturePatterns[i - 1]).left(30) + QLatin1Char(')') : QString();
1563 addMenuManager.addEntry(QLatin1String("\\") + number, QString(), i18n("Reference") + QLatin1Char(' ') + number + captureDetails);
1564 }
1565
1566 addMenuManager.addSeparator();
1567 }
1568
1569 addMenuManager.addEntry(QStringLiteral("\\n"), QString(), i18n("Line break"));
1570 addMenuManager.addEntry(QStringLiteral("\\t"), QString(), i18n("Tab"));
1571
1572 if (!replace) {
1573 addMenuManager.addEntry(QStringLiteral("\\b"), QString(), i18n("Word boundary"));

Callers

nothing calls this directly

Calls 9

capturePatternsMethod · 0.95
lineEditMethod · 0.80
execMethod · 0.80
addEntryMethod · 0.80
addSeparatorMethod · 0.80
currentTextMethod · 0.80
handleMethod · 0.80
QStringClass · 0.50
countMethod · 0.45

Tested by

no test coverage detected