Commit 698c1ce1 authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

Move filterBy to FilterChain

parent 69865507
...@@ -127,7 +127,7 @@ QRegion FilterChain::hotSpotRegion() const ...@@ -127,7 +127,7 @@ QRegion FilterChain::hotSpotRegion() const
return region; return region;
} }
int FilterChain::count(HotSpot::Type type) int FilterChain::count(HotSpot::Type type) const
{ {
const auto hSpots = hotSpots(); const auto hSpots = hotSpots();
return std::count_if(std::begin(hSpots), std::end(hSpots), return std::count_if(std::begin(hSpots), std::end(hSpots),
...@@ -136,6 +136,17 @@ int FilterChain::count(HotSpot::Type type) ...@@ -136,6 +136,17 @@ int FilterChain::count(HotSpot::Type type)
}); });
} }
QList<QSharedPointer<HotSpot>> FilterChain::filterBy(HotSpot::Type type) const
{
QList<QSharedPointer<HotSpot>> hotspots;
for (const auto &spot : hotSpots()) {
if (spot->type() == type) {
hotspots.append(spot);
}
}
return hotspots;
}
void FilterChain::leaveEvent(TerminalDisplay *td, QEvent *ev) void FilterChain::leaveEvent(TerminalDisplay *td, QEvent *ev)
{ {
Q_UNUSED(ev); Q_UNUSED(ev);
......
...@@ -85,7 +85,8 @@ public: ...@@ -85,7 +85,8 @@ public:
QRegion hotSpotRegion() const; QRegion hotSpotRegion() const;
/* Returns the amount of hotspots of the given type */ /* Returns the amount of hotspots of the given type */
int count(HotSpot::Type type); int count(HotSpot::Type type) const;
QList<QSharedPointer<HotSpot>> filterBy(HotSpot::Type type) const;
void leaveEvent(TerminalDisplay *td, QEvent *ev); void leaveEvent(TerminalDisplay *td, QEvent *ev);
protected: protected:
......
...@@ -3610,12 +3610,7 @@ void TerminalDisplay::scrollScreenWindow(enum ScreenWindow::RelativeScrollMode m ...@@ -3610,12 +3610,7 @@ void TerminalDisplay::scrollScreenWindow(enum ScreenWindow::RelativeScrollMode m
void TerminalDisplay::keyPressEvent(QKeyEvent* event) void TerminalDisplay::keyPressEvent(QKeyEvent* event)
{ {
if ((_urlHintsModifiers != 0u) && event->modifiers() == _urlHintsModifiers) { if ((_urlHintsModifiers != 0u) && event->modifiers() == _urlHintsModifiers) {
QList<QSharedPointer<HotSpot>> hotspots; QList<QSharedPointer<HotSpot>> hotspots = _filterChain->filterBy(HotSpot::Link);
for (const auto &spot : _filterChain->hotSpots()) {
if (spot->type() == HotSpot::Link) {
hotspots.append(spot);
}
}
int nHotSpots = hotspots.count(); int nHotSpots = hotspots.count();
int hintSelected = event->key() - 0x31; int hintSelected = event->key() - 0x31;
if (hintSelected >= 0 && hintSelected < 10 && hintSelected < nHotSpots) { if (hintSelected >= 0 && hintSelected < 10 && hintSelected < nHotSpots) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment