CRoomItem *CNamedItem::findRoom() const { for (CTreeItem *parent = getParent(); parent; parent = parent->getParent()) { CRoomItem *room = dynamic_cast<CRoomItem *>(parent); if (room) return room; } error("Couldn't find parent node"); }
CViewItem *CNamedItem::findView() const { for (CTreeItem *parent = getParent(); parent; parent = parent->getParent()) { CViewItem *view = dynamic_cast<CViewItem *>(parent); if (view) return view; } error("Couldn't find parent view"); }
CNodeItem *CNamedItem::findNode() const { for (CTreeItem *parent = getParent(); parent; parent = parent->getParent()) { CNodeItem *node = dynamic_cast<CNodeItem *>(parent); if (node) return node; } error("Couldn't find parent node"); }
CProjectItem *CProjectItem::loadData(SimpleFile *file) { if (!file->IsClassStart()) return nullptr; CProjectItem *root = nullptr; CTreeItem *parent = nullptr; CTreeItem *item = nullptr; do { CString entryString = file->readString(); if (entryString == "ALONG") { // Move along, nothing needed } else if (entryString == "UP") { // Move up if (parent == nullptr || (parent = parent->getParent()) == nullptr) break; } else if (entryString == "DOWN") { // Move down if (parent == nullptr) parent = item; else parent = parent->getLastChild(); } else { // Create new class instance item = dynamic_cast<CTreeItem *>(CSaveableObject::createInstance(entryString)); assert(item); if (root) { // Already created root project item->addUnder(parent); } else { root = dynamic_cast<CProjectItem *>(item); assert(root); root->_filename = _filename; } // Load the data for the item item->load(file); } file->IsClassStart(); } while (file->IsClassStart()); return root; }