WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Zbl::ZblLogScanner Class Reference

Log record scanner/highlighter object encapsulates logic for locating and marking up search text. More...

#include <ZblLogScanner.h>

Collaboration diagram for Zbl::ZblLogScanner:
Collaboration graph
[legend]

Public Types

enum  controlFlags { HighlightSearchText = 1, SendRowsMatchedSignal = 2, SendFindCompleteSignal = 4 }
 

Public Member Functions

 ZblLogScanner ()
 Constructs an invalid scanner/highlighter object. More...
 
 ZblLogScanner (const ZblLogSearchParams *searchParams, controlFlags control, bool markupColumn=false)
 Constructs a log record scanner/highlighter object for the specified input/output parameters. More...
 
QVariantList markupOrdinalRoleList (QVariantList data)
 Returns a highlighted text string for the specified QVariant objects. More...
 
ZblLogSearchList scanModelColumnRows (ZTableModel *model, int chunkSize, ZLogViewport *viewport=NULL, qint64 currentRecordID=-1)
 scanModelColumnRows More...
 
ZTableRowList scanTableColumnRows (ZTableRowList columnRows, ZblLogSearchList &searchList, ZLogViewport *viewport=NULL)
 Scans a log viewport data model for search text. More...
 
QVariant scanTextValue (QVariant data, bool &searchTextFound)
 Returns a highlighted text string for the specified QVariant object. More...
 
bool outputHighlightedText ()
 Determine if scanner is enabled. More...
 
bool outputMarkupColumn ()
 Determine if scanner will output markup column when scanning log record data models. More...
 
bool signalRowsMatched ()
 Determine if scanner will send rowsMatched signals. More...
 
bool signalFindComplete ()
 Determine if scanner will send rowsMatched signals. More...
 

Protected Member Functions

qint64 getRowSeekPos (QMap< int, QVariant > row)
 
qint64 getRowID (QMap< int, QVariant > row)
 

Protected Attributes

const ZblLogSearchParamsm_params
 Search parameters to be used by the text scanning algorithms. More...
 
bool m_markupColumn
 True if the data model has an optional markup column. More...
 
bool m_findCompleteSent
 true if fineComplete signal has been sent, false otherwise; More...
 
controlFlags m_controlFlags
 These flags control the output of the scanner. More...
 

Static Protected Attributes

static const QString m_highlightColor = "blue"
 The color to highlight text that mataches the search parameters. More...
 

Detailed Description

Log record scanner/highlighter object encapsulates logic for locating and marking up search text.

This is used by the text search feature to highlight search text in the log view. The scanner can optionally send rowsMatched signals to the search object as it scans.

A list of role numbers determines which cells will be scanned. Only data for these roles will be scanned and highlighted. Data for other roles are not scanned.

The model is assumed to contain raw data to be scanned in column 0. An optional second column of display data can be stored in column 1. The scanner will fill column 1 with exact copies of the roles from column 0 if text highlighting is turned off, and will fill column 1 with highlighted (rich) text if text highlighting is turned on.

Definition at line 34 of file ZblLogScanner.h.

Member Enumeration Documentation

◆ controlFlags

Enumerator
HighlightSearchText 

cause the scanner to output highlighted text to column 1

SendRowsMatchedSignal 

cause the scanner to send searchRowsMatched signals

SendFindCompleteSignal 

cause the scanner to send searchRowsMatched signals

Definition at line 39 of file ZblLogScanner.h.

Constructor & Destructor Documentation

◆ ZblLogScanner() [1/2]

Zbl::ZblLogScanner::ZblLogScanner ( )

Constructs an invalid scanner/highlighter object.

Definition at line 12 of file ZblLogScanner.cpp.

◆ ZblLogScanner() [2/2]

Zbl::ZblLogScanner::ZblLogScanner ( const ZblLogSearchParams searchParams,
controlFlags  control,
bool  markupColumn = false 
)

Constructs a log record scanner/highlighter object for the specified input/output parameters.

Parameters
searchParamsParameters control the text matching algorithm
controlDetermine what operations will be performed
markupColumntrue to output markup column, false to ignore markup column

Definition at line 20 of file ZblLogScanner.cpp.

Member Function Documentation

◆ getRowID()

qint64 Zbl::ZblLogScanner::getRowID ( QMap< int, QVariant >  row)
protected

Definition at line 253 of file ZblLogScanner.cpp.

Referenced by scanTableColumnRows(), and signalFindComplete().

◆ getRowSeekPos()

qint64 Zbl::ZblLogScanner::getRowSeekPos ( QMap< int, QVariant >  row)
protected

Definition at line 258 of file ZblLogScanner.cpp.

Referenced by scanTableColumnRows(), and signalFindComplete().

◆ markupOrdinalRoleList()

QVariantList Zbl::ZblLogScanner::markupOrdinalRoleList ( QVariantList  data)

Returns a highlighted text string for the specified QVariant objects.

The data list is assumed to provide an input data model cell arranged with "ordinal roles": A sequence of data whose index in the array is the role number of the data for the row. Ordinal role numbers start with zero and increment by one for each successive role number. This data arrangement is compatible with ZTableModel::prependCells() and ZTableModel::appendCells() used by ZLogReader to load viewport data into the model.

The internal m_roles list contains the role numbers for the data that should be highlighted. This method will scan the rows for only the specified roles and return an ordinal role list with only those roles that match the search text converted to highlighted text. Values for roles not in the roles list or that don't contain search text will be returned containing the original input data.

Parameters
dataAn ordinal role data model cell, each index in the list represents an ordinal role value for the cell
Returns
An ordinal role data model cell with only those roles specified in the roles list and that contain text matching the search parameters converted to highlighted text.

Definition at line 36 of file ZblLogScanner.cpp.

