mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-30 19:02:44 +00:00 
			
		
		
		
	 b91c49364d
			
		
	
	
		b91c49364d
		
	
	
	
	
		
			
			This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
		
			
				
	
	
		
			36 lines
		
	
	
	
		
			829 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
	
		
			829 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<LexicalPath>&& files)
 | |
| {
 | |
|     return adopt_ref(*new GitFilesModel(move(files)));
 | |
| }
 | |
| 
 | |
| GitFilesModel::GitFilesModel(Vector<LexicalPath>&& 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()).string();
 | |
|     }
 | |
|     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));
 | |
| }
 | |
| 
 | |
| };
 |