void ActionGraphicsItem::calculateLayout() { if(elementLayout() == 0) return; const ElementLayout & el = *elementLayout(); // calculate the size of the label QSizeF labelSize = calculateLabelSize(); QSize connectorSize = inputLayout()->connector().size(); // find the new width & height float height = labelSize.height() + 2*el.yMargin(); float width = labelSize.width() + 2*el.xMargin() + connectorSize.width(); if(width < el.minSize().width()) width = el.minSize().width(); if(height < el.minSize().height()) height = el.minSize().height(); // the height should be bigger or the same as the attached elements if(inputItem() && height < inputItem()->boundingRect().height()) height = inputItem()->boundingRect().height(); // update the bounding rect & position where text should start setInnerRect(QRectF(0, -height/2.0f, width, height)); setLabelStart(QPointF(connectorSize.width() + el.xMargin(), -labelSize.height()/2.0f)); setBoundingRect(innerRect().adjusted(-inputItem()->innerRect().width(), 0, 0, 0)); }
// Dynamisk Minneshantering ItemStruct* addItemToListinHeap(ItemStruct* ior_itemList, int* ior_currslotCount) { // ior_currslotCount ger os antalet möjliga föremål som finns i listan just nu. // Anropet till realloc behöver ett föremål extra: därav ior_currslotCount + 1 // När realloc framgångsrikt returnerat en pekare till det nya minnet räknas ior_currslotCount upp. // Annars returneras en Nullpekare. ItemStruct* ptr; int index; // Undersöker om det finns lediga slots, om ja: återanvänd. // Unik ID refererar till plats i listan. Är inte knutet till föremålet. for (index = 0; index < ior_currslotCount; index++) { if (ior_itemList[index].isId == 0) { ior_itemList[index].isId = index + 1; addItem(&ior_itemList[index]); return ior_itemList; } } // Skapa en ny slott i listan och flytta den i heapen om det behövs. ptr = (ItemStruct*)realloc(ior_itemList, sizeof(ItemStruct)*(*ior_currslotCount + 1)); if (ptr != NULL) { // Om allokering framgångsrik: flytta till ledig possition och lägg till föremål. ptr[*ior_currslotCount].isId = *ior_currslotCount + 1; inputItem(&ptr[*ior_currslotCount]); (*ior_currslotCount)++; // Uppdaterar antal slots i listan. } // Returnera en pekare till listans start. return ptr; } //addItemToListinHeap
int PLItem::id( int type ) { switch( type ) { case INPUTITEM_ID: return inputItem()->i_id; case PLAYLIST_ID: return i_playlist_id; default: case MLMEDIA_ID: vlc_assert_unreachable(); return -1; } }