vogleditor_QApiCallTreeModel::vogleditor_QApiCallTreeModel(vogl_trace_file_reader* reader, QObject *parent)
: QAbstractItemModel(parent)
{
- m_rootItem = new vogleditor_apiCallTreeItem(this);
+ m_rootItem = vogl_new(vogleditor_apiCallTreeItem, this);
setupModelData(reader, m_rootItem);
}
{
if (m_rootItem != NULL)
{
- delete m_rootItem;
+ vogl_delete(m_rootItem);
m_rootItem = NULL;
}
// and append it to the parent
if (pCurFrame == NULL)
{
- pCurFrame = new vogleditor_frameItem(total_swaps);
+ pCurFrame = vogl_new(vogleditor_frameItem, total_swaps);
vogleditor_apiCallTreeItem* pNewFrameNode = vogl_new(vogleditor_apiCallTreeItem, pCurFrame, pCurParent);
pCurParent->appendChild(pNewFrameNode);
m_itemList.append(pNewFrameNode);
// reset the CurFrame so that a new frame node will be created on the next api call
pCurFrame = NULL;
}
+ else if (entrypoint_id == VOGL_ENTRYPOINT_glBegin)
+ {
+ // items in the glBegin/glEnd block will be nested, including the glEnd
+ pCurParent = item;
+ }
+ else if (entrypoint_id == VOGL_ENTRYPOINT_glEnd)
+ {
+ // move the parent back one level of the hierarchy, to its own parent
+ pCurParent = pCurParent->parent();
+ }
}
if (pTrace_reader->get_packet_type() == cTSPTEOF)
if (!index.isValid())
return QVariant();
- vogleditor_apiCallTreeItem *item = static_cast<vogleditor_apiCallTreeItem*>(index.internalPointer());
+ vogleditor_apiCallTreeItem* pItem = static_cast<vogleditor_apiCallTreeItem*>(index.internalPointer());
- return item->columnData(index.column(), role);
+ // highlight the API call cell if it has a substring which matches the searchString
+ if (role == Qt::BackgroundRole && index.column() == VOGL_ACTC_APICALL)
+ {
+ if (!m_searchString.isEmpty())
+ {
+ QVariant data = pItem->columnData(VOGL_ACTC_APICALL, Qt::DisplayRole);
+ QString string = data.toString();
+ if (string.contains(m_searchString, Qt::CaseInsensitive))
+ {
+ return QColor(Qt::yellow);
+ }
+ }
+ }
+
+ return pItem->columnData(index.column(), role);
}
Qt::ItemFlags vogleditor_QApiCallTreeModel::flags(const QModelIndex &index) const
return QVariant();
}
-QModelIndexList vogleditor_QApiCallTreeModel::find_search_matches(const QString searchText)
+void vogleditor_QApiCallTreeModel::set_highlight_search_string(const QString searchString)
+{
+ m_searchString = searchString;
+}
+
+QModelIndex vogleditor_QApiCallTreeModel::find_prev_search_result(vogleditor_apiCallTreeItem* start, const QString searchText)
{
QLinkedListIterator<vogleditor_apiCallTreeItem*> iter(m_itemList);
- QModelIndexList matches;
- // iterate through all items and find matching text
- while (iter.hasNext())
+ if (start != NULL)
{
- vogleditor_apiCallTreeItem* pItem = iter.peekNext();
- QVariant data = pItem->columnData(VOGL_ACTC_APICALL, Qt::DisplayRole);
- QString string = data.toString();
- if (string.contains(searchText, Qt::CaseInsensitive))
+ if (iter.findNext(start) == false)
{
- matches.push_back(indexOf(pItem));
+ // the object wasn't found in the list, so return a default (invalid) item
+ return QModelIndex();
}
- iter.next();
+ // need to back up past the current item
+ iter.previous();
}
-
- return matches;
-}
-
-QModelIndex vogleditor_QApiCallTreeModel::find_prev_search_result(vogleditor_apiCallTreeItem* start, const QString searchText)
-{
- QLinkedListIterator<vogleditor_apiCallTreeItem*> iter(m_itemList);
-
- if (iter.findNext(start) == false)
+ else
{
- // the object wasn't found in the list, so just return the same item
- return indexOf(start);
+ // set the iterator to the back so that searching starts from the end of the list
+ iter.toBack();
}
- // need to back up past the current item
- iter.previous();
-
// now the iterator is pointing to the desired start object in the list,
// continually check the prev item and find one with a snapshot
- vogleditor_apiCallTreeItem* pFound = start;
+ vogleditor_apiCallTreeItem* pFound = NULL;
while (iter.hasPrevious())
{
vogleditor_apiCallTreeItem* pItem = iter.peekPrevious();
QModelIndex vogleditor_QApiCallTreeModel::find_next_search_result(vogleditor_apiCallTreeItem* start, const QString searchText)
{
-
QLinkedListIterator<vogleditor_apiCallTreeItem*> iter(m_itemList);
- if (iter.findNext(start) == false)
+ if (start != NULL)
{
- // the object wasn't found in the list, so just return the same item
- return indexOf(start);
+ if (iter.findNext(start) == false)
+ {
+ // the object wasn't found in the list, so return a default (invalid) item
+ return QModelIndex();
+ }
}
// now the iterator is pointing to the desired start object in the list,
// continually check the next item and find one with a snapshot
- vogleditor_apiCallTreeItem* pFound = start;
+ vogleditor_apiCallTreeItem* pFound = NULL;
while (iter.hasNext())
{
vogleditor_apiCallTreeItem* pItem = iter.peekNext();
{
QLinkedListIterator<vogleditor_apiCallTreeItem*> iter(m_itemList);
- if (iter.findNext(start) == false)
+ if (start != NULL)
{
- // the object wasn't found in the list, so just return the same item
- return start;
- }
+ if (iter.findNext(start) == false)
+ {
+ // the object wasn't found in the list
+ return NULL;
+ }
- // need to back up past the current item
- iter.previous();
+ // need to back up past the current item
+ iter.previous();
+ }
+ else
+ {
+ // set the iterator to the back so that searching starts from the end of the list
+ iter.toBack();
+ }
// now the iterator is pointing to the desired start object in the list,
// continually check the prev item and find one with a snapshot
- vogleditor_apiCallTreeItem* pFound = start;
+ vogleditor_apiCallTreeItem* pFound = NULL;
while (iter.hasPrevious())
{
if (iter.peekPrevious()->has_snapshot())
{
if (iter.findNext(start) == false)
{
- // the object wasn't found in the list, so just return the same item
- return start;
+ // the object wasn't found in the list
+ return NULL;
}
}
// now the iterator is pointing to the desired start object in the list,
// continually check the next item and find one with a snapshot
- vogleditor_apiCallTreeItem* pFound = start;
+ vogleditor_apiCallTreeItem* pFound = NULL;
while (iter.hasNext())
{
if (iter.peekNext()->has_snapshot())
{
QLinkedListIterator<vogleditor_apiCallTreeItem*> iter(m_itemList);
- if (iter.findNext(start) == false)
+ if (start != NULL)
{
- // the object wasn't found in the list, so just return the same item
- return start;
- }
+ if (iter.findNext(start) == false)
+ {
+ // the object wasn't found in the list
+ return NULL;
+ }
- // need to back up past the current item
- iter.previous();
+ // need to back up past the current item
+ iter.previous();
+ }
+ else
+ {
+ // set the iterator to the back so that searching starts from the end of the list
+ iter.toBack();
+ }
// now the iterator is pointing to the desired start object in the list,
// continually check the prev item and find one with a snapshot
- vogleditor_apiCallTreeItem* pFound = start;
+ vogleditor_apiCallTreeItem* pFound = NULL;
while (iter.hasPrevious())
{
vogleditor_apiCallTreeItem* pItem = iter.peekPrevious();
{
gl_entrypoint_id_t entrypointId = static_cast<gl_entrypoint_id_t>(pItem->apiCallItem()->getGLPacket()->m_entrypoint_id);
if (vogl_is_draw_entrypoint(entrypointId) ||
- vogl_is_clear_entrypoint(entrypointId))
+ vogl_is_clear_entrypoint(entrypointId) ||
+ (entrypointId == VOGL_ENTRYPOINT_glBitmap) ||
+ (entrypointId == VOGL_ENTRYPOINT_glEnd))
{
pFound = iter.peekPrevious();
break;
if (iter.findNext(start) == false)
{
- // the object wasn't found in the list, so just return the same item
- return start;
+ // the object wasn't found in the list
+ return NULL;
}
// now the iterator is pointing to the desired start object in the list,
// continually check the next item and find one with a snapshot
- vogleditor_apiCallTreeItem* pFound = start;
+ vogleditor_apiCallTreeItem* pFound = NULL;
while (iter.hasNext())
{
vogleditor_apiCallTreeItem* pItem = iter.peekNext();
{
gl_entrypoint_id_t entrypointId = static_cast<gl_entrypoint_id_t>(pItem->apiCallItem()->getGLPacket()->m_entrypoint_id);
if (vogl_is_draw_entrypoint(entrypointId) ||
- vogl_is_clear_entrypoint(entrypointId))
+ vogl_is_clear_entrypoint(entrypointId) ||
+ (entrypointId == VOGL_ENTRYPOINT_glBitmap) ||
+ (entrypointId == VOGL_ENTRYPOINT_glEnd))
{
pFound = iter.peekNext();
break;