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

#include <qmdiarea_p.h>

Inheritance diagram for QMdi::IconTiler:
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 104 of file qmdiarea_p.h.

Functions

◆ rearrange()

void IconTiler::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 399 of file qmdiarea.cpp.

400 {
401  if (widgets.isEmpty() || !sanityCheck(widgets, 0, "IconTiler"))
402  return;
403 
404  const int n = widgets.size();
405  const int width = widgets.at(0)->width();
406  const int height = widgets.at(0)->height();
407  const int ncols = qMax(domain.width() / width, 1);
408  const int nrows = n / ncols + ((n % ncols) ? 1 : 0);
409 
410  int i = 0;
411  for (int row = 0; row < nrows; ++row) {
412  for (int col = 0; col < ncols; ++col) {
413  const int x = col * width;
414  const int y = domain.height() - height - row * height;
415  if (!sanityCheck(widgets, i, "IconTiler"))
416  continue;
417  QWidget *widget = widgets.at(i++);
418  QPoint newPos(x, y);
419  QRect newGeometry = QRect(newPos.x(), newPos.y(), widget->width(), widget->height());
420  widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry));
421  if (i == n)
422  return;
423  }
424  }
425 }
QPointer< QWidget > widget
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
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
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
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
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
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

◆ type()

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

Implements QMdi::Rearranger.

Definition at line 110 of file qmdiarea_p.h.


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