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

#include <qmdiarea_p.h>

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

Functions

◆ rearrange()

void SimpleCascader::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 352 of file qmdiarea.cpp.

353 {
354  if (widgets.isEmpty())
355  return;
356 
357  // Tunables:
358  const int topOffset = 0;
359  const int bottomOffset = 50;
360  const int leftOffset = 0;
361  const int rightOffset = 100;
362  const int dx = 10;
363 
364  QStyleOptionTitleBar options;
365  options.initFrom(widgets.at(0));
366  int titleBarHeight = widgets.at(0)->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, widgets.at(0));
367 #if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
368  // ### Remove this after the mac style has been fixed
369  if (qobject_cast<QMacStyle *>(widgets.at(0)->style()))
370  titleBarHeight -= 4;
371 #endif
372  const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QWorkspaceTitleBar"));
373  const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1);
374 
375  const int n = widgets.size();
376  const int nrows = qMax((domain.height() - (topOffset + bottomOffset)) / dy, 1);
377  const int ncols = qMax(n / nrows + ((n % nrows) ? 1 : 0), 1);
378  const int dcol = (domain.width() - (leftOffset + rightOffset)) / ncols;
379 
380  int i = 0;
381  for (int row = 0; row < nrows; ++row) {
382  for (int col = 0; col < ncols; ++col) {
383  const int x = leftOffset + row * dx + col * dcol;
384  const int y = topOffset + row * dy;
385  if (!sanityCheck(widgets, i, "SimpleCascader"))
386  continue;
387  QWidget *widget = widgets.at(i++);
388  QRect newGeometry = QRect(QPoint(x, y), widget->sizeHint());
389  widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry));
390  if (i == n)
391  return;
392  }
393  }
394 }
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
QPointer< QWidget > widget
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
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 QFont font()
Returns the default application font.
static bool sanityCheck(const QMdiSubWindow *const child, const char *where)
Definition: qmdiarea.cpp:198
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
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
QSize sizeHint
the recommended size for the widget
Definition: qwidget.h:195
int height() const
Returns the height of the font.

◆ type()

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

Implements QMdi::Rearranger.

Definition at line 101 of file qmdiarea_p.h.


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