
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
36 lines
830 B
C++
36 lines
830 B
C++
/*
|
|
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "GitFilesModel.h"
|
|
|
|
namespace HackStudio {
|
|
|
|
NonnullRefPtr<GitFilesModel> GitFilesModel::create(Vector<DeprecatedString>&& files)
|
|
{
|
|
return adopt_ref(*new GitFilesModel(move(files)));
|
|
}
|
|
|
|
GitFilesModel::GitFilesModel(Vector<DeprecatedString>&& files)
|
|
: m_files(move(files))
|
|
{
|
|
}
|
|
|
|
GUI::Variant GitFilesModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
|
{
|
|
if (role == GUI::ModelRole::Display) {
|
|
return m_files.at(index.row());
|
|
}
|
|
return {};
|
|
}
|
|
|
|
GUI::ModelIndex GitFilesModel::index(int row, int column, const GUI::ModelIndex&) const
|
|
{
|
|
if (row < 0 || row >= static_cast<int>(m_files.size()))
|
|
return {};
|
|
return create_index(row, column, &m_files.at(row));
|
|
}
|
|
|
|
};
|