A filter which searches for sections of text matching a regular expression and creates a new RegExpFilter::HotSpot instance for them. More...
#include "Filter.h"
Classes | |
class | HotSpot |
Type of hotspot created by RegExpFilter. 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... | |
Signals | |
void | request_edit_mfile_signal (const QString &, int) |
void | request_open_file_signal (const QString &, int) |
Public Member Functions | |
RegExpFilter (Type) | |
Constructs a new regular expression filter. More... | |
HotSpot * | hotSpotAt (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 RegExpFilter::HotSpot * | newHotSpot (int startLine, int startColumn, int endLine, int endColumn, Type) |
Called when a match for the regular expression is encountered. More... | |
Protected Attributes | |
QRegExp | _searchText |
Type | _type |
Private Attributes | |
const QString * | _buffer |
QList< HotSpot * > | _hotspotList |
QMultiHash< int, HotSpot * > | _hotspots |
const QList< int > * | _linePositions |
A filter which searches for sections of text matching a regular expression and creates a new RegExpFilter::HotSpot instance for them.
Subclasses can reimplement newHotSpot() to return custom hotspot types when matches for the regular expression are found.
|
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 |
RegExpFilter::RegExpFilter | ( | Type | t | ) |
Constructs a new regular expression filter.
Definition at line 327 of file Filter.cpp.
|
protectedinherited |
Adds a new hotspot to the list.
Definition at line 249 of file Filter.cpp.
References Filter::_hotspotList, Filter::_hotspots, and Filter::HotSpot::startLine().
Referenced by process(), and UrlFilter::process().
|
protectedinherited |
Returns the internal buffer.
Definition at line 242 of file Filter.cpp.
References Filter::_buffer.
Referenced by process(), UrlFilter::process(), and Filter::setBuffer().
|
protectedinherited |
Converts a character position within buffer() to a line and column.
Definition at line 203 of file Filter.cpp.
References Filter::_buffer, and Filter::_linePositions.
Referenced by process(), and UrlFilter::process().
|
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 267 of file Filter.cpp.
References Filter::_hotspots, Filter::HotSpot::endColumn(), Filter::HotSpot::endLine(), Filter::HotSpot::startColumn(), and Filter::HotSpot::startLine().
|
inherited |
Returns the list of hotspots identified by the filter.
Definition at line 258 of file Filter.cpp.
References Filter::_hotspotList.
|
inherited |
Returns the list of hotspots identified by the filter which occur on a given line.
Definition at line 262 of file Filter.cpp.
References Filter::_hotspots.
|
protectedvirtual |
Called when a match for the regular expression is encountered.
Subclasses should reimplement this to return custom hotspot types
Reimplemented in UrlFilter.
Definition at line 408 of file Filter.cpp.
Referenced by process(), and 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.
Implements Filter.
Reimplemented in UrlFilter.
Definition at line 364 of file Filter.cpp.
References _searchText, _type, Filter::addHotSpot(), Filter::buffer(), Filter::getLineColumn(), newHotSpot(), and RegExpFilter::HotSpot::setCapturedTexts().
QRegExp RegExpFilter::regExp | ( | ) | const |
Returns the regular expression which the filter searches for in blocks of text.
Definition at line 356 of file Filter.cpp.
References _searchText.
Referenced by setRegExp().
|
signal |
Referenced by UrlFilter::request_open_file().
|
signal |
Referenced by UrlFilter::process(), and UrlFilter::request_open_file().
|
inherited |
Empties the filters internal buffer and resets the line count back to 0.
All hotspots are deleted.
Definition at line 191 of file Filter.cpp.
References Filter::_hotspotList, and Filter::_hotspots.
|
inherited |
TODO: Document me.
Definition at line 197 of file Filter.cpp.
References Filter::_buffer, Filter::_linePositions, and Filter::buffer().
void RegExpFilter::setRegExp | ( | const QRegExp & | text | ) |
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 352 of file Filter.cpp.
References _searchText, and regExp().
Referenced by UrlFilter::UrlFilter().
|
privateinherited |
Definition at line 189 of file Filter.h.
Referenced by Filter::buffer(), Filter::getLineColumn(), and Filter::setBuffer().
Definition at line 186 of file Filter.h.
Referenced by Filter::~Filter(), Filter::addHotSpot(), Filter::hotSpots(), and Filter::reset().
|
privateinherited |
Definition at line 185 of file Filter.h.
Referenced by Filter::addHotSpot(), Filter::hotSpotAt(), Filter::hotSpotsAtLine(), and Filter::reset().
|
privateinherited |
Definition at line 188 of file Filter.h.
Referenced by Filter::getLineColumn(), and Filter::setBuffer().
|
protected |
Definition at line 259 of file Filter.h.
Referenced by process(), UrlFilter::process(), regExp(), and setRegExp().
|
protected |
Definition at line 257 of file Filter.h.
Referenced by UrlFilter::UrlFilter(), process(), and UrlFilter::process().