summaryrefslogtreecommitdiff
path: root/Userland/DevTools/HackStudio/Debugger/VariablesModel.h
blob: b088dfee3c4da9ea701342a7dc49d9a9abbbc4f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include "Debugger.h"
#include <AK/NonnullOwnPtr.h>
#include <LibGUI/Model.h>
#include <LibGUI/TreeView.h>
#include <sys/arch/i386/regs.h>

namespace HackStudio {

class VariablesModel final : public GUI::Model {
public:
    static RefPtr<VariablesModel> create(const PtraceRegisters& regs);

    void set_variable_value(const GUI::ModelIndex&, StringView, GUI::Window*);

    virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
    virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return 1; }
    virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override;
    virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override;
    virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override;

private:
    explicit VariablesModel(NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo>&& variables, const PtraceRegisters& regs)
        : m_variables(move(variables))
        , m_regs(regs)
    {
        m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors());
    }
    NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo> m_variables;
    PtraceRegisters m_regs;

    GUI::Icon m_variable_icon;
};

}