// "start" is the model index that is searched first in a forward search, i.e. as if the // "cursor" were between start-1 and start bool TraceViewFindSupport::findOne(const QString &txt, Core::FindFlags findFlags, int start) { bool caseSensitiveSearch = (findFlags & Core::FindCaseSensitively); QRegExp regexp(txt); regexp.setPatternSyntax((findFlags & Core::FindRegularExpression) ? QRegExp::RegExp : QRegExp::FixedString); regexp.setCaseSensitivity(caseSensitiveSearch ? Qt::CaseSensitive : Qt::CaseInsensitive); QTextDocument::FindFlags flags; if (caseSensitiveSearch) flags |= QTextDocument::FindCaseSensitively; if (findFlags & Core::FindWholeWords) flags |= QTextDocument::FindWholeWords; bool forwardSearch = !(findFlags & Core::FindBackward); int increment = forwardSearch ? +1 : -1; int current = forwardSearch ? start : start - 1; QmlProfilerNotesModel *model = m_modelManager->notesModel(); while (current >= 0 && current < model->count()) { QTextDocument doc(model->text(current)); // for automatic handling of WholeWords option if (!doc.find(regexp, 0, flags).isNull()) { m_currentPosition = current; m_view->selectByEventIndex(model->timelineModel(m_currentPosition), model->timelineIndex(m_currentPosition)); m_view->updateCursorPosition(); // open file/line that belongs to event return true; } current += increment; } return false; }
QVariant FlameGraphModel::lookup(const FlameGraphData &stats, int role) const { switch (role) { case TypeIdRole: return stats.typeIndex; case NoteRole: { QString ret; if (!m_typeIdsWithNotes.contains(stats.typeIndex)) return ret; QmlProfilerNotesModel *notes = m_modelManager->notesModel(); foreach (const QVariant &item, notes->byTypeId(stats.typeIndex)) { if (ret.isEmpty()) ret = notes->text(item.toInt()); else ret += QChar::LineFeed + notes->text(item.toInt()); } return ret; } case DurationRole: return stats.duration; case CallCountRole: return stats.calls; case TimePerCallRole: return stats.duration / stats.calls; case TimeInPercentRole: return stats.duration * 100 / m_stackBottom.duration; case AllocationsRole: return stats.allocations; case MemoryRole: return stats.memory; default: break; } if (stats.typeIndex != -1) { const QVector<QmlEventType> &typeList = m_modelManager->qmlModel()->eventTypes(); const QmlEventType &type = typeList[stats.typeIndex]; switch (role) { case FilenameRole: return type.location().filename(); case LineRole: return type.location().line(); case ColumnRole: return type.location().column(); case TypeRole: return nameForType(type.rangeType()); case RangeTypeRole: return type.rangeType(); case DetailsRole: return type.data().isEmpty() ? FlameGraphModel::tr("Source code not available") : type.data(); case LocationRole: return type.displayName(); default: return QVariant(); } } else { return QVariant(); } }