Qt 4.8
Classes | Functions
qmdiarea.cpp File Reference
#include "qmdiarea_p.h"
#include <QApplication>
#include <QStyle>
#include <QMacStyle>
#include <QChildEvent>
#include <QResizeEvent>
#include <QScrollBar>
#include <QtAlgorithms>
#include <QMutableListIterator>
#include <QPainter>
#include <QFontMetrics>
#include <QStyleOption>
#include <QDesktopWidget>
#include <QDebug>
#include <qmath.h>
#include <private/qlayoutengine_p.h>
#include "moc_qmdiarea.cpp"

Go to the source code of this file.

Classes

class  QMdiAreaTabBar
 

Functions

static QMdiAreamdiAreaParent (QWidget *widget)
 
static bool sanityCheck (const QMdiSubWindow *const child, const char *where)
 
static bool sanityCheck (const QList< QWidget *> &widgets, const int index, const char *where)
 
static void setIndex (int *index, int candidate, int min, int max, bool isIncreasing)
 
static QTabBar::Shape tabBarShapeFrom (QTabWidget::TabShape shape, QTabWidget::TabPosition position)
 
static QString tabTextFor (QMdiSubWindow *subWindow)
 
static bool useScrollBar (const QRect &childrenRect, const QSize &maxViewportSize, Qt::Orientation orientation)
 

Function Documentation

◆ mdiAreaParent()

static QMdiArea* mdiAreaParent ( QWidget widget)
inlinestatic

Definition at line 259 of file qmdiarea.cpp.

Referenced by QMdiArea::eventFilter().

260 {
261  if (!widget)
262  return 0;
263 
264  QWidget *parent = widget->parentWidget();
265  while (parent) {
266  if (QMdiArea *area = qobject_cast<QMdiArea *>(parent))
267  return area;
268  parent = parent->parentWidget();
269  }
270  return 0;
271 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
static int area(const QSize &s)
Definition: qicon.cpp:155

◆ sanityCheck() [1/2]

static bool sanityCheck ( const QMdiSubWindow *const  child,
const char *  where 
)
static

Definition at line 198 of file qmdiarea.cpp.

Referenced by QMdiAreaPrivate::_q_deactivateAllWindows(), QMdiArea::closeAllSubWindows(), QMdiArea::event(), QMdiAreaPrivate::internalRaise(), QMdiArea::minimumSizeHint(), QMdiAreaPrivate::place(), QMdi::RegularTiler::rearrange(), QMdi::SimpleCascader::rearrange(), QMdi::IconTiler::rearrange(), QMdiAreaPrivate::rearrange(), QMdiArea::removeSubWindow(), QMdiArea::resizeEvent(), QMdiAreaPrivate::scrollBarPolicyChanged(), QMdiArea::setupViewport(), and QMdiArea::sizeHint().

199 {
200  if (!child) {
201  const char error[] = "null pointer";
202  Q_ASSERT_X(false, where, error);
203  qWarning("%s:%s", where, error);
204  return false;
205  }
206  return true;
207 }
#define error(msg)
Q_CORE_EXPORT void qWarning(const char *,...)
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837

◆ sanityCheck() [2/2]

static bool sanityCheck ( const QList< QWidget *> &  widgets,
const int  index,
const char *  where 
)
static

Definition at line 209 of file qmdiarea.cpp.

210 {
211  if (index < 0 || index >= widgets.size()) {
212  const char error[] = "index out of range";
213  Q_ASSERT_X(false, where, error);
214  qWarning("%s:%s", where, error);
215  return false;
216  }
217  if (!widgets.at(index)) {
218  const char error[] = "null pointer";
219  Q_ASSERT_X(false, where, error);
220  qWarning("%s:%s", where, error);
221  return false;
222  }
223  return true;
224 }
#define error(msg)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
quint16 index

◆ setIndex()

static void setIndex ( int *  index,
int  candidate,
int  min,
int  max,
bool  isIncreasing 
)
static

Definition at line 226 of file qmdiarea.cpp.

Referenced by QMdiAreaPrivate::nextVisibleSubWindow().

227 {
228  if (!index)
229  return;
230 
231  if (isIncreasing) {
232  if (candidate > max)
233  *index = min;
234  else
235  *index = qMax(candidate, min);
236  } else {
237  if (candidate < min)
238  *index = max;
239  else
240  *index = qMin(candidate, max);
241  }
242  Q_ASSERT(*index >= min && *index <= max);
243 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
quint16 index

◆ tabBarShapeFrom()

static QTabBar::Shape tabBarShapeFrom ( QTabWidget::TabShape  shape,
QTabWidget::TabPosition  position 
)
inlinestatic

◆ tabTextFor()

static QString tabTextFor ( QMdiSubWindow subWindow)
inlinestatic

Definition at line 289 of file qmdiarea.cpp.

Referenced by QMdiAreaPrivate::appendChild(), QMdiArea::eventFilter(), and QMdiAreaPrivate::setViewMode().

290 {
291  if (!subWindow)
292  return QString();
293 
294  QString title = subWindow->windowTitle();
295  if (subWindow->isWindowModified()) {
296  title.replace(QLatin1String("[*]"), QLatin1String("*"));
297  } else {
298  extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*);
299  title = qt_setWindowTitle_helperHelper(title, subWindow);
300  }
301 
302  return title.isEmpty() ? QMdiArea::tr("(Untitled)") : title;
303 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isWindowModified() const
Definition: qwidget.cpp:11554
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString windowTitle() const
QString qt_setWindowTitle_helperHelper(const QString &, const QWidget *)
Returns a modified window title with the [*] place holder replaced according to the rules described i...
Definition: qwidget.cpp:6240

◆ useScrollBar()

static bool useScrollBar ( const QRect childrenRect,
const QSize maxViewportSize,
Qt::Orientation  orientation 
)
inlinestatic

Definition at line 245 of file qmdiarea.cpp.

Referenced by QMdiAreaPrivate::updateScrollBars().

247 {
248  if (orientation == Qt::Horizontal)
249  return childrenRect.width() > maxViewportSize.width()
250  || childrenRect.left() < 0
251  || childrenRect.right() >= maxViewportSize.width();
252  else
253  return childrenRect.height() > maxViewportSize.height()
254  || childrenRect.top() < 0
255  || childrenRect.bottom() >= maxViewportSize.height();
256 }
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
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
int width() const
Returns the width.
Definition: qsize.h:126
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int height() const
Returns the height.
Definition: qsize.h:129