Qt 4.8
Private Functions | List of all members
QMdi::RegularTiler Class Reference

#include <qmdiarea_p.h>

Inheritance diagram for QMdi::RegularTiler:
QMdi::Rearranger

Private Functions

void rearrange (QList< QWidget *> &widgets, const QRect &domain) const
 
Type type () const
 

Additional Inherited Members

- Public Types inherited from QMdi::Rearranger
enum  Type { RegularTiler, SimpleCascader, IconTiler }
 
- Public Functions inherited from QMdi::Rearranger
virtual ~Rearranger ()
 

Detailed Description

Definition at line 86 of file qmdiarea_p.h.

Functions

◆ rearrange()

void RegularTiler::rearrange ( QList< QWidget *> &  widgets,
const QRect domain 
) const
privatevirtual
Warning
This function is not part of the public interface.

Implements QMdi::Rearranger.

Definition at line 308 of file qmdiarea.cpp.

309 {
310  if (widgets.isEmpty())
311  return;
312 
313  const int n = widgets.size();
314  const int ncols = qMax(qCeil(qSqrt(qreal(n))), 1);
315  const int nrows = qMax((n % ncols) ? (n / ncols + 1) : (n / ncols), 1);
316  const int nspecial = (n % ncols) ? (ncols - n % ncols) : 0;
317  const int dx = domain.width() / ncols;
318  const int dy = domain.height() / nrows;
319 
320  int i = 0;
321  for (int row = 0; row < nrows; ++row) {
322  const int y1 = int(row * (dy + 1));
323  for (int col = 0; col < ncols; ++col) {
324  if (row == 1 && col < nspecial)
325  continue;
326  const int x1 = int(col * (dx + 1));
327  int x2 = int(x1 + dx);
328  int y2 = int(y1 + dy);
329  if (row == 0 && col < nspecial) {
330  y2 *= 2;
331  if (nrows != 2)
332  y2 += 1;
333  else
334  y2 = domain.bottom();
335  }
336  if (col == ncols - 1 && x2 != domain.right())
337  x2 = domain.right();
338  if (row == nrows - 1 && y2 != domain.bottom())
339  y2 = domain.bottom();
340  if (!sanityCheck(widgets, i, "RegularTiler"))
341  continue;
342  QWidget *widget = widgets.at(i++);
343  QRect newGeometry = QRect(QPoint(x1, y1), QPoint(x2, y2));
344  widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry));
345  }
346  }
347 }
double qreal
Definition: qglobal.h:1193
QPointer< QWidget > widget
int qCeil(qreal v)
Definition: qmath.h:63
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
static bool sanityCheck(const QMdiSubWindow *const child, const char *where)
Definition: qmdiarea.cpp:198
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Qt::LayoutDirection layoutDirection
the layout direction for this widget
Definition: qwidget.h:216
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
qreal qSqrt(qreal v)
Definition: qmath.h:205

◆ type()

Type QMdi::RegularTiler::type ( ) const
inlineprivatevirtual

Implements QMdi::Rearranger.

Definition at line 92 of file qmdiarea_p.h.


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