diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-30 03:49:39 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-30 03:49:39 +0100 |
commit | 4506e3a085d19e13ce60a44876ee1e837bb0b995 (patch) | |
tree | b612da4e515fb8822392d9c5d8ea2d30befa81e6 /LibGUI/GTreeView.cpp | |
parent | a92710ce3f80c8fa3b54e71b55e8d9dd9058bfeb (diff) | |
download | serenity-4506e3a085d19e13ce60a44876ee1e837bb0b995.zip |
GTreeView: Remove test model I was using during bringup.
Diffstat (limited to 'LibGUI/GTreeView.cpp')
-rw-r--r-- | LibGUI/GTreeView.cpp | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/LibGUI/GTreeView.cpp b/LibGUI/GTreeView.cpp index fa262fc069..ee99c46491 100644 --- a/LibGUI/GTreeView.cpp +++ b/LibGUI/GTreeView.cpp @@ -4,95 +4,10 @@ //#define DEBUG_ITEM_RECTS -struct Node { - String text; - Node* parent { nullptr }; - Vector<Node*> children; -}; - -class TestModel : public GModel { -public: - static Retained<TestModel> create() { return adopt(*new TestModel); } - - TestModel(); - - virtual int row_count(const GModelIndex& = GModelIndex()) const override; - virtual int column_count(const GModelIndex& = GModelIndex()) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; - virtual void update() override; - virtual GModelIndex index(int row, int column = 0, const GModelIndex& parent = GModelIndex()) const override; - virtual ColumnMetadata column_metadata(int) const override{ return { 100 }; } - - Node* m_root { nullptr }; -}; - -Node* make_little_tree(int depth, Node* parent) -{ - static int next_id = 0; - Node* node = new Node; - node->text = String::format("Node #%d", next_id++); - node->parent = parent; - if (depth) - node->children.append(make_little_tree(depth - 1, node)); - return node; -} - -GModelIndex TestModel::index(int row, int column, const GModelIndex& parent) const -{ - if (!parent.is_valid()) - return create_index(row, column, m_root); - auto& node = *(Node*)parent.internal_data(); - return create_index(row, column, node.children[row]); -} - -TestModel::TestModel() -{ - m_root = new Node; - m_root->text = "Root"; - - m_root->children.append(make_little_tree(3, m_root)); - m_root->children.append(make_little_tree(2, m_root)); - m_root->children.append(make_little_tree(1, m_root)); -} - -int TestModel::row_count(const GModelIndex& index) const -{ - if (!index.is_valid()) - return 1; - auto& node = *(const Node*)index.internal_data(); - return node.children.size(); -} - -int TestModel::column_count(const GModelIndex&) const -{ - return 1; -} - -void TestModel::update() -{ -} - -GVariant TestModel::data(const GModelIndex& index, Role role) const -{ - if (!index.is_valid()) - return { }; - auto& node = *(const Node*)index.internal_data(); - if (role == GModel::Role::Display) { - return node.text; - } - if (role == GModel::Role::Icon) { - if (node.children.is_empty()) - return GIcon::default_icon("filetype-unknown"); - return GIcon::default_icon("filetype-folder"); - } - return { }; -} - struct GTreeView::MetadataForIndex { bool open { false }; }; - GTreeView::MetadataForIndex& GTreeView::ensure_metadata_for_index(const GModelIndex& index) const { ASSERT(index.is_valid()); @@ -112,8 +27,6 @@ GTreeView::GTreeView(GWidget* parent) set_frame_shadow(GFrame::Shadow::Sunken); set_frame_thickness(2); - set_model(TestModel::create()); - m_expand_bitmap = GraphicsBitmap::load_from_file("/res/icons/treeview-expand.png"); m_collapse_bitmap = GraphicsBitmap::load_from_file("/res/icons/treeview-collapse.png"); } |