26 mAlignment(alignment),
33 mAlignment(alignment),
40 while (!mItems.isEmpty())
41 delete mItems.takeFirst();
55 return (index >= 0 && index < mItems.count()) ? mItems[index] : 0;
60 if (index < 0 || index >= mItems.count())
62 return mItems.takeAt(index);
67 if (w != mWidthCached)
69 mHeightCached = arrange(QRect(0, 0, w, 0),
false);
77 QLayout::setGeometry(rect);
85 for (
int i = 0, end = mItems.count(); i < end; ++i)
86 size = size.expandedTo(mItems[i]->minimumSize());
88 return QSize(size.width() + m, size.height() + m);
92 int PackedLayout::arrange(
const QRect& rect,
bool set)
const
98 int end = mItems.count();
100 for (
int i = 0; i < end; ++i)
102 QLayoutItem* item = mItems[i];
105 QSize size = item->sizeHint();
106 int right = x + size.width();
107 if (right > rect.right() && x > rect.x())
110 y = y + yrow + spacing();
111 right = x + size.width();
112 yrow = size.height();
115 yrow = qMax(yrow, size.height());
117 posn.append(QRect(QPoint(x, y), size));
118 x = right + spacing();
122 int count = items.count();
123 if (mAlignment == Qt::AlignLeft)
127 for (
int i = 0; i <
count; ++i)
133 for (
int i = 0; i <
count; )
138 for (last = i + 1; last < count && posn[last].y() == y; ++last) ;
140 int free = rect.right() - posn[last - 1].right();
143 case Qt::AlignJustify:
146 items[i]->setGeometry(posn[i]);
151 for (
int j = 0; i < last; ++j, ++i)
152 items[i]->
setGeometry(QRect(QPoint(posn[i].x() + (free * j)/(n - 1), y), posn[i].size()));
155 case Qt::AlignHCenter:
159 for ( ; i < last; ++i)
160 items[i]->
setGeometry(QRect(QPoint(posn[i].x() + free, y), posn[i].size()));
168 return y + yrow - rect.y();
virtual QLayoutItem * itemAt(int index) const
virtual QSize minimumSize() const
virtual QLayoutItem * takeAt(int index)
virtual void setGeometry(const QRect &r)
PackedLayout(QWidget *parent, Qt::Alignment alignment)
Constructor.
virtual int heightForWidth(int w) const
virtual int count() const
void set(quint32, const QString &, const QString &, const QString &, const QString &, time_t)
virtual void addItem(QLayoutItem *item)