void partNode::dump( int chars ) const { kdDebug(5006) << QString().fill( ' ', chars ) << "+ " << typeString() << '/' << subTypeString() << endl; if ( mChild ) mChild->dump( chars + 1 ); if ( mNext ) mNext->dump( chars ); }
QString PerfConfigEventsModel::generateEvent(const EventDescription &description) const { switch (description.eventType) { case EventTypeHardware: case EventTypeSoftware: return subTypeString(description.eventType, description.subType); case EventTypeCache: { QString result = subTypeString(description.eventType, description.subType); switch (description.operation) { case OperationLoad: result += "-load"; break; case OperationStore: result += "-store"; break; case OperationPrefetch: result += "-prefetch"; break; default: result += "-load"; break; } switch (description.result) { case ResultRefs: return result + "-refs"; case ResultMisses: return result + "-misses"; default: return result + "-misses"; }; } case EventTypeRaw: return QString::fromLatin1("r%1").arg(description.numericEvent, 3, 16, QLatin1Char('0')); case EventTypeBreakpoint: { QString rwx; if (description.operation & OperationLoad) rwx += 'r'; if (description.operation & OperationStore) rwx += 'w'; if (description.operation & OperationExecute) rwx += 'x'; return QString::fromLatin1("mem:%1:%2") .arg(description.numericEvent, 16, 16, QLatin1Char('0')) .arg(rwx.isEmpty() ? "r" : rwx); } case EventTypeCustom: return description.customEvent; default: return QLatin1String("cpu-cycles"); } }
QVariant PerfConfigEventsModel::data(const QModelIndex &index, int role) const { switch (role) { case Qt::DisplayRole: case Qt::EditRole: break; // Retrieve the actual value default: return QVariant(); // ignore } QString event = m_settings->events().value(index.row()); const EventDescription description = parseEvent(event); switch (index.column()) { case ColumnEventType: { if (role == Qt::DisplayRole) { if (description.eventType == EventTypeInvalid) return QVariant(); auto meta = QMetaEnum::fromType<EventType>(); return QString::fromLatin1(meta.valueToKey(description.eventType)) .mid(static_cast<int>(strlen("EventType"))).toLower(); } return description.eventType; } case ColumnSubType: { switch (description.eventType) { case EventTypeHardware: case EventTypeSoftware: case EventTypeCache: if (role == Qt::DisplayRole) return subTypeString(description.eventType, description.subType); return description.subType; case EventTypeRaw: if (role == Qt::DisplayRole) return QString("r%1").arg(description.numericEvent, 3, 16, QLatin1Char('0')); else return description.numericEvent; case EventTypeBreakpoint: if (role == Qt::DisplayRole) return QString("0x%1").arg(description.numericEvent, 16, 16, QLatin1Char('0')); else return description.numericEvent; case EventTypeCustom: return description.customEvent; default: return QVariant(); } } case ColumnOperation: if (role == Qt::DisplayRole) { if (description.eventType == EventTypeBreakpoint) { QString result; if (description.operation & OperationLoad) result += 'r'; if (description.operation & OperationStore) result += 'w'; if (description.operation & OperationExecute) result += 'x'; return result; } if (description.eventType == EventTypeCache) { if (description.operation == OperationInvalid) return QVariant(); auto meta = QMetaEnum::fromType<Operation>(); return QString::fromLatin1(meta.valueToKey(description.operation)).mid( static_cast<int>(strlen("Operation"))).toLower(); } return QVariant(); } return description.operation; case ColumnResult: if (role == Qt::DisplayRole) { if (description.result == ResultInvalid) return QVariant(); auto meta = QMetaEnum::fromType<Result>(); return QString::fromLatin1(meta.valueToKey(description.result)).mid( static_cast<int>(strlen("Result"))).toLower(); } return description.result; default: return QVariant(); } }