InterruptsWidget.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "InterruptsWidget.h"
  7. #include <LibGUI/BoxLayout.h>
  8. #include <LibGUI/GroupBox.h>
  9. #include <LibGUI/JsonArrayModel.h>
  10. #include <LibGUI/SortingProxyModel.h>
  11. #include <LibGUI/TableView.h>
  12. InterruptsWidget::InterruptsWidget()
  13. {
  14. on_first_show = [this](auto&) {
  15. set_layout<GUI::VerticalBoxLayout>();
  16. layout()->set_margins(4);
  17. Vector<GUI::JsonArrayModel::FieldSpec> interrupts_field;
  18. interrupts_field.empend("interrupt_line", "Line", Gfx::TextAlignment::CenterRight);
  19. interrupts_field.empend("purpose", "Purpose", Gfx::TextAlignment::CenterLeft);
  20. interrupts_field.empend("controller", "Controller", Gfx::TextAlignment::CenterLeft);
  21. interrupts_field.empend("cpu_handler", "CPU Handler", Gfx::TextAlignment::CenterRight);
  22. interrupts_field.empend("device_sharing", "# Devices Sharing", Gfx::TextAlignment::CenterRight);
  23. interrupts_field.empend("call_count", "Call Count", Gfx::TextAlignment::CenterRight);
  24. m_interrupt_table_view = add<GUI::TableView>();
  25. m_interrupt_model = GUI::JsonArrayModel::create("/proc/interrupts", move(interrupts_field));
  26. m_interrupt_table_view->set_model(GUI::SortingProxyModel::create(*m_interrupt_model));
  27. m_update_timer = add<Core::Timer>(
  28. 1000, [this] {
  29. update_model();
  30. });
  31. update_model();
  32. };
  33. }
  34. InterruptsWidget::~InterruptsWidget()
  35. {
  36. }
  37. void InterruptsWidget::update_model()
  38. {
  39. m_interrupt_model->invalidate();
  40. }