Commit f9889eb5 authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

Move code to count hotspot types to FilterChain

parent 7fec9ea9
......@@ -26,6 +26,8 @@
#include <QRect>
#include <algorithm>
using namespace Konsole;
FilterChain::FilterChain(TerminalDisplay *terminalDisplay)
: _terminalDisplay(terminalDisplay)
......@@ -124,3 +126,12 @@ QRegion FilterChain::hotSpotRegion() const
}
return region;
}
int FilterChain::count(HotSpot::Type type)
{
const auto hSpots = hotSpots();
return std::count_if(std::begin(hSpots), std::end(hSpots),
[type](const QSharedPointer<HotSpot> &s) {
return s->type() == type;
});
}
......@@ -26,6 +26,8 @@
#include <QSharedPointer>
#include <QRegion>
#include "HotSpot.h"
namespace Konsole
{
class Filter;
......@@ -80,6 +82,8 @@ public:
/* Returns the region of the hotspot inside of the TerminalDisplay */
QRegion hotSpotRegion() const;
/* Returns the amount of hotspots of the given type */
int count(HotSpot::Type type);
protected:
QList<Filter *> _filters;
TerminalDisplay *_terminalDisplay;
......
......@@ -1424,17 +1424,13 @@ void TerminalDisplay::paintFilters(QPainter& painter)
// and draw appropriate visuals to indicate the presence of the hotspot
const auto spots = _filterChain->hotSpots();
int urlNumber = 0;
int urlNumber;
int urlNumInc;
if (_reverseUrlHints) {
for (const auto &spot : spots) {
if (spot->type() == HotSpot::Link) {
urlNumber++;
}
}
urlNumber = _filterChain->count(HotSpot::Link);
urlNumInc = -1;
} else {
urlNumber = 0;
urlNumInc = 1;
}
......
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