17 const QString& searchPhrase,
19 QList<int> searchRoles,
20 ZblLogSearch::TextSearchDirections directions,
24 m_searchPhrase(searchPhrase),
25 m_startPosition(startPosition),
75 qWarning(
"Programming error: ZblLogSearch::dismiss called for invalid object type.");
81 zSearch->deleteLater();
109 QString markName(
"%1:%2:%3");
110 markName = markName.arg(searchPhrase).arg(searchType).arg(
getSearchRolesName(searchRoles));
120 QSet<int> roles = QSet<int>::fromList(searchRoles);
122 searchRoles = roles.toList();
126 std::sort(searchRoles.begin(), searchRoles.end());
128 for(
int i=0; i<searchRoles.count(); i++)
129 name += QString(
"%1:").arg(searchRoles.at(i));
137 int ZLogSearch::appendModelRoles(
ZTableModel* model,
int nextRole)
139 nextRole = ZLogBookmark::appendModelRoles(model, nextRole);
140 model->
addRole(nextRole++,
"search_phrase");
144 void ZLogSearch::appendModelData(
145 const MarkNode& logMark,
148 ZLogBookmark::appendModelData(logMark, data);
242 QSet<int>addSet = QSet<int>::fromList(rolesFound);
269 QSet<int>addSet = QSet<int>::fromList(rolesToSearch);
293 QSet<int> roleSet = QSet<int>::fromList(searchRoles);
301 QSet<int> roleSet = QSet<int>::fromList(searchRoles);
308 QSet<int> testRoles = QSet<int>::fromList(searchRoles);
325 QList<int> modelRoles)
329 zDebug() <<
"Search row matched - id =" << recordID
330 <<
"seekPosition =" << seekPosition <<
", modelRoles =" 343 zDebug() <<
"Search rows matched, count = " << rowsFound.
m_links.count();
347 const int rowCount = rowsFound.
m_links.count();
349 for(
int i=0; i < rowCount; i++)
364 QSharedPointer<ZblLogReclinkData> strongRef =
m_linkModel.toStrongRef();
366 if(!strongRef.isNull())
372 QSharedPointer<ZblLogReclinkData>
381 connect(
this, &ZblLogSearch::searchRowMatched,
403 for(
int i=0; i < links.
m_links.count(); i++)
415 data.append(QVariant(
"<data unavailable>"));
426 QVariant vLinks(QVariant::fromValue<ZblLogLinkList>(links));
428 QMetaObject::invokeMethod(
m_reader,
"loadRecordLinkMessageText",
429 Qt::QueuedConnection,
430 Q_ARG(QObject*,
this),
431 Q_ARG(QVariant, vLinks));
438 zDebug() <<
"Processing onLinkTextComplete...";
444 if(linkModel.isNull())
449 for(
int i=0; i<links.
m_links.count(); i++)
469 zDebug() <<
"search function entered...";
475 zDebug() <<
"Programming error - Can't search while background " 476 "operation is in progress.";
495 QMetaObject::invokeMethod(
m_searcher,
"search",
496 Qt::QueuedConnection,
497 Q_ARG(QObject*,
this),
searchState getSearchState() const
QObject * linkModel()
Obtain a list model containing an item for each log record represented in the ZLogSearchMark's result...
Encapsulates information necessary to locate a collection of log records in a log file...
TextSearchDirections getSearchDirections() const
QList< LinkNode > m_links
void addSearchRole(int roleNumber)
Adds the specified role to the set of roles that will be scanned during a text search.
textSearchType m_searchType
The type of search: case sensitive/insensitive or regular expression.
void resume()
Resume the background search operation.
Q_INVOKABLE void appendCells(QVariant data, bool truncateModel=false)
Asynchronously converts an array of cell data into one or more rows of model data and appends it to t...
QList< int > getSearchRoles() const
Returns the set of roles in the log file data model that will be scanned by the text search engine wh...
bool search(int direction, qint64 startPos)
Scans the log file for text matching the current search criteria.
void onSearchRowsMatched(ZblLogSearchList rowsFound)
Called when the search engine has found target records in the log file.
ZblLogBkSearch * getSearcher()
Obtain the background searcher object associated with this search.
bool m_saved
True is search is saved, false if unsaved.
A QML type that manages reading JSON formatted Zuble log files. QML programs create using Zbl...
void clearRolesFound()
Removes all roles from the set of search result roles.
qint64 m_endSize
The file size at the successful conclusion of the search operation.
ZblLogReader * getBackgroundReader()
Obtains a pointer to the background reader object that services this log file.
void pause()
Pause the background search operation.
bool isSearch(const QString &searchPhrase, int searchType, QList< int > searchRoles) const
Determines if this object contains results from searching for the specified search phrase and type...
void clearSearchRoles()
Removes all roles from the set of search result roles.
bool getSearchBackward() const
int getSearchType() const
void onSearchRowMatched(qint64 recordID, qint64 seekPosition, QList< int > modelRoles)
Called when the search engine has found a target record in the log file.
void insertMark(qint64 recordID, qint64 lastRecordID, qint64 seekPosition)
Creates a new log mark in the database.
void onSearchRowMatched(qint64 recordID, qint64 seekPosition, QList< int > modelRoles)
Called when the search engine has found a target record in the log file.
Q_INVOKABLE void putValue(int role, int row, const QVariant &value)
Sets the value of the specified cell in the data set.
This class allows Zuble log file viewer text search operations to pass parameters between threads...
void setSearchDirections(ZblLogSearch::TextSearchDirections directions)
void invalidateModel()
Resets the model.
bool m_active
True if search is active, false if inactive.
void abort()
Resume the background search operation.
ZblLogSearchParams getSearchParameters()
Obtain parameters for this search.
static QThread * m_searcherThread
A single background thread services all ZblLogBkSearch objects.
QWeakPointer< ZblLogReclinkData > m_linkModel
A log record link data model that is shared by all ZLogReclinkModel objects created by this ZlogSearc...
static QString getSearchmarkName(QString searchPhrase, int searchType, QList< int > searchRoles)
Creates a unique name string for a given set of search parameters.
bool containsSearchRoles(QList< int > searchRoles) const
Determine if the set of roles to scan when processing this searchmark contains the specified roles...
virtual int logMapType()
Returns log map type. Override of ZLogBookmark::logMapType().
void populateLinkModel(ZblLogReclinkData &linkModel)
Creates an expanded data model of this ZLogSearch object's log record links in the specified object...
void onLinkTextComplete(QVariant linkList)
Called by ZblLogReader when loadRecordLinkMessageText has completed.
ZLogReader * m_reader
The log file reader that created this search object.
bool equalsSearchRoles(QList< int > searchRoles) const
Determine if the set of roles to scan when processing this searchmark contains exactly the specified ...
Performs log file searches in a background thread.
void setSearchForward(bool forward)
void setSearchBackward(bool backward)
void addRolesFound(QList< int > rolesFound)
Adds the specified roles to the set of roles where search results were found.
void searchRowsMatched(ZblLogSearchList rowsFound)
Sent when log records matching the search criteria have been located.
void setMarkName(const QString &name)
void addSearchRoles(QList< int > rolesToSearch)
Adds the specified roles to the set of roles that will be scanned during a text search.
ZblLogSearch(const QString &searchPhrase, int searchType, QList< int > searchRoles, ZblLogSearch::TextSearchDirections directions, qint64 startPosition, ZLogReader *reader)
ZTableModel * zModel()
Obtains the table model in which log record link data is stored.
QSet< int > m_rolesSearched
The log record rolls that are searched.
QList< LinkNode > m_links
Explicitly shared data object encapsulates a list of log record links.
This class allows Zuble log file viewer text search operations to pass log record link parameters bet...
QString getPhrase() const
void clear()
Removes all marks from the log map.
This two dimensional table model is used to store and manipulate data.
ZBL_DECLARE_LOGGED_OBJECT ZblLogMap m_map
Create the m_tag object that presents a Javascript interface to constant integer values.
bool isNull()
Determine if this search is null.
bool validateReader(ZLogReader *reader)
Determine if the specified background file reader is connected to this search object.
bool getSearchForward() const
static void dismiss(QObject *search)
QSharedPointer deleter method called when last strong reference has gone out of scope; sends detach()...
friend class ZLogReclinkModel
QSet< int > m_rolesFound
The roles in which a search result was found.
searchState
States of a search.
QList< int > getRolesFound() const
Returns the set of roles for which search results were found.
TextSearchDirections m_searchDirection
Specifies direction of search from active viewport location.
searchState m_searchState
Tracks the state of a search operation.
ZblLogLinkList getLogLinkList() const
Obtain a ZblLogLinkList object containing expanded log links.
qint64 getCompletionFileSize() const
This class allows Zuble log file viewer text search operations to pass search results between threads...
ZblLogBkSearch * m_searcher
A background searcher object to service foreground log file search requests.
static void zInit()
Initializes search engine. Must be called only once before constructing the first ZblLogSearch object...
void addRoleFound(int roleNumber)
Adds the specified role to the set of roles where search results were found.
Q_INVOKABLE bool addRole(int roleNumber)
Adds the specified role to the data model. This method may block the current thread.
textSearchType zValidateSearchType(int searchType)
Validates an integer value to be type textSearchType and returns it or a valid default value if out o...
static QString getSearchRolesName(QList< int > searchRoles)
Returns a name concatenated from the specified search role list.
This object encapsulates search operation parameters, results, and steady state.
QString m_searchPhrase
The search phrase used to generate these search results.
QList< QVariant > ZDataRow
Represents a single row (or column for column headers) of data cell values for a single role...
static void deleteReclinkData(ZblLogReclinkData *data)
calls deleteLater() method of the specified ZblLogReclinkData object.