Qt 4.8
Functions
qgridlayoutengine.cpp File Reference
#include "qglobal.h"
#include <math.h>
#include "qgraphicslayoutitem.h"
#include "qgridlayoutengine_p.h"
#include "qstyleoption.h"
#include "qvarlengtharray.h"
#include <QtDebug>
#include <QtCore/qmath.h>

Go to the source code of this file.

Functions

static qreal compare (const QGridLayoutBox &box1, const QGridLayoutBox &box2, int which)
 
static qreal fixedDescent (qreal descent, qreal ascent, qreal targetSize)
 
static qreal growthFactorBelowPreferredSize (qreal desired, qreal sumAvailable, qreal sumDesired)
 
template<typename T >
static void insertOrRemoveItems (QVector< T > &items, int index, int delta)
 
bool operator== (const QGridLayoutBox &box1, const QGridLayoutBox &box2)
 
static void visualRect (QRectF *geom, Qt::LayoutDirection dir, const QRectF &contentsRect)
 

Function Documentation

◆ compare()

static qreal compare ( const QGridLayoutBox box1,
const QGridLayoutBox box2,
int  which 
)
static

Definition at line 90 of file qgridlayoutengine.cpp.

Referenced by QGridLayoutRowData::distributeMultiCells().

91 {
92  qreal size1 = box1.q_sizes(which);
93  qreal size2 = box2.q_sizes(which);
94 
95  if (which == MaximumSize) {
96  return size2 - size1;
97  } else {
98  return size1 - size2;
99  }
100 }
double qreal
Definition: qglobal.h:1193
qreal & q_sizes(int which)

◆ fixedDescent()

static qreal fixedDescent ( qreal  descent,
qreal  ascent,
qreal  targetSize 
)
static

Definition at line 77 of file qgridlayoutengine.cpp.

Referenced by QGridLayoutRowData::calculateGeometries(), and QGridLayoutEngine::fillRowData().

78 {
79  if (descent < 0.0)
80  return -1.0;
81 
82  Q_ASSERT(descent >= 0.0);
83  Q_ASSERT(ascent >= 0.0);
84  Q_ASSERT(targetSize >= ascent + descent);
85 
86  qreal extra = targetSize - (ascent + descent);
87  return descent + (extra / qreal(2.0));
88 }
double qreal
Definition: qglobal.h:1193
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ growthFactorBelowPreferredSize()

static qreal growthFactorBelowPreferredSize ( qreal  desired,
qreal  sumAvailable,
qreal  sumDesired 
)
static

Definition at line 71 of file qgridlayoutengine.cpp.

Referenced by QGridLayoutRowData::calculateGeometries().

72 {
73  Q_ASSERT(sumDesired != 0.0);
74  return desired * qPow(sumAvailable / sumDesired, desired / sumDesired);
75 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
qreal qPow(qreal x, qreal y)
Definition: qmath.h:244

◆ insertOrRemoveItems()

template<typename T >
static void insertOrRemoveItems ( QVector< T > &  items,
int  index,
int  delta 
)
static

Definition at line 59 of file qgridlayoutengine.cpp.

Referenced by QGridLayoutRowInfo::insertOrRemoveRows().

60 {
61  int count = items.count();
62  if (index < count) {
63  if (delta > 0) {
64  items.insert(index, delta, T());
65  } else if (delta < 0) {
66  items.remove(index, qMin(-delta, count - index));
67  }
68  }
69 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
void remove(int i)
Removes the element at index position i.
Definition: qvector.h:374
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
void insert(int i, const T &t)
Inserts value at index position i in the vector.
Definition: qvector.h:362
quint16 index

◆ operator==()

bool operator== ( const QGridLayoutBox box1,
const QGridLayoutBox box2 
)

Definition at line 149 of file qgridlayoutengine.cpp.

Referenced by operator!=(), and QGridLayoutBox::q_sizes().

150 {
151  for (int i = 0; i < NSizes; ++i) {
152  if (box1.q_sizes(i) != box2.q_sizes(i))
153  return false;
154  }
155  return box1.q_minimumDescent == box2.q_minimumDescent
156  && box1.q_minimumAscent == box2.q_minimumAscent;
157 }
qreal & q_sizes(int which)

◆ visualRect()

static void visualRect ( QRectF geom,
Qt::LayoutDirection  dir,
const QRectF contentsRect 
)
static

Definition at line 1080 of file qgridlayoutengine.cpp.

Referenced by QGridLayoutEngine::setGeometries(), QWindowsMobileStyle::sizeFromContents(), and QWindowsMobileStyle::subControlRect().

1081 {
1082  if (dir == Qt::RightToLeft)
1083  geom->moveRight(contentsRect.right() - (geom->left() - contentsRect.left()));
1084 }
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
void moveRight(qreal pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s right edge at the given x coordinate...
Definition: qrect.h:693