mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
3d4afe7614
I've wasted a silly amount of time in the past fretting over which of these words to use. Let's just choose one and use it everywhere. :^)
71 lines
1.6 KiB
C++
71 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "IndividualSampleModel.h"
|
|
#include "Profile.h"
|
|
#include <AK/StringBuilder.h>
|
|
#include <stdio.h>
|
|
|
|
IndividualSampleModel::IndividualSampleModel(Profile& profile, size_t event_index)
|
|
: m_profile(profile)
|
|
, m_event_index(event_index)
|
|
{
|
|
}
|
|
|
|
IndividualSampleModel::~IndividualSampleModel()
|
|
{
|
|
}
|
|
|
|
int IndividualSampleModel::row_count(const GUI::ModelIndex&) const
|
|
{
|
|
auto& event = m_profile.events().at(m_event_index);
|
|
return event.frames.size();
|
|
}
|
|
|
|
int IndividualSampleModel::column_count(const GUI::ModelIndex&) const
|
|
{
|
|
return Column::__Count;
|
|
}
|
|
|
|
String IndividualSampleModel::column_name(int column) const
|
|
{
|
|
switch (column) {
|
|
case Column::Address:
|
|
return "Address";
|
|
case Column::ObjectName:
|
|
return "Object";
|
|
case Column::Symbol:
|
|
return "Symbol";
|
|
default:
|
|
VERIFY_NOT_REACHED();
|
|
}
|
|
}
|
|
|
|
GUI::Variant IndividualSampleModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
|
{
|
|
auto& event = m_profile.events().at(m_event_index);
|
|
auto& frame = event.frames[event.frames.size() - index.row() - 1];
|
|
|
|
if (role == GUI::ModelRole::Display) {
|
|
if (index.column() == Column::Address)
|
|
return String::formatted("{:p}", frame.address);
|
|
|
|
if (index.column() == Column::Symbol) {
|
|
return frame.symbol;
|
|
}
|
|
|
|
if (index.column() == Column::ObjectName) {
|
|
return frame.object_name;
|
|
}
|
|
return {};
|
|
}
|
|
return {};
|
|
}
|
|
|
|
void IndividualSampleModel::update()
|
|
{
|
|
did_update(Model::InvalidateAllIndices);
|
|
}
|