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
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<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)
{
Q_UNUSED(ev);
......
......@@ -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<QSharedPointer<HotSpot>> filterBy(HotSpot::Type type) const;
void leaveEvent(TerminalDisplay *td, QEvent *ev);
protected:
......
......@@ -3610,12 +3610,7 @@ void TerminalDisplay::scrollScreenWindow(enum ScreenWindow::RelativeScrollMode m
void TerminalDisplay::keyPressEvent(QKeyEvent* event)
{
if ((_urlHintsModifiers != 0u) && event->modifiers() == _urlHintsModifiers) {
QList<QSharedPointer<HotSpot>> hotspots;
for (const auto &spot : _filterChain->hotSpots()) {
if (spot->type() == HotSpot::Link) {
hotspots.append(spot);
}
}
QList<QSharedPointer<HotSpot>> hotspots = _filterChain->filterBy(HotSpot::Link);
int nHotSpots = hotspots.count();
int hintSelected = event->key() - 0x31;
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