Serenity Operating System
at master 54 lines 1.3 kB view raw
1/* 2 * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <LibGUI/Model.h> 10 11namespace Profiler { 12 13class Profile; 14class ProfileNode; 15 16struct SourceLineData { 17 u32 event_count { 0 }; 18 float percent { 0 }; 19 DeprecatedString location; 20 u32 line_number { 0 }; 21 DeprecatedString source_code; 22}; 23 24class SourceModel final : public GUI::Model { 25public: 26 static NonnullRefPtr<SourceModel> create(Profile& profile, ProfileNode& node) 27 { 28 return adopt_ref(*new SourceModel(profile, node)); 29 } 30 31 enum Column { 32 SampleCount, 33 Location, 34 LineNumber, 35 SourceCode, 36 __Count 37 }; 38 39 virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override; 40 virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Count; } 41 virtual DeprecatedString column_name(int) const override; 42 virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override; 43 virtual bool is_column_sortable(int) const override { return false; } 44 45private: 46 SourceModel(Profile&, ProfileNode&); 47 48 Profile& m_profile; 49 ProfileNode& m_node; 50 51 Vector<SourceLineData> m_source_lines; 52}; 53 54}