Esempio n. 1
0
void Task::abandon(Plasma::Applet *host)
{
    QGraphicsWidget *widget = d->widgetsByHost.take(host);
    if (widget) {
        widget->deleteLater();
    }
}
Esempio n. 2
0
bool TitleWidget::removeWidget( TitleWidget::WidgetType widgetType, RemoveWidgetOptions options )
{
    if ( !m_widgets.contains(widgetType) ) {
        return false;
    }

    if ( widgetType == WidgetFilter || widgetType == WidgetQuickJourneySearch ||
         widgetType == WidgetTitle )
    {
        // Don't delete widgets that are also stored in a member variable
        // (m_filterWidget, m_journeySearchWidget, m_title)
        options ^= DeleteWidget;
        options |= HideAndRemoveWidget;
    }

    QGraphicsWidget *widget;
    if ( options.testFlag(RemoveWidget) || options.testFlag(DeleteWidget) ) {
        widget = m_widgets.take(widgetType);
        m_layout->removeItem(widget);
    } else {
        widget = m_widgets[widgetType];
    }
    if ( !widget ) {
        // A null value is stored in m_widgets, can happen if a default value gets constructed
        kDebug() << "Null value stored for widget type" << widgetType << "This can happen if a "
                "default value gets constructed for that widget type, ie. when a widget of that "
                "type gets requested from TitleWidget::m_widgets without checking if it is contained.";
        m_widgets.remove( widgetType );
        return false;
    }

    if ( options == DeleteWidget ) {
        widget->deleteLater();
    } else if ( options.testFlag(HideWidget) ) {
        widget->hide();
    }
    return true;
}