Referenced by Zbl::ZblLogReader::parseNextFileRecord().

◆ outputHighlightedText()

bool Zbl::ZblLogScanner::outputHighlightedText ( )
inline

Determine if scanner is enabled.

Returns
true if scanner is enabled, false if disabled

Definition at line 173 of file ZblLogScanner.h.

Referenced by Zbl::ZblLogReader::parseNextFileRecord(), scanTableColumnRows(), and scanTextValue().

◆ outputMarkupColumn()

bool Zbl::ZblLogScanner::outputMarkupColumn ( )
inline

Determine if scanner will output markup column when scanning log record data models.

Returns
true if scanner will output markup column, false if scanner will ignore markup column

Definition at line 183 of file ZblLogScanner.h.

Referenced by Zbl::ZblLogReader::parseNextFileRecord().

◆ scanModelColumnRows()

ZblLogSearchList Zbl::ZblLogScanner::scanModelColumnRows ( ZTableModel model,
int  chunkSize,
ZLogViewport viewport = NULL,
qint64  currentRecordID = -1 
)

scanModelColumnRows

Parameters
modelThe log record data model to scan
chunkSizeThe number of rows to scan at a time
viewportThe viewport to receive signals or NULL to receive no signals.

Definition at line 65 of file ZblLogScanner.cpp.

Referenced by Zbl::ZblLogBkSearch::markupViewport(), and Zbl::ZblLogBkSearch::onLoadComplete().

◆ scanTableColumnRows()

ZTableRowList Zbl::ZblLogScanner::scanTableColumnRows ( ZTableRowList  columnRows,
ZblLogSearchList searchList,
ZLogViewport viewport = NULL 
)

Scans a log viewport data model for search text.

Each cell in the specified zRableRowList will be scanned and only those that match the search text will be (optionally) converted to highlighted text. Cells for roles not in the roles list or that don't contain search text will be returned containing the original input data.

This method is compatible with ZTableModel::getTableColumnRows() and ZTableModel::putTableColumnRows() used by ZblLogBkSearch to scan viewport data models for search text.

Parameters
AZTableRowList object containg the QVariant data to highlight
AZblLogSearchList object will receive links rows that match the search parameters if SendRowsMatchedSignal control bit is set.
Returns
A ZTableRowList object containg the highlighted text cells

Definition at line 137 of file ZblLogScanner.cpp.

Referenced by scanModelColumnRows().

◆ scanTextValue()

QVariant Zbl::ZblLogScanner::scanTextValue ( QVariant  data,
bool &  searchTextFound 
)

Returns a highlighted text string for the specified QVariant object.

The method first converts the specified data QVariant into text using QVariant::toString() and then scans the specified text using the encapsulated search parameters to locate search strings and enclose them in rich text tags that cause the text to appear highlighted.

If the data, when converted to text, doesn't contain any instances of the search text the original data value is returned.

Parameters
dataThe QVariant data to highlight
searchTextFoundSet to true by this method if text matching the search parameters was found, false if not found
Returns
A rich text highlighted string representing the specified data object or the original data value if it didn't match the search parameters.

Definition at line 206 of file ZblLogScanner.cpp.

Referenced by markupOrdinalRoleList(), and scanTableColumnRows().

◆ signalFindComplete()

bool Zbl::ZblLogScanner::signalFindComplete ( )
inline

Determine if scanner will send rowsMatched signals.

Returns
true if scanner will send rowsMatched signals

Definition at line 197 of file ZblLogScanner.h.

Referenced by scanModelColumnRows(), and ZblLogScanner().

◆ signalRowsMatched()

bool Zbl::ZblLogScanner::signalRowsMatched ( )
inline

Determine if scanner will send rowsMatched signals.

Returns
true if scanner will send rowsMatched signals

Definition at line 190 of file ZblLogScanner.h.

Referenced by scanModelColumnRows(), and scanTableColumnRows().

Member Data Documentation

◆ m_controlFlags

controlFlags Zbl::ZblLogScanner::m_controlFlags
protected

These flags control the output of the scanner.

Definition at line 253 of file ZblLogScanner.h.

Referenced by outputHighlightedText(), signalFindComplete(), signalRowsMatched(), and ZblLogScanner().

◆ m_findCompleteSent

bool Zbl::ZblLogScanner::m_findCompleteSent
protected

true if fineComplete signal has been sent, false otherwise;

Definition at line 246 of file ZblLogScanner.h.

Referenced by ZblLogScanner().

◆ m_highlightColor

const QString Zbl::ZblLogScanner::m_highlightColor = "blue"
staticprotected

The color to highlight text that mataches the search parameters.

Definition at line 214 of file ZblLogScanner.h.

Referenced by scanTextValue().

◆ m_markupColumn

bool Zbl::ZblLogScanner::m_markupColumn
protected

True if the data model has an optional markup column.

Column 0 holds the raw data from the log file. When a data model is used to hold visual data column 1 holds the display data where markup can occur.

When this flag is true column 1 will receive EITHER:

  • if text highlighting is turned off: a copy of column 0 for all roles
  • OR if text highlighting is turned on: highlighted text for roles that match the search phrase and a copy of column 0 for roles that don't match the search phrase

When this flag is false column 1 will receive nothing. This is true even if text highlighting is turned on.

Definition at line 240 of file ZblLogScanner.h.

Referenced by outputMarkupColumn(), and ZblLogScanner().

◆ m_params

const ZblLogSearchParams* Zbl::ZblLogScanner::m_params
protected

Search parameters to be used by the text scanning algorithms.

Definition at line 220 of file ZblLogScanner.h.

Referenced by markupOrdinalRoleList(), scanModelColumnRows(), scanTableColumnRows(), scanTextValue(), and ZblLogScanner().


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