Serenity Operating System
at master 42 lines 951 B view raw
1/* 2 * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org> 3 * Copyright (c) 2022, the SerenityOS developers. 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#include "InboxModel.h" 9 10InboxModel::InboxModel(Vector<InboxEntry> entries) 11 : m_entries(move(entries)) 12{ 13} 14 15int InboxModel::row_count(GUI::ModelIndex const&) const 16{ 17 return m_entries.size(); 18} 19 20DeprecatedString InboxModel::column_name(int column_index) const 21{ 22 switch (column_index) { 23 case Column::From: 24 return "From"; 25 case Subject: 26 return "Subject"; 27 default: 28 VERIFY_NOT_REACHED(); 29 } 30} 31 32GUI::Variant InboxModel::data(GUI::ModelIndex const& index, GUI::ModelRole role) const 33{ 34 auto& value = m_entries[index.row()]; 35 if (role == GUI::ModelRole::Display) { 36 if (index.column() == Column::From) 37 return value.from; 38 if (index.column() == Column::Subject) 39 return value.subject; 40 } 41 return {}; 42}