Changeset View
Changeset View
Standalone View
Standalone View
krusader/BookMan/krbookmarkhandler.cpp
Show First 20 Lines • Show All 586 Lines • ▼ Show 20 Line(s) | 584 | if (eventType == QEvent::KeyPress && menu) { | |||
---|---|---|---|---|---|
587 | bool quickSearchStarted = false; | 587 | bool quickSearchStarted = false; | ||
588 | bool searchInSpecialItems = KConfigGroup(krConfig, "Look&Feel").readEntry("Search in special items", false); | 588 | bool searchInSpecialItems = KConfigGroup(krConfig, "Look&Feel").readEntry("Search in special items", false); | ||
589 | 589 | | |||
590 | if (kev->key() == Qt::Key_Left && kev->modifiers() == Qt::NoModifier) { | 590 | if (kev->key() == Qt::Key_Left && kev->modifiers() == Qt::NoModifier) { | ||
591 | menu->close(); | 591 | menu->close(); | ||
592 | return true; | 592 | return true; | ||
593 | } | 593 | } | ||
594 | 594 | | |||
595 | if (kev->modifiers() != Qt::NoModifier || | 595 | if ((kev->modifiers() != Qt::ShiftModifier && | ||
596 | kev->modifiers() != Qt::NoModifier) || | ||||
596 | kev->text().isEmpty() || | 597 | kev->text().isEmpty() || | ||
597 | kev->key() == Qt::Key_Delete || | 598 | kev->key() == Qt::Key_Delete || | ||
598 | kev->key() == Qt::Key_Return || | 599 | kev->key() == Qt::Key_Return || | ||
599 | kev->key() == Qt::Key_Escape) { | 600 | kev->key() == Qt::Key_Escape) { | ||
600 | | ||||
601 | return QObject::eventFilter(obj, ev); | 601 | return QObject::eventFilter(obj, ev); | ||
602 | } | 602 | } | ||
603 | 603 | | |||
604 | // update quick search text | 604 | // update quick search text | ||
605 | if (kev->key() == Qt::Key_Backspace) { | 605 | if (kev->key() == Qt::Key_Backspace) { | ||
606 | auto newSearchText = _quickSearchText(); | 606 | auto newSearchText = _quickSearchText(); | ||
607 | newSearchText.chop(1); | 607 | newSearchText.chop(1); | ||
608 | _setQuickSearchText(newSearchText); | 608 | _setQuickSearchText(newSearchText); | ||
Show All 9 Lines | |||||
618 | if (quickSearchStarted) { | 618 | if (quickSearchStarted) { | ||
619 | _quickSearchMenu = menu; | 619 | _quickSearchMenu = menu; | ||
620 | qDebug() << "Bookmark search: started on menu" << menu; | 620 | qDebug() << "Bookmark search: started on menu" << menu; | ||
621 | } | 621 | } | ||
622 | 622 | | |||
623 | // match actions | 623 | // match actions | ||
624 | QAction *matchedAction = nullptr; | 624 | QAction *matchedAction = nullptr; | ||
625 | int nMatches = 0; | 625 | int nMatches = 0; | ||
626 | const Qt::CaseSensitivity matchCase = | ||||
627 | _quickSearchText() == _quickSearchText().toLower() ? Qt::CaseInsensitive : Qt::CaseSensitive; | ||||
626 | for (auto act : acts) { | 628 | for (auto act : acts) { | ||
627 | if (act->isSeparator() || act->text() == "") { | 629 | if (act->isSeparator() || act->text() == "") { | ||
628 | continue; | 630 | continue; | ||
629 | } | 631 | } | ||
630 | 632 | | |||
631 | if (!searchInSpecialItems && _specialBookmarks.contains(act)) { | 633 | if (!searchInSpecialItems && _specialBookmarks.contains(act)) { | ||
632 | continue; | 634 | continue; | ||
633 | } | 635 | } | ||
634 | 636 | | |||
635 | if (quickSearchStarted) { | 637 | if (quickSearchStarted) { | ||
636 | // if the first key press is an accelerator key, let the accelerator handler process this event | 638 | // if the first key press is an accelerator key, let the accelerator handler process this event | ||
637 | if (act->text().contains('&' + kev->text(), Qt::CaseInsensitive)) { | 639 | if (act->text().contains('&' + kev->text(), Qt::CaseInsensitive)) { | ||
638 | qDebug() << "Bookmark search: hit accelerator key of" << act; | 640 | qDebug() << "Bookmark search: hit accelerator key of" << act; | ||
639 | _setQuickSearchText(""); | 641 | _setQuickSearchText(""); | ||
640 | return QObject::eventFilter(obj, ev); | 642 | return QObject::eventFilter(obj, ev); | ||
641 | } | 643 | } | ||
642 | 644 | | |||
643 | // strip accelerator keys from actions so they don't interfere with the search key press events | 645 | // strip accelerator keys from actions so they don't interfere with the search key press events | ||
644 | auto text = act->text(); | 646 | auto text = act->text(); | ||
645 | _quickSearchOriginalActionTitles.insert(act, text); | 647 | _quickSearchOriginalActionTitles.insert(act, text); | ||
646 | act->setText(KLocalizedString::removeAcceleratorMarker(text)); | 648 | act->setText(KLocalizedString::removeAcceleratorMarker(text)); | ||
647 | } | 649 | } | ||
648 | 650 | | |||
649 | // match prefix of the action text to the query | 651 | // match prefix of the action text to the query | ||
650 | if (act->text().left(_quickSearchText().length()).compare(_quickSearchText(), Qt::CaseInsensitive) == 0) { | 652 | if (act->text().left(_quickSearchText().length()).compare(_quickSearchText(), matchCase) == 0) { | ||
651 | _highlightAction(act); | 653 | _highlightAction(act); | ||
652 | if (!matchedAction || matchedAction->menu()) { | 654 | if (!matchedAction || matchedAction->menu()) { | ||
653 | // Can't highlight menus (see comment below), hopefully pick something we can | 655 | // Can't highlight menus (see comment below), hopefully pick something we can | ||
654 | matchedAction = act; | 656 | matchedAction = act; | ||
655 | } | 657 | } | ||
656 | nMatches++; | 658 | nMatches++; | ||
657 | } else { | 659 | } else { | ||
658 | _highlightAction(act, false); | 660 | _highlightAction(act, false); | ||
▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines |