Exemplo n.º 1
0
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();
}
Exemplo n.º 2
0
void HGLayout::setAlignment(Qt::Alignment align)
{
    HLayout::setAlignment(align);

    if (!layout()) return ;

    QGraphicsLayout* l = layout();
    if (!l) return ;

    for (int i = 0; i <l->count(); i++)
        setAlignment(l->itemAt(i), align);
}
Exemplo n.º 3
0
/*!
    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;
            }
        }
    }
}
Exemplo n.º 4
0
bool KWidget::bylayout()
{
    KWidget *itemParent = qobject_cast<KWidget*>(parent());
    if(itemParent == NULL)
        return false;
    QGraphicsLayoutItem *item = dynamic_cast<QGraphicsLayoutItem*>(this);
    QGraphicsLayout *layout = itemParent->layout();
    for(int i = 0; i < layout->count(); i++)
    {
        if(layout->itemAt(i) == item)
            return true;
    }
    return false;
}
Exemplo n.º 5
0
void QGraphicsLayoutPrivate::activateRecursive(QGraphicsLayoutItem *item)
{
    if (item->isLayout()) {
        QGraphicsLayout *layout = static_cast<QGraphicsLayout *>(item);
        if (layout->d_func()->activated)
            layout->invalidate();
        
        for (int i = layout->count() - 1; i >= 0; --i) {
            QGraphicsLayoutItem *childItem = layout->itemAt(i);
            if (childItem)
                activateRecursive(childItem);
        }
        layout->d_func()->activated = true;
    }
}
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;
        }
    }
}
Exemplo n.º 7
0
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;
        }
    }
}
Exemplo n.º 8
0
void QGraphicsLayoutPrivate::activateRecursive(QGraphicsLayoutItem *item)
{
    if (item->isLayout()) {
        QGraphicsLayout *layout = static_cast<QGraphicsLayout *>(item);
        if (layout->d_func()->activated) {
            if (QGraphicsLayout::instantInvalidatePropagation()) {
                return;
            } else {
                layout->invalidate();   // ### LOOKS SUSPICIOUSLY WRONG!!???
            }
        }

        for (int i = layout->count() - 1; i >= 0; --i) {
            QGraphicsLayoutItem *childItem = layout->itemAt(i);
            if (childItem)
                activateRecursive(childItem);
        }
        layout->d_func()->activated = true;
    }
}