summaryrefslogtreecommitdiff
path: root/DevTools/HackStudio/WidgetTreeModel.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-11 19:13:36 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-11 22:20:02 +0100
commitd5f735ecec90e25d423f0f2bc1b5476e6d7c4196 (patch)
tree27469ddfb98a0dff92f877e2f15e69e4058290b4 /DevTools/HackStudio/WidgetTreeModel.h
parent524da0ad01ef6b76669fcb69539b907d315e8e87 (diff)
downloadserenity-d5f735ecec90e25d423f0f2bc1b5476e6d7c4196.zip
HackStudio: Show the edited form widget's widget tree in the tree view
This patch introduces a simple WidgetTreeModel that models the widget tree inside of a given root GWidget.
Diffstat (limited to 'DevTools/HackStudio/WidgetTreeModel.h')
-rw-r--r--DevTools/HackStudio/WidgetTreeModel.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/DevTools/HackStudio/WidgetTreeModel.h b/DevTools/HackStudio/WidgetTreeModel.h
new file mode 100644
index 0000000000..10a81da3fa
--- /dev/null
+++ b/DevTools/HackStudio/WidgetTreeModel.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <LibGUI/GModel.h>
+#include <LibGUI/GPainter.h>
+
+class WidgetTreeModel final : public GModel {
+public:
+ static NonnullRefPtr<WidgetTreeModel> create(GWidget& root) { return adopt(*new WidgetTreeModel(root)); }
+ virtual ~WidgetTreeModel() override;
+
+ 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 GModelIndex index(int row, int column, const GModelIndex& parent = GModelIndex()) const override;
+ virtual GModelIndex parent_index(const GModelIndex&) const override;
+ virtual void update() override;
+
+private:
+ explicit WidgetTreeModel(GWidget&);
+
+ NonnullRefPtr<GWidget> m_root;
+ GIcon m_widget_icon;
+};