Move code to count hotspot types to FilterChain

wilder
Tomaz Canabrava 6 years ago
parent 7fec9ea98b
commit f9889eb57c
  1. 11
      src/filterHotSpots/FilterChain.cpp
  2. 4
      src/filterHotSpots/FilterChain.h
  3. 10
      src/widgets/TerminalDisplay.cpp

@ -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;
}

Loading…
Cancel
Save