GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
UrlFilter Class Reference

A filter which matches URLs in blocks of text. More...

#include "Filter.h"

Inheritance diagram for UrlFilter:
Collaboration diagram for UrlFilter:

Classes

class  HotSpot
 Hotspot type created by UrlFilter instances. More...
 

Public Types

enum  Type { NotSpecified, Link, Marker, ErrorLink }
 Represents an area of text which matched the pattern a particular filter has been looking for. More...
 

Public Slots

void request_open_file (const QString &, int)
 

Signals

void request_edit_mfile_signal (const QString &, int)
 
void request_open_file_signal (const QString &, int)
 

Public Member Functions

 UrlFilter (Type t=Link)
 
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 ()
 Reimplemented to search the filter's text buffer for text matching regExp() More...
 
QRegExp regExp () const
 Returns the regular expression which the filter searches for in blocks of text. 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...
 
void setRegExp (const QRegExp &text)
 Sets the regular expression which the filter searches for in blocks of text. 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...
 
virtual HotSpotnewHotSpot (int, int, int, int, Type)
 Called when a match for the regular expression is encountered. More...
 

Protected Attributes

QRegExp _searchText
 
Type _type
 

Static Private Attributes

static const QRegExp CompleteErrorLinkRegExp
 
static const QRegExp CompleteUrlRegExp
 
static const QRegExp EmailAddressRegExp
 
static const QRegExp ErrorLinkRegExp
 
static const QRegExp FullUrlRegExp
 
static const QRegExp ParseErrorLinkRegExp
 

Detailed Description

A filter which matches URLs in blocks of text.

Definition at line 265 of file Filter.h.

Member Enumeration Documentation

◆ Type

enum Filter::Type
inherited

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

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. These actions may then be displayed in a popup menu or toolbar for example.

Enumerator
NotSpecified 
Link 
Marker 
ErrorLink 

Definition at line 74 of file Filter.h.

Constructor & Destructor Documentation

◆ UrlFilter()

UrlFilter::UrlFilter ( Type  t = Link)

Member Function Documentation

◆ addHotSpot()

void Filter::addHotSpot ( HotSpot spot)
protectedinherited

Adds a new hotspot to the list.

Definition at line 252 of file Filter.cpp.

References Filter::_hotspotList, and Filter::_hotspots.

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

◆ buffer()

const QString * Filter::buffer ( )
protectedinherited

Returns the internal buffer.

Definition at line 245 of file Filter.cpp.

References Filter::_buffer.

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

◆ getLineColumn()

void Filter::getLineColumn ( int  position,
int &  startLine,
int &  startColumn 
)
protectedinherited

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

Definition at line 206 of file Filter.cpp.

References Filter::_buffer, Filter::_linePositions, and i.

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

◆ hotSpotAt()

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

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 270 of file Filter.cpp.

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

◆ hotSpots()

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

Returns the list of hotspots identified by the filter.

Definition at line 261 of file Filter.cpp.

References Filter::_hotspotList.

◆ hotSpotsAtLine()

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

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

Definition at line 265 of file Filter.cpp.

References Filter::_hotspots.

◆ newHotSpot()

UrlFilter::HotSpot * UrlFilter::newHotSpot ( int  startLine,
int  startColumn,
int  endLine,
int  endColumn,
Filter::Type  t 
)
protectedvirtual

Called when a match for the regular expression is encountered.

Subclasses should reimplement this to return custom hotspot types

Reimplemented from RegExpFilter.

Definition at line 418 of file Filter.cpp.

References t.

◆ process()

void UrlFilter::process ( )
virtual

Reimplemented to search the filter's text buffer for text matching regExp()

If regexp matches the empty string, then process() will return immediately without finding results.

Reimplemented from RegExpFilter.

Definition at line 425 of file Filter.cpp.

References RegExpFilter::_searchText, RegExpFilter::_type, Filter::addHotSpot(), Filter::buffer(), Filter::getLineColumn(), RegExpFilter::newHotSpot(), and RegExpFilter::request_open_file_signal().

◆ regExp()

QRegExp RegExpFilter::regExp ( ) const
inherited

Returns the regular expression which the filter searches for in blocks of text.

Definition at line 359 of file Filter.cpp.

References RegExpFilter::_searchText.

Referenced by RegExpFilter::setRegExp().

◆ request_edit_mfile_signal

void RegExpFilter::request_edit_mfile_signal ( const QString &  ,
int   
)
signalinherited

Referenced by request_open_file().

◆ request_open_file

void UrlFilter::request_open_file ( const QString &  file,
int  line 
)
slot

◆ request_open_file_signal

void RegExpFilter::request_open_file_signal ( const QString &  ,
int   
)
signalinherited

Referenced by process(), and request_open_file().

◆ reset()

void Filter::reset ( void  )
inherited

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

All hotspots are deleted.

Definition at line 194 of file Filter.cpp.

References Filter::_hotspotList, and Filter::_hotspots.

◆ setBuffer()

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

TODO: Document me.

Definition at line 200 of file Filter.cpp.

References Filter::_buffer, Filter::_linePositions, and Filter::buffer().

◆ setRegExp()

void RegExpFilter::setRegExp ( const QRegExp &  text)
inherited

Sets the regular expression which the filter searches for in blocks of text.

Regular expressions which match the empty string are treated as not matching anything.

Definition at line 355 of file Filter.cpp.

References RegExpFilter::_searchText, and RegExpFilter::regExp().

Referenced by UrlFilter().

Member Data Documentation

◆ _searchText

QRegExp RegExpFilter::_searchText
protectedinherited

◆ _type

Type RegExpFilter::_type
protectedinherited

Definition at line 257 of file Filter.h.

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

◆ CompleteErrorLinkRegExp

const QRegExp UrlFilter::CompleteErrorLinkRegExp
staticprivate

Definition at line 323 of file Filter.h.

Referenced by UrlFilter().

◆ CompleteUrlRegExp

const QRegExp UrlFilter::CompleteUrlRegExp
staticprivate

Definition at line 326 of file Filter.h.

Referenced by UrlFilter().

◆ EmailAddressRegExp

const QRegExp UrlFilter::EmailAddressRegExp
staticprivate

Definition at line 320 of file Filter.h.

Referenced by UrlFilter::HotSpot::urlType().

◆ ErrorLinkRegExp

const QRegExp UrlFilter::ErrorLinkRegExp
staticprivate

◆ FullUrlRegExp

const QRegExp UrlFilter::FullUrlRegExp
staticprivate

Definition at line 319 of file Filter.h.

Referenced by UrlFilter::HotSpot::urlType().

◆ ParseErrorLinkRegExp

const QRegExp UrlFilter::ParseErrorLinkRegExp
staticprivate

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