MCPcopy Create free account
hub / github.com/Illation/ETEngine / RebuildDirectoryTree

Method RebuildDirectoryTree

Engine/source/EtEditor/Content/ResourceView.cpp:198–237  ·  view source on GitHub ↗

------------------------------------------------ ResourceView::RebuildDirectoryTree

Source from the content-addressed store, hash-verified

196// ResourceView::RebuildDirectoryTree
197//
198void ResourceView::RebuildDirectoryTree()
199{
200 FileResourceManager* const resourceMan = static_cast<FileResourceManager*>(core::ResourceManager::Instance());
201 ET_ASSERT(resourceMan != nullptr);
202
203 m_BaseDirectory = m_ProjectSelected ? resourceMan->GetProjectDirectory() : resourceMan->GetEngineDirectory();
204
205 m_TreeModel->clear();
206
207 Gtk::TreeModel::Row row = *(m_TreeModel->append());
208 row[m_Columns.m_Name] = m_ProjectSelected ? "Project Resources" : "Engine Resources";
209 row[m_Columns.m_Directory] = m_BaseDirectory;
210
211 auto recursiveAddChildren = [this](Gtk::TreeModel::Row& row, auto& fnRef) mutable -> void
212 {
213 core::Directory* const baseDir = row[m_Columns.m_Directory];
214 ET_ASSERT(baseDir != nullptr);
215
216 for (core::Entry* const entry : baseDir->GetChildren())
217 {
218 if (entry->GetType() == core::Entry::EntryType::ENTRY_DIRECTORY)
219 {
220 core::Directory* const childDir = static_cast<core::Directory*>(entry);
221
222 Gtk::TreeModel::Row childRow = *(m_TreeModel->append(row.children()));
223 childRow[m_Columns.m_Name] = childDir->GetNameOnly().substr(0, childDir->GetNameOnly().size() - 1).c_str();
224 childRow[m_Columns.m_Directory] = childDir;
225
226 fnRef(childRow, fnRef);
227 }
228 }
229 };
230
231 recursiveAddChildren(row, recursiveAddChildren);
232
233 m_TreeSelection->select(row);
234
235 m_TreeView->show_all_children();
236 m_TreeView->expand_all();
237}
238
239//------------------------------------------------
240// ResourceView::RebuildDirectoryTree

Callers

nothing calls this directly

Calls 4

GetProjectDirectoryMethod · 0.80
GetEngineDirectoryMethod · 0.80
GetChildrenMethod · 0.80
GetTypeMethod · 0.45

Tested by

no test coverage detected