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
ZblLogSearch.h
Go to the documentation of this file.
1 #ifndef ZBLLOGSEARCH_H
2 #define ZBLLOGSEARCH_H
3 
4 #include "ZLogBookmark.h"
5 #include "zglobal.h"
6 #include "ZblLogSearchList.h"
7 #include "ZblLogMark.h"
8 
9 namespace Zbl
10 {
11 
12 class ZblLogReclinkData;
13 class ZblLogReader;
14 class ZblLogBkSearch;
15 class ZblLogSearchParams;
16 
35 class ZblLogSearch : public ZLogBookmark
36 {
37  Q_OBJECT
38  //Q_ENUMS(searchType)
39 
40 public:
41 
47  {
48  BEGIN = 0,
52  };
53  Q_ENUM(searchState)
54 
55 
56 
61  {
66  };
67  Q_DECLARE_FLAGS(TextSearchDirections, TextSearchDirection)
68  Q_FLAG(TextSearchDirection)
69 
70 
71  explicit ZblLogSearch(
72  const QString& searchPhrase,
73  int searchType,
74  QList<int> searchRoles,
75  ZblLogSearch::TextSearchDirections directions,
76  qint64 startPosition,
77  ZLogReader* reader
78  );
79 
85  static void zInit();
86 
87 
88 #if 0
89  // these have been moved to ZLogSearch class
90 
91 
92  Q_PROPERTY(QString searchPhrase READ getPhrase)
93  Q_PROPERTY(int searchType READ getSearchType)
94  Q_PROPERTY(QList<int> searchRoles READ getSearchRoles)
95  Q_PROPERTY(searchState status READ getSearchState)
96  Q_PROPERTY(bool searchForward READ getSearchForward WRITE setSearchForward)
97  Q_PROPERTY(bool searchBackward READ getSearchBackward WRITE setSearchBackward)
98 
99 #endif
100 
101  // begin indelible
102 
103  QString getPhrase() const;
104 
105  int getSearchType() const;
106 
107 
117  QList<int> getSearchRoles() const;
118 
119  // begin indelible
120 
121 
122  // begin variable
123 
124  searchState getSearchState() const;
125 
126  bool getActive() const;
127  bool getSaved() const;
128  qint64 getCompletionFileSize() const;
129 
130  bool getSearchForward() const;
131  void setSearchForward(bool forward);
132  bool getSearchBackward() const;
133  void setSearchBackward(bool backward);
134 
135  TextSearchDirections getSearchDirections() const;
136  void setSearchDirections(ZblLogSearch::TextSearchDirections directions);
137 
138 
139  // end variable
140 
141 
142 
153  void addRoleFound(int roleNumber);
154 
165  void addRolesFound(QList<int> rolesFound);
166 
171  void clearRolesFound();
172 
181 
192  bool validateReader(ZLogReader *reader);
193 
194 
203 
204 
215  static QString getSearchmarkName(QString searchPhrase, int searchType, QList<int> searchRoles);
216 
224  static void dismiss(QObject* search);
225 
226 private:
227  Q_DISABLE_COPY(ZblLogSearch)
228 
229 signals:
230 
243  void invalidate();
244 
245 
246 
247  void notifySearchState(int newValue);
248  void notifySearchForward(bool newValue);
249  void notifySearchBackward(bool newValue);
250 
251  void notifyActive(bool newValue);
252  void notifySaved(bool newValue);
253  void notifyCompletionFileSize(qint64 newValue);
254 
255 
256 #if 0
257 
264  void detach();
265 #endif
266 
267 
268 #if 0
269 
284  void searchRowMatched(
285  qint64 recordID,
286  qint64 seekPosition,
287  QList<int> modelRoles);
288 #endif
289 
290 
291 
292 public slots:
293 
309  void onSearchRowMatched(
310  qint64 recordID,
311  qint64 seekPosition,
312  QList<int> modelRoles);
313 
321  void onSearchRowsMatched(ZblLogSearchList rowsFound);
322 
328  void onLinkTextComplete(QVariant linkList);
329 
336  QList<int> getRolesFound() const;
337 
347  bool isSearch(const QString& searchPhrase, int searchType, QList<int> searchRoles) const;
348 
349 
357  bool isNull();
358 
368  void addSearchRole(int roleNumber);
369 
381  void addSearchRoles(QList<int> rolesToSearch);
382 
397  void setSearchRoles(QList<int> rolesToSearch);
398 
403  void clearSearchRoles();
404 
405 
417  bool containsSearchRoles(QList<int> searchRoles) const;
418 
427  bool equalsSearchRoles(QList<int> searchRoles) const;
428 
443  QObject* linkModel();
444 
459  bool search(
460  int direction,
461  qint64 startPos
462  );
463 
464 
465 
470  void pause();
471 
476  void resume();
477 
482  void abort();
483 
484 protected:
485 
491  virtual int logMapType();
492 
493 
506 
507 
516  static void deleteReclinkData(ZblLogReclinkData* data);
517 
527  static QString getSearchRolesName(QList<int> searchRoles);
528 
529 
530 
531 #if 0
532 
540  int appendModelRoles(ZTableModel* model, int nextRole);
541 
548  void appendModelData(
549  const MarkNode& logMark,
550  ZDataRow data);
551 
552 #endif
553 
558  QString m_searchPhrase;
559 
565 
573  QSet<int> m_rolesSearched;
574 
584  QSet<int> m_rolesFound;
585 
605  QWeakPointer<ZblLogReclinkData> m_linkModel;
606 
607 
613 
622  bool m_active;
623 
631  bool m_saved;
632 
637  TextSearchDirections m_searchDirection;
638 
639 
645 
652  qint64 m_endSize;
653 
659 
666 
670  static QThread* m_searcherThread;
671 
672 #if 0
673 
678 #endif
679 };
680 
681 typedef QSharedPointer<ZblLogSearch> zblLogSearchPtr;
682 
683 
684 } // Zbl
685 
686 #endif // ZBLLOGSEARCH_H
searchState getSearchState() const
QObject * linkModel()
Obtain a list model containing an item for each log record represented in the ZLogSearchMark&#39;s result...
void notifyActive(bool newValue)
ZLogMap m_searchArea
Links in this map represent areas of the log file that have already been searched.
Definition: ZblLogSearch.h:658
Encapsulates information necessary to locate a collection of log records in a log file...
Definition: ZLogBookmark.h:46
TextSearchDirections getSearchDirections() const
void notifySearchBackward(bool newValue)
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.
Definition: ZblLogSearch.h:564
void resume()
Resume the background search operation.
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.
Definition: ZblLogSearch.h:631
A QML type that manages reading JSON formatted Zuble log files. QML programs create using Zbl...
Definition: ZLogReader.h:62
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.
Definition: ZblLogSearch.h:652
void pause()
Pause the background search operation.
void clearSearchRoles()
Removes all roles from the set of search result roles.
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...
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.
This class allows Zuble log file viewer text search operations to pass parameters between threads...
Maintains a list of log record links pertaining to a specific log file.
Definition: ZLogMap.h:28
void setSearchDirections(ZblLogSearch::TextSearchDirections directions)
void invalidate()
Sent when a request to delete this object requires all references to be released. ...
bool getActive() const
bool m_active
True if search is active, false if inactive.
Definition: ZblLogSearch.h:622
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.
Definition: ZblLogSearch.h:670
QWeakPointer< ZblLogReclinkData > m_linkModel
A log record link data model that is shared by all ZLogReclinkModel objects created by this ZlogSearc...
Definition: ZblLogSearch.h:605
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...
TextSearchDirection
Specify search direction from initial log file position at start of search.
Definition: ZblLogSearch.h:60
virtual int logMapType()
Returns log map type. Override of ZLogBookmark::logMapType().
void populateLinkModel(ZblLogReclinkData &linkModel)
Creates an expanded data model of this ZLogSearch object&#39;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.
Definition: ZLogMap.h:281
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.
Definition: ZAndGate.cpp:6
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 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)
QSet< int > m_rolesSearched
The log record rolls that are searched.
Definition: ZblLogSearch.h:573
void notifyCompletionFileSize(qint64 newValue)
Explicitly shared data object encapsulates a list of log record links.
QString getPhrase() const
This two dimensional table model is used to store and manipulate data.
Definition: ZTableModel.h:96
textSearchType
Specifies search case sensitivity.
Definition: zglobal.h:209
QSharedPointer< ZblLogSearch > zblLogSearchPtr
Definition: ZblLogSearch.h:681
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()...
void notifySaved(bool newValue)
qint64 m_startPosition
File seek position of the log record from which to start the search operation.
Definition: ZblLogSearch.h:644
QSet< int > m_rolesFound
The roles in which a search result was found.
Definition: ZblLogSearch.h:584
searchState
States of a search.
Definition: ZblLogSearch.h:46
TextSearchDirections m_searchDirection
Specifies direction of search from active viewport location.
Definition: ZblLogSearch.h:637
QList< int > getRolesFound() const
Returns the set of roles for which search results were found.
searchState m_searchState
Tracks the state of a search operation.
Definition: ZblLogSearch.h:612
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.
Definition: ZblLogSearch.h:665
void notifySearchForward(bool newValue)
static void zInit()
Initializes search engine. Must be called only once before constructing the first ZblLogSearch object...
bool getSaved() const
void addRoleFound(int roleNumber)
Adds the specified role to the set of roles where search results were found.
void notifySearchState(int newValue)
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.
Definition: ZblLogSearch.h:35
QString m_searchPhrase
The search phrase used to generate these search results.
Definition: ZblLogSearch.h:558
QList< QVariant > ZDataRow
Represents a single row (or column for column headers) of data cell values for a single role...
Definition: ZTableModel.h:57
static void deleteReclinkData(ZblLogReclinkData *data)
calls deleteLater() method of the specified ZblLogReclinkData object.
void setSearchRoles(QList< int > rolesToSearch)
Replaces the current set of roles to scan during a text search with the specified roles...