From 698c1ce1ff4e68e5147ad392a3169799b5c2637d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 19 Jul 2020 21:54:47 +0200 Subject: [PATCH] Move filterBy to FilterChain --- src/filterHotSpots/FilterChain.cpp | 13 ++++++++++++- src/filterHotSpots/FilterChain.h | 3 ++- src/widgets/TerminalDisplay.cpp | 7 +------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/filterHotSpots/FilterChain.cpp b/src/filterHotSpots/FilterChain.cpp index 74279ddd..cd74f53b 100644 --- a/src/filterHotSpots/FilterChain.cpp +++ b/src/filterHotSpots/FilterChain.cpp @@ -127,7 +127,7 @@ QRegion FilterChain::hotSpotRegion() const return region; } -int FilterChain::count(HotSpot::Type type) +int FilterChain::count(HotSpot::Type type) const { const auto hSpots = hotSpots(); return std::count_if(std::begin(hSpots), std::end(hSpots), @@ -136,6 +136,17 @@ int FilterChain::count(HotSpot::Type type) }); } +QList> FilterChain::filterBy(HotSpot::Type type) const +{ + QList> hotspots; + for (const auto &spot : hotSpots()) { + if (spot->type() == type) { + hotspots.append(spot); + } + } + return hotspots; +} + void FilterChain::leaveEvent(TerminalDisplay *td, QEvent *ev) { Q_UNUSED(ev); diff --git a/src/filterHotSpots/FilterChain.h b/src/filterHotSpots/FilterChain.h index 305aa9ed..de194705 100644 --- a/src/filterHotSpots/FilterChain.h +++ b/src/filterHotSpots/FilterChain.h @@ -85,7 +85,8 @@ public: QRegion hotSpotRegion() const; /* Returns the amount of hotspots of the given type */ - int count(HotSpot::Type type); + int count(HotSpot::Type type) const; + QList> filterBy(HotSpot::Type type) const; void leaveEvent(TerminalDisplay *td, QEvent *ev); protected: diff --git a/src/widgets/TerminalDisplay.cpp b/src/widgets/TerminalDisplay.cpp index 79b2b94e..9397d17e 100644 --- a/src/widgets/TerminalDisplay.cpp +++ b/src/widgets/TerminalDisplay.cpp @@ -3610,12 +3610,7 @@ void TerminalDisplay::scrollScreenWindow(enum ScreenWindow::RelativeScrollMode m void TerminalDisplay::keyPressEvent(QKeyEvent* event) { if ((_urlHintsModifiers != 0u) && event->modifiers() == _urlHintsModifiers) { - QList> hotspots; - for (const auto &spot : _filterChain->hotSpots()) { - if (spot->type() == HotSpot::Link) { - hotspots.append(spot); - } - } + QList> hotspots = _filterChain->filterBy(HotSpot::Link); int nHotSpots = hotspots.count(); int hintSelected = event->key() - 0x31; if (hintSelected >= 0 && hintSelected < 10 && hintSelected < nHotSpots) { -- GitLab