summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSarah Smith <sarah.j.smith@nokia.com>2009-09-07 00:23:22 (GMT)
committerSarah Smith <sarah.j.smith@nokia.com>2009-09-07 00:23:22 (GMT)
commitf4fa50c25aea68b7696ad7de289d93facac9f3e5 (patch)
tree8e1057a29f163383b2dd21d7e21ec231c550cd56 /src/gui
parent2f8ad3dad31ee96798cb17d8a782b78ae4c1eabc (diff)
parent6d908473ec1a8c72f4bbb9d772e801024c3a62a0 (diff)
downloadQt-f4fa50c25aea68b7696ad7de289d93facac9f3e5.zip
Qt-f4fa50c25aea68b7696ad7de289d93facac9f3e5.tar.gz
Qt-f4fa50c25aea68b7696ad7de289d93facac9f3e5.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/dialogs/qfiledialog_embedded.ui1
-rw-r--r--src/gui/effects/qgraphicseffect.cpp1
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp36
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp6
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.cpp164
-rw-r--r--src/gui/itemviews/qlistview.cpp4
-rw-r--r--src/gui/kernel/qapplication_win.cpp1
-rw-r--r--src/gui/kernel/qevent.cpp4
-rw-r--r--src/gui/kernel/qsizepolicy.h12
-rw-r--r--src/gui/kernel/qx11embed_x11.cpp8
-rw-r--r--src/gui/math3d/qgenericmatrix.cpp53
-rw-r--r--src/gui/math3d/qgenericmatrix.h209
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp298
-rw-r--r--src/gui/math3d/qmatrix4x4.h232
-rw-r--r--src/gui/math3d/qquaternion.cpp17
-rw-r--r--src/gui/math3d/qquaternion.h60
-rw-r--r--src/gui/math3d/qvector3d.h3
-rw-r--r--src/gui/math3d/qvector4d.h3
-rw-r--r--src/gui/painting/qpaintbuffer.cpp101
-rw-r--r--src/gui/painting/qpaintbuffer_p.h8
-rw-r--r--src/gui/painting/qpaintengine_mac.cpp8
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h12
-rw-r--r--src/gui/painting/qpainter.cpp68
-rw-r--r--src/gui/painting/qprinter.cpp17
-rw-r--r--src/gui/painting/qprinter.h2
-rw-r--r--src/gui/painting/qrasterizer_p.h6
-rw-r--r--src/gui/styles/qcommonstyle.cpp1
-rw-r--r--src/gui/styles/qmacstyle_mac.mm1
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp11
-rw-r--r--src/gui/text/qtextdocument.cpp8
-rw-r--r--src/gui/text/qtextengine.cpp33
-rw-r--r--src/gui/widgets/qdatetimeedit_p.h2
-rw-r--r--src/gui/widgets/qmenu_symbian.cpp1
33 files changed, 822 insertions, 569 deletions
diff --git a/src/gui/dialogs/qfiledialog_embedded.ui b/src/gui/dialogs/qfiledialog_embedded.ui
index 1bd189e..f134f64 100644
--- a/src/gui/dialogs/qfiledialog_embedded.ui
+++ b/src/gui/dialogs/qfiledialog_embedded.ui
@@ -2,6 +2,7 @@
<comment>*********************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
index 6629a6d..dd64ced 100644
--- a/src/gui/effects/qgraphicseffect.cpp
+++ b/src/gui/effects/qgraphicseffect.cpp
@@ -67,7 +67,6 @@
\o QGraphicsOpacityEffect - renders the item with an opacity
\o QGraphicsPixelizeEffect - pixelizes the item with any pixel size
\o QGraphicsGrayscaleEffect - renders the item in shades of gray
- \o QGraphicsShaderEffect - renders the item with a pixel shader fragment
\endlist
\img graphicseffect-effects.png
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index b7c2e26..eae3e63 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -303,13 +303,17 @@
drop shadow effects and for decoration objects that follow the parent
item's geometry without drawing on top of it.
- \value ItemUsesExtendedStyleOption The item makes use of either the
- exposedRect or matrix member of the QStyleOptionGraphicsItem. Implementers
- of QGraphicsItem subclasses should set that flag if this data is required.
- By default, the exposedRect is initialized to the item's boundingRect and
- the matrix is untransformed. Enable this flag for more fine-grained values.
- Use QStyleOptionGraphicsItem::levelOfDetailFromTransform() for a more
- fine-grained value.
+ \value ItemUsesExtendedStyleOption The item makes use of either
+ \l{QStyleOptionGraphicsItem::}{exposedRect} or
+ \l{QStyleOptionGraphicsItem::}{matrix} in QStyleOptionGraphicsItem. By default,
+ the \l{QStyleOptionGraphicsItem::}{exposedRect} is initialized to the item's
+ boundingRect() and the \l{QStyleOptionGraphicsItem::}{matrix} is untransformed.
+ You can enable this flag for the style options to be set up with more
+ fine-grained values.
+ Note that QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag
+ and always initialized to 1. Use
+ QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need a higher
+ value.
\value ItemHasNoContents The item does not paint anything (i.e., calling
paint() on the item has no effect). You should set this flag on items that
@@ -4766,7 +4770,7 @@ void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &n
{
Q_ASSERT(inSetPosHelper);
- if (!(ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
+ if (inDestructor || !(ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
return; // Not clipped by any ancestor.
// Find closest clip ancestor and transform.
@@ -4776,15 +4780,19 @@ void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &n
if (transformData)
thisToParentTransform = transformData->computedFullTransform(&thisToParentTransform);
QGraphicsItem *clipParent = parent;
- while (clipParent && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) {
+ while (clipParent && !clipParent->d_ptr->inDestructor && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) {
thisToParentTransform *= clipParent->d_ptr->transformToParent();
clipParent = clipParent->d_ptr->parent;
}
- // thisToParentTransform is now the same as q->itemTransform(clipParent), except
- // that the new position (which is not yet set on the item) is taken into account.
- Q_ASSERT(clipParent);
- Q_ASSERT(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
+ // Ensure no parents are currently being deleted. This can only
+ // happen if the item is moved by a dying ancestor.
+ QGraphicsItem *p = clipParent;
+ while (p) {
+ if (p->d_ptr->inDestructor)
+ return;
+ p = p->d_ptr->parent;
+ }
// From here everything is calculated in clip parent's coordinates.
const QRectF parentBoundingRect(clipParent->boundingRect());
@@ -6846,6 +6854,8 @@ void QGraphicsItem::removeFromIndex()
*/
void QGraphicsItem::prepareGeometryChange()
{
+ if (d_ptr->inDestructor)
+ return;
if (d_ptr->scene) {
d_ptr->scene->d_func()->dirtyGrowingItemsBoundingRect = true;
d_ptr->geometryChanged = 1;
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index afabf49..d0f3b99 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -687,11 +687,13 @@ QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
Q_D(const QGraphicsWidget);
QSizeF sh;
if (d->layout) {
- sh = d->layout->effectiveSizeHint(which, constraint);
+ QSizeF marginSize(0,0);
if (d->margins) {
- sh += QSizeF(d->margins[d->Left] + d->margins[d->Right],
+ marginSize = QSizeF(d->margins[d->Left] + d->margins[d->Right],
d->margins[d->Top] + d->margins[d->Bottom]);
}
+ sh = d->layout->effectiveSizeHint(which, constraint - marginSize);
+ sh += marginSize;
} else {
switch (which) {
case Qt::MinimumSize:
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp
index 787bbb1..bf826a9 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.cpp
+++ b/src/gui/graphicsview/qgraphicswidget_p.cpp
@@ -393,49 +393,162 @@ void QGraphicsWidgetPrivate::windowFrameMousePressEvent(QGraphicsSceneMouseEvent
event->setAccepted(windowData->grabbedSection != Qt::NoSection);
}
+/*!
+ Used to calculate the
+ Precondition:
+ \a widget should support either hfw or wfh
+
+ If \a heightForWidth is set to false, this function will query the width for height
+ instead. \a width will then be interpreted as height, \a minh and \a maxh will be interpreted
+ as minimum width and maximum width.
+ */
+static qreal minimumHeightForWidth(qreal width, qreal minh, qreal maxh,
+ const QGraphicsWidget *widget,
+ bool heightForWidth = true)
+{
+ qreal minimumHeightForWidth = -1;
+ const QSizePolicy sp = widget->layout() ? widget->layout()->sizePolicy() : widget->sizePolicy();
+ const bool hasHFW = sp.hasHeightForWidth();
+ if (hasHFW == heightForWidth) {
+ minimumHeightForWidth = hasHFW
+ ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(width, -1)).height()
+ : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, width)).width(); //"width" is here height!
+ } else {
+ // widthForHeight
+ const qreal constraint = width;
+ while (maxh - minh > 0.1) {
+ qreal middle = minh + (maxh - minh)/2;
+ // ### really bad, if we are a widget with a layout it will call
+ // layout->effectiveSizeHint(Qt::MiniumumSize), which again will call
+ // sizeHint three times because of how the cache works
+ qreal hfw = hasHFW
+ ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(middle, -1)).height()
+ : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, middle)).width();
+ if (hfw > constraint) {
+ minh = middle;
+ } else if (hfw <= constraint) {
+ maxh = middle;
+ }
+ }
+ minimumHeightForWidth = maxh;
+ }
+ return minimumHeightForWidth;
+}
+
+static qreal minimumWidthForHeight(qreal height, qreal minw, qreal maxw,
+ const QGraphicsWidget *widget)
+{
+ return minimumHeightForWidth(height, minw, maxw, widget, false);
+}
+
+static QSizeF closestAcceptableSize(const QSizeF &proposed,
+ const QGraphicsWidget *widget)
+{
+ const QSizeF current = widget->size();
+
+ qreal minw = proposed.width();
+ qreal maxw = current.width();
+ qreal minh = proposed.height();
+ qreal maxh = current.height();
+
+ qreal middlew = maxw;
+ qreal middleh = maxh;
+ qreal min_hfw;
+ min_hfw = minimumHeightForWidth(maxw, minh, maxh, widget);
+
+ do {
+ if (maxw - minw < 0.1) {
+ // we still havent found anything, cut off binary search
+ minw = maxw;
+ minh = maxh;
+ }
+ middlew = minw + (maxw - minw)/2.0;
+ middleh = minh + (maxh - minh)/2.0;
+
+ min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget);
+
+ if (min_hfw > middleh) {
+ minw = middlew;
+ minh = middleh;
+ } else if (min_hfw <= middleh) {
+ maxw = middlew;
+ maxh = middleh;
+ }
+ } while (maxw != minw);
+
+ min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget);
+
+ QSizeF result;
+ if (min_hfw < maxh) {
+ result = QSizeF(middlew, min_hfw);
+ } else {
+ // Needed because of the cut-off we do above.
+ result = QSizeF(minimumWidthForHeight(maxh, proposed.width(), current.width(), widget), maxh);
+ }
+ return result;
+}
+
static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry,
QRectF *rect, Qt::WindowFrameSection section,
- const QSizeF &min, const QSizeF &max)
+ const QSizeF &min, const QSizeF &max,
+ const QGraphicsWidget *widget)
{
- int height;
- int width;
+ const QRectF proposedRect = *rect;
+ qreal width = qBound(min.width(), proposedRect.width(), max.width());
+ qreal height = qBound(min.height(), proposedRect.height(), max.height());
+
+ QSizePolicy sp = widget->sizePolicy();
+ if (const QGraphicsLayout *l = widget->layout()) {
+ sp = l->sizePolicy();
+ }
+ const bool hasHFW = sp.hasHeightForWidth(); // || sp.hasWidthForHeight();
+
+ const bool widthChanged = proposedRect.width() < widget->size().width();
+ const bool heightChanged = proposedRect.height() < widget->size().height();
+
+ if (hasHFW) {
+ if (widthChanged || heightChanged) {
+ const qreal minh = min.height();
+ const qreal maxh = max.height();
+ const qreal proposedHFW = minimumHeightForWidth(width, minh, maxh, widget);
+ if (proposedHFW > proposedRect.height()) {
+ QSizeF effectiveSize = closestAcceptableSize(QSizeF(width, height), widget);
+ width = effectiveSize.width();
+ height = effectiveSize.height();
+ }
+ }
+ }
+
switch (section) {
case Qt::LeftSection:
- width = qRound(qBound(min.width(), rect->width(), max.width()));
- rect->setRect(startGeometry.right() - width, startGeometry.top(),
- width, startGeometry.height());
+ rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
+ qRound(width), startGeometry.height());
break;
case Qt::TopLeftSection:
- width = qRound(qBound(min.width(), rect->width(), max.width()));
- height = qRound(qBound(min.height(), rect->height(), max.height()));
- rect->setRect(startGeometry.right() - width, startGeometry.bottom() - height,
- width, height);
+ rect->setRect(startGeometry.right() - qRound(width), startGeometry.bottom() - qRound(height),
+ qRound(width), qRound(height));
break;
case Qt::TopSection:
- height = qRound(qBound(min.height(), rect->height(), max.height()));
- rect->setRect(startGeometry.left(), startGeometry.bottom() - height,
- startGeometry.width(), height);
+ rect->setRect(startGeometry.left(), startGeometry.bottom() - qRound(height),
+ startGeometry.width(), qRound(height));
break;
case Qt::TopRightSection:
- height = qRound(qBound(min.height(), rect->height(), max.height()));
- rect->setTop(rect->bottom() - height);
- rect->setWidth(qBound(min.width(), rect->width(), max.width()));
+ rect->setTop(rect->bottom() - qRound(height));
+ rect->setWidth(qRound(width));
break;
case Qt::RightSection:
- rect->setWidth(qBound(min.width(), rect->width(), max.width()));
+ rect->setWidth(qRound(width));
break;
case Qt::BottomRightSection:
- rect->setWidth(qBound(min.width(), rect->width(), max.width()));
- rect->setHeight(qBound(min.height(), rect->height(), max.height()));
+ rect->setWidth(qRound(width));
+ rect->setHeight(qRound(height));
break;
case Qt::BottomSection:
- rect->setHeight(qBound(min.height(), rect->height(), max.height()));
+ rect->setHeight(qRound(height));
break;
case Qt::BottomLeftSection:
- height = qRound(qBound(min.height(), rect->height(), max.height()));
- width = qRound(qBound(min.width(), rect->width(), max.width()));
- rect->setRect(startGeometry.right() - width, startGeometry.top(),
- width, height);
+ rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
+ qRound(width), qRound(height));
break;
default:
break;
@@ -506,7 +619,8 @@ void QGraphicsWidgetPrivate::windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent
_q_boundGeometryToSizeConstraints(windowData->startGeometry, &newGeometry,
windowData->grabbedSection,
q->effectiveSizeHint(Qt::MinimumSize),
- q->effectiveSizeHint(Qt::MaximumSize));
+ q->effectiveSizeHint(Qt::MaximumSize),
+ q);
q->setGeometry(newGeometry);
}
}
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index fc801ad..5b5cfa1 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -1804,12 +1804,12 @@ QItemSelection QListViewPrivate::selection(const QRect &rect) const
void QCommonListViewBase::appendHiddenRow(int row)
{
- dd->hiddenRows.append(dd->model->index(row, 0));
+ dd->hiddenRows.append(dd->model->index(row, 0, qq->rootIndex()));
}
void QCommonListViewBase::removeHiddenRow(int row)
{
- dd->hiddenRows.remove(dd->hiddenRows.indexOf(dd->model->index(row, 0)));
+ dd->hiddenRows.remove(dd->hiddenRows.indexOf(dd->model->index(row, 0, qq->rootIndex())));
}
void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step)
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 84edf1f..729b791 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -2035,7 +2035,6 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
#endif
// Ignore the activate message send by WindowsXP to a minimized window
#ifdef Q_WS_WINCE_WM
- {
if (widget->windowState() & Qt::WindowFullScreen)
qt_wince_hide_taskbar(widget->winId());
#endif
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index a61b6fa..0b282bc 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3648,13 +3648,13 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
\i As mentioned above, enabling touch events means multiple widgets can be receiving touch
events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents,
this gives you great flexibility in designing multi-touch user interfaces. Be aware of the
- implications. For example, is is possible that the user is moving a QSlider with one finger and
+ implications. For example, it is possible that the user is moving a QSlider with one finger and
pressing a QPushButton with another. The signals emitted by these widgets will be
interleaved.
\i Recursion into the event loop using one of the exec() methods (e.g., QDialog::exec() or
QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event
- recipients, unexpected recursion may cause problems, including but not limited to lost events
+ recipients, recursion may cause problems, including but not limited to lost events
and unexpected infinite recursion.
\i QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
diff --git a/src/gui/kernel/qsizepolicy.h b/src/gui/kernel/qsizepolicy.h
index 4261dda..eb13788 100644
--- a/src/gui/kernel/qsizepolicy.h
+++ b/src/gui/kernel/qsizepolicy.h
@@ -64,6 +64,7 @@ private:
VMask = HMask << HSize,
CTShift = 9,
CTSize = 5,
+ WFHShift = CTShift + CTSize,
CTMask = ((0x1 << CTSize) - 1) << CTShift,
UnusedShift = CTShift + CTSize,
UnusedSize = 2
@@ -199,6 +200,17 @@ private:
QSizePolicy(int i) : data(i) { }
quint32 data;
+/* use bit flags instead, keep it here for improved readability for now
+ quint32 horzPolicy : 4;
+ quint32 vertPolicy : 4;
+ quint32 hfw : 1;
+ quint32 ctype : 5;
+ quint32 wfh : 1;
+ quint32 padding : 1; // we cannot use the highest bit
+ quint32 horStretch : 8;
+ quint32 verStretch : 8;
+*/
+
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QSizePolicy::ControlTypes)
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp
index 8e2eb1e..3140af9 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/gui/kernel/qx11embed_x11.cpp
@@ -123,8 +123,8 @@ QT_BEGIN_NAMESPACE
emitted.
There are XEmbed widgets available for KDE and GTK+. The GTK+
- equivalent of QX11EmbedWidget is GtkPlug. The KDE widget is called
- QXEmbed.
+ equivalent of QX11EmbedWidget is GtkPlug. The corresponding KDE 3
+ widget is called QXEmbed.
\sa QX11EmbedContainer, {XEmbed Specification}
*/
@@ -177,8 +177,8 @@ QT_BEGIN_NAMESPACE
features such as window activation and focus handling are then
lost.
- The GTK+ equivalent of QX11EmbedContainer is GtkSocket. The KDE
- widget is called QXEmbed.
+ The GTK+ equivalent of QX11EmbedContainer is GtkSocket. The
+ corresponding KDE 3 widget is called QXEmbed.
\sa QX11EmbedWidget, {XEmbed Specification}
*/
diff --git a/src/gui/math3d/qgenericmatrix.cpp b/src/gui/math3d/qgenericmatrix.cpp
index 290c9c2..b5d8824 100644
--- a/src/gui/math3d/qgenericmatrix.cpp
+++ b/src/gui/math3d/qgenericmatrix.cpp
@@ -50,19 +50,14 @@ QT_BEGIN_NAMESPACE
\ingroup painting
\ingroup painting-3D
- The QGenericMatrix template has four parameters:
+ The QGenericMatrix template has three parameters:
\table
\row \i N \i Number of columns.
\row \i M \i Number of rows.
\row \i T \i Element type that is visible to users of the class.
- \row \i InnerT \i Element type that is used inside the class.
\endtable
- Normally T and InnerT are the same type; e.g. float or double.
- But they can be different if the user wants to store elements
- internally in a fixed-point format for the underlying hardware.
-
\sa QMatrix4x4
*/
@@ -73,7 +68,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QGenericMatrix::QGenericMatrix(const QGenericMatrix<N, M, T, InnerT>& other)
+ \fn QGenericMatrix::QGenericMatrix(const QGenericMatrix<N, M, T>& other)
Constructs a copy of \a other.
*/
@@ -89,13 +84,14 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn T QGenericMatrix::operator()(int row, int column) const
+ \fn const T& QGenericMatrix::operator()(int row, int column) const
- Returns the element at position (\a row, \a column) in this matrix.
+ Returns a constant reference to the element at position
+ (\a row, \a column) in this matrix.
*/
/*!
- \fn InnerT& QGenericMatrix::operator()(int row, int column)
+ \fn T& QGenericMatrix::operator()(int row, int column)
Returns a reference to the element at position (\a row, \a column)
in this matrix so that the element can be assigned to.
@@ -130,57 +126,57 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QGenericMatrix<N, M, T, InnerT>& QGenericMatrix::operator+=(const QGenericMatrix<N, M, T, InnerT>& other)
+ \fn QGenericMatrix<N, M, T>& QGenericMatrix::operator+=(const QGenericMatrix<N, M, T>& other)
Adds the contents of \a other to this matrix.
*/
/*!
- \fn QGenericMatrix<N, M, T, InnerT>& QGenericMatrix::operator-=(const QGenericMatrix<N, M, T, InnerT>& other)
+ \fn QGenericMatrix<N, M, T>& QGenericMatrix::operator-=(const QGenericMatrix<N, M, T>& other)
Subtracts the contents of \a other from this matrix.
*/
/*!
- \fn QGenericMatrix<N, M, T, InnerT>& QGenericMatrix::operator*=(T factor)
+ \fn QGenericMatrix<N, M, T>& QGenericMatrix::operator*=(T factor)
Multiplies all elements of this matrix by \a factor.
*/
/*!
- \fn QGenericMatrix<N, M, T, InnerT>& QGenericMatrix::operator/=(T divisor)
+ \fn QGenericMatrix<N, M, T>& QGenericMatrix::operator/=(T divisor)
Divides all elements of this matrix by \a divisor.
*/
/*!
- \fn bool QGenericMatrix::operator==(const QGenericMatrix<N, M, T, InnerT>& other) const
+ \fn bool QGenericMatrix::operator==(const QGenericMatrix<N, M, T>& other) const
Returns true if this matrix is identical to \a other; false otherwise.
*/
/*!
- \fn bool QGenericMatrix::operator!=(const QGenericMatrix<N, M, T, InnerT>& other) const
+ \fn bool QGenericMatrix::operator!=(const QGenericMatrix<N, M, T>& other) const
Returns true if this matrix is not identical to \a other; false otherwise.
*/
/*!
- \fn QGenericMatrix<N, M, T, InnerT> operator+(const QGenericMatrix<N, M, T, InnerT>& m1, const QGenericMatrix<N, M, T, InnerT>& m2)
+ \fn QGenericMatrix<N, M, T> operator+(const QGenericMatrix<N, M, T>& m1, const QGenericMatrix<N, M, T>& m2)
\relates QGenericMatrix
Returns the sum of \a m1 and \a m2.
*/
/*!
- \fn QGenericMatrix<N, M, T, InnerT> operator-(const QGenericMatrix<N, M, T, InnerT>& m1, const QGenericMatrix<N, M, T, InnerT>& m2)
+ \fn QGenericMatrix<N, M, T> operator-(const QGenericMatrix<N, M, T>& m1, const QGenericMatrix<N, M, T>& m2)
\relates QGenericMatrix
Returns the difference of \a m1 and \a m2.
*/
/*!
- \fn QGenericMatrix<M1, M2, T, InnerT> operator*(const QGenericMatrix<N, M2, T, InnerT>& m1, const QGenericMatrix<M1, N, T, InnerT>& m2)
+ \fn QGenericMatrix<M1, M2, T> operator*(const QGenericMatrix<N, M2, T>& m1, const QGenericMatrix<M1, N, T>& m2)
\relates QGenericMatrix
Returns the product of the NxM2 matrix \a m1 and the M1xN matrix \a m2
@@ -188,7 +184,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QGenericMatrix<N, M, T, InnerT> operator-(const QGenericMatrix<N, M, T, InnerT>& matrix)
+ \fn QGenericMatrix<N, M, T> operator-(const QGenericMatrix<N, M, T>& matrix)
\overload
\relates QGenericMatrix
@@ -196,21 +192,21 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QGenericMatrix<N, M, T, InnerT> operator*(T factor, const QGenericMatrix<N, M, T, InnerT>& matrix)
+ \fn QGenericMatrix<N, M, T> operator*(T factor, const QGenericMatrix<N, M, T>& matrix)
\relates QGenericMatrix
Returns the result of multiplying all elements of \a matrix by \a factor.
*/
/*!
- \fn QGenericMatrix<N, M, T, InnerT> operator*(const QGenericMatrix<N, M, T, InnerT>& matrix, T factor)
+ \fn QGenericMatrix<N, M, T> operator*(const QGenericMatrix<N, M, T>& matrix, T factor)
\relates QGenericMatrix
Returns the result of multiplying all elements of \a matrix by \a factor.
*/
/*!
- \fn QGenericMatrix<N, M, T, InnerT> operator/(const QGenericMatrix<N, M, T, InnerT>& matrix, T divisor)
+ \fn QGenericMatrix<N, M, T> operator/(const QGenericMatrix<N, M, T>& matrix, T divisor)
\relates QGenericMatrix
Returns the result of dividing all elements of \a matrix by \a divisor.
@@ -224,28 +220,25 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn InnerT *QGenericMatrix::data()
+ \fn T *QGenericMatrix::data()
- Returns a pointer to the raw data of this matrix. This is intended
- for use with raw GL functions.
+ Returns a pointer to the raw data of this matrix.
\sa constData()
*/
/*!
- \fn const InnerT *QGenericMatrix::data() const
+ \fn const T *QGenericMatrix::data() const
Returns a constant pointer to the raw data of this matrix.
- This is intended for use with raw GL functions.
\sa constData()
*/
/*!
- \fn const InnerT *QGenericMatrix::constData() const
+ \fn const T *QGenericMatrix::constData() const
Returns a constant pointer to the raw data of this matrix.
- This is intended for use with raw GL functions.
\sa data()
*/
diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h
index fe7ba5f..39c4ed8 100644
--- a/src/gui/math3d/qgenericmatrix.h
+++ b/src/gui/math3d/qgenericmatrix.h
@@ -51,103 +51,103 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
-template <int N, int M, typename T, typename InnerT = T>
+template <int N, int M, typename T>
class QGenericMatrix
{
public:
QGenericMatrix();
- QGenericMatrix(const QGenericMatrix<N, M, T, InnerT>& other);
+ QGenericMatrix(const QGenericMatrix<N, M, T>& other);
explicit QGenericMatrix(const T *values);
- T operator()(int row, int column) const;
- InnerT& operator()(int row, int column);
+ const T& operator()(int row, int column) const;
+ T& operator()(int row, int column);
bool isIdentity() const;
void setIdentity();
void fill(T value);
- QGenericMatrix<M, N, T, InnerT> transposed() const;
+ QGenericMatrix<M, N, T> transposed() const;
- QGenericMatrix<N, M, T, InnerT>& operator+=(const QGenericMatrix<N, M, T, InnerT>& other);
- QGenericMatrix<N, M, T, InnerT>& operator-=(const QGenericMatrix<N, M, T, InnerT>& other);
- QGenericMatrix<N, M, T, InnerT>& operator*=(T factor);
- QGenericMatrix<N, M, T, InnerT>& operator/=(T divisor);
- bool operator==(const QGenericMatrix<N, M, T, InnerT>& other) const;
- bool operator!=(const QGenericMatrix<N, M, T, InnerT>& other) const;
+ QGenericMatrix<N, M, T>& operator+=(const QGenericMatrix<N, M, T>& other);
+ QGenericMatrix<N, M, T>& operator-=(const QGenericMatrix<N, M, T>& other);
+ QGenericMatrix<N, M, T>& operator*=(T factor);
+ QGenericMatrix<N, M, T>& operator/=(T divisor);
+ bool operator==(const QGenericMatrix<N, M, T>& other) const;
+ bool operator!=(const QGenericMatrix<N, M, T>& other) const;
void toValueArray(T *values);
- InnerT *data() { return m[0]; }
- const InnerT *data() const { return m[0]; }
- const InnerT *constData() const { return m[0]; }
+ T *data() { return m[0]; }
+ const T *data() const { return m[0]; }
+ const T *constData() const { return m[0]; }
#if !defined(Q_NO_TEMPLATE_FRIENDS)
- template<int NN, int MM, typename TT, typename ITT>
- friend QGenericMatrix<NN, MM, TT, ITT> operator+(const QGenericMatrix<NN, MM, TT, ITT>& m1, const QGenericMatrix<NN, MM, TT, ITT>& m2);
- template<int NN, int MM, typename TT, typename ITT>
- friend QGenericMatrix<NN, MM, TT, ITT> operator-(const QGenericMatrix<NN, MM, TT, ITT>& m1, const QGenericMatrix<NN, MM, TT, ITT>& m2);
- template<int NN, int M1, int M2, typename TT, typename ITT>
- friend QGenericMatrix<M1, M2, TT, ITT> operator*(const QGenericMatrix<NN, M2, TT, ITT>& m1, const QGenericMatrix<M1, NN, TT, ITT>& m2);
- template<int NN, int MM, typename TT, typename ITT>
- friend QGenericMatrix<NN, MM, TT, ITT> operator-(const QGenericMatrix<NN, MM, TT, ITT>& matrix);
- template<int NN, int MM, typename TT, typename ITT>
- friend QGenericMatrix<NN, MM, TT, ITT> operator*(TT factor, const QGenericMatrix<NN, MM, TT, ITT>& matrix);
- template<int NN, int MM, typename TT, typename ITT>
- friend QGenericMatrix<NN, MM, TT, ITT> operator*(const QGenericMatrix<NN, MM, TT, ITT>& matrix, TT factor);
- template<int NN, int MM, typename TT, typename ITT>
- friend QGenericMatrix<NN, MM, TT, ITT> operator/(const QGenericMatrix<NN, MM, TT, ITT>& matrix, TT divisor);
+ template<int NN, int MM, typename TT>
+ friend QGenericMatrix<NN, MM, TT> operator+(const QGenericMatrix<NN, MM, TT>& m1, const QGenericMatrix<NN, MM, TT>& m2);
+ template<int NN, int MM, typename TT>
+ friend QGenericMatrix<NN, MM, TT> operator-(const QGenericMatrix<NN, MM, TT>& m1, const QGenericMatrix<NN, MM, TT>& m2);
+ template<int NN, int M1, int M2, typename TT>
+ friend QGenericMatrix<M1, M2, TT> operator*(const QGenericMatrix<NN, M2, TT>& m1, const QGenericMatrix<M1, NN, TT>& m2);
+ template<int NN, int MM, typename TT>
+ friend QGenericMatrix<NN, MM, TT> operator-(const QGenericMatrix<NN, MM, TT>& matrix);
+ template<int NN, int MM, typename TT>
+ friend QGenericMatrix<NN, MM, TT> operator*(TT factor, const QGenericMatrix<NN, MM, TT>& matrix);
+ template<int NN, int MM, typename TT>
+ friend QGenericMatrix<NN, MM, TT> operator*(const QGenericMatrix<NN, MM, TT>& matrix, TT factor);
+ template<int NN, int MM, typename TT>
+ friend QGenericMatrix<NN, MM, TT> operator/(const QGenericMatrix<NN, MM, TT>& matrix, TT divisor);
private:
#endif
- InnerT m[N][M]; // Column-major order to match OpenGL.
+ T m[N][M]; // Column-major order to match OpenGL.
QGenericMatrix(int) {} // Construct without initializing identity matrix.
#if !defined(Q_NO_TEMPLATE_FRIENDS)
- template <int NN, int MM, typename TT, typename ITT>
+ template <int NN, int MM, typename TT>
friend class QGenericMatrix;
#endif
};
-template <int N, int M, typename T, typename InnerT>
-Q_INLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT>::QGenericMatrix()
+template <int N, int M, typename T>
+Q_INLINE_TEMPLATE QGenericMatrix<N, M, T>::QGenericMatrix()
{
setIdentity();
}
-template <int N, int M, typename T, typename InnerT>
-Q_INLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT>::QGenericMatrix(const QGenericMatrix<N, M, T, InnerT>& other)
+template <int N, int M, typename T>
+Q_INLINE_TEMPLATE QGenericMatrix<N, M, T>::QGenericMatrix(const QGenericMatrix<N, M, T>& other)
{
for (int col = 0; col < N; ++col)
for (int row = 0; row < M; ++row)
m[col][row] = other.m[col][row];
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT>::QGenericMatrix(const T *values)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T>::QGenericMatrix(const T *values)
{
for (int col = 0; col < N; ++col)
for (int row = 0; row < M; ++row)
m[col][row] = values[row * N + col];
}
-template <int N, int M, typename T, typename InnerT>
-Q_INLINE_TEMPLATE T QGenericMatrix<N, M, T, InnerT>::operator()(int row, int column) const
+template <int N, int M, typename T>
+Q_INLINE_TEMPLATE const T& QGenericMatrix<N, M, T>::operator()(int row, int column) const
{
Q_ASSERT(row >= 0 && row < M && column >= 0 && column < N);
- return T(m[column][row]);
+ return m[column][row];
}
-template <int N, int M, typename T, typename InnerT>
-Q_INLINE_TEMPLATE InnerT& QGenericMatrix<N, M, T, InnerT>::operator()(int row, int column)
+template <int N, int M, typename T>
+Q_INLINE_TEMPLATE T& QGenericMatrix<N, M, T>::operator()(int row, int column)
{
Q_ASSERT(row >= 0 && row < M && column >= 0 && column < N);
return m[column][row];
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE bool QGenericMatrix<N, M, T, InnerT>::isIdentity() const
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE bool QGenericMatrix<N, M, T>::isIdentity() const
{
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
@@ -163,8 +163,8 @@ Q_OUTOFLINE_TEMPLATE bool QGenericMatrix<N, M, T, InnerT>::isIdentity() const
return true;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::setIdentity()
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T>::setIdentity()
{
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
@@ -176,51 +176,50 @@ Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::setIdentity()
}
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::fill(T value)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T>::fill(T value)
{
for (int col = 0; col < N; ++col)
for (int row = 0; row < M; ++row)
m[col][row] = value;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<M, N, T, InnerT> QGenericMatrix<N, M, T, InnerT>::transposed() const
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<M, N, T> QGenericMatrix<N, M, T>::transposed() const
{
- QGenericMatrix<M, N, T, InnerT> result(1);
+ QGenericMatrix<M, N, T> result(1);
for (int row = 0; row < M; ++row)
for (int col = 0; col < N; ++col)
result.m[row][col] = m[col][row];
return result;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT>& QGenericMatrix<N, M, T, InnerT>::operator+=(const QGenericMatrix<N, M, T, InnerT>& other)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator+=(const QGenericMatrix<N, M, T>& other)
{
for (int index = 0; index < N * M; ++index)
m[0][index] += other.m[0][index];
return *this;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT>& QGenericMatrix<N, M, T, InnerT>::operator-=(const QGenericMatrix<N, M, T, InnerT>& other)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator-=(const QGenericMatrix<N, M, T>& other)
{
for (int index = 0; index < N * M; ++index)
m[0][index] -= other.m[0][index];
return *this;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT>& QGenericMatrix<N, M, T, InnerT>::operator*=(T factor)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator*=(T factor)
{
- InnerT f(factor);
for (int index = 0; index < N * M; ++index)
- m[0][index] *= f;
+ m[0][index] *= factor;
return *this;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE bool QGenericMatrix<N, M, T, InnerT>::operator==(const QGenericMatrix<N, M, T, InnerT>& other) const
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE bool QGenericMatrix<N, M, T>::operator==(const QGenericMatrix<N, M, T>& other) const
{
for (int index = 0; index < N * M; ++index) {
if (m[0][index] != other.m[0][index])
@@ -229,8 +228,8 @@ Q_OUTOFLINE_TEMPLATE bool QGenericMatrix<N, M, T, InnerT>::operator==(const QGen
return true;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE bool QGenericMatrix<N, M, T, InnerT>::operator!=(const QGenericMatrix<N, M, T, InnerT>& other) const
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE bool QGenericMatrix<N, M, T>::operator!=(const QGenericMatrix<N, M, T>& other) const
{
for (int index = 0; index < N * M; ++index) {
if (m[0][index] != other.m[0][index])
@@ -239,40 +238,39 @@ Q_OUTOFLINE_TEMPLATE bool QGenericMatrix<N, M, T, InnerT>::operator!=(const QGen
return false;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT>& QGenericMatrix<N, M, T, InnerT>::operator/=(T divisor)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T>& QGenericMatrix<N, M, T>::operator/=(T divisor)
{
- InnerT d(divisor);
for (int index = 0; index < N * M; ++index)
- m[0][index] /= d;
+ m[0][index] /= divisor;
return *this;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT> operator+(const QGenericMatrix<N, M, T, InnerT>& m1, const QGenericMatrix<N, M, T, InnerT>& m2)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator+(const QGenericMatrix<N, M, T>& m1, const QGenericMatrix<N, M, T>& m2)
{
- QGenericMatrix<N, M, T, InnerT> result(1);
+ QGenericMatrix<N, M, T> result(1);
for (int index = 0; index < N * M; ++index)
result.m[0][index] = m1.m[0][index] + m2.m[0][index];
return result;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT> operator-(const QGenericMatrix<N, M, T, InnerT>& m1, const QGenericMatrix<N, M, T, InnerT>& m2)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator-(const QGenericMatrix<N, M, T>& m1, const QGenericMatrix<N, M, T>& m2)
{
- QGenericMatrix<N, M, T, InnerT> result(1);
+ QGenericMatrix<N, M, T> result(1);
for (int index = 0; index < N * M; ++index)
result.m[0][index] = m1.m[0][index] - m2.m[0][index];
return result;
}
-template <int N, int M1, int M2, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<M1, M2, T, InnerT> operator*(const QGenericMatrix<N, M2, T, InnerT>& m1, const QGenericMatrix<M1, N, T, InnerT>& m2)
+template <int N, int M1, int M2, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<M1, M2, T> operator*(const QGenericMatrix<N, M2, T>& m1, const QGenericMatrix<M1, N, T>& m2)
{
- QGenericMatrix<M1, M2, T, InnerT> result(1);
+ QGenericMatrix<M1, M2, T> result(1);
for (int row = 0; row < M2; ++row) {
for (int col = 0; col < M1; ++col) {
- InnerT sum(0.0f);
+ T sum(0.0f);
for (int j = 0; j < N; ++j)
sum += m1.m[j][row] * m2.m[col][j];
result.m[col][row] = sum;
@@ -281,47 +279,44 @@ Q_OUTOFLINE_TEMPLATE QGenericMatrix<M1, M2, T, InnerT> operator*(const QGenericM
return result;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT> operator-(const QGenericMatrix<N, M, T, InnerT>& matrix)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator-(const QGenericMatrix<N, M, T>& matrix)
{
- QGenericMatrix<N, M, T, InnerT> result(1);
+ QGenericMatrix<N, M, T> result(1);
for (int index = 0; index < N * M; ++index)
result.m[0][index] = -matrix.m[0][index];
return result;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT> operator*(T factor, const QGenericMatrix<N, M, T, InnerT>& matrix)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator*(T factor, const QGenericMatrix<N, M, T>& matrix)
{
- InnerT f(factor);
- QGenericMatrix<N, M, T, InnerT> result(1);
+ QGenericMatrix<N, M, T> result(1);
for (int index = 0; index < N * M; ++index)
- result.m[0][index] = matrix.m[0][index] * f;
+ result.m[0][index] = matrix.m[0][index] * factor;
return result;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT> operator*(const QGenericMatrix<N, M, T, InnerT>& matrix, T factor)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator*(const QGenericMatrix<N, M, T>& matrix, T factor)
{
- InnerT f(factor);
- QGenericMatrix<N, M, T, InnerT> result(1);
+ QGenericMatrix<N, M, T> result(1);
for (int index = 0; index < N * M; ++index)
- result.m[0][index] = matrix.m[0][index] * f;
+ result.m[0][index] = matrix.m[0][index] * factor;
return result;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T, InnerT> operator/(const QGenericMatrix<N, M, T, InnerT>& matrix, T divisor)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator/(const QGenericMatrix<N, M, T>& matrix, T divisor)
{
- InnerT d(divisor);
- QGenericMatrix<N, M, T, InnerT> result(1);
+ QGenericMatrix<N, M, T> result(1);
for (int index = 0; index < N * M; ++index)
- result.m[0][index] = matrix.m[0][index] / d;
+ result.m[0][index] = matrix.m[0][index] / divisor;
return result;
}
-template <int N, int M, typename T, typename InnerT>
-Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::toValueArray(T *values)
+template <int N, int M, typename T>
+Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T>::toValueArray(T *values)
{
for (int col = 0; col < N; ++col)
for (int row = 0; row < M; ++row)
@@ -329,22 +324,22 @@ Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::toValueArray(T *value
}
// Define aliases for the useful variants of QGenericMatrix.
-typedef QGenericMatrix<2, 2, qreal, float> QMatrix2x2;
-typedef QGenericMatrix<2, 3, qreal, float> QMatrix2x3;
-typedef QGenericMatrix<2, 4, qreal, float> QMatrix2x4;
-typedef QGenericMatrix<3, 2, qreal, float> QMatrix3x2;
-typedef QGenericMatrix<3, 3, qreal, float> QMatrix3x3;
-typedef QGenericMatrix<3, 4, qreal, float> QMatrix3x4;
-typedef QGenericMatrix<4, 2, qreal, float> QMatrix4x2;
-typedef QGenericMatrix<4, 3, qreal, float> QMatrix4x3;
+typedef QGenericMatrix<2, 2, qreal> QMatrix2x2;
+typedef QGenericMatrix<2, 3, qreal> QMatrix2x3;
+typedef QGenericMatrix<2, 4, qreal> QMatrix2x4;
+typedef QGenericMatrix<3, 2, qreal> QMatrix3x2;
+typedef QGenericMatrix<3, 3, qreal> QMatrix3x3;
+typedef QGenericMatrix<3, 4, qreal> QMatrix3x4;
+typedef QGenericMatrix<4, 2, qreal> QMatrix4x2;
+typedef QGenericMatrix<4, 3, qreal> QMatrix4x3;
#ifndef QT_NO_DEBUG_STREAM
-template <int N, int M, typename T, typename InnerT>
-QDebug operator<<(QDebug dbg, const QGenericMatrix<N, M, T, InnerT> &m)
+template <int N, int M, typename T>
+QDebug operator<<(QDebug dbg, const QGenericMatrix<N, M, T> &m)
{
dbg.nospace() << "QGenericMatrix<" << N << ", " << M
- << ", " << QTypeInfo<T>::name() << ", " << QTypeInfo<InnerT>::name()
+ << ", " << QTypeInfo<T>::name()
<< ">(" << endl << qSetFieldWidth(10);
for (int row = 0; row < M; ++row) {
for (int col = 0; col < N; ++col)
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index eb5858c..2164aca 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -103,7 +103,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
/*!
- \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
+ \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, qreal>& matrix)
Constructs a 4x4 matrix from the left-most 4 columns and top-most
4 rows of \a matrix. If \a matrix has less than 4 columns or rows,
@@ -114,7 +114,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
*/
/*!
- \fn QGenericMatrix<N, M, qreal, float> QMatrix4x4::toGenericMatrix() const
+ \fn QGenericMatrix<N, M, qreal> QMatrix4x4::toGenericMatrix() const
Constructs a NxM generic matrix from the left-most N columns and
top-most M rows of this 4x4 matrix. If N or M is greater than 4,
@@ -127,7 +127,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
#endif
/*!
- \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
+ \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal>& matrix)
\relates QMatrix4x4
Returns a 4x4 matrix constructed from the left-most 4 columns and
@@ -139,7 +139,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
*/
/*!
- \fn QGenericMatrix<N, M, qreal, float> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
+ \fn QGenericMatrix<N, M, qreal> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
\relates QMatrix4x4
Returns a NxM generic matrix constructed from the left-most N columns
@@ -153,7 +153,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
/*!
\internal
*/
-QMatrix4x4::QMatrix4x4(const float *values, int cols, int rows)
+QMatrix4x4::QMatrix4x4(const qreal *values, int cols, int rows)
{
for (int col = 0; col < 4; ++col) {
for (int row = 0; row < 4; ++row) {
@@ -233,15 +233,16 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
}
/*!
- \fn qreal QMatrix4x4::operator()(int row, int column) const
+ \fn const qreal& QMatrix4x4::operator()(int row, int column) const
- Returns the element at position (\a row, \a column) in this matrix.
+ Returns a constant reference to the element at position
+ (\a row, \a column) in this matrix.
\sa column(), row()
*/
/*!
- \fn float& QMatrix4x4::operator()(int row, int column)
+ \fn qreal& QMatrix4x4::operator()(int row, int column)
Returns a reference to the element at position (\a row, \a column)
in this matrix so that the element can be assigned to.
@@ -312,8 +313,8 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
// | A B C |
// M = | D E F | det(M) = A * (EI - HF) - B * (DI - GF) + C * (DH - GE)
// | G H I |
-static inline float matrixDet3
- (const float m[4][4], int col0, int col1, int col2,
+static inline qreal matrixDet3
+ (const qreal m[4][4], int col0, int col1, int col2,
int row0, int row1, int row2)
{
return m[col0][row0] *
@@ -328,9 +329,9 @@ static inline float matrixDet3
}
// Calculate the determinant of a 4x4 matrix.
-static inline float matrixDet4(const float m[4][4])
+static inline qreal matrixDet4(const qreal m[4][4])
{
- float det;
+ qreal det;
det = m[0][0] * matrixDet3(m, 1, 2, 3, 1, 2, 3);
det -= m[1][0] * matrixDet3(m, 0, 2, 3, 1, 2, 3);
det += m[2][0] * matrixDet3(m, 0, 1, 3, 1, 2, 3);
@@ -382,7 +383,7 @@ QMatrix4x4 QMatrix4x4::inverted(bool *invertible) const
QMatrix4x4 inv(1); // The "1" says to not load the identity.
- float det = matrixDet4(m);
+ qreal det = matrixDet4(m);
if (det == 0.0f) {
if (invertible)
*invertible = false;
@@ -436,12 +437,12 @@ QMatrix3x3 QMatrix4x4::normalMatrix() const
return inv;
}
- float det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
+ qreal det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
if (det == 0.0f)
return inv;
det = 1.0f / det;
- float *invm = inv.data();
+ qreal *invm = inv.data();
// Invert and transpose in a single step.
invm[0 + 0 * 3] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]) * det;
@@ -697,9 +698,9 @@ QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor)
*/
QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
{
- float vx = vector.xp;
- float vy = vector.yp;
- float vz = vector.zp;
+ qreal vx = vector.x();
+ qreal vy = vector.y();
+ qreal vz = vector.z();
if (flagBits == Identity) {
m[0][0] = vx;
m[1][1] = vy;
@@ -743,28 +744,26 @@ QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y)
{
- float vx(x);
- float vy(y);
if (flagBits == Identity) {
- m[0][0] = vx;
- m[1][1] = vy;
+ m[0][0] = x;
+ m[1][1] = y;
flagBits = Scale;
} else if (flagBits == Scale || flagBits == (Scale | Translation)) {
- m[0][0] *= vx;
- m[1][1] *= vy;
+ m[0][0] *= x;
+ m[1][1] *= y;
} else if (flagBits == Translation) {
- m[0][0] = vx;
- m[1][1] = vy;
+ m[0][0] = x;
+ m[1][1] = y;
flagBits |= Scale;
} else {
- m[0][0] *= vx;
- m[0][1] *= vx;
- m[0][2] *= vx;
- m[0][3] *= vx;
- m[1][0] *= vy;
- m[1][1] *= vy;
- m[1][2] *= vy;
- m[1][3] *= vy;
+ m[0][0] *= x;
+ m[0][1] *= x;
+ m[0][2] *= x;
+ m[0][3] *= x;
+ m[1][0] *= y;
+ m[1][1] *= y;
+ m[1][2] *= y;
+ m[1][3] *= y;
flagBits = General;
}
return *this;
@@ -780,36 +779,33 @@ QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y)
*/
QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y, qreal z)
{
- float vx(x);
- float vy(y);
- float vz(z);
if (flagBits == Identity) {
- m[0][0] = vx;
- m[1][1] = vy;
- m[2][2] = vz;
+ m[0][0] = x;
+ m[1][1] = y;
+ m[2][2] = z;
flagBits = Scale;
} else if (flagBits == Scale || flagBits == (Scale | Translation)) {
- m[0][0] *= vx;
- m[1][1] *= vy;
- m[2][2] *= vz;
+ m[0][0] *= x;
+ m[1][1] *= y;
+ m[2][2] *= z;
} else if (flagBits == Translation) {
- m[0][0] = vx;
- m[1][1] = vy;
- m[2][2] = vz;
+ m[0][0] = x;
+ m[1][1] = y;
+ m[2][2] = z;
flagBits |= Scale;
} else {
- m[0][0] *= vx;
- m[0][1] *= vx;
- m[0][2] *= vx;
- m[0][3] *= vx;
- m[1][0] *= vy;
- m[1][1] *= vy;
- m[1][2] *= vy;
- m[1][3] *= vy;
- m[2][0] *= vz;
- m[2][1] *= vz;
- m[2][2] *= vz;
- m[2][3] *= vz;
+ m[0][0] *= x;
+ m[0][1] *= x;
+ m[0][2] *= x;
+ m[0][3] *= x;
+ m[1][0] *= y;
+ m[1][1] *= y;
+ m[1][2] *= y;
+ m[1][3] *= y;
+ m[2][0] *= z;
+ m[2][1] *= z;
+ m[2][2] *= z;
+ m[2][3] *= z;
flagBits = General;
}
return *this;
@@ -866,9 +862,9 @@ QMatrix4x4& QMatrix4x4::scale(qreal factor)
*/
QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
{
- float vx = vector.xp;
- float vy = vector.yp;
- float vz = vector.zp;
+ qreal vx = vector.x();
+ qreal vy = vector.y();
+ qreal vz = vector.z();
if (flagBits == Identity) {
m[3][0] = vx;
m[3][1] = vy;
@@ -912,28 +908,26 @@ QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y)
{
- float vx(x);
- float vy(y);
if (flagBits == Identity) {
- m[3][0] = vx;
- m[3][1] = vy;
+ m[3][0] = x;
+ m[3][1] = y;
flagBits = Translation;
} else if (flagBits == Translation) {
- m[3][0] += vx;
- m[3][1] += vy;
+ m[3][0] += x;
+ m[3][1] += y;
} else if (flagBits == Scale) {
- m[3][0] = m[0][0] * vx;
- m[3][1] = m[1][1] * vy;
+ m[3][0] = m[0][0] * x;
+ m[3][1] = m[1][1] * y;
m[3][2] = 0.;
flagBits |= Translation;
} else if (flagBits == (Scale | Translation)) {
- m[3][0] += m[0][0] * vx;
- m[3][1] += m[1][1] * vy;
+ m[3][0] += m[0][0] * x;
+ m[3][1] += m[1][1] * y;
} else {
- m[3][0] += m[0][0] * vx + m[1][0] * vy;
- m[3][1] += m[0][1] * vx + m[1][1] * vy;
- m[3][2] += m[0][2] * vx + m[1][2] * vy;
- m[3][3] += m[0][3] * vx + m[1][3] * vy;
+ m[3][0] += m[0][0] * x + m[1][0] * y;
+ m[3][1] += m[0][1] * x + m[1][1] * y;
+ m[3][2] += m[0][2] * x + m[1][2] * y;
+ m[3][3] += m[0][3] * x + m[1][3] * y;
if (flagBits == Rotation)
flagBits |= Translation;
else if (flagBits != (Rotation | Translation))
@@ -952,32 +946,29 @@ QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y)
*/
QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y, qreal z)
{
- float vx(x);
- float vy(y);
- float vz(z);
if (flagBits == Identity) {
- m[3][0] = vx;
- m[3][1] = vy;
- m[3][2] = vz;
+ m[3][0] = x;
+ m[3][1] = y;
+ m[3][2] = z;
flagBits = Translation;
} else if (flagBits == Translation) {
- m[3][0] += vx;
- m[3][1] += vy;
- m[3][2] += vz;
+ m[3][0] += x;
+ m[3][1] += y;
+ m[3][2] += z;
} else if (flagBits == Scale) {
- m[3][0] = m[0][0] * vx;
- m[3][1] = m[1][1] * vy;
- m[3][2] = m[2][2] * vz;
+ m[3][0] = m[0][0] * x;
+ m[3][1] = m[1][1] * y;
+ m[3][2] = m[2][2] * z;
flagBits |= Translation;
} else if (flagBits == (Scale | Translation)) {
- m[3][0] += m[0][0] * vx;
- m[3][1] += m[1][1] * vy;
- m[3][2] += m[2][2] * vz;
+ m[3][0] += m[0][0] * x;
+ m[3][1] += m[1][1] * y;
+ m[3][2] += m[2][2] * z;
} else {
- m[3][0] += m[0][0] * vx + m[1][0] * vy + m[2][0] * vz;
- m[3][1] += m[0][1] * vx + m[1][1] * vy + m[2][1] * vz;
- m[3][2] += m[0][2] * vx + m[1][2] * vy + m[2][2] * vz;
- m[3][3] += m[0][3] * vx + m[1][3] * vy + m[2][3] * vz;
+ m[3][0] += m[0][0] * x + m[1][0] * y + m[2][0] * z;
+ m[3][1] += m[0][1] * x + m[1][1] * y + m[2][1] * z;
+ m[3][2] += m[0][2] * x + m[1][2] * y + m[2][2] * z;
+ m[3][3] += m[0][3] * x + m[1][3] * y + m[2][3] * z;
if (flagBits == Rotation)
flagBits |= Translation;
else if (flagBits != (Rotation | Translation))
@@ -1126,15 +1117,15 @@ QMatrix4x4& QMatrix4x4::rotate(const QQuaternion& quaternion)
// Algorithm from:
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54
QMatrix4x4 m(1);
- float xx = quaternion.xp * quaternion.xp;
- float xy = quaternion.xp * quaternion.yp;
- float xz = quaternion.xp * quaternion.zp;
- float xw = quaternion.xp * quaternion.wp;
- float yy = quaternion.yp * quaternion.yp;
- float yz = quaternion.yp * quaternion.zp;
- float yw = quaternion.yp * quaternion.wp;
- float zz = quaternion.zp * quaternion.zp;
- float zw = quaternion.zp * quaternion.wp;
+ qreal xx = quaternion.x() * quaternion.x();
+ qreal xy = quaternion.x() * quaternion.y();
+ qreal xz = quaternion.x() * quaternion.z();
+ qreal xw = quaternion.x() * quaternion.scalar();
+ qreal yy = quaternion.y() * quaternion.y();
+ qreal yz = quaternion.y() * quaternion.z();
+ qreal yw = quaternion.y() * quaternion.scalar();
+ qreal zz = quaternion.z() * quaternion.z();
+ qreal zw = quaternion.z() * quaternion.scalar();
m.m[0][0] = 1.0f - 2 * (yy + zz);
m.m[1][0] = 2 * (xy - zw);
m.m[2][0] = 2 * (xz + yw);
@@ -1222,11 +1213,11 @@ QMatrix4x4& QMatrix4x4::ortho(qreal left, qreal right, qreal bottom, qreal top,
translate(QVector3D
(-(left + right) / width,
-(top + bottom) / invheight,
- 0.0f, 1));
+ 0.0f));
scale(QVector3D
(2.0f / width,
2.0f / invheight,
- -1.0f, 1));
+ -1.0f));
return *this;
}
#endif
@@ -1356,17 +1347,17 @@ QMatrix4x4& QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, co
QMatrix4x4 m(1);
- m.m[0][0] = side.xp;
- m.m[1][0] = side.yp;
- m.m[2][0] = side.zp;
+ m.m[0][0] = side.x();
+ m.m[1][0] = side.y();
+ m.m[2][0] = side.z();
m.m[3][0] = 0.0f;
- m.m[0][1] = upVector.xp;
- m.m[1][1] = upVector.yp;
- m.m[2][1] = upVector.zp;
+ m.m[0][1] = upVector.x();
+ m.m[1][1] = upVector.y();
+ m.m[2][1] = upVector.z();
m.m[3][1] = 0.0f;
- m.m[0][2] = -forward.xp;
- m.m[1][2] = -forward.yp;
- m.m[2][2] = -forward.zp;
+ m.m[0][2] = -forward.x();
+ m.m[1][2] = -forward.y();
+ m.m[2][2] = -forward.z();
m.m[3][2] = 0.0f;
m.m[0][3] = 0.0f;
m.m[1][3] = 0.0f;
@@ -1434,9 +1425,9 @@ void QMatrix4x4::toValueArray(qreal *values) const
*/
QMatrix QMatrix4x4::toAffine() const
{
- return QMatrix(qreal(m[0][0]), qreal(m[0][1]),
- qreal(m[1][0]), qreal(m[1][1]),
- qreal(m[3][0]), qreal(m[3][1]));
+ return QMatrix(m[0][0], m[0][1],
+ m[1][0], m[1][1],
+ m[3][0], m[3][1]);
}
static const qreal inv_dist_to_plane = 1. / 1024.;
@@ -1462,15 +1453,12 @@ QTransform QMatrix4x4::toTransform(qreal distanceToPlane) const
{
if (distanceToPlane == 1024.0f) {
// Optimize the common case with constants.
- return QTransform(qreal(m[0][0]), qreal(m[0][1]),
- qreal(m[0][3]) - qreal(m[0][2]) *
- inv_dist_to_plane,
- qreal(m[1][0]), qreal(m[1][1]),
- qreal(m[1][3]) - qreal(m[1][2]) *
- inv_dist_to_plane,
- qreal(m[3][0]), qreal(m[3][1]),
- qreal(m[3][3]) - qreal(m[3][2]) *
- inv_dist_to_plane);
+ return QTransform(m[0][0], m[0][1],
+ m[0][3] - m[0][2] * inv_dist_to_plane,
+ m[1][0], m[1][1],
+ m[1][3] - m[1][2] * inv_dist_to_plane,
+ m[3][0], m[3][1],
+ m[3][3] - m[3][2] * inv_dist_to_plane);
} else if (distanceToPlane != 0.0f) {
// The following projection matrix is pre-multiplied with "matrix":
// | 1 0 0 0 |
@@ -1480,17 +1468,14 @@ QTransform QMatrix4x4::toTransform(qreal distanceToPlane) const
// where d = -1 / distanceToPlane. After projection, row 3 and
// column 3 are dropped to form the final QTransform.
qreal d = 1.0f / distanceToPlane;
- return QTransform(qreal(m[0][0]), qreal(m[0][1]),
- qreal(m[0][3]) - qreal(m[0][2]) * d,
- qreal(m[1][0]), qreal(m[1][1]),
- qreal(m[1][3]) - qreal(m[1][2]) * d,
- qreal(m[3][0]), qreal(m[3][1]),
- qreal(m[3][3]) - qreal(m[3][2]) * d);
+ return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * d,
+ m[1][0], m[1][1], m[1][3] - m[1][2] * d,
+ m[3][0], m[3][1], m[3][3] - m[3][2] * d);
} else {
// Orthographic projection: drop row 3 and column 3.
- return QTransform(qreal(m[0][0]), qreal(m[0][1]), qreal(m[0][3]),
- qreal(m[1][0]), qreal(m[1][1]), qreal(m[1][3]),
- qreal(m[3][0]), qreal(m[3][1]), qreal(m[3][3]));
+ return QTransform(m[0][0], m[0][1], m[0][3],
+ m[1][0], m[1][1], m[1][3],
+ m[3][0], m[3][1], m[3][3]);
}
}
@@ -1618,28 +1603,25 @@ QRectF QMatrix4x4::mapRect(const QRectF& rect) const
}
/*!
- \fn float *QMatrix4x4::data()
+ \fn qreal *QMatrix4x4::data()
- Returns a pointer to the raw data of this matrix. This is intended
- for use with raw GL functions.
+ Returns a pointer to the raw data of this matrix.
\sa constData(), inferSpecialType()
*/
/*!
- \fn const float *QMatrix4x4::data() const
+ \fn const qreal *QMatrix4x4::data() const
Returns a constant pointer to the raw data of this matrix.
- This is intended for use with raw GL functions.
\sa constData()
*/
/*!
- \fn const float *QMatrix4x4::constData() const
+ \fn const qreal *QMatrix4x4::constData() const
Returns a constant pointer to the raw data of this matrix.
- This is intended for use with raw GL functions.
\sa data()
*/
@@ -1695,7 +1677,7 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
{
// Orientation is dependent on the upper 3x3 matrix; subtract the
// homogeneous scaling element from the trace of the 4x4 matrix
- float tr = m[0][0] + m[1][1] + m[2][2];
+ qreal tr = m[0][0] + m[1][1] + m[2][2];
qreal cosa = qreal(0.5f * (tr - 1.0f));
angle = acos(cosa) * 180.0f / M_PI;
@@ -1708,38 +1690,38 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
}
if (angle < 180.0f) {
- axis.xp = m[1][2] - m[2][1];
- axis.yp = m[2][0] - m[0][2];
- axis.zp = m[0][1] - m[1][0];
+ axis.setX(m[1][2] - m[2][1]);
+ axis.setY(m[2][0] - m[0][2]);
+ axis.setZ(m[0][1] - m[1][0]);
axis.normalize();
return;
}
// rads == PI
- float tmp;
+ qreal tmp;
// r00 is maximum
if ((m[0][0] >= m[2][2]) && (m[0][0] >= m[1][1])) {
- axis.xp = 0.5f * qSqrt(m[0][0] - m[1][1] - m[2][2] + 1.0f);
+ axis.setX(0.5f * qSqrt(m[0][0] - m[1][1] - m[2][2] + 1.0f));
tmp = 0.5f / axis.x();
- axis.yp = m[1][0] * tmp;
- axis.zp = m[2][0] * tmp;
+ axis.setY(m[1][0] * tmp);
+ axis.setZ(m[2][0] * tmp);
}
// r11 is maximum
if ((m[1][1] >= m[2][2]) && (m[1][1] >= m[0][0])) {
- axis.yp = 0.5f * qSqrt(m[1][1] - m[0][0] - m[2][2] + 1.0f);
+ axis.setY(0.5f * qSqrt(m[1][1] - m[0][0] - m[2][2] + 1.0f));
tmp = 0.5f / axis.y();
- axis.xp = tmp * m[1][0];
- axis.zp = tmp * m[2][1];
+ axis.setX(tmp * m[1][0]);
+ axis.setZ(tmp * m[2][1]);
}
// r22 is maximum
if ((m[2][2] >= m[1][1]) && (m[2][2] >= m[0][0])) {
- axis.zp = 0.5f * qSqrt(m[2][2] - m[0][0] - m[1][1] + 1.0f);
+ axis.setZ(0.5f * qSqrt(m[2][2] - m[0][0] - m[1][1] + 1.0f));
tmp = 0.5f / axis.z();
- axis.xp = m[2][0]*tmp;
- axis.yp = m[2][1]*tmp;
+ axis.setX(m[2][0]*tmp);
+ axis.setY(m[2][1]*tmp);
}
}
@@ -1756,7 +1738,7 @@ QVector3D QMatrix4x4::extractTranslation() const
return QVector3D
(m[0][0] * m[3][0] + m[0][1] * m[3][1] + m[0][2] * m[3][2],
m[1][0] * m[3][0] + m[1][1] * m[3][1] + m[1][2] * m[3][2],
- m[2][0] * m[3][0] + m[2][1] * m[3][1] + m[2][2] * m[3][2], 1);
+ m[2][0] * m[3][0] + m[2][1] * m[3][1] + m[2][2] * m[3][2]);
}
#endif
@@ -1894,7 +1876,7 @@ QDataStream &operator>>(QDataStream &stream, QMatrix4x4 &matrix)
for (int row = 0; row < 4; ++row) {
for (int col = 0; col < 4; ++col) {
stream >> x;
- matrix(row, col) = float(x);
+ matrix(row, col) = qreal(x);
}
}
matrix.inferSpecialType();
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index 4207bdf..8811027 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -71,14 +71,14 @@ public:
qreal m41, qreal m42, qreal m43, qreal m44);
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
template <int N, int M>
- explicit QMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix);
+ explicit QMatrix4x4(const QGenericMatrix<N, M, qreal>& matrix);
#endif
- QMatrix4x4(const float *values, int cols, int rows);
+ QMatrix4x4(const qreal *values, int cols, int rows);
QMatrix4x4(const QTransform& transform);
QMatrix4x4(const QMatrix& matrix);
- inline qreal operator()(int row, int column) const;
- inline float& operator()(int row, int column);
+ inline const qreal& operator()(int row, int column) const;
+ inline qreal& operator()(int row, int column);
inline QVector4D column(int index) const;
inline void setColumn(int index, const QVector4D& value);
@@ -174,12 +174,12 @@ public:
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
template <int N, int M>
- QGenericMatrix<N, M, qreal, float> toGenericMatrix() const;
+ QGenericMatrix<N, M, qreal> toGenericMatrix() const;
#endif
- inline float *data();
- inline const float *data() const { return m[0]; }
- inline const float *constData() const { return m[0]; }
+ inline qreal *data();
+ inline const qreal *data() const { return m[0]; }
+ inline const qreal *constData() const { return m[0]; }
void inferSpecialType();
@@ -190,7 +190,7 @@ public:
#endif
private:
- float m[4][4]; // Column-major order to match OpenGL.
+ qreal m[4][4]; // Column-major order to match OpenGL.
int flagBits; // Flag bits from the enum below.
enum {
@@ -224,9 +224,9 @@ inline QMatrix4x4::QMatrix4x4
template <int N, int M>
Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4
- (const QGenericMatrix<N, M, qreal, float>& matrix)
+ (const QGenericMatrix<N, M, qreal>& matrix)
{
- const float *values = matrix.constData();
+ const qreal *values = matrix.constData();
for (int col = 0; col < 4; ++col) {
for (int row = 0; row < 4; ++row) {
if (col < N && row < M)
@@ -241,10 +241,10 @@ Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4
}
template <int N, int M>
-QGenericMatrix<N, M, qreal, float> QMatrix4x4::toGenericMatrix() const
+QGenericMatrix<N, M, qreal> QMatrix4x4::toGenericMatrix() const
{
- QGenericMatrix<N, M, qreal, float> result;
- float *values = result.data();
+ QGenericMatrix<N, M, qreal> result;
+ qreal *values = result.data();
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
if (col < 4 && row < 4)
@@ -260,13 +260,13 @@ QGenericMatrix<N, M, qreal, float> QMatrix4x4::toGenericMatrix() const
#endif
-inline qreal QMatrix4x4::operator()(int row, int column) const
+inline const qreal& QMatrix4x4::operator()(int row, int column) const
{
Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
- return qreal(m[column][row]);
+ return m[column][row];
}
-inline float& QMatrix4x4::operator()(int row, int column)
+inline qreal& QMatrix4x4::operator()(int row, int column)
{
Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
flagBits = General;
@@ -276,32 +276,32 @@ inline float& QMatrix4x4::operator()(int row, int column)
inline QVector4D QMatrix4x4::column(int index) const
{
Q_ASSERT(index >= 0 && index < 4);
- return QVector4D(m[index][0], m[index][1], m[index][2], m[index][3], 1);
+ return QVector4D(m[index][0], m[index][1], m[index][2], m[index][3]);
}
inline void QMatrix4x4::setColumn(int index, const QVector4D& value)
{
Q_ASSERT(index >= 0 && index < 4);
- m[index][0] = value.xp;
- m[index][1] = value.yp;
- m[index][2] = value.zp;
- m[index][3] = value.wp;
+ m[index][0] = value.x();
+ m[index][1] = value.y();
+ m[index][2] = value.z();
+ m[index][3] = value.w();
flagBits = General;
}
inline QVector4D QMatrix4x4::row(int index) const
{
Q_ASSERT(index >= 0 && index < 4);
- return QVector4D(m[0][index], m[1][index], m[2][index], m[3][index], 1);
+ return QVector4D(m[0][index], m[1][index], m[2][index], m[3][index]);
}
inline void QMatrix4x4::setRow(int index, const QVector4D& value)
{
Q_ASSERT(index >= 0 && index < 4);
- m[0][index] = value.xp;
- m[1][index] = value.yp;
- m[2][index] = value.zp;
- m[3][index] = value.wp;
+ m[0][index] = value.x();
+ m[1][index] = value.y();
+ m[2][index] = value.z();
+ m[3][index] = value.w();
flagBits = General;
}
@@ -608,68 +608,68 @@ inline QMatrix4x4 operator*(const QMatrix4x4& m1, const QMatrix4x4& m2)
inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix)
{
- float x, y, z, w;
- x = vector.xp * matrix.m[0][0] +
- vector.yp * matrix.m[0][1] +
- vector.zp * matrix.m[0][2] +
+ qreal x, y, z, w;
+ x = vector.x() * matrix.m[0][0] +
+ vector.y() * matrix.m[0][1] +
+ vector.z() * matrix.m[0][2] +
matrix.m[0][3];
- y = vector.xp * matrix.m[1][0] +
- vector.yp * matrix.m[1][1] +
- vector.zp * matrix.m[1][2] +
+ y = vector.x() * matrix.m[1][0] +
+ vector.y() * matrix.m[1][1] +
+ vector.z() * matrix.m[1][2] +
matrix.m[1][3];
- z = vector.xp * matrix.m[2][0] +
- vector.yp * matrix.m[2][1] +
- vector.zp * matrix.m[2][2] +
+ z = vector.x() * matrix.m[2][0] +
+ vector.y() * matrix.m[2][1] +
+ vector.z() * matrix.m[2][2] +
matrix.m[2][3];
- w = vector.xp * matrix.m[3][0] +
- vector.yp * matrix.m[3][1] +
- vector.zp * matrix.m[3][2] +
+ w = vector.x() * matrix.m[3][0] +
+ vector.y() * matrix.m[3][1] +
+ vector.z() * matrix.m[3][2] +
matrix.m[3][3];
if (w == 1.0f)
- return QVector3D(x, y, z, 1);
+ return QVector3D(x, y, z);
else
- return QVector3D(x / w, y / w, z / w, 1);
+ return QVector3D(x / w, y / w, z / w);
}
inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector)
{
- float x, y, z, w;
+ qreal x, y, z, w;
if (matrix.flagBits == QMatrix4x4::Identity) {
return vector;
} else if (matrix.flagBits == QMatrix4x4::Translation) {
- return QVector3D(vector.xp + matrix.m[3][0],
- vector.yp + matrix.m[3][1],
- vector.zp + matrix.m[3][2], 1);
+ return QVector3D(vector.x() + matrix.m[3][0],
+ vector.y() + matrix.m[3][1],
+ vector.z() + matrix.m[3][2]);
} else if (matrix.flagBits ==
(QMatrix4x4::Translation | QMatrix4x4::Scale)) {
- return QVector3D(vector.xp * matrix.m[0][0] + matrix.m[3][0],
- vector.yp * matrix.m[1][1] + matrix.m[3][1],
- vector.zp * matrix.m[2][2] + matrix.m[3][2], 1);
+ return QVector3D(vector.x() * matrix.m[0][0] + matrix.m[3][0],
+ vector.y() * matrix.m[1][1] + matrix.m[3][1],
+ vector.z() * matrix.m[2][2] + matrix.m[3][2]);
} else if (matrix.flagBits == QMatrix4x4::Scale) {
- return QVector3D(vector.xp * matrix.m[0][0],
- vector.yp * matrix.m[1][1],
- vector.zp * matrix.m[2][2], 1);
+ return QVector3D(vector.x() * matrix.m[0][0],
+ vector.y() * matrix.m[1][1],
+ vector.z() * matrix.m[2][2]);
} else {
- x = vector.xp * matrix.m[0][0] +
- vector.yp * matrix.m[1][0] +
- vector.zp * matrix.m[2][0] +
+ x = vector.x() * matrix.m[0][0] +
+ vector.y() * matrix.m[1][0] +
+ vector.z() * matrix.m[2][0] +
matrix.m[3][0];
- y = vector.xp * matrix.m[0][1] +
- vector.yp * matrix.m[1][1] +
- vector.zp * matrix.m[2][1] +
+ y = vector.x() * matrix.m[0][1] +
+ vector.y() * matrix.m[1][1] +
+ vector.z() * matrix.m[2][1] +
matrix.m[3][1];
- z = vector.xp * matrix.m[0][2] +
- vector.yp * matrix.m[1][2] +
- vector.zp * matrix.m[2][2] +
+ z = vector.x() * matrix.m[0][2] +
+ vector.y() * matrix.m[1][2] +
+ vector.z() * matrix.m[2][2] +
matrix.m[3][2];
- w = vector.xp * matrix.m[0][3] +
- vector.yp * matrix.m[1][3] +
- vector.zp * matrix.m[2][3] +
+ w = vector.x() * matrix.m[0][3] +
+ vector.y() * matrix.m[1][3] +
+ vector.z() * matrix.m[2][3] +
matrix.m[3][3];
if (w == 1.0f)
- return QVector3D(x, y, z, 1);
+ return QVector3D(x, y, z);
else
- return QVector3D(x / w, y / w, z / w, 1);
+ return QVector3D(x / w, y / w, z / w);
}
}
@@ -679,54 +679,54 @@ inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector)
inline QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix)
{
- float x, y, z, w;
- x = vector.xp * matrix.m[0][0] +
- vector.yp * matrix.m[0][1] +
- vector.zp * matrix.m[0][2] +
- vector.wp * matrix.m[0][3];
- y = vector.xp * matrix.m[1][0] +
- vector.yp * matrix.m[1][1] +
- vector.zp * matrix.m[1][2] +
- vector.wp * matrix.m[1][3];
- z = vector.xp * matrix.m[2][0] +
- vector.yp * matrix.m[2][1] +
- vector.zp * matrix.m[2][2] +
- vector.wp * matrix.m[2][3];
- w = vector.xp * matrix.m[3][0] +
- vector.yp * matrix.m[3][1] +
- vector.zp * matrix.m[3][2] +
- vector.wp * matrix.m[3][3];
- return QVector4D(x, y, z, w, 1);
+ qreal x, y, z, w;
+ x = vector.x() * matrix.m[0][0] +
+ vector.y() * matrix.m[0][1] +
+ vector.z() * matrix.m[0][2] +
+ vector.w() * matrix.m[0][3];
+ y = vector.x() * matrix.m[1][0] +
+ vector.y() * matrix.m[1][1] +
+ vector.z() * matrix.m[1][2] +
+ vector.w() * matrix.m[1][3];
+ z = vector.x() * matrix.m[2][0] +
+ vector.y() * matrix.m[2][1] +
+ vector.z() * matrix.m[2][2] +
+ vector.w() * matrix.m[2][3];
+ w = vector.x() * matrix.m[3][0] +
+ vector.y() * matrix.m[3][1] +
+ vector.z() * matrix.m[3][2] +
+ vector.w() * matrix.m[3][3];
+ return QVector4D(x, y, z, w);
}
inline QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector)
{
- float x, y, z, w;
- x = vector.xp * matrix.m[0][0] +
- vector.yp * matrix.m[1][0] +
- vector.zp * matrix.m[2][0] +
- vector.wp * matrix.m[3][0];
- y = vector.xp * matrix.m[0][1] +
- vector.yp * matrix.m[1][1] +
- vector.zp * matrix.m[2][1] +
- vector.wp * matrix.m[3][1];
- z = vector.xp * matrix.m[0][2] +
- vector.yp * matrix.m[1][2] +
- vector.zp * matrix.m[2][2] +
- vector.wp * matrix.m[3][2];
- w = vector.xp * matrix.m[0][3] +
- vector.yp * matrix.m[1][3] +
- vector.zp * matrix.m[2][3] +
- vector.wp * matrix.m[3][3];
- return QVector4D(x, y, z, w, 1);
+ qreal x, y, z, w;
+ x = vector.x() * matrix.m[0][0] +
+ vector.y() * matrix.m[1][0] +
+ vector.z() * matrix.m[2][0] +
+ vector.w() * matrix.m[3][0];
+ y = vector.x() * matrix.m[0][1] +
+ vector.y() * matrix.m[1][1] +
+ vector.z() * matrix.m[2][1] +
+ vector.w() * matrix.m[3][1];
+ z = vector.x() * matrix.m[0][2] +
+ vector.y() * matrix.m[1][2] +
+ vector.z() * matrix.m[2][2] +
+ vector.w() * matrix.m[3][2];
+ w = vector.x() * matrix.m[0][3] +
+ vector.y() * matrix.m[1][3] +
+ vector.z() * matrix.m[2][3] +
+ vector.w() * matrix.m[3][3];
+ return QVector4D(x, y, z, w);
}
#endif
inline QPoint operator*(const QPoint& point, const QMatrix4x4& matrix)
{
- float xin, yin;
- float x, y, w;
+ qreal xin, yin;
+ qreal x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -746,8 +746,8 @@ inline QPoint operator*(const QPoint& point, const QMatrix4x4& matrix)
inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
{
- float xin, yin;
- float x, y, w;
+ qreal xin, yin;
+ qreal x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -768,8 +768,8 @@ inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point)
{
- float xin, yin;
- float x, y, w;
+ qreal xin, yin;
+ qreal x, y, w;
xin = point.x();
yin = point.y();
if (matrix.flagBits == QMatrix4x4::Identity) {
@@ -803,8 +803,8 @@ inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point)
inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point)
{
- float xin, yin;
- float x, y, w;
+ qreal xin, yin;
+ qreal x, y, w;
xin = point.x();
yin = point.y();
if (matrix.flagBits == QMatrix4x4::Identity) {
@@ -951,7 +951,7 @@ inline QVector4D QMatrix4x4::map(const QVector4D& point) const
#endif
-inline float *QMatrix4x4::data()
+inline qreal *QMatrix4x4::data()
{
// We have to assume that the caller will modify the matrix elements,
// so we flip it over to "General" mode.
@@ -969,17 +969,17 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QMatrix4x4 &);
#endif
template <int N, int M>
-QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
+QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal>& matrix)
{
return QMatrix4x4(matrix.constData(), N, M);
}
template <int N, int M>
-QGenericMatrix<N, M, qreal, float> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
+QGenericMatrix<N, M, qreal> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
{
- QGenericMatrix<N, M, qreal, float> result;
- const float *m = matrix.constData();
- float *values = result.data();
+ QGenericMatrix<N, M, qreal> result;
+ const qreal *m = matrix.constData();
+ qreal *values = result.data();
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
if (col < 4 && row < 4)
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index ece4482..7206e9a 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -353,7 +353,7 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
qreal s = qSin(a);
qreal c = qCos(a);
QVector3D ax = axis.normalized();
- return QQuaternion(c, ax.xp * s, ax.yp * s, ax.zp * s, 1).normalized();
+ return QQuaternion(c, ax.x() * s, ax.y() * s, ax.z() * s).normalized();
}
#endif
@@ -365,19 +365,16 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
QQuaternion QQuaternion::fromAxisAndAngle
(qreal x, qreal y, qreal z, qreal angle)
{
- float xp = x;
- float yp = y;
- float zp = z;
- qreal length = qSqrt(xp * xp + yp * yp + zp * zp);
- if (!qIsNull(length)) {
- xp /= length;
- yp /= length;
- zp /= length;
+ qreal length = qSqrt(x * x + y * y + z * z);
+ if (!qFuzzyIsNull(length - 1.0f) && !qFuzzyIsNull(length)) {
+ x /= length;
+ y /= length;
+ z /= length;
}
qreal a = (angle / 2.0f) * M_PI / 180.0f;
qreal s = qSin(a);
qreal c = qCos(a);
- return QQuaternion(c, xp * s, yp * s, zp * s, 1).normalized();
+ return QQuaternion(c, x * s, y * s, z * s).normalized();
}
/*!
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index 12576d2..f243c42 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -133,11 +133,7 @@ public:
(const QQuaternion& q1, const QQuaternion& q2, qreal t);
private:
- float wp, xp, yp, zp;
-
- friend class QMatrix4x4;
-
- QQuaternion(float scalar, float xpos, float ypos, float zpos, int dummy);
+ qreal wp, xp, yp, zp;
};
inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {}
@@ -145,8 +141,6 @@ inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {}
inline QQuaternion::QQuaternion(qreal scalar, qreal xpos, qreal ypos, qreal zpos) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
-inline QQuaternion::QQuaternion(float scalar, float xpos, float ypos, float zpos, int) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
-
inline bool QQuaternion::isNull() const
{
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && qIsNull(wp);
@@ -169,7 +163,7 @@ inline void QQuaternion::setScalar(qreal scalar) { wp = scalar; }
inline QQuaternion QQuaternion::conjugate() const
{
- return QQuaternion(wp, -xp, -yp, -zp, 1);
+ return QQuaternion(wp, -xp, -yp, -zp);
}
inline QQuaternion &QQuaternion::operator+=(const QQuaternion &quaternion)
@@ -201,18 +195,18 @@ inline QQuaternion &QQuaternion::operator*=(qreal factor)
inline const QQuaternion operator*(const QQuaternion &q1, const QQuaternion& q2)
{
- float ww = (q1.zp + q1.xp) * (q2.xp + q2.yp);
- float yy = (q1.wp - q1.yp) * (q2.wp + q2.zp);
- float zz = (q1.wp + q1.yp) * (q2.wp - q2.zp);
- float xx = ww + yy + zz;
- float qq = 0.5 * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp));
-
- float w = qq - ww + (q1.zp - q1.yp) * (q2.yp - q2.zp);
- float x = qq - xx + (q1.xp + q1.wp) * (q2.xp + q2.wp);
- float y = qq - yy + (q1.wp - q1.xp) * (q2.yp + q2.zp);
- float z = qq - zz + (q1.zp + q1.yp) * (q2.wp - q2.xp);
-
- return QQuaternion(w, x, y, z, 1);
+ qreal ww = (q1.zp + q1.xp) * (q2.xp + q2.yp);
+ qreal yy = (q1.wp - q1.yp) * (q2.wp + q2.zp);
+ qreal zz = (q1.wp + q1.yp) * (q2.wp - q2.zp);
+ qreal xx = ww + yy + zz;
+ qreal qq = 0.5 * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp));
+
+ qreal w = qq - ww + (q1.zp - q1.yp) * (q2.yp - q2.zp);
+ qreal x = qq - xx + (q1.xp + q1.wp) * (q2.xp + q2.wp);
+ qreal y = qq - yy + (q1.wp - q1.xp) * (q2.yp + q2.zp);
+ qreal z = qq - zz + (q1.zp + q1.yp) * (q2.wp - q2.xp);
+
+ return QQuaternion(w, x, y, z);
}
inline QQuaternion &QQuaternion::operator*=(const QQuaternion &quaternion)
@@ -242,32 +236,32 @@ inline bool operator!=(const QQuaternion &q1, const QQuaternion &q2)
inline const QQuaternion operator+(const QQuaternion &q1, const QQuaternion &q2)
{
- return QQuaternion(q1.wp + q2.wp, q1.xp + q2.xp, q1.yp + q2.yp, q1.zp + q2.zp, 1);
+ return QQuaternion(q1.wp + q2.wp, q1.xp + q2.xp, q1.yp + q2.yp, q1.zp + q2.zp);
}
inline const QQuaternion operator-(const QQuaternion &q1, const QQuaternion &q2)
{
- return QQuaternion(q1.wp - q2.wp, q1.xp - q2.xp, q1.yp - q2.yp, q1.zp - q2.zp, 1);
+ return QQuaternion(q1.wp - q2.wp, q1.xp - q2.xp, q1.yp - q2.yp, q1.zp - q2.zp);
}
inline const QQuaternion operator*(qreal factor, const QQuaternion &quaternion)
{
- return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor, 1);
+ return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor);
}
inline const QQuaternion operator*(const QQuaternion &quaternion, qreal factor)
{
- return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor, 1);
+ return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor);
}
inline const QQuaternion operator-(const QQuaternion &quaternion)
{
- return QQuaternion(-quaternion.wp, -quaternion.xp, -quaternion.yp, -quaternion.zp, 1);
+ return QQuaternion(-quaternion.wp, -quaternion.xp, -quaternion.yp, -quaternion.zp);
}
inline const QQuaternion operator/(const QQuaternion &quaternion, qreal divisor)
{
- return QQuaternion(quaternion.wp / divisor, quaternion.xp / divisor, quaternion.yp / divisor, quaternion.zp / divisor, 1);
+ return QQuaternion(quaternion.wp / divisor, quaternion.xp / divisor, quaternion.yp / divisor, quaternion.zp / divisor);
}
inline bool qFuzzyCompare(const QQuaternion& q1, const QQuaternion& q2)
@@ -281,18 +275,18 @@ inline bool qFuzzyCompare(const QQuaternion& q1, const QQuaternion& q2)
#ifndef QT_NO_VECTOR3D
inline QQuaternion::QQuaternion(qreal scalar, const QVector3D& vector)
- : wp(scalar), xp(vector.xp), yp(vector.yp), zp(vector.zp) {}
+ : wp(scalar), xp(vector.x()), yp(vector.y()), zp(vector.z()) {}
inline void QQuaternion::setVector(const QVector3D& vector)
{
- xp = vector.xp;
- yp = vector.yp;
- zp = vector.zp;
+ xp = vector.x();
+ yp = vector.y();
+ zp = vector.z();
}
inline QVector3D QQuaternion::vector() const
{
- return QVector3D(xp, yp, zp, 1);
+ return QVector3D(xp, yp, zp);
}
#endif
@@ -307,11 +301,11 @@ inline void QQuaternion::setVector(qreal x, qreal y, qreal z)
#ifndef QT_NO_VECTOR4D
inline QQuaternion::QQuaternion(const QVector4D& vector)
- : wp(vector.wp), xp(vector.xp), yp(vector.yp), zp(vector.zp) {}
+ : wp(vector.w()), xp(vector.x()), yp(vector.y()), zp(vector.z()) {}
inline QVector4D QQuaternion::toVector4D() const
{
- return QVector4D(xp, yp, zp, wp, 1);
+ return QVector4D(xp, yp, zp, wp);
}
#endif
diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h
index 767517e..1e95865 100644
--- a/src/gui/math3d/qvector3d.h
+++ b/src/gui/math3d/qvector3d.h
@@ -54,7 +54,6 @@ QT_MODULE(Gui)
class QMatrix4x4;
class QVector2D;
class QVector4D;
-class QQuaternion;
#ifndef QT_NO_VECTOR3D
@@ -136,8 +135,6 @@ private:
friend class QVector2D;
friend class QVector4D;
- friend class QQuaternion;
- friend class QMatrix4x4;
#ifndef QT_NO_MATRIX4X4
friend QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix);
friend QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector);
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h
index 4bd6639..520319a 100644
--- a/src/gui/math3d/qvector4d.h
+++ b/src/gui/math3d/qvector4d.h
@@ -54,7 +54,6 @@ QT_MODULE(Gui)
class QMatrix4x4;
class QVector2D;
class QVector3D;
-class QQuaternion;
#ifndef QT_NO_VECTOR4D
@@ -133,8 +132,6 @@ private:
friend class QVector2D;
friend class QVector3D;
- friend class QQuaternion;
- friend class QMatrix4x4;
#ifndef QT_NO_MATRIX4X4
friend QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix);
friend QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector);
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp
index 04ddd7d..4d8b8c9 100644
--- a/src/gui/painting/qpaintbuffer.cpp
+++ b/src/gui/painting/qpaintbuffer.cpp
@@ -239,7 +239,7 @@ bool QPaintBuffer::isEmpty() const
-void QPaintBuffer::draw(QPainter *painter) const
+void QPaintBuffer::draw(QPainter *painter, int frame) const
{
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << "QPaintBuffer::draw() --------------------------------";
@@ -270,10 +270,10 @@ void QPaintBuffer::draw(QPainter *painter) const
? (QPaintEngineEx *) painter->paintEngine() : 0;
if (xengine) {
QPaintEngineExReplayer player;
- player.draw(*this, painter);
+ player.draw(*this, painter, frame);
} else {
QPainterReplayer player;
- player.draw(*this, painter);
+ player.draw(*this, painter, frame);
}
#ifdef QPAINTBUFFER_DEBUG_DRAW
@@ -1035,17 +1035,31 @@ void QPainterReplayer::setupTransform(QPainter *_painter)
painter->setTransform(m_world_matrix);
}
-void QPainterReplayer::draw(const QPaintBuffer &buffer, QPainter *_painter)
+void QPainterReplayer::draw(const QPaintBuffer &buffer, QPainter *_painter, int frame)
{
d = buffer.d_ptr;
setupTransform(_painter);
- for (int cmdIndex=0; cmdIndex<d->commands.size(); ++cmdIndex) {
+ int frameStart = (frame == 0) ? 0 : d->frames.at(frame-1);
+ int frameEnd = (frame == d->frames.size()) ? d->commands.size() : d->frames.at(frame);
+
+ for (int cmdIndex=frameStart; cmdIndex<frameEnd; ++cmdIndex) {
const QPaintBufferCommand &cmd = d->commands.at(cmdIndex);
process(cmd);
}
}
+void QPaintBuffer::beginNewFrame()
+{
+ if (!d_ptr->commands.isEmpty())
+ d_ptr->frames << d_ptr->commands.size();
+}
+
+int QPaintBuffer::numFrames() const
+{
+ return d_ptr->frames.size() + 1;
+}
+
void QPainterReplayer::process(const QPaintBufferCommand &cmd)
{
switch (cmd.id) {
@@ -1721,24 +1735,99 @@ QDataStream &operator>>(QDataStream &stream, QPaintBufferCommand &command)
return stream;
}
+struct QPaintBufferCacheEntry
+{
+ QVariant::Type type;
+ quint64 cacheKey;
+};
+Q_DECLARE_METATYPE(QPaintBufferCacheEntry);
+
+QDataStream &operator<<(QDataStream &stream, const QPaintBufferCacheEntry &entry)
+{
+ return stream << entry.type << entry.cacheKey;
+}
+
+QDataStream &operator>>(QDataStream &stream, QPaintBufferCacheEntry &entry)
+{
+ return stream >> entry.type >> entry.cacheKey;
+}
+
+static int qRegisterPaintBufferMetaTypes()
+{
+ qRegisterMetaType<QPaintBufferCacheEntry>();
+ qRegisterMetaTypeStreamOperators<QPaintBufferCacheEntry>("QPaintBufferCacheEntry");
+
+ return 0; // something
+}
+
+Q_CONSTRUCTOR_FUNCTION(qRegisterPaintBufferMetaTypes)
+
QDataStream &operator<<(QDataStream &stream, const QPaintBuffer &buffer)
{
+ QHash<qint64, QPixmap> pixmaps;
+ QHash<qint64, QImage> images;
+
+ QVector<QVariant> variants = buffer.d_ptr->variants;
+ for (int i = 0; i < variants.size(); ++i) {
+ const QVariant &v = variants.at(i);
+ if (v.type() == QVariant::Image) {
+ const QImage image(v.value<QImage>());
+ images[image.cacheKey()] = image;
+
+ QPaintBufferCacheEntry entry;
+ entry.type = QVariant::Image;
+ entry.cacheKey = image.cacheKey();
+ variants[i] = QVariant::fromValue(entry);
+ } else if (v.type() == QVariant::Pixmap) {
+ const QPixmap pixmap(v.value<QPixmap>());
+ pixmaps[pixmap.cacheKey()] = pixmap;
+
+ QPaintBufferCacheEntry entry;
+ entry.type = QVariant::Pixmap;
+ entry.cacheKey = pixmap.cacheKey();
+ variants[i] = QVariant::fromValue(entry);
+ }
+ }
+
+ stream << pixmaps;
+ stream << images;
+
stream << buffer.d_ptr->ints;
stream << buffer.d_ptr->floats;
- stream << buffer.d_ptr->variants;
+ stream << variants;
stream << buffer.d_ptr->commands;
stream << buffer.d_ptr->boundingRect;
+ stream << buffer.d_ptr->frames;
return stream;
}
QDataStream &operator>>(QDataStream &stream, QPaintBuffer &buffer)
{
+ QHash<qint64, QPixmap> pixmaps;
+ QHash<qint64, QImage> images;
+
+ stream >> pixmaps;
+ stream >> images;
+
stream >> buffer.d_ptr->ints;
stream >> buffer.d_ptr->floats;
stream >> buffer.d_ptr->variants;
stream >> buffer.d_ptr->commands;
stream >> buffer.d_ptr->boundingRect;
+ stream >> buffer.d_ptr->frames;
+
+ QVector<QVariant> &variants = buffer.d_ptr->variants;
+ for (int i = 0; i < variants.size(); ++i) {
+ const QVariant &v = variants.at(i);
+ if (v.canConvert<QPaintBufferCacheEntry>()) {
+ QPaintBufferCacheEntry entry = v.value<QPaintBufferCacheEntry>();
+ if (entry.type == QVariant::Image)
+ variants[i] = QVariant(images.value(entry.cacheKey));
+ else
+ variants[i] = QVariant(pixmaps.value(entry.cacheKey));
+ }
+ }
return stream;
}
diff --git a/src/gui/painting/qpaintbuffer_p.h b/src/gui/painting/qpaintbuffer_p.h
index b360279..2cb1d7c 100644
--- a/src/gui/painting/qpaintbuffer_p.h
+++ b/src/gui/painting/qpaintbuffer_p.h
@@ -71,7 +71,10 @@ public:
bool isEmpty() const;
- void draw(QPainter *painter) const;
+ void beginNewFrame();
+ int numFrames() const;
+
+ void draw(QPainter *painter, int frame = 0) const;
void setBoundingRect(const QRectF &rect);
QRectF boundingRect() const;
@@ -270,6 +273,7 @@ public:
QVector<QVariant> variants;
QVector<QPaintBufferCommand> commands;
+ QList<int> frames;
QPaintBufferEngine *engine;
QRectF boundingRect;
@@ -306,7 +310,7 @@ public:
void setupTransform(QPainter *painter);
void process(const QPaintBufferCommand &cmd);
- void draw(const QPaintBuffer &buffer, QPainter *painter);
+ void draw(const QPaintBuffer &buffer, QPainter *painter, int frame);
protected:
QPaintBufferPrivate *d;
diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp
index 934b385..249bcfa 100644
--- a/src/gui/painting/qpaintengine_mac.cpp
+++ b/src/gui/painting/qpaintengine_mac.cpp
@@ -116,11 +116,15 @@ QMacCGContext::QMacCGContext(QPainter *p)
if (devType == QInternal::Widget) {
QRegion clip = p->paintEngine()->systemClip();
+ QTransform native = p->deviceTransform();
+ QTransform logical = p->combinedTransform();
if (p->hasClipping()) {
+ QRegion r = p->clipRegion();
+ r.translate(native.dx() - logical.dx(), native.dy() - logical.dy());
if (clip.isEmpty())
- clip = p->clipRegion();
+ clip = r;
else
- clip &= p->clipRegion();
+ clip &= r;
}
qt_mac_clip_cg(context, clip, 0);
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index c31a087..b13fb62 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -373,7 +373,11 @@ public:
};
-class Q_GUI_EXPORT QClipData {
+class
+#ifdef Q_WS_QWS
+Q_GUI_EXPORT
+#endif
+QClipData {
public:
QClipData(int height);
~QClipData();
@@ -480,7 +484,11 @@ private:
/*******************************************************************************
* QRasterBuffer
*/
-class Q_GUI_EXPORT QRasterBuffer
+class
+#ifdef Q_WS_QWS
+Q_GUI_EXPORT
+#endif
+QRasterBuffer
{
public:
QRasterBuffer() : m_width(0), m_height(0), m_buffer(0) { init(); }
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index a6bea76..263e53e 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -7545,10 +7545,9 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
if (!painter)
tf |= Qt::TextDontPrint;
- int maxUnderlines = 0;
+ uint maxUnderlines = 0;
int numUnderlines = 0;
- int underlinePositionStack[32];
- int *underlinePositions = underlinePositionStack;
+ QVarLengthArray<int, 32> underlinePositions(1);
QFontMetricsF fm(fnt);
QString text = str;
@@ -7557,54 +7556,46 @@ start_lengthVariant:
bool hasMoreLengthVariants = false;
// compatible behaviour to the old implementation. Replace
// tabs by spaces
- QChar *chr = text.data() + offset;
- QChar *end = text.data() + text.length();
bool has_tab = false;
- while (chr != end) {
- if (*chr == QLatin1Char('\r') || (singleline && *chr == QLatin1Char('\n'))) {
- *chr = QLatin1Char(' ');
- } else if (*chr == QLatin1Char('\n')) {
- *chr = QChar::LineSeparator;
- } else if (*chr == QLatin1Char('&')) {
+ int old_offset = offset;
+ for (; offset < text.length(); offset++) {
+ QChar chr = text.at(offset);
+ if (chr == QLatin1Char('\r') || (singleline && chr == QLatin1Char('\n'))) {
+ text[offset] = QLatin1Char(' ');
+ } else if (chr == QLatin1Char('\n')) {
+ text[offset] = QChar::LineSeparator;
+ } else if (chr == QLatin1Char('&')) {
++maxUnderlines;
- } else if (*chr == QLatin1Char('\t')) {
+ } else if (chr == QLatin1Char('\t')) {
+ if (!expandtabs) {
+ text[offset] = QLatin1Char(' ');
+ } else if (!tabarraylen && !tabstops) {
+ tabstops = qRound(fm.width(QLatin1Char('x'))*8);
+ }
has_tab = true;
- } else if (*chr == QChar(ushort(0x9c))) {
+ } else if (chr == QChar(ushort(0x9c))) {
// string with multiple length variants
- end = chr;
hasMoreLengthVariants = true;
break;
}
- ++chr;
- }
- if (has_tab) {
- if (!expandtabs) {
- chr = text.data() + offset;
- while (chr != end) {
- if (*chr == QLatin1Char('\t'))
- *chr = QLatin1Char(' ');
- ++chr;
- }
- } else if (!tabarraylen && !tabstops) {
- tabstops = qRound(fm.width(QLatin1Char('x'))*8);
- }
}
- QChar *cout = end;
- if (hidemnmemonic || showmnemonic) {
- if (maxUnderlines > 32)
- underlinePositions = new int[maxUnderlines];
- cout = text.data() + offset;
+ int length = offset - old_offset;
+ if ((hidemnmemonic || showmnemonic) && maxUnderlines > 0) {
+ underlinePositions.resize(maxUnderlines + 1);
+
+ QChar *cout = text.data() + old_offset;
QChar *cin = cout;
- int l = end - cout;
+ int l = length;
while (l) {
if (*cin == QLatin1Char('&')) {
++cin;
+ --length;
--l;
if (!l)
break;
if (*cin != QLatin1Char('&') && !hidemnmemonic)
- underlinePositions[numUnderlines++] = cout - text.unicode();
+ underlinePositions[numUnderlines++] = cout - text.data() - old_offset;
}
*cout = *cin;
++cout;
@@ -7621,7 +7612,7 @@ start_lengthVariant:
qreal height = 0;
qreal width = 0;
- QString finalText = text.mid(offset, cout - (text.data() + offset));
+ QString finalText = text.mid(old_offset, length);
QStackTextEngine engine(finalText, fnt);
if (option) {
engine.option = *option;
@@ -7640,7 +7631,7 @@ start_lengthVariant:
engine.forceJustification = true;
QTextLayout textLayout(&engine);
textLayout.setCacheEnabled(true);
- textLayout.engine()->underlinePositions = underlinePositions;
+ textLayout.engine()->underlinePositions = underlinePositions.data();
if (finalText.isEmpty()) {
height = fm.height();
@@ -7709,7 +7700,7 @@ start_lengthVariant:
QRectF bounds = QRectF(r.x() + xoff, r.y() + yoff, width, height);
if (hasMoreLengthVariants && !(tf & Qt::TextLongestVariant) && !r.contains(bounds)) {
- offset = end - text.data() + 1;
+ offset++;
goto start_lengthVariant;
}
if (brect)
@@ -7738,9 +7729,6 @@ start_lengthVariant:
painter->restore();
}
}
-
- if (underlinePositions != underlinePositionStack)
- delete [] underlinePositions;
}
/*!
diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp
index 882e6bc..882f994 100644
--- a/src/gui/painting/qprinter.cpp
+++ b/src/gui/painting/qprinter.cpp
@@ -1286,6 +1286,23 @@ int QPrinter::numCopies() const
/*!
+ Returns the number of copies that will be printed. The default
+ value is 1.
+
+ This function always returns the actual value specified in the print
+ dialog or using setNumCopies().
+
+ \sa setNumCopies(), numCopies();
+*/
+int QPrinter::actualNumCopies() const
+{
+ Q_D(const QPrinter);
+ return qt_printerRealNumCopies(d->paintEngine);
+}
+
+
+
+/*!
Sets the number of copies to be printed to \a numCopies.
The printer driver reads this setting and prints the specified
diff --git a/src/gui/painting/qprinter.h b/src/gui/painting/qprinter.h
index 46419f4..16f2182 100644
--- a/src/gui/painting/qprinter.h
+++ b/src/gui/painting/qprinter.h
@@ -197,6 +197,8 @@ public:
void setNumCopies(int);
int numCopies() const;
+ int actualNumCopies() const;
+
void setPaperSource(PaperSource);
PaperSource paperSource() const;
diff --git a/src/gui/painting/qrasterizer_p.h b/src/gui/painting/qrasterizer_p.h
index 4cfdbbf..059d772 100644
--- a/src/gui/painting/qrasterizer_p.h
+++ b/src/gui/painting/qrasterizer_p.h
@@ -65,7 +65,11 @@ struct QSpanData;
class QRasterBuffer;
class QRasterizerPrivate;
-class Q_GUI_EXPORT QRasterizer
+class
+#ifdef Q_WS_QWS
+Q_GUI_EXPORT
+#endif
+QRasterizer
{
public:
QRasterizer();
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 41f9ec0..7fefb19 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -1882,7 +1882,6 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
break;
case CE_TabBarTabLabel:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- // ### consider merging this with SE_TabBarTabText
QStyleOptionTabV3 tabV2(*tab);
QRect tr = tabV2.rect;
bool verticalTabs = tabV2.shape == QTabBar::RoundedEast
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index ef1818d..e7ef51a 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -1951,6 +1951,7 @@ void QMacStyle::polish(QWidget* w)
w->setWindowOpacity(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 ? 0.985 : 0.94);
if (!w->testAttribute(Qt::WA_SetPalette)) {
QPixmap px(64, 64);
+ px.fill(Qt::white);
HIThemeMenuDrawInfo mtinfo;
mtinfo.version = qt_mac_hitheme_version;
mtinfo.menuType = kThemeMenuTypePopUp;
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index cead2ac..3d8dec6 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -3948,7 +3948,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
QFont oldFont = p->font();
if (subRule.hasFont)
p->setFont(subRule.font);
- if (subRule.hasBox()) {
+ if (subRule.hasBox() || !subRule.hasNativeBorder()) {
tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(r)
: subRule.contentsRect(r);
QWindowsStyle::drawControl(ce, &tabCopy, p, w);
@@ -5702,6 +5702,15 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
}
break;
}
+ case SE_TabBarTabText:
+ case SE_TabBarTabLeftButton:
+ case SE_TabBarTabRightButton: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
+ if (subRule.hasBox() || !subRule.hasNativeBorder()) {
+ return ParentStyle::subElementRect(se, opt, w);
+ }
+ break;
+ }
#endif // QT_NO_TABBAR
case SE_DockWidgetCloseButton:
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 1bdaceb..e565d0a 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -2521,13 +2521,15 @@ void QTextHtmlExporter::emitBlock(const QTextBlock &block)
default: html += QLatin1String("<ul"); // ### should not happen
}
+ html += QLatin1String(" style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;");
+
if (format.hasProperty(QTextFormat::ListIndent)) {
- html += QLatin1String(" style=\"-qt-list-indent: ");
+ html += QLatin1String(" -qt-list-indent: ");
html += QString::number(format.indent());
- html += QLatin1String(";\"");
+ html += QLatin1Char(';');
}
- html += QLatin1Char('>');
+ html += QLatin1String("\">");
}
html += QLatin1String("<li");
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 2b84c6c..ba9145e 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -2245,6 +2245,28 @@ void QTextEngine::indexAdditionalFormats()
}
}
+/* These two helper functions are used to determine whether we need to insert a ZWJ character
+ between the text that gets truncated and the ellipsis. This is important to get
+ correctly shaped results for arabic text.
+*/
+static bool nextCharJoins(const QString &string, int pos)
+{
+ while (pos < string.length() && string.at(pos).category() == QChar::Mark_NonSpacing)
+ ++pos;
+ if (pos == string.length())
+ return false;
+ return string.at(pos).joining() != QChar::OtherJoining;
+}
+
+static bool prevCharJoins(const QString &string, int pos)
+{
+ while (pos > 0 && string.at(pos - 1).category() == QChar::Mark_NonSpacing)
+ --pos;
+ if (pos == 0)
+ return false;
+ return (string.at(pos - 1).joining() == QChar::Dual || string.at(pos - 1).joining() == QChar::Center);
+}
+
QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int flags) const
{
// qDebug() << "elidedText; available width" << width.toReal() << "text width:" << this->width(0, layoutData->string.length()).toReal();
@@ -2345,6 +2367,9 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
} while (nextBreak < layoutData->string.length()
&& currentWidth < availableWidth);
+ if (nextCharJoins(layoutData->string, pos))
+ ellipsisText.prepend(QChar(0x200d) /* ZWJ */);
+
return layoutData->string.left(pos) + ellipsisText;
} else if (mode == Qt::ElideLeft) {
QFixed currentWidth;
@@ -2362,6 +2387,9 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
} while (nextBreak > 0
&& currentWidth < availableWidth);
+ if (prevCharJoins(layoutData->string, pos))
+ ellipsisText.append(QChar(0x200d) /* ZWJ */);
+
return ellipsisText + layoutData->string.mid(pos);
} else if (mode == Qt::ElideMiddle) {
QFixed leftWidth;
@@ -2391,6 +2419,11 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
&& nextRightBreak > 0
&& leftWidth + rightWidth < availableWidth);
+ if (nextCharJoins(layoutData->string, leftPos))
+ ellipsisText.prepend(QChar(0x200d) /* ZWJ */);
+ if (prevCharJoins(layoutData->string, rightPos))
+ ellipsisText.append(QChar(0x200d) /* ZWJ */);
+
return layoutData->string.left(leftPos) + ellipsisText + layoutData->string.mid(rightPos);
}
diff --git a/src/gui/widgets/qdatetimeedit_p.h b/src/gui/widgets/qdatetimeedit_p.h
index 7e1c24d..689b508 100644
--- a/src/gui/widgets/qdatetimeedit_p.h
+++ b/src/gui/widgets/qdatetimeedit_p.h
@@ -89,7 +89,7 @@ public:
QDateTime validateAndInterpret(QString &input, int &, QValidator::State &state,
bool fixup = false) const;
void clearSection(int index);
- virtual QString displayText() const { return edit->displayText(); } // this is from QDateTimeParser
+ virtual QString displayText() const { return edit->text(); } // this is from QDateTimeParser
int absoluteIndex(QDateTimeEdit::Section s, int index) const;
int absoluteIndex(const SectionNode &s) const;
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
index 7ae799c..c5953af 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/gui/widgets/qmenu_symbian.cpp
@@ -3,6 +3,7 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
+** This file is part of the S60 port of the Qt toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage