50 m_optimalCount(recordCount),
51 m_assumeRecordSize(-1),
68 static bool zLogViewportInitialized =
false;
70 if(!zLogViewportInitialized)
73 zLogViewportInitialized =
true;
114 qmlRegisterUncreatableType<ZLogViewport>
115 (
"org.zuble.qml", 1, 0,
117 "Use ZLogReader to create ZLogViewport objects.");
119 qint64 nextRole =
zLogMan.getLogBufferRoleCount();
129 zDebug() <<
"Viewport was notified of log marks updated.";
137 for(
int i=0; i < modelRowCount; i++)
168 zWarning() <<
"Programming error: search parameter must be a ZLogSearch object.";
174 zWarning() <<
"Programming error: specified ZLogSearch object is not from this viewport's log file.";
213 QVariant ZLogViewport::getCurrentSearchParams()
215 QVariant searchParams;
249 QMetaObject::invokeMethod(
this,
"setLock",
250 Qt::BlockingQueuedConnection,
287 else if(size > 1024 * 64)
317 for(qint64 i=0; i < rowCount; i++)
321 if(nextID == recordID)
338 if(recordID < firstID || recordID > lastID)
341 for(qint64 i=0; i < rowCount; i++)
345 if(nextID == recordID)
356 int ZLogViewport::getSelectionType()
361 int ZLogViewport::getSearchType()
363 return ZLogMap::Search;
366 int ZLogViewport::getBookmarkType()
371 int ZLogViewport::getInvalidType()
376 int ZLogViewport::getAllType()
383 qint64 ZLogViewport::insertMark(qint64 recordID,
391 QList<QObject*> ZLogViewport::getMarks(qint64 recordID,
int markTypes)
393 QList<QObject*> marks;
395 const int count = m_mapList.count();
397 for(
int i=0; i<count; i++)
399 ZLogMap* nextMap = m_mapList.at(i);
401 if((nextMap->getMarkType() | markTypes) && nextMap->
hasMark(recordID))
402 marks.append(nextMap);
408 int ZLogViewport::getMarkTypes(qint64 recordID)
413 const int count = m_mapList.count();
415 for(
int i=0; i<count; i++)
417 ZLogMap* nextMap = m_mapList.at(i);
421 if(nextType && markTypes)
425 markTypes |= nextType;
471 throw ZblException(
"ZLogViewport::loadRecordByIndex - can't load " 472 "viewport while background operation in progress.");
480 QMetaObject::invokeMethod(
m_reader,
"loadViewport",
481 Qt::QueuedConnection,
482 Q_ARG(QObject*,
this),
483 Q_ARG(qint64, seekPosition),
484 Q_ARG(qint64, recordCount),
486 Q_ARG(
bool, markupColumn),
487 Q_ARG(QVariantMap, empty));
499 throw ZblException(
"ZLogViewport::loadRecordByIndex - can't load " 500 "viewport while background operation in progress.");
508 zWarning() <<
"Can't move zero length viewport.";
524 zDebug() <<
"Moving viewport, forward = " << forward
525 <<
", recordCount = " << recordCount
526 <<
", seekIndex = " << seekIndex;
528 QMetaObject::invokeMethod(
m_reader,
"move",
529 Qt::QueuedConnection,
530 Q_ARG(QObject*,
this),
531 Q_ARG(qint64, recordCount),
532 Q_ARG(qint64, seekIndex),
533 Q_ARG(
bool, forward),
535 Q_ARG(
bool, loadMarkupColumn));
543 zDebug() <<
"ZLogViewport::markupText";
551 zDebug() <<
"Programming error - Can't search while background " 552 "operation is in progress.";
569 QMetaObject::invokeMethod(
m_currentSearch->getSearcher(),
"markupViewport",
570 Qt::QueuedConnection,
571 Q_ARG(QObject*,
this),
574 zDebug() <<
"ZLogViewport::markupText returning";
582 QString searchPhrase,
585 zDebug() <<
"ZLogViewport::markupText roles=" 586 << roles <<
"; phrase=" 587 << searchPhrase <<
"; type=" << type;
595 zDebug() <<
"Programming error - Can't search while background " 596 "operation is in progress.";
620 QMetaObject::invokeMethod(
m_currentSearch->getSearcher(),
"markupViewport",
621 Qt::QueuedConnection,
622 Q_ARG(QObject*,
this),
625 zDebug() <<
"ZLogViewport::markupText returning";
632 zDebug() <<
"ZLogViewport::onMarkupCompleted";
636 zDebug() <<
"Not mine! viewport=" << viewport <<
"; this=" <<
this;
654 QList<int> modelRoles,
661 zDebug() <<
"Search row matched - row =" << modelRow <<
", modelRoles =" 662 << modelRoles <<
", markupText =" <<
markupText;
674 for(
int i=0; i < modelRoles.size(); i++)
676 int nextRole = modelRoles.at(i);
691 zWarning() <<
"Invalid object passed to method. Object should be of " 692 "class Zbl::ZLogSearch";
696 zDebug() <<
"Releasing current search: " << search;
746 zWarning() <<
"Zero length viewport.";
750 const qint64 lastRow = rowCount - 1;
qint64 getActiveLocation()
void onMarkupCompleted(ZLogViewport *viewport, ZblLogSearchList rowsFound)
Connected to the ZblLogBkSearch::markupUpdatred signal.
static int m_roleByteCount
Role number of the byte count value in the log record data model.
ZTableModel * m_model
The data model that receives the viewport's log records.
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.
Q_INVOKABLE void move(qint64 recordCount, bool forward)
Moves the viewport forward or backwards. This method is asynchronous.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
QAbstractTableModel override.
static int m_roleSeekIndex
Role number of the seek index value in the log record data model.
bool m_motionLock
Flag prevents viewport from being moved or updated during background operations.
static int getByteCountRole()
Obtain the role number for the byte count of a log record in the viewport's log record data model...
This class performs log file I/O operations and JSON parsing in a background thread on behalf of a ZL...
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...
void markupUpdated(ZLogViewport *viewport, ZblLogSearchList rowsFound)
Sent when a viewport's markeup data (model column 1) has been updated.
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's log file. This value must not be nu...
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's data model asynchronously using the current search parameters...
void insertMark(qint64 recordID, qint64 lastRecordID, qint64 seekPosition)
Creates a new log mark in the database.
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...
static int getBookmarksRole()
Obtain the role number for the bookmark data of a log record in the viewport's log record data model...
Maintains a list of log record links pertaining to a specific log file.
ZLogViewport * m_listener
Companion ZLogViewport object to receive forwarded signals. Value may be null.
Q_INVOKABLE void truncate(int rowCount, bool removeFromFront=false)
#define ZBL_REGISTER_LOGGED_OBJECT
void invalidateModel()
Resets the model.
A wrapper for the explicitly shared ZblLogSearch object.
qint64 m_assumeRecordSize
The viewport will assume log records average this number of bytes (including JSON formating character...
void bookmarksUpdated()
Sent when the master log mark database has been updated.
bool hasMark(qint64 recordID)
Determine if the log map contains a mark for the specified log record.
Q_INVOKABLE QVariant getValue(int role, int row)
Obtains the value of the specified data cell.
ZTableModel * getZModel()
Returns the data model containing the viewport's log records.
bool setCurrentSearch(QObject *search)
Sets this viewport's current search object.
Q_INVOKABLE zblLogSearchPtr getZSearch(const QString &searchPhrase, int searchType, QList< int > searchRoles)
Obtains or creates a search mark with the given search parameters.
A log viewport encapsulates a ZTableModel containing a contiguous subset of log records from a Zuble ...
void setListener(ZLogViewport *listener)
ZLogViewport * getListener() const
static int m_roleBookmarks
Role number of the bookmarks value in the log record data model.
void markupUpdated()
Sent when search has completed marking up viewport model data.
#define ZBL_SLOT_BEGIN_TRY
QStringList getBookmarkNames(qint64 recordID)
Obtains a list of bookmark names for the specified log record.
#define ZBL_DEFINE_LOGGED_OBJECT(class_name)
int getSearchDirBackward()
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.
ZLogMap * m_selectionMap
A log mark map that holds the current selection for this viewport.
This two dimensional table model is used to store and manipulate data.
qint64 getMaxRecordCount()
Returns the number of log records the viewport data model will attempt to hold.
#define ZBL_SLOT_END_VOID(facility, code, error_message)
QSharedPointer< ZblLogSearch > zblLogSearchPtr
MarkType
Types of log maps: Invalid, Selection, Search, Bookmark.
ZBL_DECLARE_LOGGED_OBJECT ZblLogSearchParams getSearchParameters()
A Qt log category for this class.
QObject * getModel()
Obtains the log viewport's data model which contains a contiguous subset of rows from the log file...
qint64 getNextPageLocation()
zblLogSearchPtr getZSearch()
Obtains the current search log map for this viewport.
Q_INVOKABLE QObject * getSearch(const QString &searchPhrase, int searchType, QList< int > searchRoles)
Obtains or creates the searchmark with the given search parameters.
ZblLogSearchList m_searchLinks
A list of log record links for records in the viewport that satisfy the current search criteria...
Q_INVOKABLE void setColumnCount(int count)
Sets the number of columns the table will contain. This method may block the current thread...
bool inObjectThread(const QObject &object)
Q_INVOKABLE int modelRowCount() const
Returns the number of rows in the data set. This method may block the current thread.
int m_timerID
ID for the viewport's event timer.
qint64 getCurrentLocation()
This class allows Zuble log file viewer text search operations to pass search results between threads...
static int getSeekIndexRole()
Obtain the role number for the file seek position of a log record in the viewport's log record data m...
Zuble's Qt Exception Object.
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.
QSharedPointer< ZblLogSearch > m_search
qint64 m_optimalCount
Identifies the first record in the viewport.
int getSearchDirForward()
Q_INVOKABLE bool addRole(int roleNumber)
Adds the specified role to the data model. This method may block the current thread.
QSharedPointer< ZblLogSearch > getZSearch()
static const qint64 m_minimumRecordSize
The minimum record size ZLogViewport will use. Currently 1024 bytes.
zblLogSearchPtr m_currentSearch
A log mark map that holds the current search results for this viewport.
static void registerType()
Registers ZLogViewport as a QML type.
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.
QObject * getCurrentBookmarklinks()
Obtain a data model containing the log record links for the current bookmark. [TBD: does this even ma...
Q_INVOKABLE int modelColumnCount() const
Returns the number of columns in the data set. This method may block the current thread.