1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:34:57 +00:00
serenity/Userland/Applications/KeyboardSettings/CharacterMapFileListModel.h
2021-04-29 22:16:18 +02:00

54 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright (c) 2020, Hüseyin Aslıtürk <asliturk@hotmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Vector.h>
#include <LibGUI/Model.h>
class CharacterMapFileListModel final : public GUI::Model {
public:
static NonnullRefPtr<CharacterMapFileListModel> create(Vector<String>& filenames)
{
return adopt_ref(*new CharacterMapFileListModel(filenames));
}
virtual ~CharacterMapFileListModel() override { }
virtual int row_count(const GUI::ModelIndex&) const override
{
return m_filenames.size();
}
virtual int column_count(const GUI::ModelIndex&) const override
{
return 1;
}
virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override
{
VERIFY(index.is_valid());
VERIFY(index.column() == 0);
if (role == GUI::ModelRole::Display)
return m_filenames.at(index.row());
return {};
}
virtual void update() override
{
did_update();
}
private:
explicit CharacterMapFileListModel(Vector<String>& filenames)
: m_filenames(filenames)
{
}
Vector<String>& m_filenames;
};