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
ZLogViewport.h
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2015 Bob Dinitto
4  *
5  * Filename: ZLogViewport.h
6  * Created on: 11/22/2015
7  * Author: Bob Dinitto
8  *
9  * Zuble is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 #ifndef ZLOGVIEWPORT_H
26 #define ZLOGVIEWPORT_H
27 
28 #include <QObject>
29 #include <QVariant>
30 #include <QPointer>
31 #include "ZblLogMark.h"
32 #include "ZLogMap.h"
33 #include "ZblLogSearch.h"
34 #include "zglobal.h"
35 #include "ZLogReclinkModel.h"
36 #include "ZblLogSearchParams.h"
37 
38 namespace Zbl {
39 
40 class ZTableModel;
41 class ZblLogReader;
42 class ZLogReader;
43 class ZblLogSearchParams;
44 
95 class ZLogViewport : public QObject
96 {
97  friend class ZLogReader;
98  friend class ZblLogReader;
99 
100  typedef QPointer<ZblLogReader> zblLogReaderPtr;
101  //typedef QPointer<ZblLogBkSearch> zblLogSearcherPtr;
102 
103  Q_OBJECT
104 private:
105  Q_DISABLE_COPY(ZLogViewport)
106 
107 public:
108 
125  explicit ZLogViewport(
126  ZblLogReader* reader,
127  qint64 recordCount,
128  QObject* parent = 0,
129  bool background = false);
130 
136  Q_PROPERTY(qint64 currentLocation READ getCurrentLocation)
137 
138 
143  Q_PROPERTY(int currentID READ getCurrentID)
144 
150  Q_PROPERTY(int activeLocation READ getActiveID)
151 
157  Q_PROPERTY(int activeID READ getActiveID)
158 
159 
160 
161 
162 
167  Q_PROPERTY(int seekIndexRole READ getSeekIndexRole)
168 
172  Q_PROPERTY(int byteCountRole READ getByteCountRole)
173 
177  Q_PROPERTY(int bookmarksRole READ getBookmarksRole)
178 
179 
187  Q_PROPERTY(int assumeRecordSize READ getRecordSize WRITE putRecordSize)
188 
193  Q_PROPERTY(bool locked READ getLock)
194 
195 
202  Q_PROPERTY(bool searchDirectionForward READ getSearchDirForward CONSTANT)
203 
210  Q_PROPERTY(bool searchDirectionBackward READ getSearchDirBackward CONSTANT)
211 
218  Q_PROPERTY(bool searchDirectionBoth READ getSearchDirBoth CONSTANT)
219 
220 
225  static void registerType();
226 
227 
232  Q_INVOKABLE void loadRecords(
233  qint64 seekPosition,
234  qint64 recordCount);
235 
247  Q_INVOKABLE void move(
248  qint64 recordCount,
249  bool forward);
250 
251 
252 
259 
267 
268 
276 
277 
289  qint64 getMaxRecordCount();
290 
291  // role constants for accessing the model
292 
300  static int getSeekIndexRole();
301 
309  static int getByteCountRole();
310 
311 
319  static int getBookmarksRole();
320 
328  int getRecordSize();
329 
336  void putRecordSize(int size);
337 
338  bool getLock();
339 
340  int getSearchDirForward();
341  int getSearchDirBackward();
342  int getSearchDirBoth();
343 
344  qint64 getCurrentLocation();
345  int getCurrentID();
346  qint64 getActiveLocation();
347  int getActiveID();
348  qint64 getNextPageLocation();
349 
350 
351 
352 
353 #if 0
354 
355  // mark type constants
356 
357  int getSelectionType();
358 
359  int getSearchType();
360 
361  int getBookmarkType();
362 
363  int getInvalidType();
364 
365  int getAllType();
366 #endif
367 
368 
369 
370 
371  ZLogViewport *getListener() const;
372 
373  void setListener(ZLogViewport *listener);
374 
375 signals:
376 
385  void loadComplete(bool endOfData, QString errorMsg, QVariantMap context);
386 
397  void moveComplete(qint64 rowsFound,
398  qint64 rowsStored,
399  bool endOfData,
400  QString errorMsg);
401 
402 
417  void findComplete(
418  qint64 recordID,
419  qint64 seekPos,
420  QList<int>columns);
421 
426  void searchComplete();
427 
428 
435  void markupUpdated();
436 
437 
438 
452  void rowMatched(
453  qint64 modelRow,
454  QList<int> modelRoles,
455  QList<QString> markupText);
456 
457 
458 
459 public slots:
460 
467  QObject* getModel();
468 
475  QObject* getSelection();
476 
483  QObject* getCurrentSearch();
484 
502  bool setCurrentSearch(QObject* search);
503 
504 
511  QObject* getReader();
512 
524  qint64 getRecordSeekPos(qint64 recordID);
525 
536  qint64 getRecordModelRow(qint64 recordID);
537 
543  QObject* getCurrentSearchlinks();
544 
551  QObject* getCurrentBookmarklinks();
552 
566  bool markupText();
567 
568 
590  bool markupText(
591  QList<int> roles,
592  QString searchPhrase,
593  int type);
594 
606  void setLock(bool locked);
607 
621  void onRowMatched(
622  qint64 modelRow,
623  QList<int> modelRoles,
624  QList<QString> markupText);
625 
633  void onMarkupCompleted(ZLogViewport* viewport, ZblLogSearchList rowsFound);
634 
635 
636 
637 protected:
638 
644 
645 #if 0
646 
654  QVariant getCurrentSearchParams();
655 
656 #endif
657 
666 
667 
673  void onUpdateBookmarks();
674 
680  virtual void timerEvent(QTimerEvent * event);
681 
682 
693  void onSearchDeleteRequested(QObject* searchObject);
694 
695 
696 
697 
703 
709  zblLogReaderPtr m_reader; // TBD: why QPointer?
710 
711 
716  //ZblLogMark m_rootMark; // TBD: need this?
717 
723 
732 
737  static const qint64 m_minimumRecordSize;
738 
743  static const qint64 m_maximumRecordSize;
744 
749 
756  static int m_roleSeekIndex;
757 
764  static int m_roleByteCount;
765 
772  static int m_roleBookmarks;
773 
780 
787 
792 
803 
804 
815 
816 
823 
824 };
825 
826 } // Zbl
827 
828 #endif // ZLOGVIEWPORT_H
qint64 getActiveLocation()
void onMarkupCompleted(ZLogViewport *viewport, ZblLogSearchList rowsFound)
Connected to the ZblLogBkSearch::markupUpdatred signal.
int bookmarksRole
Role number of the log record bookmarks in the viewport data model.
Definition: ZLogViewport.h:177
static int m_roleByteCount
Role number of the byte count value in the log record data model.
Definition: ZLogViewport.h:764
ZTableModel * m_model
The data model that receives the viewport&#39;s log records.
Definition: ZLogViewport.h:702
void putRecordSize(int size)
Set the average log record size ZLogViewport will use when calculating memory buffer sizes...
static const qint64 m_maximumRecordSize
The maximum record size ZLogViewport will use. Currently 65536 bytes.
Definition: ZLogViewport.h:743
Q_INVOKABLE void move(qint64 recordCount, bool forward)
Moves the viewport forward or backwards. This method is asynchronous.
static int m_roleSeekIndex
Role number of the seek index value in the log record data model.
Definition: ZLogViewport.h:756
bool m_motionLock
Flag prevents viewport from being moved or updated during background operations.
Definition: ZLogViewport.h:791
static int getByteCountRole()
Obtain the role number for the byte count of a log record in the viewport&#39;s log record data model...
ZblLogMark m_logMark
The viewport&#39;s active location indicates the log record from which search operations will start...
Definition: ZLogViewport.h:814
int assumeRecordSize
The log reader assumes this is the average number of bytes per log record for calculating buffer size...
Definition: ZLogViewport.h:187
bool searchDirectionBoth
Returns (SearchDirectionBackward || SearchDirectionForward)
Definition: ZLogViewport.h:218
#define ZBL_DECLARE_LOGGED_OBJECT
Definition: zglobal.h:94
This class performs log file I/O operations and JSON parsing in a background thread on behalf of a ZL...
Definition: ZblLogReader.h:91
QObject * getCurrentSearch()
Obtains a javascript wrapper for the current search object for this viewport.
int getRecordSize()
Obtain the average log record size ZLogViewport will use when calculating memory buffer sizes...
A QML type that manages reading JSON formatted Zuble log files. QML programs create using Zbl...
Definition: ZLogReader.h:62
void rowMatched(qint64 modelRow, QList< int > modelRoles, QList< QString > markupText)
Received when the ZblLogBkSearch has found a row matching the search criteria within the viewport&#39;s d...
Q_INVOKABLE void loadRecords(qint64 seekPosition, qint64 recordCount)
Loads a consecutive set of log records from the log file into the viewport.
zblLogReaderPtr m_reader
The background worker object that reads and parses the viewport&#39;s log file. This value must not be nu...
Definition: ZLogViewport.h:709
bool searchDirectionForward
Returns the flag for searching forward.
Definition: ZLogViewport.h:202
void onRowMatched(qint64 modelRow, QList< int > modelRoles, QList< QString > markupText)
Connected to the rowMatched signal to update encapsulated ZLogSearch and ZLogMapModel objects when se...
void onUpdateBookmarks()
Signal handler for ZLogReader::updateLogMarks signal.
qint64 getRecordModelRow(qint64 recordID)
Obtain the index position for the specified log record in the model.
ZLogReader * getZReader()
Obtains the ZLogReader object that is the parent of this ZLogViewport object.
void onSearchDeleteRequested(QObject *searchObject)
Handler for ZLogReader::searchDeleteRequested signal.
bool markupText()
Marks up text in the viewport&#39;s data model asynchronously using the current search parameters...
int activeLocation
Obtain the file seek position for the currently active log record in the viewport.
Definition: ZLogViewport.h:150
This class allows Zuble log file viewer text search operations to pass parameters between threads...
static int getBookmarksRole()
Obtain the role number for the bookmark data of a log record in the viewport&#39;s log record data model...
Maintains a list of log record links pertaining to a specific log file.
Definition: ZLogMap.h:28
ZLogViewport * m_listener
Companion ZLogViewport object to receive forwarded signals. Value may be null.
Definition: ZLogViewport.h:802
qint64 m_assumeRecordSize
The viewport will assume log records average this number of bytes (including JSON formating character...
Definition: ZLogViewport.h:731
void searchComplete()
Sent when entire background search operation has completed.
int currentID
Obtain the log record ID for the first log record in the viewport.
Definition: ZLogViewport.h:143
ZTableModel * getZModel()
Returns the data model containing the viewport&#39;s log records.
bool setCurrentSearch(QObject *search)
Sets this viewport&#39;s current search object.
Defines the location of a single log record in a log file.
Definition: ZblLogMark.h:47
A log viewport encapsulates a ZTableModel containing a contiguous subset of log records from a Zuble ...
Definition: ZLogViewport.h:95
void setListener(ZLogViewport *listener)
Definition: ZAndGate.cpp:6
ZLogViewport * getListener() const
int activeID
Obtain the log record ID for the currently active log record in the viewport.
Definition: ZLogViewport.h:157
static int m_roleBookmarks
Role number of the bookmarks value in the log record data model.
Definition: ZLogViewport.h:772
void markupUpdated()
Sent when search has completed marking up viewport model data.
qint64 getRecordSeekPos(qint64 recordID)
Obtain the file seek position for the specified log record ID from model data in the viewport...
ZLogViewport(ZblLogReader *reader, qint64 recordCount, QObject *parent=0, bool background=false)
Viewport constructor.
bool searchDirectionBackward
Returns the flag for searching backward.
Definition: ZLogViewport.h:210
ZLogMap * m_selectionMap
A log mark map that holds the current selection for this viewport.
Definition: ZLogViewport.h:779
This two dimensional table model is used to store and manipulate data.
Definition: ZTableModel.h:96
qint64 getMaxRecordCount()
Returns the number of log records the viewport data model will attempt to hold.
void findComplete(qint64 recordID, qint64 seekPos, QList< int >columns)
Sent when a search operation started with findNext() function has located a target log record...
QSharedPointer< ZblLogSearch > zblLogSearchPtr
Definition: ZblLogSearch.h:681
int byteCountRole
Role number of the log record byte count in the viewport data model.
Definition: ZLogViewport.h:172
ZBL_DECLARE_LOGGED_OBJECT ZblLogSearchParams getSearchParameters()
A Qt log category for this class.
QObject * getModel()
Obtains the log viewport&#39;s data model which contains a contiguous subset of rows from the log file...
qint64 getNextPageLocation()
void loadComplete(bool endOfData, QString errorMsg, QVariantMap context)
Signals that loading of the viewport requested by a call to loadRecordByIndex() has completed...
zblLogSearchPtr getZSearch()
Obtains the current search log map for this viewport.
void moveComplete(qint64 rowsFound, qint64 rowsStored, bool endOfData, QString errorMsg)
Signals that moving of the viewport requested by a call to move() has completed.
ZblLogSearchList m_searchLinks
A list of log record links for records in the viewport that satisfy the current search criteria...
Definition: ZLogViewport.h:822
qint64 currentLocation
Obtain the file seek position for the first log record in the viewport.
Definition: ZLogViewport.h:136
int m_timerID
ID for the viewport&#39;s event timer.
Definition: ZLogViewport.h:748
qint64 getCurrentLocation()
This class allows Zuble log file viewer text search operations to pass search results between threads...
int seekIndexRole
Role number of the log record seek index in the viewport data model.
Definition: ZLogViewport.h:167
static int getSeekIndexRole()
Obtain the role number for the file seek position of a log record in the viewport&#39;s log record data m...
QObject * getReader()
Obtains the ZLogReader object that is the parent of this ZLogViewport object.
QObject * getCurrentSearchlinks()
Obtain a data model containing the log record links for the current search.
void setLock(bool locked)
Sets or clears the viewport motion lock.
qint64 m_optimalCount
Identifies the first record in the viewport.
Definition: ZLogViewport.h:722
static const qint64 m_minimumRecordSize
The minimum record size ZLogViewport will use. Currently 1024 bytes.
Definition: ZLogViewport.h:737
zblLogSearchPtr m_currentSearch
A log mark map that holds the current search results for this viewport.
Definition: ZLogViewport.h:786
static void registerType()
Registers ZLogViewport as a QML type.
QPointer< ZblLogReader > zblLogReaderPtr
Definition: ZLogViewport.h:100
QObject * getSelection()
Obtains the selection log mark map for this viewport. Each viewport has its own selection.
virtual void timerEvent(QTimerEvent *event)
Timer is used to flush excess log records from the log record buffer.
bool locked
True if the viewport is locked for scanning, false otherwise.
Definition: ZLogViewport.h:193
QObject * getCurrentBookmarklinks()
Obtain a data model containing the log record links for the current bookmark. [TBD: does this even ma...