Qt 4.8
Public Functions | Public Variables | List of all members
QToolBarAreaLayoutLine Class Reference

#include <qtoolbararealayout_p.h>

Public Functions

void fitLayout ()
 
QSize minimumSize () const
 
 QToolBarAreaLayoutLine (Qt::Orientation orientation)
 
QSize sizeHint () const
 
bool skip () const
 

Public Variables

Qt::Orientation o
 
QRect rect
 
QList< QToolBarAreaLayoutItemtoolBarItems
 

Detailed Description

Definition at line 138 of file qtoolbararealayout_p.h.

Constructors and Destructors

◆ QToolBarAreaLayoutLine()

QToolBarAreaLayoutLine::QToolBarAreaLayoutLine ( Qt::Orientation  orientation)

Definition at line 105 of file qtoolbararealayout.cpp.

106  : o(orientation)
107 {
108 }

Functions

◆ fitLayout()

void QToolBarAreaLayoutLine::fitLayout ( )

Definition at line 150 of file qtoolbararealayout.cpp.

Referenced by QToolBarAreaLayoutInfo::fitLayout().

151 {
152  int last = -1;
153  int min = pick(o, minimumSize());
154  int space = pick(o, rect.size());
155  int extra = qMax(0, space - min);
156 
157  for (int i = 0; i < toolBarItems.count(); ++i) {
159  if (item.skip())
160  continue;
161 
162  if (QToolBarLayout *tblayout = qobject_cast<QToolBarLayout*>(item.widgetItem->widget()->layout()))
163  tblayout->checkUsePopupMenu();
164 
165  const int itemMin = pick(o, item.minimumSize());
166  //preferredSize is the default if it is set, otherwise, we take the sizehint
167  item.size = item.preferredSize > 0 ? item.preferredSize : pick(o, item.sizeHint());
168 
169  //the extraspace is the space above the item minimum sizehint
170  const int extraSpace = qMin(item.size - itemMin, extra);
171  item.size = itemMin + extraSpace; //that is the real size
172 
173  extra -= extraSpace;
174 
175  last = i;
176  }
177 
178  // calculate the positions from the sizes
179  int pos = 0;
180  for (int i = 0; i < toolBarItems.count(); ++i) {
182  if (item.skip())
183  continue;
184 
185  item.pos = pos;
186  if (i == last) // stretch the last item to the end of the line
187  item.size = qMax(0, pick(o, rect.size()) - item.pos);
188  pos += item.size;
189  }
190 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
QList< QToolBarAreaLayoutItem > toolBarItems
static int pick(bool vertical, const QSize &size)
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073

◆ minimumSize()

QSize QToolBarAreaLayoutLine::minimumSize ( ) const

Definition at line 130 of file qtoolbararealayout.cpp.

Referenced by fitLayout(), and QToolBarAreaLayoutInfo::minimumSize().

131 {
132  int a = 0, b = 0;
133  for (int i = 0; i < toolBarItems.count(); ++i) {
134  const QToolBarAreaLayoutItem &item = toolBarItems[i];
135  if (item.skip())
136  continue;
137 
138  QSize ms = item.minimumSize();
139  a += pick(o, ms);
140  b = qMax(b, perp(o, ms));
141  }
142 
143  QSize result;
144  rpick(o, result) = a;
145  rperp(o, result) = b;
146 
147  return result;
148 }
static int & rpick(Qt::Orientation o, QPoint &pos)
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
static int perp(bool vertical, const QSize &size)
QList< QToolBarAreaLayoutItem > toolBarItems
static int pick(bool vertical, const QSize &size)
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static int & rperp(Qt::Orientation o, QPoint &pos)

◆ sizeHint()

QSize QToolBarAreaLayoutLine::sizeHint ( ) const

Definition at line 110 of file qtoolbararealayout.cpp.

Referenced by QToolBarAreaLayoutInfo::fitLayout(), and QToolBarAreaLayoutInfo::sizeHint().

111 {
112  int a = 0, b = 0;
113  for (int i = 0; i < toolBarItems.count(); ++i) {
114  const QToolBarAreaLayoutItem &item = toolBarItems.at(i);
115  if (item.skip())
116  continue;
117 
118  QSize sh = item.sizeHint();
119  a += item.preferredSize > 0 ? item.preferredSize : pick(o, sh);
120  b = qMax(b, perp(o, sh));
121  }
122 
123  QSize result;
124  rpick(o, result) = a;
125  rperp(o, result) = b;
126 
127  return result;
128 }
static int & rpick(Qt::Orientation o, QPoint &pos)
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static int perp(bool vertical, const QSize &size)
QList< QToolBarAreaLayoutItem > toolBarItems
static int pick(bool vertical, const QSize &size)
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static int & rperp(Qt::Orientation o, QPoint &pos)

◆ skip()

bool QToolBarAreaLayoutLine::skip ( ) const

Definition at line 192 of file qtoolbararealayout.cpp.

Referenced by QToolBarAreaLayout::apply(), QToolBarAreaLayoutInfo::fitLayout(), QToolBarAreaLayoutInfo::gapIndex(), QToolBarAreaLayoutInfo::minimumSize(), and QToolBarAreaLayoutInfo::sizeHint().

193 {
194  for (int i = 0; i < toolBarItems.count(); ++i) {
195  if (!toolBarItems.at(i).skip())
196  return false;
197  }
198  return true;
199 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QToolBarAreaLayoutItem > toolBarItems

Properties

◆ o

Qt::Orientation QToolBarAreaLayoutLine::o

◆ rect

QRect QToolBarAreaLayoutLine::rect

◆ toolBarItems

QList<QToolBarAreaLayoutItem> QToolBarAreaLayoutLine::toolBarItems

The documentation for this class was generated from the following files: