GAbstractView.cpp 928 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <LibGUI/GAbstractView.h>
  2. #include <LibGUI/GModel.h>
  3. #include <LibGUI/GScrollBar.h>
  4. #include <LibGUI/GPainter.h>
  5. #include <Kernel/KeyCode.h>
  6. GAbstractView::GAbstractView(GWidget* parent)
  7. : GScrollableWidget(parent)
  8. {
  9. }
  10. GAbstractView::~GAbstractView()
  11. {
  12. }
  13. void GAbstractView::set_model(RetainPtr<GModel>&& model)
  14. {
  15. if (model.ptr() == m_model.ptr())
  16. return;
  17. if (m_model)
  18. m_model->unregister_view(Badge<GAbstractView>(), *this);
  19. m_model = move(model);
  20. if (m_model)
  21. m_model->register_view(Badge<GAbstractView>(), *this);
  22. did_update_model();
  23. }
  24. void GAbstractView::model_notification(const GModelNotification& notification)
  25. {
  26. if (on_model_notification)
  27. on_model_notification(notification);
  28. }
  29. void GAbstractView::did_update_model()
  30. {
  31. model_notification(GModelNotification(GModelNotification::ModelUpdated));
  32. }
  33. void GAbstractView::did_update_selection()
  34. {
  35. }