43 #include "private/qlayoutengine_p.h" 60 return (i % 256 < 128) ? i / 256 : 1 + i / 256;
79 int pos,
int space,
int spacer)
86 int expandingCount = 0;
88 bool allEmptyNonstretch =
true;
89 int pendingSpacing = -1;
93 for (i = start; i < start + count; i++) {
106 if (pendingSpacing >= 0) {
107 sumSpacing += pendingSpacing;
119 if (space < cMin + sumSpacing) {
124 int minSize = cMin + sumSpacing;
128 spacer = minSize > 0 ? spacer * space / minSize : 0;
129 sumSpacing = spacer * spacerCount;
134 for (i = start; i < start + count; i++)
139 int space_left = space - sumSpacing;
145 while (idx < count && space_used < space_left) {
146 current = list.
at(idx);
147 space_used = sum + current * (count - idx);
152 int deficit = space_used - space_left;
154 int items = count - idx;
160 int deficitPerItem = deficit/items;
161 int remainder = deficit % items;
162 int maxval = current - deficitPerItem;
165 for (i = start; i < start + count; i++) {
176 }
else if (space < cHint + sumSpacing) {
184 int space_left = space - sumSpacing;
185 int overdraft = cHint - space_left;
188 for (i = start; i < start + count; i++) {
199 bool finished = n == 0;
205 for (i = start; i < start+count; i++) {
229 int space_left = space - sumSpacing;
231 for (i = start; i < start + count; i++) {
235 || (!allEmptyNonstretch && data->
empty &&
239 space_left -= data->
size;
246 extraspace = space_left;
258 int surplus, deficit;
260 surplus = deficit = 0;
263 for (i = start; i < start + count; i++) {
268 if (sumStretch > 0) {
269 fp_w += (fp_space * data->
stretch) / sumStretch;
270 }
else if (expandingCount > 0) {
271 fp_w += (fp_space * (data->
expansive ? 1 : 0)) / expandingCount;
273 fp_w += fp_space * 1 / n;
278 if (w < data->smartSizeHint()) {
284 if (deficit > 0 && surplus <= deficit) {
286 for (i = start; i < start+count; i++) {
299 if (surplus > 0 && surplus >= deficit) {
301 for (i = start; i < start + count; i++) {
314 }
while (n > 0 && surplus != deficit);
316 extraspace = space_left;
325 int extra = extraspace / (spacerCount + 2);
327 for (i = start; i < start+count; i++) {
335 #ifdef QLAYOUT_EXTRA_DEBUG 336 qDebug() <<
"qGeomCalc" <<
"start" << start <<
"count" << count <<
"pos" << pos
337 <<
"space" << space <<
"spacer" << spacer;
338 for (i = start; i < start + count; ++i) {
339 qDebug() << i <<
':' << chain[i].minimumSize << chain[i].smartSizeHint()
340 << chain[i].maximumSize <<
"stretch" << chain[i].stretch
341 <<
"empty" << chain[i].
empty <<
"expansive" << chain[i].expansive
342 <<
"spacing" << chain[i].spacing;
343 qDebug() <<
"result pos" << chain[i].pos <<
"size" << chain[i].
size;
370 if (minSize.
width() > 0)
395 const QSizePolicy &sizePolicy, Qt::Alignment align)
411 if (align & Qt::AlignVertical_Mask)
439 return static_cast<QLayout *
>(parent)->spacing();
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
static Fixed64 toFixed(int i)
Q_GUI_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
Q_GUI_EXPORT QSize qSmartMaxSize(const QSize &sizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy, Qt::Alignment align)
Policy horizontalPolicy() const
PixelMetric
This enum describes the various available pixel metrics.
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
void setHeight(int h)
Sets the height to the given height.
The QObject class is the base class of all Qt objects.
bool empty() const
This function is provided for STL compatibility.
static int fRound(Fixed64 i)
int effectiveSpacer(int uniformSpacer) const
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
void setWidth(int w)
Sets the width to the given width.
Q_CORE_EXPORT void qDebug(const char *,...)
int width() const
Returns the width.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QLayout class is the base class of geometry managers.
const T & at(int i) const
Returns the item at index position i in the list.
static const char * data(const QByteArray &arr)
void qSort(RandomAccessIterator start, RandomAccessIterator end)
const T & at(int i) const
Returns the item at index position i in the vector.
void qGeomCalc(QVector< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Q_GUI_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm)
QObject * parent() const
Returns a pointer to the parent object.
Policy verticalPolicy() const
int height() const
Returns the height.
The QSize class defines the size of a two-dimensional object using integer point precision.
static const int QLAYOUTSIZE_MAX
int size() const
Returns the number of items in the vector.