Correct the layout invalidation logic. As with Qt, when a layout is invalidated it finds its top-level layout and causes that to be updated. Calling Widget::updageGeometry() causes the parent widget's layout to be invalidated.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=709495
This commit is contained in:
Robert Knight 2007-09-07 16:15:46 +00:00
parent 45f7769d44
commit 3dc0a4795f
2 changed files with 14 additions and 44 deletions

View File

@ -82,26 +82,17 @@ void Layout::update()
}
void Layout::invalidate()
{
//qDebug() << "Layout update";
LayoutItem *item = parent();
while ( item ) {
//qDebug() << "Looking at item " << item;
Widget *widget = dynamic_cast<Widget*>(item);
if ( widget ) {
//qDebug() << "Parent widget found and invalidated";
widget->updateGeometry();
break;
}
else {
Layout *layout = dynamic_cast<Layout*>(item);
if ( layout ) {
item = layout->parent();
// qDebug() << "Item is a layout";
}
else
item = 0;
}
}
// find and update the top level layout
Layout *layout = this;
Layout *parentLayout = 0;
do {
parentLayout = dynamic_cast<Layout*>(layout->parent());
if ( parentLayout )
layout = parentLayout;
} while ( parentLayout );
layout->update();
}

View File

@ -180,30 +180,9 @@ void Widget::setGeometry(const QRectF& geometry)
void Widget::updateGeometry()
{
prepareGeometryChange();
Widget *widget = this;
while ( widget ) {
if ( widget->parent() == 0 || widget->parent()->layout() != 0 ) {
if ( widget->layout() ) {
widget->layout()->update();
widget->update();
if ( parent() && parent()->layout() ) {
parent()->layout()->invalidate();
}
break;
}
widget = widget->parent();
}
#if 0
prepareGeometryChange();
if (layout()) {
// kDebug() << (void *) this << " updating geometry to " << size();
//
//qDebug() << "Widget" << metaObject()->className() << "updating geometry to " << boundingRect();
layout()->setGeometry(boundingRect());
}
#endif
}
QSizeF Widget::sizeHint() const