GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Filter Class Referenceabstract

A filter processes blocks of text looking for certain patterns (such as URLs or keywords from a list) and marks the areas which match the filter's patterns as 'hotspots'. More...

#include "Filter.h"

Inheritance diagram for Filter:
Inheritance graph
[legend]
Collaboration diagram for Filter:
Collaboration graph
[legend]

Classes

class  HotSpot
 Represents an area of text which matched the pattern a particular filter has been looking for. More...
 

Public Member Functions

 Filter ()
 Constructs a new filter. More...
 
virtual ~Filter ()
 
HotSpothotSpotAt (int line, int column) const
 Adds a new line of text to the filter and increments the line count. More...
 
QList< HotSpot * > hotSpots () const
 Returns the list of hotspots identified by the filter. More...
 
QList< HotSpot * > hotSpotsAtLine (int line) const
 Returns the list of hotspots identified by the filter which occur on a given line. More...
 
virtual void process ()=0
 Causes the filter to process the block of text currently in its internal buffer. More...
 
void reset ()
 Empties the filters internal buffer and resets the line count back to 0. More...
 
void setBuffer (const QString *buffer, const QList< int > *linePositions)
 TODO: Document me. More...
 

Protected Member Functions

void addHotSpot (HotSpot *)
 Adds a new hotspot to the list. More...
 
const QString * buffer ()
 Returns the internal buffer. More...
 
void getLineColumn (int position, int &startLine, int &startColumn)
 Converts a character position within buffer() to a line and column. More...
 

Private Attributes

const QString * _buffer
 
QList< HotSpot * > _hotspotList
 
QMultiHash< int, HotSpot * > _hotspots
 
const QList< int > * _linePositions
 

Detailed Description

A filter processes blocks of text looking for certain patterns (such as URLs or keywords from a list) and marks the areas which match the filter's patterns as 'hotspots'.

Each hotspot has a type identifier associated with it ( such as a link or a highlighted section ), and an action. When the user performs some activity such as a mouse-click in a hotspot area ( the exact action will depend on what is displaying the block of text which the filter is processing ), the hotspot's activate() method should be called. Depending on the type of hotspot this will trigger a suitable response.

For example, if a hotspot represents a URL then a suitable action would be opening that URL in a web browser. Hotspots may have more than one action, in which case the list of actions can be obtained using the actions() method.

Different subclasses of filter will return different types of hotspot. Subclasses must reimplement the process() method to examine a block of text and identify sections of interest. When processing the text they should create instances of Filter::HotSpot subclasses for sections of interest and add them to the filter's list of hotspots using addHotSpot()

Definition at line 54 of file Filter.h.

Constructor & Destructor Documentation

Filter::Filter ( )

Constructs a new filter.

Definition at line 178 of file Filter.cpp.

Filter::~Filter ( )
virtual

Definition at line 184 of file Filter.cpp.

References _hotspotList.

Member Function Documentation

void Filter::addHotSpot ( HotSpot spot)
protected

Adds a new hotspot to the list.

Definition at line 250 of file Filter.cpp.

References _hotspotList, and _hotspots.

Referenced by RegExpFilter::process().

const QString * Filter::buffer ( )
protected

Returns the internal buffer.

Definition at line 243 of file Filter.cpp.

References _buffer.

Referenced by RegExpFilter::process(), and setBuffer().

void Filter::getLineColumn ( int  position,
int startLine,
int startColumn 
)
protected

Converts a character position within buffer() to a line and column.

Definition at line 204 of file Filter.cpp.

References _buffer, and _linePositions.

Referenced by RegExpFilter::process().

Filter::HotSpot * Filter::hotSpotAt ( int  line,
int  column 
) const

Adds a new line of text to the filter and increments the line count.

Returns the hotspot which covers the given line and column, or 0 if no hotspot covers that area

Definition at line 268 of file Filter.cpp.

References _hotspots, column, Filter::HotSpot::endColumn(), Filter::HotSpot::endLine(), Filter::HotSpot::startColumn(), and Filter::HotSpot::startLine().

Referenced by FilterChain::hotSpotAt().

QList< Filter::HotSpot * > Filter::hotSpots ( ) const

Returns the list of hotspots identified by the filter.

Definition at line 259 of file Filter.cpp.

References _hotspotList.

Referenced by FilterChain::hotSpots().

QList< Filter::HotSpot * > Filter::hotSpotsAtLine ( int  line) const

Returns the list of hotspots identified by the filter which occur on a given line.

Definition at line 263 of file Filter.cpp.

References _hotspots.

virtual void Filter::process ( )
pure virtual

Causes the filter to process the block of text currently in its internal buffer.

Implemented in RegExpFilter.

void Filter::reset ( void  )

Empties the filters internal buffer and resets the line count back to 0.

All hotspots are deleted.

Definition at line 192 of file Filter.cpp.

References _hotspotList, and _hotspots.

void Filter::setBuffer ( const QString *  buffer,
const QList< int > *  linePositions 
)

TODO: Document me.

Definition at line 198 of file Filter.cpp.

References _buffer, _linePositions, and buffer().

Member Data Documentation

const QString* Filter::_buffer
private

Definition at line 181 of file Filter.h.

Referenced by buffer(), getLineColumn(), and setBuffer().

QList<HotSpot*> Filter::_hotspotList
private

Definition at line 178 of file Filter.h.

Referenced by addHotSpot(), hotSpots(), reset(), and ~Filter().

QMultiHash<int,HotSpot*> Filter::_hotspots
private

Definition at line 177 of file Filter.h.

Referenced by addHotSpot(), hotSpotAt(), hotSpotsAtLine(), and reset().

const QList<int>* Filter::_linePositions
private

Definition at line 180 of file Filter.h.

Referenced by getLineColumn(), and setBuffer().


The documentation for this class was generated from the following files: