static void doubleRotate(TLDNode *k1, TLDNode *k2, TLDNode *k3, TLDNode *p, int isLeftChild, TLDList *tld) { if (p == NULL) { tld->root = k2; k2->parent = NULL; } else if (isLeftChild) { p->left = k2; k2->parent = p; } else { p->right = k2; k2->parent = p; } k3->left = k2->right; updateParent(k3, k2->right); k1->right = k2->left; updateParent(k1, k2->left); k2->left = k1; k2->right = k3; k1->parent = k2; k3->parent = k2; updateHeight(k1); updateHeight(k3); }
/************************************************ * No Change * RETURN: * success - successfully created the index list header * failure - it did not create the index list header ***********************************************************/ const int IndexList::updateLastPtrAndParent(const int lastCount) { int rc = NO_ERROR; rc = updateLastPtr(lastCount); rc = updateParent(); return rc; }
void ScanGallery::addImage(const QImage *img, const ImageMetaInfo *info) { if (img==NULL) return; // nothing to save! kDebug() << "size" << img->size() << "depth" << img->depth(); if (mSaver==NULL) prepareToSave(NULL); // if not done already if (mSaver==NULL) return; // should never happen ImgSaver::ImageSaveStatus isstat = mSaver->saveImage(img); // try to save the image KUrl lurl = mSaver->lastURL(); // record where it ended up if (isstat!=ImgSaver::SaveStatusOk && // image saving failed isstat!=ImgSaver::SaveStatusCanceled) // user cancelled, just ignore { KMessageBox::error(this, i18n("<qt>Could not save the image<br><filename>%2</filename><br><br>%1", mSaver->errorString(isstat), lurl.prettyUrl()), i18n("Image Save Error")); } delete mSaver; mSaver = NULL; // now finished with this if (isstat==ImgSaver::SaveStatusOk) // image was saved OK, { // select the new image slotSetNextUrlToSelect(lurl); m_nextUrlToShow = lurl; if (mSavedTo!=NULL) updateParent(mSavedTo); } }
void Label::redraw() { if(m_font && m_text.length() > 0) { if(m_renderedText != nullptr) { SDL_DestroyTexture(m_renderedText); } SDL_Surface *rendered = nullptr; if(getBoundingBox().w == 0) { rendered = TTF_RenderUTF8_Blended(m_font->getFont(), m_text.c_str(), m_color); } else { rendered = TTF_RenderUTF8_Blended_Wrapped(m_font->getFont(), m_text.c_str(), m_color, getBoundingBox().w); } if(rendered == nullptr) { cout << "Problem rendering text to surface: " << TTF_GetError() << endl; } m_renderedText = SDL_CreateTextureFromSurface(getGlobalConfig()->getSDLRenderer(), rendered); if(m_renderedText == nullptr) { cout << "Problem rendering text to texture: " << SDL_GetError() << endl; } SDL_FreeSurface(rendered); SDL_QueryTexture(m_renderedText, nullptr, nullptr, &m_textW, &m_textH); updateParent(); } }
void DropShadower::componentParentHierarchyChanged (Component& c) { if (owner == &c) { updateParent(); updateShadows(); } }
DropShadower::~DropShadower() { if (owner != nullptr) { owner->removeComponentListener (this); owner = nullptr; } updateParent(); reentrant = true; shadowWindows.clear(); }
SoundEffectInstance::SoundEffectInstance(SoundEffect* effect) { assert(effect != nullptr); m_isLooped = false; m_gain = 1.0f; m_positioned = false; m_isFireAndForget = false; #ifdef NXNA_AUDIOENGINE_OPENAL alGenSources(1, (ALuint*)&m_source); #endif updateParent(effect); }
std::vector<const Edge*> connection(const std::vector<Edge*> &edges, const KDTree &tree) { std::vector<const Edge*> solution; double best = std::numeric_limits<double>::infinity(); for(const auto edge : edges) { auto res = tree.kNearestWithin(edge, linkRadius); for(const auto e : res.elements) { Edge newEdge = agent.steer(edge->end, e->end, std::numeric_limits<double>::infinity()); if(workspace.safeEdge(agent, newEdge, collisionCheckDT)) { double newSolutionCost = edge->gCost() + e->gCost(); if(newSolutionCost >= best) { continue; } best = newSolutionCost; std::vector<Edge *> newSolution; newSolution.push_back(edge); unsigned int edgeCount = 1; while(newSolution.back()->parent != NULL) { edgeCount++; newSolution.push_back(newSolution.back()->parent); } std::reverse(newSolution.begin(), newSolution.end()); newEdge.updateParent(edge); auto curEdge = e; newSolution.push_back(curEdge); while(curEdge->parent != NULL) { auto prevEdge = newSolution.back(); curEdge = curEdge->parent; auto saved = new Edge(*curEdge); saved->updateParent(prevEdge); newSolution.push_back(saved); } solution.insert(solution.begin(), newSolution.begin(), newSolution.end()); } } } return solution; }
void DropShadower::setOwner (Component* componentToFollow) { if (componentToFollow != owner) { if (owner != nullptr) owner->removeComponentListener (this); // (the component can't be null) jassert (componentToFollow != nullptr); owner = componentToFollow; jassert (owner != nullptr); updateParent(); owner->addComponentListener (this); updateShadows(); } }
static void RRRotation(TLDNode *x, TLDList *tld) { TLDNode *k1 = x; TLDNode *k2 = x->right; TLDNode *p = k1->parent; if (p == NULL) { tld->root = k2; k2->parent = NULL; } else if (isLeftChild(k1)) p->left = k2; else p->right = k2; k1->right = k2->left; updateParent(k1, k2->left); k1->parent = k2; k2->parent = p; k2->left = k1; updateHeight(k1); }
static void LLRodation(TLDNode *x, TLDList *tld) { TLDNode *k2 = x; TLDNode *k1 = k2->left; TLDNode *p = k2->parent; if (p == NULL) { tld->root = k1; k1->parent = NULL; } else if (isLeftChild(k2)) p->left = k1; else p->right = k1; k2->left = k1->right; updateParent(k2, k1->right); k2->parent = k1; k1->parent = p; k1->right = k2; updateHeight(k2); }
void ScanGallery::slotDeleteItems() { FileTreeViewItem *curr = highlightedFileTreeViewItem(); if (curr==NULL) return; KUrl urlToDel = curr->url(); // item to be deleted bool isDir = curr->isDir(); // deleting a folder? QTreeWidgetItem *nextToSelect = curr->treeWidget()->itemBelow(curr); // select this afterwards QString s; QString dontAskKey; if (isDir) { s = i18n("<qt>Do you really want to permanently delete the folder<br>" "<filename>%1</filename><br>" "and all of its contents? It cannot be restored.", urlToDel.pathOrUrl()); dontAskKey = "AskForDeleteDirs"; } else { s = i18n("<qt>Do you really want to permanently delete the image<br>" "<filename>%1</filename>?<br>" "It cannot be restored.", urlToDel.pathOrUrl()); dontAskKey = "AskForDeleteFiles"; } if (KMessageBox::warningContinueCancel(this, s, i18n("Delete Gallery Item"), KStandardGuiItem::del(), KStandardGuiItem::cancel(), dontAskKey)!=KMessageBox::Continue) return; slotUnloadItem(curr); kDebug() << "Deleting" << urlToDel; /* Since we are currently talking about local files here, NetAccess is OK */ if (!KIO::NetAccess::del(urlToDel,NULL)) { KMessageBox::error(this, i18n("<qt>Could not delete the image or folder<br><filename>%2</filename><br><br>%1", KIO::NetAccess::lastErrorString(), urlToDel.prettyUrl()), i18n("File Delete Error")); return; } updateParent(curr); // update parent folder count if (isDir) // remove from the name combo { emit galleryDirectoryRemoved(curr->branch(), itemDirectoryRelative(curr)); } #if 0 if (nextToSelect!=NULL) setSelected(nextToSelect,true); // TODO: if doing the above, also need to signal to update thumbnail // as below. // // But doing that leads to inconsistency between deleting the last item // in a folder (nothing is selected afterwards) and deleting anything // else (the next image is selected and loaded). So leaving this // commented out for now. curr = highlightedFileTreeViewItem(); kDebug() << "new selection after delete" << (curr==NULL ? "NULL" : curr->url().prettyURL()); if (curr!=NULL) emit showItem(curr->fileItem()); #endif }
QtMenuBar::QtMenuBar(QDeclarativeItem *parent) : QDeclarativeItem(parent), _menuBar(0) /*, _menuBar(new QMenuBar)*/ { connect(this, SIGNAL(parentChanged()), this, SLOT(updateParent())); setFlag(QGraphicsItem::ItemHasNoContents, true); }