editor::Buffer *BufferWidget::doOpenDescriptor(const FileDescriptor &d) { // If we only have one "Untitled" buffer, we'll replace it. if(tabs.count() == 1) { QSet<Pane *>::iterator i = tabs.begin(); Pane *p = *i; int idx = tabWidget->indexOf(p); if((!p->getBuffer()->hasBeenSaved()) && (!p->getBuffer()->isModified())) { tabWidget->removeTab(idx); delete p; tabs.clear(); } } // Open each of the files. int existing = findBufferWithPath(d.fileName); if(existing != -1) { tabWidget->setCurrentIndex(existing); return nullptr; } Pane *p = newPane(); p->getBuffer()->open(d); Q_EMIT pathOpened(d.fileName); return p->getBuffer(); }
void PathFind::continuePath() { for (int i = 0; i < 4; ++i) { if (openList.empty()) { return; } Node* currentNode = getNextNode(); if (currentNode->getID() == endNode->getID()) { endNode->setParentNode(currentNode->getParentNode()); Node* getPath; for (getPath = endNode; getPath != NULL; getPath = getPath->getParentNode()) { pathToEnd.push_back(new Vector2(getPath->getPos())); } foundEnd = true; return; } else { // right side pathOpened(Vector2(currentNode->getPos().x + 1, currentNode->getPos().y), currentNode->getG() + 1, currentNode); // left side pathOpened(Vector2(currentNode->getPos().x - 1, currentNode->getPos().y), currentNode->getG() + 1, currentNode); // up pathOpened(Vector2(currentNode->getPos().x, currentNode->getPos().y + 1), currentNode->getG() + 1, currentNode); // down pathOpened(Vector2(currentNode->getPos().x, currentNode->getPos().y - 1), currentNode->getG() + 1, currentNode); // top left pathOpened(Vector2(currentNode->getPos().x - 1, currentNode->getPos().y + 1), currentNode->getG() + 1.414f, currentNode); // top right pathOpened(Vector2(currentNode->getPos().x + 1, currentNode->getPos().y + 1), currentNode->getG() + 1.414f, currentNode); // bottom left pathOpened(Vector2(currentNode->getPos().x - 1, currentNode->getPos().y - 1), currentNode->getG() + 1.414f, currentNode); // bottom right pathOpened(Vector2(currentNode->getPos().x + 1, currentNode->getPos().y - 1), currentNode->getG() + 1.414f, currentNode); for (unsigned i = 0; i < openList.size(); ++i) { if (currentNode->getID() == openList[i]->getID()) { openList.erase(openList.begin() + i); } } } } }