equal
deleted
inserted
replaced
92 #ifdef QT_DEBUG |
92 #ifdef QT_DEBUG |
93 void dump(int indent) const; |
93 void dump(int indent) const; |
94 #endif |
94 #endif |
95 }; |
95 }; |
96 |
96 |
|
97 Q_GLOBAL_STATIC(QWidget, globalStyleInfoWidget); |
|
98 |
97 QLayoutStyleInfo QGraphicsGridLayoutPrivate::styleInfo() const |
99 QLayoutStyleInfo QGraphicsGridLayoutPrivate::styleInfo() const |
98 { |
100 { |
99 static QWidget *wid = 0; |
|
100 if (!wid) |
|
101 wid = new QWidget; |
|
102 QGraphicsItem *item = parentItem(); |
101 QGraphicsItem *item = parentItem(); |
103 QStyle *style = (item && item->isWidget()) ? static_cast<QGraphicsWidget*>(item)->style() : QApplication::style(); |
102 QStyle *style = (item && item->isWidget()) ? static_cast<QGraphicsWidget*>(item)->style() : QApplication::style(); |
104 return QLayoutStyleInfo(style, wid); |
103 return QLayoutStyleInfo(style, globalStyleInfoWidget()); |
105 } |
104 } |
106 |
105 |
107 /*! |
106 /*! |
108 Constructs a QGraphicsGridLayout instance. \a parent is passed to |
107 Constructs a QGraphicsGridLayout instance. \a parent is passed to |
109 QGraphicsLayout's constructor. |
108 QGraphicsLayout's constructor. |
570 } |
569 } |
571 if (QGridLayoutItem *gridItem = d->engine.itemAt(index)) { |
570 if (QGridLayoutItem *gridItem = d->engine.itemAt(index)) { |
572 if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem()) |
571 if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem()) |
573 layoutItem->setParentLayoutItem(0); |
572 layoutItem->setParentLayoutItem(0); |
574 d->engine.removeItem(gridItem); |
573 d->engine.removeItem(gridItem); |
|
574 |
|
575 // recalculate rowInfo.count if we remove an item that is on the right/bottommost row |
|
576 for (int j = 0; j < NOrientations; ++j) { |
|
577 // 0: Hor, 1: Ver |
|
578 const Qt::Orientation orient = (j == 0 ? Qt::Horizontal : Qt::Vertical); |
|
579 const int oldCount = d->engine.rowCount(orient); |
|
580 if (gridItem->lastRow(orient) == oldCount - 1) { |
|
581 const int newCount = d->engine.effectiveLastRow(orient) + 1; |
|
582 d->engine.removeRows(newCount, oldCount - newCount, orient); |
|
583 } |
|
584 } |
|
585 |
575 delete gridItem; |
586 delete gridItem; |
576 invalidate(); |
587 invalidate(); |
577 } |
588 } |
578 } |
589 } |
579 |
590 |