diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-24 09:40:11 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-24 09:40:11 +0200 |
commit | e2798d6208302a1195cb2888b69034d08dc95d89 (patch) | |
tree | 279e53c0cdf517cc341aafacabc0ad1d1e48a7de /DevTools | |
parent | 31a2a6ca2d79183d4961665dd915bbfca84f7c2f (diff) | |
download | serenity-e2798d6208302a1195cb2888b69034d08dc95d89.zip |
VisualBuilder: Convert Vector<OwnPtr> to NonnullOwnPtrVector.
Diffstat (limited to 'DevTools')
-rw-r--r-- | DevTools/VisualBuilder/VBWidget.cpp | 12 | ||||
-rw-r--r-- | DevTools/VisualBuilder/VBWidget.h | 5 | ||||
-rw-r--r-- | DevTools/VisualBuilder/VBWidgetPropertyModel.cpp | 10 | ||||
-rw-r--r-- | DevTools/VisualBuilder/VBWidgetRegistry.cpp | 2 | ||||
-rw-r--r-- | DevTools/VisualBuilder/VBWidgetRegistry.h | 3 |
5 files changed, 17 insertions, 15 deletions
diff --git a/DevTools/VisualBuilder/VBWidget.cpp b/DevTools/VisualBuilder/VBWidget.cpp index 6006d2edd6..a3de2ac241 100644 --- a/DevTools/VisualBuilder/VBWidget.cpp +++ b/DevTools/VisualBuilder/VBWidget.cpp @@ -89,7 +89,7 @@ Direction VBWidget::grabber_at(const Point& position) const void VBWidget::for_each_property(Function<void(VBProperty&)> callback) { for (auto& it : m_properties) { - callback(*it); + callback(it); } } @@ -176,8 +176,8 @@ void VBWidget::setup_properties() void VBWidget::synchronize_properties() { for (auto& prop : m_properties) { - if (prop->m_getter) - prop->m_value = prop->m_getter(*gwidget()); + if (prop.m_getter) + prop.m_value = prop.m_getter(*gwidget()); } m_property_model->update(); @@ -186,11 +186,11 @@ void VBWidget::synchronize_properties() VBProperty& VBWidget::property(const String& name) { for (auto& prop : m_properties) { - if (prop->name() == name) - return *prop; + if (prop.name() == name) + return prop; } m_properties.append(make<VBProperty>(*this, name, GVariant())); - return *m_properties.last(); + return m_properties.last(); } void VBWidget::property_did_change() diff --git a/DevTools/VisualBuilder/VBWidget.h b/DevTools/VisualBuilder/VBWidget.h index d341dbd033..8c17e77d0d 100644 --- a/DevTools/VisualBuilder/VBWidget.h +++ b/DevTools/VisualBuilder/VBWidget.h @@ -3,8 +3,9 @@ #include "VBWidgetType.h" #include <AK/Function.h> #include <AK/HashMap.h> -#include <AK/RefCounted.h> +#include <AK/NonnullOwnPtrVector.h> #include <AK/NonnullRefPtr.h> +#include <AK/RefCounted.h> #include <AK/Weakable.h> #include <LibDraw/Rect.h> @@ -79,7 +80,7 @@ private: VBWidgetType m_type { VBWidgetType::None }; VBForm& m_form; GWidget* m_gwidget { nullptr }; - Vector<OwnPtr<VBProperty>> m_properties; + NonnullOwnPtrVector<VBProperty> m_properties; NonnullRefPtr<VBWidgetPropertyModel> m_property_model; Rect m_transform_origin_rect; }; diff --git a/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp b/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp index 608f7f8502..aa9661f9d9 100644 --- a/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp +++ b/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp @@ -42,13 +42,13 @@ GModel::ColumnMetadata VBWidgetPropertyModel::column_metadata(int column) const GVariant VBWidgetPropertyModel::data(const GModelIndex& index, Role role) const { if (role == Role::Custom) { - auto& property = *m_widget.m_properties[index.row()]; + auto& property = m_widget.m_properties[index.row()]; if (index.column() == Column::Type) return (int)property.value().type(); return {}; } if (role == Role::Display) { - auto& property = *m_widget.m_properties[index.row()]; + auto& property = m_widget.m_properties[index.row()]; switch (index.column()) { case Column::Name: return property.name(); @@ -60,7 +60,7 @@ GVariant VBWidgetPropertyModel::data(const GModelIndex& index, Role role) const ASSERT_NOT_REACHED(); } if (role == Role::ForegroundColor) { - auto& property = *m_widget.m_properties[index.row()]; + auto& property = m_widget.m_properties[index.row()]; switch (index.column()) { case Column::Name: return Color::Black; @@ -77,7 +77,7 @@ GVariant VBWidgetPropertyModel::data(const GModelIndex& index, Role role) const void VBWidgetPropertyModel::set_data(const GModelIndex& index, const GVariant& value) { ASSERT(index.column() == Column::Value); - auto& property = *m_widget.m_properties[index.row()]; + auto& property = m_widget.m_properties[index.row()]; ASSERT(!property.is_readonly()); property.set_value(value); } @@ -86,6 +86,6 @@ bool VBWidgetPropertyModel::is_editable(const GModelIndex& index) const { if (index.column() != Column::Value) return false; - auto& property = *m_widget.m_properties[index.row()]; + auto& property = m_widget.m_properties[index.row()]; return !property.is_readonly(); } diff --git a/DevTools/VisualBuilder/VBWidgetRegistry.cpp b/DevTools/VisualBuilder/VBWidgetRegistry.cpp index a528935b0e..661d639a47 100644 --- a/DevTools/VisualBuilder/VBWidgetRegistry.cpp +++ b/DevTools/VisualBuilder/VBWidgetRegistry.cpp @@ -125,7 +125,7 @@ static GWidget* build_gwidget(VBWidgetType type, GWidget* parent) } } -GWidget* VBWidgetRegistry::build_gwidget(VBWidget& widget, VBWidgetType type, GWidget* parent, Vector<OwnPtr<VBProperty>>& properties) +GWidget* VBWidgetRegistry::build_gwidget(VBWidget& widget, VBWidgetType type, GWidget* parent, NonnullOwnPtrVector<VBProperty>& properties) { auto* gwidget = ::build_gwidget(type, parent); auto add_readonly_property = [&](const String& name, const GVariant& value) { diff --git a/DevTools/VisualBuilder/VBWidgetRegistry.h b/DevTools/VisualBuilder/VBWidgetRegistry.h index 779cd305fb..6aa7fd26e2 100644 --- a/DevTools/VisualBuilder/VBWidgetRegistry.h +++ b/DevTools/VisualBuilder/VBWidgetRegistry.h @@ -3,6 +3,7 @@ #include "VBWidgetType.h" #include <AK/AKString.h> #include <AK/HashMap.h> +#include <AK/NonnullOwnPtrVector.h> #include <AK/OwnPtr.h> class GWidget; @@ -18,7 +19,7 @@ public: callback((VBWidgetType)i); } - static GWidget* build_gwidget(VBWidget&, VBWidgetType, GWidget* parent, Vector<OwnPtr<VBProperty>>&); + static GWidget* build_gwidget(VBWidget&, VBWidgetType, GWidget* parent, NonnullOwnPtrVector<VBProperty>&); }; String to_class_name(VBWidgetType); |