void Context::Applet::cleanUpAndDelete() { QGraphicsWidget *parent = dynamic_cast<QGraphicsWidget *>( parentItem() ); //it probably won't matter, but right now if there are applethandles, *they* are the parent. //not the containment. //is the applet in a containment and is the containment have a layout? if yes, we remove the applet in the layout if ( parent && parent->layout() ) { QGraphicsLayout *l = parent->layout(); for ( int i = 0; i < l->count(); ++i ) { if ( this == l->itemAt( i ) ) { l->removeAt( i ); break; } } } if ( Plasma::Applet::configScheme() ) { Plasma::Applet::configScheme()->setDefaults(); } Plasma::Applet::scene()->removeItem( this ); Plasma::Applet::deleteLater(); }
/*! Destroys the QGraphicsLayoutItem object. */ QGraphicsLayoutItem::~QGraphicsLayoutItem() { QGraphicsLayoutItem *parentLI = parentLayoutItem(); if (parentLI && parentLI->isLayout()) { QGraphicsLayout *lay = static_cast<QGraphicsLayout*>(parentLI); // this is not optimal for (int i = lay->count() - 1; i >= 0; --i) { if (lay->itemAt(i) == this) { lay->removeAt(i); break; } } } }
static void clearLayout(QGraphicsGridLayout *grid) { int rows = grid->rowCount(); for (int i=0; i<rows; i++) { QGraphicsLayout *child = static_cast<QGraphicsLayout *>(grid->itemAt(i, 0)); if (child) { int childCount = child->count(); for (int j=0; j<childCount; j++) { QGraphicsLayoutItem *item = child->itemAt(0); child->removeAt(0); delete item; } delete child; } } }
void KWidget::removeLayoutItem( KWidget *item ) { Q_D(KWidget); if(item == NULL) return; QGraphicsLayout *tmpLayout = layout(); if(tmpLayout == NULL) return; d->bAddToAnchor = false; for(int i = 0; i < tmpLayout->count(); i++) { if(tmpLayout->itemAt(i) == item) { tmpLayout->removeAt(i); break; } } }