summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@nokia.com>2009-08-10 15:07:31 (GMT)
committerThomas Hartmann <Thomas.Hartmann@nokia.com>2009-08-10 15:07:31 (GMT)
commite67cd6560eea4e4b600d5e3586cd823347e101d2 (patch)
tree19e7a596b37c2da517b5d2d0dc0de4f7ee8f5b99 /src
parent9a92aee8ff94a1b705e92f895831f9437762da75 (diff)
parentcbd8a54f8c55e1982430fc929e9d74f977699428 (diff)
downloadQt-e67cd6560eea4e4b600d5e3586cd823347e101d2.zip
Qt-e67cd6560eea4e4b600d5e3586cd823347e101d2.tar.gz
Qt-e67cd6560eea4e4b600d5e3586cd823347e101d2.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts: src/gui/kernel/qapplication_win.cpp
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/phonon/ds9/mediaobject.cpp55
-rw-r--r--src/3rdparty/phonon/ds9/mediaobject.h1
-rw-r--r--src/3rdparty/phonon/phonon/mediasource.cpp8
-rw-r--r--src/3rdparty/webkit/WebCore/WebCore.pro2
-rw-r--r--src/corelib/arch/arch.pri2
-rw-r--r--src/corelib/io/qdir.cpp15
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp2
-rw-r--r--src/corelib/statemachine/qhistorystate.cpp4
-rw-r--r--src/corelib/statemachine/qstate_p.h2
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp1
-rw-r--r--src/corelib/tools/qsharedpointer.cpp10
-rw-r--r--src/corelib/tools/qtimeline.cpp16
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp19
-rw-r--r--src/gui/graphicsview/qgraphicstransform.cpp40
-rw-r--r--src/gui/graphicsview/qgraphicstransform_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp9
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks.cpp3
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp2
-rw-r--r--src/gui/itemviews/qitemselectionmodel.cpp22
-rw-r--r--src/gui/itemviews/qitemselectionmodel_p.h2
-rw-r--r--src/gui/itemviews/qlistwidget.cpp454
-rw-r--r--src/gui/kernel/kernel.pri6
-rw-r--r--src/gui/kernel/qapplication.h4
-rw-r--r--src/gui/kernel/qapplication_p.h5
-rw-r--r--src/gui/kernel/qapplication_win.cpp32
-rw-r--r--src/gui/kernel/qapplication_x11.cpp202
-rw-r--r--src/gui/kernel/qevent_p.h5
-rw-r--r--src/gui/kernel/qgesture.cpp2
-rw-r--r--src/gui/kernel/qgesture.h3
-rw-r--r--src/gui/kernel/qkde.cpp159
-rw-r--r--src/gui/kernel/qkde_p.h76
-rw-r--r--src/gui/kernel/qstandardgestures.cpp210
-rw-r--r--src/gui/kernel/qstandardgestures.h43
-rw-r--r--src/gui/kernel/qstandardgestures_p.h25
-rw-r--r--src/gui/kernel/qt_x11_p.h3
-rw-r--r--src/gui/kernel/qwidget_win.cpp40
-rw-r--r--src/gui/kernel/qwidget_x11.cpp7
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp3
-rw-r--r--src/gui/styles/qcommonstyle.cpp39
-rw-r--r--src/gui/widgets/qdockarealayout.cpp2
-rw-r--r--src/gui/widgets/qdockwidget.cpp2
-rw-r--r--src/gui/widgets/qtoolbararealayout.cpp2
-rw-r--r--src/network/access/qhttp.cpp10
-rw-r--r--src/network/access/qnetworkcookie.h6
-rw-r--r--src/openvg/qpixmapdata_vg.cpp25
-rw-r--r--src/qbase.pri2
-rw-r--r--src/script/qscriptable.cpp4
-rw-r--r--src/script/qscriptable_p.h4
-rw-r--r--src/script/qscriptclassdata.cpp2
-rw-r--r--src/testlib/qabstracttestlogger.cpp49
-rw-r--r--src/testlib/qabstracttestlogger_p.h52
-rw-r--r--src/testlib/qbenchmark.cpp21
-rw-r--r--src/testlib/qbenchmark.h10
-rw-r--r--src/testlib/qbenchmark_p.h1
-rw-r--r--src/testlib/qplaintestlogger.cpp10
-rw-r--r--src/testlib/qtest_global.h1
-rw-r--r--src/testlib/qtestbasicstreamer.cpp40
-rw-r--r--src/testlib/qtestbasicstreamer.h11
-rw-r--r--src/testlib/qtestcase.cpp57
-rw-r--r--src/testlib/qtestlightxmlstreamer.cpp70
-rw-r--r--src/testlib/qtestlightxmlstreamer.h6
-rw-r--r--src/testlib/qtestxmlstreamer.cpp61
-rw-r--r--src/testlib/qtestxmlstreamer.h6
-rw-r--r--src/testlib/qtestxunitstreamer.cpp43
-rw-r--r--src/testlib/qtestxunitstreamer.h8
-rw-r--r--src/testlib/qxmltestlogger.cpp75
-rw-r--r--src/testlib/qxmltestlogger_p.h8
-rw-r--r--src/tools/uic/uic.cpp2
-rw-r--r--src/xmlpatterns/query.pri2
-rw-r--r--src/xmlpatterns/xmlpatterns.pro3
71 files changed, 1349 insertions, 785 deletions
diff --git a/src/3rdparty/phonon/ds9/mediaobject.cpp b/src/3rdparty/phonon/ds9/mediaobject.cpp
index 10782c2..b163ad4 100644
--- a/src/3rdparty/phonon/ds9/mediaobject.cpp
+++ b/src/3rdparty/phonon/ds9/mediaobject.cpp
@@ -57,24 +57,6 @@ namespace Phonon
{
}
- WorkerThread::Work WorkerThread::dequeueWork()
- {
- QMutexLocker locker(&m_mutex);
- if (m_finished) {
- return Work();
- }
- Work ret = m_queue.dequeue();
-
- //we ensure to have the wait condition in the right state
- if (m_queue.isEmpty()) {
- m_waitCondition.reset();
- } else {
- m_waitCondition.set();
- }
-
- return ret;
- }
-
void WorkerThread::run()
{
while (m_finished == false) {
@@ -88,11 +70,6 @@ namespace Phonon
}
DWORD result = ::WaitForMultipleObjects(count, handles, FALSE, INFINITE);
if (result == WAIT_OBJECT_0) {
- if (m_finished) {
- //that's the end of the thread execution
- return;
- }
-
handleTask();
} else {
//this is the event management
@@ -199,22 +176,25 @@ namespace Phonon
void WorkerThread::handleTask()
{
- const Work w = dequeueWork();
-
- if (m_finished) {
+ QMutexLocker locker(&m_mutex);
+ if (m_finished || m_queue.isEmpty()) {
return;
}
- HRESULT hr = S_OK;
+ const Work w = m_queue.dequeue();
- {
- QMutexLocker locker(&m_mutex);
- m_currentRender = w.graph;
- m_currentRenderId = w.id;
+ //we ensure to have the wait condition in the right state
+ if (m_queue.isEmpty()) {
+ m_waitCondition.reset();
+ } else {
+ m_waitCondition.set();
}
+ HRESULT hr = S_OK;
+
+ m_currentRender = w.graph;
+ m_currentRenderId = w.id;
if (w.task == ReplaceGraph) {
- QMutexLocker locker(&m_mutex);
int index = -1;
for(int i = 0; i < FILTER_COUNT; ++i) {
if (m_graphHandle[i].graph == w.oldGraph) {
@@ -237,6 +217,9 @@ namespace Phonon
m_graphHandle[index].handle = h;
}
} else if (w.task == Render) {
+ //we need to unlock here because the use might trigger a call to abort
+ //which uses the same mutex
+ locker.unlock();
if (w.filter) {
//let's render pins
w.graph->AddFilter(w.filter, 0);
@@ -255,6 +238,7 @@ namespace Phonon
if (hr != E_ABORT) {
emit asyncRenderFinished(w.id, hr, w.graph);
}
+ locker.relock();
} else if (w.task == Seek) {
//that's a seekrequest
ComPointer<IMediaSeeking> mediaSeeking(w.graph, IID_IMediaSeeking);
@@ -327,11 +311,8 @@ namespace Phonon
}
}
- {
- QMutexLocker locker(&m_mutex);
- m_currentRender = Graph();
- m_currentRenderId = 0;
- }
+ m_currentRender = Graph();
+ m_currentRenderId = 0;
}
void WorkerThread::abortCurrentRender(qint16 renderId)
diff --git a/src/3rdparty/phonon/ds9/mediaobject.h b/src/3rdparty/phonon/ds9/mediaobject.h
index 2c34ffc..fe52604 100644
--- a/src/3rdparty/phonon/ds9/mediaobject.h
+++ b/src/3rdparty/phonon/ds9/mediaobject.h
@@ -135,7 +135,6 @@ namespace Phonon
};
QList<Filter> decoders; //for the state change requests
};
- Work dequeueWork();
void handleTask();
Graph m_currentRender;
diff --git a/src/3rdparty/phonon/phonon/mediasource.cpp b/src/3rdparty/phonon/phonon/mediasource.cpp
index 0a21c87..c003af9 100644
--- a/src/3rdparty/phonon/phonon/mediasource.cpp
+++ b/src/3rdparty/phonon/phonon/mediasource.cpp
@@ -140,8 +140,12 @@ MediaSourcePrivate::~MediaSourcePrivate()
{
#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
if (autoDelete) {
- delete stream;
- delete ioDevice;
+ //here we use deleteLater because this object
+ //might be destroyed from another thread
+ if (stream)
+ stream->deleteLater();
+ if (ioDevice)
+ ioDevice->deleteLater();
}
#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM
}
diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro
index e49ab13..2eb7c08 100644
--- a/src/3rdparty/webkit/WebCore/WebCore.pro
+++ b/src/3rdparty/webkit/WebCore/WebCore.pro
@@ -3159,7 +3159,7 @@ xpathbison.dependency_type = TYPE_C
xpathbison.variable_out = GENERATED_SOURCES
addExtraCompilerWithHeader(xpathbison)
-include($$PWD/../WebKit/qt/Api/headers.pri)
+include($$PWD/../WebKit/qt/Api/headers.pri, "", true)
HEADERS += $$WEBKIT_API_HEADERS
!CONFIG(QTDIR_build) {
target.path = $$[QT_INSTALL_LIBS]
diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri
index dd3141a..18f54ee 100644
--- a/src/corelib/arch/arch.pri
+++ b/src/corelib/arch/arch.pri
@@ -25,4 +25,4 @@ vxworks:HEADERS += arch/qatomic_vxworks.h
QT_ARCH_CPP = $$QT_SOURCE_TREE/src/corelib/arch/$$QT_ARCH
DEPENDPATH += $$QT_ARCH_CPP
-include($$QT_ARCH_CPP/arch.pri)
+include($$QT_ARCH_CPP/arch.pri, "", true)
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 072eb27..cb0fdeb 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1541,9 +1541,11 @@ bool QDir::isReadable() const
/*!
\overload
- Returns true if the \e directory exists; otherwise returns false.
- (If a file with the same name is found this function will return
- false).
+ Returns true if the directory exists; otherwise returns false.
+ (If a file with the same name is found this function will return false).
+
+ The overload of this function that accepts an argument is used to test
+ for the presence of files and directories within a directory.
\sa QFileInfo::exists(), QFile::exists()
*/
@@ -1773,8 +1775,11 @@ bool QDir::rename(const QString &oldName, const QString &newName)
/*!
Returns true if the file called \a name exists; otherwise returns
- false. Unless \a name contains an absolute file path, the file
- name is assumed to be relative to the current directory.
+ false.
+
+ Unless \a name contains an absolute file path, the file name is assumed
+ to be relative to the directory itself, so this function is typically used
+ to check for the presence of files within a directory.
\sa QFileInfo::exists(), QFile::exists()
*/
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index 7982d4c..da15148 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -627,7 +627,7 @@ QEventDispatcherUNIX::~QEventDispatcherUNIX()
int QEventDispatcherUNIX::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
timeval *timeout)
{
- return ::qt_safe_select(nfds, readfds, writefds, exceptfds, timeout);
+ return qt_safe_select(nfds, readfds, writefds, exceptfds, timeout);
}
/*!
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index d43c5dd..f153c7e 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -2488,6 +2488,7 @@ bool QMetaProperty::isUser(const QObject *object) const
}
/*!
+ \since 4.6
Returns true if the property is constant; otherwise returns false.
A property is constant if the \c{Q_PROPERTY()}'s \c CONSTANT attribute
@@ -2502,6 +2503,7 @@ bool QMetaProperty::isConstant() const
}
/*!
+ \since 4.6
Returns true if the property is final; otherwise returns false.
A property is final if the \c{Q_PROPERTY()}'s \c FINAL attribute
diff --git a/src/corelib/statemachine/qhistorystate.cpp b/src/corelib/statemachine/qhistorystate.cpp
index e5ca837..d21eee9 100644
--- a/src/corelib/statemachine/qhistorystate.cpp
+++ b/src/corelib/statemachine/qhistorystate.cpp
@@ -120,7 +120,7 @@ QT_BEGIN_NAMESPACE
*/
QHistoryStatePrivate::QHistoryStatePrivate()
- : defaultState(0)
+ : defaultState(0), historyType(QHistoryState::ShallowHistory)
{
}
@@ -135,8 +135,6 @@ QHistoryStatePrivate *QHistoryStatePrivate::get(QHistoryState *q)
QHistoryState::QHistoryState(QState *parent)
: QAbstractState(*new QHistoryStatePrivate, parent)
{
- Q_D(QHistoryState);
- d->historyType = ShallowHistory;
}
/*!
Constructs a new history state of the given \a type, with the given \a
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index 20eb5ea..c43a26c 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
struct QPropertyAssignment
{
QPropertyAssignment()
- : object(0) {}
+ : object(0), explicitlySet(true) {}
QPropertyAssignment(QObject *o, const QByteArray &n,
const QVariant &v, bool es = true)
: object(o), propertyName(n), value(v), explicitlySet(es)
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 9cb1d4d..5926176 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -209,6 +209,7 @@ QStateMachinePrivate::QStateMachinePrivate()
processing = false;
processingScheduled = false;
stop = false;
+ stopProcessingReason = EventQueueEmpty;
error = QStateMachine::NoError;
globalRestorePolicy = QStateMachine::DoNotRestoreProperties;
signalEventGenerator = 0;
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index f18dee8..cdb7d1d 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -867,6 +867,8 @@
#if !defined(QT_NO_QOBJECT)
#include "../kernel/qobject_p.h"
+QT_BEGIN_NAMESPACE
+
/*!
\internal
This function is called for a just-created QObject \a obj, to enable
@@ -910,6 +912,9 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge
}
return d->sharedRefcount;
}
+
+QT_END_NAMESPACE
+
#endif
@@ -932,6 +937,8 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge
# include <unistd.h>
# include <sys/wait.h>
+QT_BEGIN_NAMESPACE
+
static inline QByteArray saveBacktrace() __attribute__((always_inline));
static inline QByteArray saveBacktrace()
{
@@ -992,6 +999,9 @@ static void printBacktrace(QByteArray stacktrace)
waitpid(child, 0, 0);
}
}
+
+QT_END_NAMESPACE
+
# endif // BACKTRACE_SUPPORTED
namespace {
diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp
index e32fc03..6dbad34 100644
--- a/src/corelib/tools/qtimeline.cpp
+++ b/src/corelib/tools/qtimeline.cpp
@@ -69,7 +69,6 @@ public:
int currentLoopCount;
int currentTime;
- int elapsedTime;
int timerId;
QTime timer;
@@ -212,7 +211,7 @@ void QTimeLinePrivate::setCurrentTime(int msecs)
applies an interpolation algorithm to generate these value. You can choose
from a set of predefined timeline algorithms by calling
setCurveShape().
-
+
Note that by default, QTimeLine uses the EaseInOut curve shape,
which provides a value that grows slowly, then grows steadily, and
finally grows slowly. For a custom timeline, you can reimplement
@@ -549,7 +548,7 @@ void QTimeLine::setCurveShape(CurveShape shape)
case CosineCurve:
setEasingCurve(QEasingCurve(QEasingCurve::CosineCurve));
break;
- }
+ }
}
/*!
@@ -559,7 +558,7 @@ void QTimeLine::setCurveShape(CurveShape shape)
Specifies the easing curve that the timeline will use.
If both easing curve and curveShape are set, the last set property will
- override the previous one. (If valueForTime() is reimplemented it will
+ override the previous one. (If valueForTime() is reimplemented it will
override both)
*/
@@ -663,6 +662,7 @@ qreal QTimeLine::valueForTime(int msec) const
second). You can change the update interval by calling
setUpdateInterval().
+ The timeline will start from position 0, or the end if going backward.
If you want to resume a stopped timeline without restarting, you can call
resume() instead.
@@ -675,10 +675,8 @@ void QTimeLine::start()
qWarning("QTimeLine::start: already running");
return;
}
- int curTime = d->currentTime;
- if (curTime == d->duration && d->direction == Forward)
- curTime = 0;
- else if (curTime == 0 && d->direction == Backward)
+ int curTime = 0;
+ if (d->direction == Backward)
curTime = d->duration;
d->timerId = startTimer(d->updateInterval);
d->startTime = curTime;
@@ -694,7 +692,7 @@ void QTimeLine::start()
frame and value at regular intervals.
In contrast to start(), this function does not restart the timeline before
- is resumes.
+ it resumes.
\sa start(), updateInterval(), frameChanged(), valueChanged()
*/
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index beaf42b..8d9a1f8 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -9837,20 +9837,25 @@ void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)
}
// COMBINE
- // ### Use itemTransform() instead.
- QTransform oldSceneMatrix = item->sceneTransform();
+ bool ok;
+ QTransform itemTransform = item->itemTransform(this, &ok);
+
+ if (!ok) {
+ qWarning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates");
+ return;
+ }
+
+ QTransform newItemTransform(itemTransform);
item->setPos(mapFromItem(item, 0, 0));
item->setParentItem(this);
- QTransform newItemTransform(oldSceneMatrix);
- newItemTransform *= sceneTransform().inverted();
+
+ // removing position from translation component of the new transform
if (!item->pos().isNull())
newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
+
item->setTransform(newItemTransform);
item->d_func()->setIsMemberOfGroup(true);
prepareGeometryChange();
- QTransform itemTransform(item->transform());
- if (!item->pos().isNull())
- itemTransform *= QTransform::fromTranslate(item->x(), item->y());
d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());
update();
}
diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp
index 778cd94..775a0d5 100644
--- a/src/gui/graphicsview/qgraphicstransform.cpp
+++ b/src/gui/graphicsview/qgraphicstransform.cpp
@@ -80,11 +80,7 @@
#include "qgraphicsitem_p.h"
#include "qgraphicstransform_p.h"
#include <QDebug>
-
-#include <math.h>
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
+#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
@@ -355,7 +351,6 @@ public:
QGraphicsRotationPrivate()
: angle(0) {}
QPointF origin;
- qreal originY;
qreal angle;
};
@@ -475,13 +470,18 @@ void QGraphicsRotation::applyTo(QTransform *t) const
By default the axis is (0, 0, 1), giving QGraphicsRotation3D the same
default behavior as QGraphicsRotation (i.e., rotation around the Z axis).
+ Note: the final rotation is the combined effect of a rotation in
+ 3D space followed by a projection back to 2D. If several rotations
+ are performed in succession, they will not behave as expected unless
+ they were all around the Z axis.
+
\sa QGraphicsTransform, QGraphicsItem::setRotation(), QTransform::rotate()
*/
class QGraphicsRotation3DPrivate : public QGraphicsRotationPrivate
{
public:
- QGraphicsRotation3DPrivate() {}
+ QGraphicsRotation3DPrivate() : axis(0, 0, 1) {}
QVector3D axis;
};
@@ -522,10 +522,14 @@ QVector3D QGraphicsRotation3D::axis()
void QGraphicsRotation3D::setAxis(const QVector3D &axis)
{
Q_D(QGraphicsRotation3D);
+ if (d->axis == axis)
+ return;
d->axis = axis;
update();
+ emit axisChanged();
}
+const qreal deg2rad = qreal(0.017453292519943295769); // pi/180
static const qreal inv_dist_to_plane = 1. / 1024.;
/*!
@@ -535,13 +539,27 @@ void QGraphicsRotation3D::applyTo(QTransform *t) const
{
Q_D(const QGraphicsRotation3D);
- if (d->angle == 0. ||
+ qreal a = d->angle;
+
+ if (a == 0. ||
(d->axis.z() == 0. && d->axis.y() == 0 && d->axis.x() == 0))
return;
- qreal rad = d->angle * 2. * M_PI / 360.;
- qreal c = ::cos(rad);
- qreal s = ::sin(rad);
+ qreal c, s;
+ if (a == 90. || a == -270.) {
+ s = 1.;
+ c = 0.;
+ } else if (a == 270. || a == -90.) {
+ s = -1.;
+ c = 0.;
+ } else if (a == 180.) {
+ s = 0.;
+ c = -1.;
+ } else {
+ qreal b = deg2rad*a;
+ s = qSin(b);
+ c = qCos(b);
+ }
qreal x = d->axis.x();
qreal y = d->axis.y();
diff --git a/src/gui/graphicsview/qgraphicstransform_p.h b/src/gui/graphicsview/qgraphicstransform_p.h
index 2d36eda..467021f 100644
--- a/src/gui/graphicsview/qgraphicstransform_p.h
+++ b/src/gui/graphicsview/qgraphicstransform_p.h
@@ -55,6 +55,8 @@
#include "private/qobject_p.h"
+QT_BEGIN_NAMESPACE
+
class QGraphicsItem;
class QGraphicsTransformPrivate : public QObjectPrivate {
@@ -70,4 +72,6 @@ public:
static void updateItem(QGraphicsItem *item);
};
+QT_END_NAMESPACE
+
#endif // QGRAPHICSTRANSFORM_P_H
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index ca55f2e..92f8816 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -2209,8 +2209,7 @@ QPolygonF QGraphicsView::mapToScene(const QRect &rect) const
QPointF br = scrollOffset + r.bottomRight();
QPointF bl = scrollOffset + r.bottomLeft();
- QPolygonF poly;
- poly.resize(4);
+ QPolygonF poly(4);
if (!d->identityMatrix) {
QTransform x = d->matrix.inverted();
poly[0] = x.map(tl);
@@ -2313,8 +2312,7 @@ QPolygon QGraphicsView::mapFromScene(const QRectF &rect) const
br -= scrollOffset;
bl -= scrollOffset;
- QPolygon poly;
- poly.resize(4);
+ QPolygon poly(4);
poly[0] = tl.toPoint();
poly[1] = tr.toPoint();
poly[2] = br.toPoint();
@@ -3647,8 +3645,7 @@ QRectF QGraphicsViewPrivate::mapToScene(const QRectF &rect) const
QPointF br = scrollOffset + rect.bottomRight();
QPointF bl = scrollOffset + rect.bottomLeft();
- QPolygonF poly;
- poly.resize(4);
+ QPolygonF poly(4);
if (!identityMatrix) {
QTransform x = matrix.inverted();
poly[0] = x.map(tl);
diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp
index 7d1c5fb..789700a 100644
--- a/src/gui/image/qimagepixmapcleanuphooks.cpp
+++ b/src/gui/image/qimagepixmapcleanuphooks.cpp
@@ -43,6 +43,8 @@
#include "qpixmapdata_p.h"
+QT_BEGIN_NAMESPACE
+
// Legacy, single instance hooks: ### Qt 5: remove
typedef void (*_qt_pixmap_cleanup_hook)(int);
typedef void (*_qt_pixmap_cleanup_hook_64)(qint64);
@@ -108,3 +110,4 @@ void QImagePixmapCleanupHooks::executeImageHooks(qint64 key)
qt_image_cleanup_hook_64(key);
}
+QT_END_NAMESPACE
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index d929590..421d511 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -2650,7 +2650,7 @@ void QAbstractItemView::keyboardSearch(const QString &search)
if (search.isEmpty()
|| (d->keyboardInputTime.msecsTo(now) > QApplication::keyboardInputInterval())) {
d->keyboardInput = search;
- skipRow = true;
+ skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0)
} else {
d->keyboardInput += search;
}
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp
index 9dad95f..0f35ac1 100644
--- a/src/gui/itemviews/qitemselectionmodel.cpp
+++ b/src/gui/itemviews/qitemselectionmodel.cpp
@@ -593,10 +593,30 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
// update selectionsx
QModelIndex tl = model->index(start, 0, parent);
QModelIndex br = model->index(end, model->columnCount(parent) - 1, parent);
- q->select(QItemSelection(tl, br), QItemSelectionModel::Deselect);
+ recursiveDeselect(QItemSelectionRange(tl, br));
finalize();
}
+void QItemSelectionModelPrivate::recursiveDeselect(const QItemSelectionRange &range)
+{
+ Q_Q(QItemSelectionModel);
+
+ QItemSelection sel(range.topLeft(), range.bottomRight());
+ q->select(sel, QItemSelectionModel::Deselect);
+
+ QModelIndexList idxList = range.indexes();
+ QModelIndexList::const_iterator it = idxList.begin();
+ for (; it != idxList.end(); ++it)
+ {
+ if (!model->hasChildren(*it))
+ continue;
+
+ const QModelIndex &firstChild = it->child(0,0);
+ const QModelIndex &lastChild = it->child(model->rowCount(*it) - 1, model->columnCount(*it) - 1);
+ recursiveDeselect(QItemSelectionRange(firstChild, lastChild));
+ }
+}
+
/*!
\internal
*/
diff --git a/src/gui/itemviews/qitemselectionmodel_p.h b/src/gui/itemviews/qitemselectionmodel_p.h
index 18ad506..8176d4c 100644
--- a/src/gui/itemviews/qitemselectionmodel_p.h
+++ b/src/gui/itemviews/qitemselectionmodel_p.h
@@ -77,6 +77,8 @@ public:
void _q_layoutAboutToBeChanged();
void _q_layoutChanged();
+ void recursiveDeselect(const QItemSelectionRange &range);
+
inline void remove(QList<QItemSelectionRange> &r)
{
QList<QItemSelectionRange>::const_iterator it = r.constBegin();
diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp
index 2565657..b518ff2 100644
--- a/src/gui/itemviews/qlistwidget.cpp
+++ b/src/gui/itemviews/qlistwidget.cpp
@@ -447,21 +447,20 @@ Qt::DropActions QListModel::supportedDropActions() const
\ingroup model-view
- QListWidgetItem is used to represent items in a list provided by the
- QListWidget class. Each item can hold several pieces of information,
- and will display these appropriately.
+ A QListWidgetItem represents a single item in a QListWidget. Each item can
+ hold several pieces of information, and will display them appropriately.
- The item view convenience classes use a classic item-based interface
- rather than a pure model/view approach. For a more flexible list view
- widget, consider using the QListView class with a standard model.
+ The item view convenience classes use a classic item-based interface rather
+ than a pure model/view approach. For a more flexible list view widget,
+ consider using the QListView class with a standard model.
- List items can be automatically inserted into a list when they are
- constructed by specifying the list widget:
+ List items can be inserted automatically into a list, when they are
+ constructed, by specifying the list widget:
\snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 2
- They can also be created without a parent widget, and later inserted into
- a list (see \l{QListWidget::insertItem()}).
+ Alternatively, list items can also be created without a parent widget, and
+ later inserted into a list using QListWidget::insertItem().
List items are typically used to display text() and an icon(). These are
set with the setText() and setIcon() functions. The appearance of the text
@@ -471,22 +470,24 @@ Qt::DropActions QListModel::supportedDropActions() const
with setToolTip(), setStatusTip(), and setWhatsThis().
By default, items are enabled, selectable, checkable, and can be the source
- of a drag and drop operation.
+ of drag and drop operations.
+
Each item's flags can be changed by calling setFlags() with the appropriate
- value (see \l{Qt::ItemFlags}). Checkable items can be checked, unchecked and
+ value (see Qt::ItemFlags). Checkable items can be checked, unchecked and
partially checked with the setCheckState() function. The corresponding
- checkState() function indicates what check state the item currently has.
+ checkState() function indicates the item's current check state.
+
+ The isHidden() function can be used to determine whether the item is
+ hidden. To hide an item, use setHidden().
- The isHidden() function can be used to determine whether the
- item is hidden. Items can be hidden with setHidden().
\section1 Subclassing
When subclassing QListWidgetItem to provide custom items, it is possible to
- define new types for them so that they can be distinguished from standard
- items. The constructors for subclasses that require this feature need to
- call the base class constructor with a new type value equal to or greater
- than \l UserType.
+ define new types for them enabling them to be distinguished from standard
+ items. For subclasses that require this feature, ensure that you call the
+ base class constructor with a new type value equal to or greater than
+ \l UserType, within \e your constructor.
\sa QListWidget, {Model/View Programming}, QTreeWidgetItem, QTableWidgetItem
*/
@@ -515,59 +516,58 @@ Qt::DropActions QListModel::supportedDropActions() const
/*!
\fn QListWidget *QListWidgetItem::listWidget() const
- Returns the list widget that contains the item.
+ Returns the list widget containing the item.
*/
/*!
- \fn void QListWidgetItem::setSelected(bool select)
- \since 4.2
+ \fn void QListWidgetItem::setSelected(bool select)
+ \since 4.2
- Sets the selected state of the item to \a select.
+ Sets the selected state of the item to \a select.
- \sa isSelected()
+ \sa isSelected()
*/
/*!
- \fn bool QListWidgetItem::isSelected() const
- \since 4.2
+ \fn bool QListWidgetItem::isSelected() const
+ \since 4.2
- Returns true if the item is selected, otherwise returns false.
+ Returns true if the item is selected; otherwise returns false.
- \sa setSelected()
+ \sa setSelected()
*/
/*!
- \fn void QListWidgetItem::setHidden(bool hide)
- \since 4.2
+ \fn void QListWidgetItem::setHidden(bool hide)
+ \since 4.2
- Hides the item if \a hide is true, otherwise shows the item.
+ Hides the item if \a hide is true; otherwise shows the item.
- \sa isHidden()
+ \sa isHidden()
*/
/*!
- \fn bool QListWidgetItem::isHidden() const
- \since 4.2
+ \fn bool QListWidgetItem::isHidden() const
+ \since 4.2
- Returns true if the item is hidden, otherwise returns false.
+ Returns true if the item is hidden; otherwise returns false.
- \sa setHidden()
+ \sa setHidden()
*/
/*!
\fn QListWidgetItem::QListWidgetItem(QListWidget *parent, int type)
Constructs an empty list widget item of the specified \a type with the
- given \a parent.
- If the parent is not specified, the item will need to be inserted into a
- list widget with QListWidget::insertItem().
-
- \note that this constructor inserts this same object into the model of
- the parent that is passed to the constructor. If the model is sorted then
- the behavior of the insert is undetermined since the model will call
- the '<' operator method on this object which has still not yet been
- constructed. In this case it would be better not to specify the parent
- and use the QListWidget::insertItem method to insert the item instead.
+ given \a parent. If \a parent is not specified, the item will need to be
+ inserted into a list widget with QListWidget::insertItem().
+
+ This constructor inserts the item into the model of the parent that is
+ passed to the constructor. If the model is sorted then the behavior of the
+ insert is undetermined since the model will call the \c '<' operator method
+ on the item which, at this point, is not yet constructed. To avoid the
+ undetermined behavior, we recommend not to specify the parent and use
+ QListWidget::insertItem() instead.
\sa type()
*/
@@ -586,16 +586,15 @@ QListWidgetItem::QListWidgetItem(QListWidget *view, int type)
\fn QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *parent, int type)
Constructs an empty list widget item of the specified \a type with the
- given \a text and \a parent.
- If the parent is not specified, the item will need to be inserted into a
- list widget with QListWidget::insertItem().
-
- \note that this constructor inserts this same object into the model of
- the parent that is passed to the constructor. If the model is sorted then
- the behavior of the insert is undetermined since the model will call
- the '<' operator method on this object which has still not yet been
- constructed. In this case it would be better not to specify the parent
- and use the QListWidget::insertItem method to insert the item instead.
+ given \a text and \a parent. If the parent is not specified, the item will
+ need to be inserted into a list widget with QListWidget::insertItem().
+
+ This constructor inserts the item into the model of the parent that is
+ passed to the constructor. If the model is sorted then the behavior of the
+ insert is undetermined since the model will call the \c '<' operator method
+ on the item which, at this point, is not yet constructed. To avoid the
+ undetermined behavior, we recommend not to specify the parent and use
+ QListWidget::insertItem() instead.
\sa type()
*/
@@ -616,17 +615,17 @@ QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *view, int typ
\fn QListWidgetItem::QListWidgetItem(const QIcon &icon, const QString &text, QListWidget *parent, int type)
Constructs an empty list widget item of the specified \a type with the
- given \a icon, \a text and \a parent.
- If the parent is not specified, the item will need to be inserted into a
- list widget with QListWidget::insertItem().
-
- \note that this constructor inserts this same object into the model of
- the parent that is passed to the constructor. If the model is sorted then
- the behavior of the insert is undetermined since the model will call
- the '<' operator method on this object which has still not yet been
- constructed. In this case it would be better not to specify the parent
- and use the QListWidget::insertItem method to insert the item instead.
-
+ given \a icon, \a text and \a parent. If the parent is not specified, the
+ item will need to be inserted into a list widget with
+ QListWidget::insertItem().
+
+ This constructor inserts the item into the model of the parent that is
+ passed to the constructor. If the model is sorted then the behavior of the
+ insert is undetermined since the model will call the \c '<' operator method
+ on the item which, at this point, is not yet constructed. To avoid the
+ undetermined behavior, we recommend not to specify the parent and use
+ QListWidget::insertItem() instead.
+
\sa type()
*/
QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text,
@@ -645,7 +644,7 @@ QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text,
}
/*!
- Destroys the list item.
+ Destroys the list item.
*/
QListWidgetItem::~QListWidgetItem()
{
@@ -655,7 +654,7 @@ QListWidgetItem::~QListWidgetItem()
}
/*!
- Creates an exact copy of the item.
+ Creates an exact copy of the item.
*/
QListWidgetItem *QListWidgetItem::clone() const
{
@@ -663,11 +662,10 @@ QListWidgetItem *QListWidgetItem::clone() const
}
/*!
- This function sets the data for a given \a role to the given \a value (see
- \l{Qt::ItemDataRole}). Reimplement this function if you need
- extra roles or special behavior for certain roles.
+ Sets the data for a given \a role to the given \a value. Reimplement this
+ function if you need extra roles or special behavior for certain roles.
- \sa Qt::ItemDataRole, data()
+ \sa Qt::ItemDataRole, data()
*/
void QListWidgetItem::setData(int role, const QVariant &value)
{
@@ -689,9 +687,10 @@ void QListWidgetItem::setData(int role, const QVariant &value)
}
/*!
- This function returns the item's data for a given \a role (see
- Qt::ItemDataRole). Reimplement this function if you need
- extra roles or special behavior for certain roles.
+ Returns the item's data for a given \a role. Reimplement this function if
+ you need extra roles or special behavior for certain roles.
+
+ \sa Qt::ItemDataRole, setData()
*/
QVariant QListWidgetItem::data(int role) const
{
@@ -703,8 +702,8 @@ QVariant QListWidgetItem::data(int role) const
}
/*!
- Returns true if this item's text is less then \a other item's text;
- otherwise returns false.
+ Returns true if this item's text is less then \a other item's text;
+ otherwise returns false.
*/
bool QListWidgetItem::operator<(const QListWidgetItem &other) const
{
@@ -740,8 +739,8 @@ void QListWidgetItem::write(QDataStream &out) const
/*!
\since 4.1
- Constructs a copy of \a other. Note that type() and listWidget()
- are not copied.
+ Constructs a copy of \a other. Note that type() and listWidget() are not
+ copied.
This function is useful when reimplementing clone().
@@ -756,8 +755,8 @@ QListWidgetItem::QListWidgetItem(const QListWidgetItem &other)
}
/*!
- Assigns \a other's data and flags to this item. Note that type()
- and listWidget() are not copied.
+ Assigns \a other's data and flags to this item. Note that type() and
+ listWidget() are not copied.
This function is useful when reimplementing clone().
@@ -805,9 +804,9 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
#endif // QT_NO_DATASTREAM
/*!
- \fn Qt::ItemFlags QListWidgetItem::flags() const
+ \fn Qt::ItemFlags QListWidgetItem::flags() const
- Returns the item flags for this item (see \l{Qt::ItemFlags}).
+ Returns the item flags for this item (see \l{Qt::ItemFlags}).
*/
/*!
@@ -851,15 +850,17 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
*/
/*!
- \fn QFont QListWidgetItem::font() const
+ \fn QFont QListWidgetItem::font() const
- Returns the font used to display this list item's text.
+ Returns the font used to display this list item's text.
*/
/*!
- \fn int QListWidgetItem::textAlignment() const
+ \fn int QListWidgetItem::textAlignment() const
- Returns the text alignment for the list item (see \l{Qt::AlignmentFlag}).
+ Returns the text alignment for the list item.
+
+ \sa Qt::AlignmentFlag
*/
/*!
@@ -905,26 +906,26 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
*/
/*!
- \fn QSize QListWidgetItem::sizeHint() const
- \since 4.1
+ \fn QSize QListWidgetItem::sizeHint() const
+ \since 4.1
- Returns the size hint set for the list item.
+ Returns the size hint set for the list item.
*/
/*!
- \fn void QListWidgetItem::setSizeHint(const QSize &size)
- \since 4.1
+ \fn void QListWidgetItem::setSizeHint(const QSize &size)
+ \since 4.1
- Sets the size hint for the list item to be \a size.
- If no size hint is set, the item delegate will compute the
- size hint based on the item data.
+ Sets the size hint for the list item to be \a size. If no size hint is set,
+ the item delegate will compute the size hint based on the item data.
*/
/*!
- \fn void QListWidgetItem::setFlags(Qt::ItemFlags flags)
+ \fn void QListWidgetItem::setFlags(Qt::ItemFlags flags)
- Sets the item flags for the list item to \a flags (see
- \l{Qt::ItemFlags}).
+ Sets the item flags for the list item to \a flags.
+
+ \sa Qt::ItemFlags
*/
void QListWidgetItem::setFlags(Qt::ItemFlags aflags) {
itemFlags = aflags;
@@ -953,10 +954,10 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) {
\fn void QListWidgetItem::setStatusTip(const QString &statusTip)
Sets the status tip for the list item to the text specified by
- \a statusTip. QListWidget mouse tracking needs to be enabled for this
+ \a statusTip. QListWidget mouseTracking needs to be enabled for this
feature to work.
- \sa statusTip() setToolTip() setWhatsThis()
+ \sa statusTip(), setToolTip(), setWhatsThis(), QWidget::setMouseTracking()
*/
/*!
@@ -964,29 +965,30 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) {
Sets the tooltip for the list item to the text specified by \a toolTip.
- \sa toolTip() setStatusTip() setWhatsThis()
+ \sa toolTip(), setStatusTip(), setWhatsThis()
*/
/*!
\fn void QListWidgetItem::setWhatsThis(const QString &whatsThis)
- Sets the "What's This?" help for the list item to the text specified
- by \a whatsThis.
+ Sets the "What's This?" help for the list item to the text specified by
+ \a whatsThis.
- \sa whatsThis() setStatusTip() setToolTip()
+ \sa whatsThis(), setStatusTip(), setToolTip()
*/
/*!
- \fn void QListWidgetItem::setFont(const QFont &font)
+ \fn void QListWidgetItem::setFont(const QFont &font)
- Sets the font used when painting the item to the given \a font.
+ Sets the font used when painting the item to the given \a font.
*/
/*!
- \fn void QListWidgetItem::setTextAlignment(int alignment)
+ \fn void QListWidgetItem::setTextAlignment(int alignment)
+
+ Sets the list item's text alignment to \a alignment.
- Sets the list item's text alignment to \a alignment (see
- \l{Qt::AlignmentFlag}).
+ \sa Qt::AlignmentFlag
*/
/*!
@@ -1127,10 +1129,10 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
\ingroup model-view
\mainclass
- QListWidget is a convenience class that provides a list view similar to
- the one supplied by QListView, but with a classic item-based interface
- for adding and removing items. QListWidget uses an internal model to
- manage each QListWidgetItem in the list.
+ QListWidget is a convenience class that provides a list view similar to the
+ one supplied by QListView, but with a classic item-based interface for
+ adding and removing items. QListWidget uses an internal model to manage
+ each QListWidgetItem in the list.
For a more flexible list view widget, use the QListView class with a
standard model.
@@ -1145,23 +1147,23 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
function.
There are two ways to add items to the list: they can be constructed with
- the list widget as their parent widget, or they can be constructed with
- no parent widget and added to the list later. If a list widget already
- exists when the items are constructed, the first method is easier to use:
+ the list widget as their parent widget, or they can be constructed with no
+ parent widget and added to the list later. If a list widget already exists
+ when the items are constructed, the first method is easier to use:
\snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 1
- If you need to insert a new item into the list at a particular position,
- it is more required to construct the item without a parent widget and
- use the insertItem() function to place it within the list. The list
- widget will take ownership of the item.
+ If you need to insert a new item into the list at a particular position, it
+ is more required to construct the item without a parent widget and use the
+ insertItem() function to place it within the list. The list widget will
+ take ownership of the item.
\snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 6
\snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 7
- For multiple items, insertItems() can be used instead. The number of
- items in the list is found with the count() function.
- To remove items from the list, use takeItem().
+ For multiple items, insertItems() can be used instead. The number of items
+ in the list is found with the count() function. To remove items from the
+ list, use takeItem().
The current item in the list can be found with currentItem(), and changed
with setCurrentItem(). The user can also change the current item by
@@ -1187,9 +1189,9 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
Inserts the \a item at the end of the list widget.
- \warning A QListWidgetItem can only be added to a
- QListWidget once. Adding the same QListWidgetItem multiple
- times to a QListWidget will result in undefined behavior.
+ \warning A QListWidgetItem can only be added to a QListWidget once. Adding
+ the same QListWidgetItem multiple times to a QListWidget will result in
+ undefined behavior.
\sa insertItem()
*/
@@ -1197,8 +1199,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
/*!
\fn void QListWidget::addItem(const QString &label)
- Inserts an item with the text \a label at the end of the list
- widget.
+ Inserts an item with the text \a label at the end of the list widget.
*/
/*!
@@ -1212,8 +1213,8 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
/*!
\fn void QListWidget::itemPressed(QListWidgetItem *item)
- This signal is emitted with the specified \a item when a mouse button is pressed
- on an item in the widget.
+ This signal is emitted with the specified \a item when a mouse button is
+ pressed on an item in the widget.
\sa itemClicked(), itemDoubleClicked()
*/
@@ -1221,8 +1222,8 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
/*!
\fn void QListWidget::itemClicked(QListWidgetItem *item)
- This signal is emitted with the specified \a item when a mouse button is clicked
- on an item in the widget.
+ This signal is emitted with the specified \a item when a mouse button is
+ clicked on an item in the widget.
\sa itemPressed(), itemDoubleClicked()
*/
@@ -1230,8 +1231,8 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
/*!
\fn void QListWidget::itemDoubleClicked(QListWidgetItem *item)
- This signal is emitted with the specified \a item when a mouse button is double
- clicked on an item in the widget.
+ This signal is emitted with the specified \a item when a mouse button is
+ double clicked on an item in the widget.
\sa itemClicked(), itemPressed()
*/
@@ -1239,20 +1240,21 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
/*!
\fn void QListWidget::itemActivated(QListWidgetItem *item)
- This signal is emitted when the \a item is activated. The \a item
- is activated when the user clicks or double clicks on it,
- depending on the system configuration. It is also activated when
- the user presses the activation key (on Windows and X11 this is
- the \gui Return key, on Mac OS X it is \key{Ctrl+0}).
+ This signal is emitted when the \a item is activated. The \a item is
+ activated when the user clicks or double clicks on it, depending on the
+ system configuration. It is also activated when the user presses the
+ activation key (on Windows and X11 this is the \gui Return key, on Mac OS
+ X it is \key{Ctrl+0}).
*/
/*!
\fn void QListWidget::itemEntered(QListWidgetItem *item)
- This signal is emitted when the mouse cursor enters an item. The
- \a item is the item entered. This signal is only emitted when
- mouseTracking is turned on, or when a mouse button is pressed
- while moving into an item.
+ This signal is emitted when the mouse cursor enters an item. The \a item is
+ the item entered. This signal is only emitted when mouseTracking is turned
+ on, or when a mouse button is pressed while moving into an item.
+
+ \sa QWidget::setMouseTracking()
*/
/*!
@@ -1264,24 +1266,28 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
/*!
\fn void QListWidget::currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
- This signal is emitted whenever the current item changes. The \a
- previous item is the item that previously had the focus, \a
- current is the new current item.
+ This signal is emitted whenever the current item changes.
+
+ \a previous is the item that previously had the focus; \a current is the
+ new current item.
*/
/*!
- \fn void QListWidget::currentTextChanged(const QString &currentText)
+ \fn void QListWidget::currentTextChanged(const QString &currentText)
- This signal is emitted whenever the current item changes. The \a currentText
- is the text data in the current item. If there is no current item, the \a currentText
- is invalid.
+ This signal is emitted whenever the current item changes.
+
+ \a currentText is the text data in the current item. If there is no current
+ item, the \a currentText is invalid.
*/
/*!
- \fn void QListWidget::currentRowChanged(int currentRow)
+ \fn void QListWidget::currentRowChanged(int currentRow)
+
+ This signal is emitted whenever the current item changes.
- This signal is emitted whenever the current item changes. The \a currentRow
- is the row of the current item. If there is no current item, the \a currentRow is -1.
+ \a currentRow is the row of the current item. If there is no current item,
+ the \a currentRow is -1.
*/
/*!
@@ -1289,15 +1295,15 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
This signal is emitted whenever the selection changes.
- \sa selectedItems() QListWidgetItem::isSelected() currentItemChanged()
+ \sa selectedItems(), QListWidgetItem::isSelected(), currentItemChanged()
*/
/*!
- \since 4.3
+ \since 4.3
- \fn void QListWidget::removeItemWidget(QListWidgetItem *item)
+ \fn void QListWidget::removeItemWidget(QListWidgetItem *item)
- Removes the widget set on the given \a item.
+ Removes the widget set on the given \a item.
*/
/*!
@@ -1361,8 +1367,8 @@ void QListWidget::insertItem(int row, QListWidgetItem *item)
}
/*!
- Inserts an item with the text \a label in the list widget at the
- position given by \a row.
+ Inserts an item with the text \a label in the list widget at the position
+ given by \a row.
\sa addItem()
*/
@@ -1387,11 +1393,11 @@ void QListWidget::insertItems(int row, const QStringList &labels)
}
/*!
- Removes and returns the item from the given \a row in the list widget; otherwise
- returns 0.
+ Removes and returns the item from the given \a row in the list widget;
+ otherwise returns 0.
- Items removed from a list widget will not be managed by Qt, and will need to be
- deleted manually.
+ Items removed from a list widget will not be managed by Qt, and will need
+ to be deleted manually.
\sa insertItem(), addItem()
*/
@@ -1405,8 +1411,8 @@ QListWidgetItem *QListWidget::takeItem(int row)
}
/*!
- \property QListWidget::count
- \brief the number of items in the list including any hidden items.
+ \property QListWidget::count
+ \brief the number of items in the list including any hidden items.
*/
int QListWidget::count() const
@@ -1416,7 +1422,7 @@ int QListWidget::count() const
}
/*!
- Returns the current item.
+ Returns the current item.
*/
QListWidgetItem *QListWidget::currentItem() const
{
@@ -1426,9 +1432,9 @@ QListWidgetItem *QListWidget::currentItem() const
/*!
- Sets the current item to \a item.
+ Sets the current item to \a item.
- Depending on the current selection mode, the item may also be selected.
+ Depending on the current selection mode, the item may also be selected.
*/
void QListWidget::setCurrentItem(QListWidgetItem *item)
{
@@ -1436,8 +1442,8 @@ void QListWidget::setCurrentItem(QListWidgetItem *item)
}
/*!
- \since 4.4
- Set the current item to \a item, using the given \a command.
+ \since 4.4
+ Set the current item to \a item, using the given \a command.
*/
void QListWidget::setCurrentItem(QListWidgetItem *item, QItemSelectionModel::SelectionFlags command)
{
@@ -1445,10 +1451,10 @@ void QListWidget::setCurrentItem(QListWidgetItem *item, QItemSelectionModel::Sel
}
/*!
- \property QListWidget::currentRow
- \brief the row of the current item.
+ \property QListWidget::currentRow
+ \brief the row of the current item.
- Depending on the current selection mode, the row may also be selected.
+ Depending on the current selection mode, the row may also be selected.
*/
int QListWidget::currentRow() const
@@ -1469,9 +1475,9 @@ void QListWidget::setCurrentRow(int row)
}
/*!
- \since 4.4
+ \since 4.4
- Sets the current row to be the given \a row, using the given \a command,
+ Sets the current row to be the given \a row, using the given \a command,
*/
void QListWidget::setCurrentRow(int row, QItemSelectionModel::SelectionFlags command)
{
@@ -1498,7 +1504,7 @@ QListWidgetItem *QListWidget::itemAt(const QPoint &p) const
/*!
- Returns the rectangle on the viewport occupied by the item at \a item.
+ Returns the rectangle on the viewport occupied by the item at \a item.
*/
QRect QListWidget::visualItemRect(const QListWidgetItem *item) const
{
@@ -1508,7 +1514,7 @@ QRect QListWidget::visualItemRect(const QListWidgetItem *item) const
}
/*!
- Sorts all the items in the list widget according to the specified \a order.
+ Sorts all the items in the list widget according to the specified \a order.
*/
void QListWidget::sortItems(Qt::SortOrder order)
{
@@ -1522,8 +1528,10 @@ void QListWidget::sortItems(Qt::SortOrder order)
\property QListWidget::sortingEnabled
\brief whether sorting is enabled
- If this property is true, sorting is enabled for the list; if the
- property is false, sorting is not enabled. The default value is false.
+ If this property is true, sorting is enabled for the list; if the property
+ is false, sorting is not enabled.
+
+ The default value is false.
*/
void QListWidget::setSortingEnabled(bool enable)
{
@@ -1538,7 +1546,7 @@ bool QListWidget::isSortingEnabled() const
}
/*!
- \internal
+ \internal
*/
Qt::SortOrder QListWidget::sortOrder() const
{
@@ -1547,7 +1555,7 @@ Qt::SortOrder QListWidget::sortOrder() const
}
/*!
- Starts editing the \a item if it is editable.
+ Starts editing the \a item if it is editable.
*/
void QListWidget::editItem(QListWidgetItem *item)
@@ -1557,9 +1565,10 @@ void QListWidget::editItem(QListWidgetItem *item)
}
/*!
- Opens an editor for the given \a item. The editor remains open after editing.
+ Opens an editor for the given \a item. The editor remains open after
+ editing.
- \sa closePersistentEditor()
+ \sa closePersistentEditor()
*/
void QListWidget::openPersistentEditor(QListWidgetItem *item)
{
@@ -1569,9 +1578,9 @@ void QListWidget::openPersistentEditor(QListWidgetItem *item)
}
/*!
- Closes the persistent editor for the given \a item.
+ Closes the persistent editor for the given \a item.
- \sa openPersistentEditor()
+ \sa openPersistentEditor()
*/
void QListWidget::closePersistentEditor(QListWidgetItem *item)
{
@@ -1597,9 +1606,10 @@ QWidget *QListWidget::itemWidget(QListWidgetItem *item) const
Sets the \a widget to be displayed in the give \a item.
- This function should only be used to display static content in the place of a list
- widget item. If you want to display custom dynamic content or implement a custom
- editor widget, use QListView and subclass QItemDelegate instead.
+ This function should only be used to display static content in the place of
+ a list widget item. If you want to display custom dynamic content or
+ implement a custom editor widget, use QListView and subclass QItemDelegate
+ instead.
\sa {Delegate Classes}
*/
@@ -1611,11 +1621,11 @@ void QListWidget::setItemWidget(QListWidgetItem *item, QWidget *widget)
}
/*!
- Returns true if \a item is selected; otherwise returns false.
+ Returns true if \a item is selected; otherwise returns false.
- \obsolete
+ \obsolete
- This function is deprecated. Use \l{QListWidgetItem::isSelected()} instead.
+ This function is deprecated. Use QListWidgetItem::isSelected() instead.
*/
bool QListWidget::isItemSelected(const QListWidgetItem *item) const
{
@@ -1625,12 +1635,12 @@ bool QListWidget::isItemSelected(const QListWidgetItem *item) const
}
/*!
- Selects or deselects the given \a item depending on whether \a select is
- true of false.
+ Selects or deselects the given \a item depending on whether \a select is
+ true of false.
- \obsolete
+ \obsolete
- This function is deprecated. Use \l{QListWidgetItem::setSelected()} instead.
+ This function is deprecated. Use QListWidgetItem::setSelected() instead.
*/
void QListWidget::setItemSelected(const QListWidgetItem *item, bool select)
{
@@ -1650,7 +1660,7 @@ void QListWidget::setItemSelected(const QListWidgetItem *item, bool select)
}
/*!
- Returns a list of all selected items in the list widget.
+ Returns a list of all selected items in the list widget.
*/
QList<QListWidgetItem*> QListWidget::selectedItems() const
@@ -1664,7 +1674,8 @@ QList<QListWidgetItem*> QListWidget::selectedItems() const
}
/*!
- Finds items with the text that matches the string \a text using the given \a flags.
+ Finds items with the text that matches the string \a text using the given
+ \a flags.
*/
QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFlags flags) const
@@ -1679,11 +1690,11 @@ QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFla
}
/*!
- Returns true if the \a item is explicitly hidden; otherwise returns false.
+ Returns true if the \a item is explicitly hidden; otherwise returns false.
- \obsolete
+ \obsolete
- This function is deprecated. Use \l{QListWidgetItem::isHidden()} instead.
+ This function is deprecated. Use QListWidgetItem::isHidden() instead.
*/
bool QListWidget::isItemHidden(const QListWidgetItem *item) const
{
@@ -1691,11 +1702,11 @@ bool QListWidget::isItemHidden(const QListWidgetItem *item) const
}
/*!
- If \a hide is true, the \a item will be hidden; otherwise it will be shown.
+ If \a hide is true, the \a item will be hidden; otherwise it will be shown.
- \obsolete
+ \obsolete
- This function is deprecated. Use \l{QListWidgetItem::setHidden()} instead.
+ This function is deprecated. Use QListWidgetItem::setHidden() instead.
*/
void QListWidget::setItemHidden(const QListWidgetItem *item, bool hide)
{
@@ -1703,9 +1714,9 @@ void QListWidget::setItemHidden(const QListWidgetItem *item, bool hide)
}
/*!
- Scrolls the view if necessary to ensure that the \a item is
- visible. The \a hint parameter specifies more precisely where the
- \a item should be located after the operation.
+ Scrolls the view if necessary to ensure that the \a item is visible.
+
+ \a hint specifies where the \a item should be located after the operation.
*/
void QListWidget::scrollToItem(const QListWidgetItem *item, QAbstractItemView::ScrollHint hint)
@@ -1718,7 +1729,7 @@ void QListWidget::scrollToItem(const QListWidgetItem *item, QAbstractItemView::S
/*!
Removes all items and selections in the view.
- \note All items will be permanently deleted.
+ \warning All items will be permanently deleted.
*/
void QListWidget::clear()
{
@@ -1743,8 +1754,8 @@ QStringList QListWidget::mimeTypes() const
\a items. The format used to describe the items is obtained from the
mimeTypes() function.
- If the list of items is empty, 0 is returned rather than a serialized
- empty list.
+ If the list of items is empty, 0 is returned instead of a serialized empty
+ list.
*/
QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*>) const
{
@@ -1753,10 +1764,9 @@ QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*>) const
#ifndef QT_NO_DRAGANDDROP
/*!
- Handles the \a data supplied by an external drag and drop operation
- that ended with the given \a action in the given \a index.
- Returns true if the data and action can be handled by the model;
- otherwise returns false.
+ Handles \a data supplied by an external drag and drop operation that ended
+ with the given \a action in the given \a index. Returns true if \a data and
+ \a action can be handled by the model; otherwise returns false.
\sa supportedDropActions()
*/
@@ -1823,9 +1833,9 @@ void QListWidget::dropEvent(QDropEvent *event) {
}
/*!
- Returns the drop actions supported by this view.
+ Returns the drop actions supported by this view.
- \sa Qt::DropActions
+ \sa Qt::DropActions
*/
Qt::DropActions QListWidget::supportedDropActions() const
{
@@ -1835,9 +1845,9 @@ Qt::DropActions QListWidget::supportedDropActions() const
#endif // QT_NO_DRAGANDDROP
/*!
- Returns a list of pointers to the items contained in the \a data object.
- If the object was not created by a QListWidget in the same process, the list
- is empty.
+ Returns a list of pointers to the items contained in the \a data object. If
+ the object was not created by a QListWidget in the same process, the list
+ is empty.
*/
QList<QListWidgetItem*> QListWidget::items(const QMimeData *data) const
{
@@ -1848,7 +1858,7 @@ QList<QListWidgetItem*> QListWidget::items(const QMimeData *data) const
}
/*!
- Returns the QModelIndex assocated with the given \a item.
+ Returns the QModelIndex assocated with the given \a item.
*/
QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const
@@ -1858,7 +1868,7 @@ QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const
}
/*!
- Returns a pointer to the QListWidgetItem assocated with the given \a index.
+ Returns a pointer to the QListWidgetItem assocated with the given \a index.
*/
QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const
@@ -1870,7 +1880,7 @@ QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const
}
/*!
- \internal
+ \internal
*/
void QListWidget::setModel(QAbstractItemModel * /*model*/)
{
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index e6eff6e..d9deefe 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -100,7 +100,8 @@ unix:x11 {
INCLUDEPATH += ../3rdparty/xorg
HEADERS += \
kernel/qx11embed_x11.h \
- kernel/qx11info_x11.h
+ kernel/qx11info_x11.h \
+ kernel/qkde_p.h
SOURCES += \
kernel/qapplication_x11.cpp \
@@ -114,7 +115,8 @@ unix:x11 {
kernel/qwidgetcreate_x11.cpp \
kernel/qx11embed_x11.cpp \
kernel/qx11info_x11.cpp \
- kernel/qkeymapper_x11.cpp
+ kernel/qkeymapper_x11.cpp \
+ kernel/qkde.cpp
contains(QT_CONFIG, glib) {
SOURCES += \
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h
index 19ae085..58e0cc3 100644
--- a/src/gui/kernel/qapplication.h
+++ b/src/gui/kernel/qapplication.h
@@ -375,10 +375,6 @@ private:
friend class QDirectPainterPrivate;
#endif
-#if defined(Q_WS_WIN)
- friend QApplicationPrivate* getQApplicationPrivateInternal();
-#endif
-
#if defined(Q_WS_MAC) || defined(Q_WS_X11)
Q_PRIVATE_SLOT(d_func(), void _q_alertTimeOut())
#endif
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 700d1ab..f809672 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -235,6 +235,7 @@ typedef struct tagGESTUREINFO
# define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
# define GC_ZOOM 0x00000001
+# define GC_ROTATE 0x00000001
typedef struct tagGESTURECONFIG
{
@@ -243,6 +244,8 @@ typedef struct tagGESTURECONFIG
DWORD dwBlock;
} GESTURECONFIG;
+# define GID_ROTATE_ANGLE_FROM_ARGUMENT(arg) ((((double)(arg) / 65535.0) * 4.0 * 3.14159265) - 2.0*3.14159265)
+
#endif // WM_GESTURE
#endif // Q_WS_WIN
@@ -284,7 +287,6 @@ public:
#if defined(Q_WS_X11)
#ifndef QT_NO_SETTINGS
- static QString kdeHome();
static QString x11_desktop_style();
static bool x11_apply_settings();
#endif
@@ -525,7 +527,6 @@ public:
static PtrCloseTouchInputHandle CloseTouchInputHandle;
QHash<DWORD, int> touchInputIDToTouchPointID;
- QList<QTouchEvent::TouchPoint> appAllTouchPoints;
bool translateTouchEvent(const MSG &msg);
PtrGetGestureInfo GetGestureInfo;
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 281be33..5843c34 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -431,11 +431,6 @@ extern QCursor *qt_grab_cursor();
#define __export
#endif
-QApplicationPrivate* getQApplicationPrivateInternal()
-{
- return qApp->d_func();
-}
-
extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
class QETWidget : public QWidget // event translator widget
@@ -1475,7 +1470,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
// we receive the message for each toplevel window included internal hidden ones,
// but the aboutToQuit signal should be emitted only once.
- QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
if (endsession && !qAppPriv->aboutToQuitEmitted) {
qAppPriv->aboutToQuitEmitted = true;
int index = QApplication::staticMetaObject.indexOfSignal("aboutToQuit()");
@@ -1662,7 +1657,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
} else {
switch (message) {
case WM_TOUCH:
- result = getQApplicationPrivateInternal()->translateTouchEvent(msg);
+ result = QApplicationPrivate::instance()->translateTouchEvent(msg);
break;
case WM_KEYDOWN: // keyboard event
case WM_SYSKEYDOWN:
@@ -3744,17 +3739,20 @@ bool QETWidget::translateGestureEvent(const MSG &msg)
if (qAppPriv->GetGestureInfo)
bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi);
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
+ BOOL bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi);
+ if (bResult) {
+ const QPoint widgetPos = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
+ QWidget *alienWidget = !internalWinId() ? this : childAt(widgetPos);
+ if (alienWidget && alienWidget->internalWinId())
+ alienWidget = 0;
+ QWidget *widget = alienWidget ? alienWidget : this;
- const QPoint widgetPos = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
- QWidget *alienWidget = !internalWinId() ? this : childAt(widgetPos);
- if (alienWidget && alienWidget->internalWinId())
- alienWidget = 0;
- QWidget *widget = alienWidget ? alienWidget : this;
+ QNativeGestureEvent event;
+ event.sequenceId = gi.dwSequenceID;
+ event.position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
+ event.argument = gi.ullArguments;
- QNativeGestureEvent event;
- event.sequenceId = gi.dwSequenceID;
- event.position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
- if (bResult) {
switch (gi.dwID) {
case GID_BEGIN:
event.gestureType = QNativeGestureEvent::GestureBegin;
@@ -3769,6 +3767,8 @@ bool QETWidget::translateGestureEvent(const MSG &msg)
event.gestureType = QNativeGestureEvent::Pan;
break;
case GID_ROTATE:
+ event.gestureType = QNativeGestureEvent::Rotate;
+ break;
case GID_TWOFINGERTAP:
case GID_ROLLOVER:
default:
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 4016563..32e7e3c 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -83,6 +83,7 @@
#include "qtimer.h"
#include "qlibrary.h"
#include <private/qgraphicssystemfactory_p.h>
+#include "qkde_p.h"
#if !defined (QT_NO_TABLET)
extern "C" {
@@ -813,33 +814,6 @@ Q_GUI_EXPORT void qt_x11_apply_settings_in_all_apps()
PropModeReplace, (unsigned char *)stamp.data(), stamp.size());
}
-static int kdeSessionVersion()
-{
- static int kdeVersion = 0;
- if (!kdeVersion)
- kdeVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();
- return kdeVersion;
-}
-
-/*! \internal
- Gets the current KDE 3 or 4 home path
-*/
-QString QApplicationPrivate::kdeHome()
-{
- static QString kdeHomePath;
- if (kdeHomePath.isEmpty()) {
- kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));
- if (kdeHomePath.isEmpty()) {
- QDir homeDir(QDir::homePath());
- QString kdeConfDir(QLatin1String("/.kde"));
- if (4 == kdeSessionVersion() && homeDir.exists(QLatin1String(".kde4")))
- kdeConfDir = QLatin1String("/.kde4");
- kdeHomePath = QDir::homePath() + kdeConfDir;
- }
- }
- return kdeHomePath;
-}
-
/*! \internal
apply the settings to the application
*/
@@ -905,8 +879,8 @@ bool QApplicationPrivate::x11_apply_settings()
QFont font(QApplication::font());
QString fontDescription;
// Override Qt font if KDE4 settings can be used
- if (4 == kdeSessionVersion()) {
- QSettings kdeSettings(kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
+ if (X11->desktopEnvironment == DE_KDE && X11->desktopVersion >= 4) {
+ QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
fontDescription = kdeSettings.value(QLatin1String("font")).toString();
if (fontDescription.isEmpty()) {
// KDE stores fonts without quotes
@@ -936,7 +910,6 @@ bool QApplicationPrivate::x11_apply_settings()
// read new QStyle
QString stylename = settings.value(QLatin1String("style")).toString();
-
if (stylename.isEmpty() && QApplicationPrivate::styleOverride.isNull() && X11->use_xrender) {
stylename = x11_desktop_style();
}
@@ -1094,22 +1067,6 @@ static void qt_set_input_encoding()
XFree((char *)data);
}
-// Reads a KDE color setting
-static QColor kdeColor(const QString &key, const QSettings &kdeSettings)
-{
- QVariant variant = kdeSettings.value(key);
- if (variant.isValid()) {
- QStringList values = variant.toStringList();
- if (values.size() == 3) {
- int r = values[0].toInt();
- int g = values[1].toInt();
- int b = values[2].toInt();
- return QColor(r, g, b);
- }
- }
- return QColor();
-}
-
// set font, foreground and background from x11 resources. The
// arguments may override the resource settings.
static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
@@ -1276,9 +1233,10 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
QApplicationPrivate::setSystemFont(fnt);
}
+ // QGtkStyle sets it's own system palette
+ bool gtkStyle = QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle");
bool kdeColors = (QApplication::desktopSettingsAware() && X11->desktopEnvironment == DE_KDE);
-
- if (kdeColors || (button || !resBG.isEmpty() || !resFG.isEmpty())) {// set app colors
+ if (!gtkStyle && (kdeColors || (button || !resBG.isEmpty() || !resFG.isEmpty()))) {// set app colors
bool allowX11ColorNames = QColor::allowX11ColorNames();
QColor::setAllowX11ColorNames(true);
@@ -1314,45 +1272,6 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
bright_mode = true;
}
- if (kdeColors) {
- const QSettings theKdeSettings(
- QApplicationPrivate::kdeHome()
- + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
-
- // Setup KDE palette
- QColor color;
- color = kdeColor(QLatin1String("buttonBackground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Button/BackgroundNormal"), theKdeSettings);
- if (color.isValid())
- btn = color;
-
- color = kdeColor(QLatin1String("background"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Window/BackgroundNormal"), theKdeSettings);
- if (color.isValid())
- bg = color;
-
- color = kdeColor(QLatin1String("foreground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:View/ForegroundNormal"), theKdeSettings);
- if (color.isValid()) {
- fg = color;
- }
-
- color = kdeColor(QLatin1String("windowForeground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Window/ForegroundNormal"), theKdeSettings);
- if (color.isValid())
- wfg = color;
-
- color = kdeColor(QLatin1String("windowBackground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:View/BackgroundNormal"), theKdeSettings);
- if (color.isValid())
- base = color;
- }
-
QPalette pal(fg, btn, btn.lighter(125), btn.darker(130), btn.darker(120), wfg.isValid() ? wfg : fg, Qt::white, base, bg);
QColor disabled((fg.red() + btn.red()) / 2,
(fg.green() + btn.green())/ 2,
@@ -1365,50 +1284,6 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
highlight = QColor(selectBackground);
highlightText = QColor(selectForeground);
}
- // Use KDE3 or KDE4 color settings if present
- if (kdeColors) {
- const QSettings theKdeSettings(
- QApplicationPrivate::kdeHome()
- + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
-
- QColor color = kdeColor(QLatin1String("selectBackground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Selection/BackgroundNormal"), theKdeSettings);
- if (color.isValid())
- highlight = color;
-
- color = kdeColor(QLatin1String("selectForeground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Selection/ForegroundNormal"), theKdeSettings);
- if (color.isValid())
- highlightText = color;
-
- color = kdeColor(QLatin1String("alternateBackground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:View/BackgroundAlternate"), theKdeSettings);
- if (color.isValid())
- pal.setColor(QPalette::AlternateBase, color);
- else
- pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(110));
-
- color = kdeColor(QLatin1String("buttonForeground"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:Button/ForegroundNormal"), theKdeSettings);
- if (color.isValid())
- pal.setColor(QPalette::ButtonText, color);
-
- color = kdeColor(QLatin1String("linkColor"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:View/ForegroundLink"), theKdeSettings);
- if (color.isValid())
- pal.setColor(QPalette::Link, color);
-
- color = kdeColor(QLatin1String("visitedLinkColor"), theKdeSettings);
- if (!color.isValid())
- color = kdeColor(QLatin1String("Colors:View/ForegroundVisited"), theKdeSettings);
- if (color.isValid())
- pal.setColor(QPalette::LinkVisited, color);
- }
if (highlight.isValid() && highlightText.isValid()) {
pal.setColor(QPalette::Highlight, highlight);
@@ -1431,10 +1306,9 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::darkBlue);
}
- // QGtkStyle sets it's own system palette
- if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) {
- QApplicationPrivate::setSystemPalette(pal);
- }
+ if (kdeColors)
+ pal = QKde::kdePalette().resolve(pal);
+ QApplicationPrivate::setSystemPalette(pal);
QColor::setAllowX11ColorNames(allowX11ColorNames);
}
@@ -2315,6 +2189,7 @@ void qt_init(QApplicationPrivate *priv, int,
X11->compositingManagerRunning = XGetSelectionOwner(X11->display,
ATOM(_NET_WM_CM_S0));
X11->desktopEnvironment = DE_UNKNOWN;
+ X11->desktopVersion = 0;
// See if the current window manager is using the freedesktop.org spec to give its name
Window windowManagerWindow = XNone;
@@ -2390,6 +2265,9 @@ void qt_init(QApplicationPrivate *priv, int,
XFree((char *)data);
}
+ if (X11->desktopEnvironment == DE_KDE)
+ X11->desktopVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();
+
qt_set_input_encoding();
qt_set_x11_resources(appFont, appFGCol, appBGCol, appBTNCol);
@@ -2657,44 +2535,30 @@ void qt_init(QApplicationPrivate *priv, int,
QString QApplicationPrivate::x11_desktop_style()
{
QString stylename;
- QStringList availableStyles = QStyleFactory::keys();
- // Override Qt style if KDE4 settings can be used
- if (4 == kdeSessionVersion()) {
- QSettings kdeSettings(kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
- QString kde4Style = kdeSettings.value(QLatin1String("widgetStyle"),
- QLatin1String("Oxygen")).toString();
- foreach (const QString &style, availableStyles) {
- if (style.toLower() == kde4Style.toLower())
- stylename = kde4Style;
- }
- // Set QGtkStyle for GNOME
- } else if (X11->desktopEnvironment == DE_GNOME) {
+ switch(X11->desktopEnvironment) {
+ case DE_KDE:
+ stylename = QKde::kdeStyle();
+ break;
+ case DE_GNOME: {
+ QStringList availableStyles = QStyleFactory::keys();
+ // Set QGtkStyle for GNOME if available
QString gtkStyleKey = QString::fromLatin1("GTK+");
- if (availableStyles.contains(gtkStyleKey))
+ if (availableStyles.contains(gtkStyleKey)) {
stylename = gtkStyleKey;
- }
-
- if (stylename.isEmpty()) {
- switch(X11->desktopEnvironment) {
- case DE_KDE:
- if (X11->use_xrender)
- stylename = QLatin1String("plastique");
- else
- stylename = QLatin1String("windows");
- break;
- case DE_GNOME:
- if (X11->use_xrender)
- stylename = QLatin1String("cleanlooks");
- else
- stylename = QLatin1String("windows");
- break;
- case DE_CDE:
- stylename = QLatin1String("cde");
- break;
- default:
- // Don't do anything
break;
}
+ if (X11->use_xrender)
+ stylename = QLatin1String("cleanlooks");
+ else
+ stylename = QLatin1String("windows");
+ break;
+ }
+ case DE_CDE:
+ stylename = QLatin1String("cde");
+ break;
+ default:
+ // Don't do anything
+ break;
}
return stylename;
}
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index b21b35c..2ff672b 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -133,9 +133,9 @@ public:
};
QNativeGestureEvent()
- : QEvent(QEvent::NativeGesture), gestureType(None), percentage(0), direction(0, 0)
+ : QEvent(QEvent::NativeGesture), gestureType(None), percentage(0)
#ifdef Q_WS_WIN
- , sequenceId(0)
+ , sequenceId(0), argument(0)
#endif
{
}
@@ -146,6 +146,7 @@ public:
QSize direction;
#ifdef Q_WS_WIN
ulong sequenceId;
+ quint64 argument;
#endif
};
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index 38e8851..672fc1c 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -204,7 +204,7 @@ Qt::GestureState QGesture::state() const
\a state, and it should be called after all the internal properties have been
initialized.
- \sa started, triggered, finished, cancelled
+ \sa started(), triggered(), finished(), cancelled()
*/
void QGesture::updateState(Qt::GestureState state)
{
diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h
index 7da37c4..839fdca 100644
--- a/src/gui/kernel/qgesture.h
+++ b/src/gui/kernel/qgesture.h
@@ -73,14 +73,13 @@ public:
void setGraphicsItem(QGraphicsItem *);
QGraphicsItem *graphicsItem() const;
- virtual void reset();
-
Qt::GestureState state() const;
protected:
QGesture(QGesturePrivate &dd, QObject *parent);
bool eventFilter(QObject*, QEvent*);
+ virtual void reset();
void updateState(Qt::GestureState state);
Q_SIGNALS:
diff --git a/src/gui/kernel/qkde.cpp b/src/gui/kernel/qkde.cpp
new file mode 100644
index 0000000..96ff21e
--- /dev/null
+++ b/src/gui/kernel/qkde.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qkde_p.h"
+#include <QtCore/QLibrary>
+#include <QtCore/QDir>
+#include <QtCore/qdebug.h>
+#include <QtCore/QSettings>
+#include "QtGui/qstylefactory.h"
+#include "qt_x11_p.h"
+
+#if defined(Q_WS_X11)
+
+QT_BEGIN_NAMESPACE
+
+/*! \internal
+Gets the current KDE home path
+like "/home/troll/.kde"
+*/
+QString QKde::kdeHome()
+{
+ static QString kdeHomePath;
+ if (kdeHomePath.isEmpty()) {
+ kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));
+ if (kdeHomePath.isEmpty()) {
+ QDir homeDir(QDir::homePath());
+ QString kdeConfDir(QLatin1String("/.kde"));
+ if (4 == X11->desktopVersion && homeDir.exists(QLatin1String(".kde4")))
+ kdeConfDir = QLatin1String("/.kde4");
+ kdeHomePath = QDir::homePath() + kdeConfDir;
+ }
+ }
+ return kdeHomePath;
+}
+
+/*!\internal
+ Reads the color from the config, and store it in the palette with the given color role if found
+ */
+static bool kdeColor(QPalette *pal, QPalette::ColorRole role, const QSettings &kdeSettings, const QString &kde4Key, const QString &kde3Key = QString())
+{
+ QVariant variant = kdeSettings.value(kde4Key);
+ if (!variant.isValid())
+ QVariant variant = kdeSettings.value(kde3Key);
+ if (variant.isValid()) {
+ QStringList values = variant.toStringList();
+ if (values.size() == 3) {
+ int r = values[0].toInt();
+ int g = values[1].toInt();
+ int b = values[2].toInt();
+ pal->setBrush(role, QColor(r, g, b));
+ return true;
+ }
+ }
+ return false;
+}
+
+
+/*!\internal
+ Returns the KDE palette
+*/
+QPalette QKde::kdePalette()
+{
+ const QSettings theKdeSettings(QKde::kdeHome() +
+ QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
+ QPalette pal;
+
+ // Setup KDE palette
+ kdeColor(&pal, QPalette::Button, theKdeSettings, QLatin1String("Colors:Button/BackgroundNormal"), QLatin1String("buttonBackground"));
+ kdeColor(&pal, QPalette::Window, theKdeSettings, QLatin1String("Colors:Window/BackgroundNormal"), QLatin1String("background"));
+ kdeColor(&pal, QPalette::Text, theKdeSettings, QLatin1String("Colors:View/ForegroundNormal"), QLatin1String("foreground"));
+ kdeColor(&pal, QPalette::WindowText, theKdeSettings, QLatin1String("Colors:Window/ForegroundNormal"), QLatin1String("windowForeground"));
+ kdeColor(&pal, QPalette::Base, theKdeSettings, QLatin1String("Colors:View/BackgroundNormal"), QLatin1String("windowBackground"));
+ kdeColor(&pal, QPalette::Highlight, theKdeSettings, QLatin1String("Colors:Selection/BackgroundNormal"), QLatin1String("selectBackground"));
+ kdeColor(&pal, QPalette::HighlightedText, theKdeSettings, QLatin1String("Colors:Selection/ForegroundNormal"), QLatin1String("selectForeground"));
+ kdeColor(&pal, QPalette::AlternateBase, theKdeSettings, QLatin1String("Colors:View/BackgroundAlternate"), QLatin1String("alternateBackground"));
+ kdeColor(&pal, QPalette::ButtonText, theKdeSettings, QLatin1String("Colors:Button/ForegroundNormal"), QLatin1String("buttonForeground"));
+ kdeColor(&pal, QPalette::Link, theKdeSettings, QLatin1String("Colors:View/ForegroundLink"), QLatin1String("linkColor"));
+ kdeColor(&pal, QPalette::LinkVisited, theKdeSettings, QLatin1String("Colors:View/ForegroundVisited"), QLatin1String("visitedLinkColor"));
+ //## TODO tooltip color
+
+ return pal;
+}
+
+/*!\internal
+ Returns the name of the QStyle to use.
+ (read from the kde config if needed)
+*/
+QString QKde::kdeStyle()
+{
+ if (X11->desktopVersion >= 4) {
+ QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
+ QString style = kdeSettings.value(QLatin1String("widgetStyle"), QLatin1String("Oxygen")).toString();
+
+ QStringList availableStyles = QStyleFactory::keys();
+ if(availableStyles.contains(style, Qt::CaseInsensitive))
+ return style;
+ }
+
+ if (X11->use_xrender)
+ return QLatin1String("plastique");
+ else
+ return QLatin1String("windows");
+
+ return QString();
+}
+
+/*!\internal
+ placeholder to load icon from kde.
+ to be implemented
+ */
+QIcon QKde::kdeIcon(const QString &name)
+{
+ //###todo
+ return QIcon();
+}
+
+QT_END_NAMESPACE
+
+#endif //Q_WS_X11
+
diff --git a/src/gui/kernel/qkde_p.h b/src/gui/kernel/qkde_p.h
new file mode 100644
index 0000000..ac760bd
--- /dev/null
+++ b/src/gui/kernel/qkde_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QKDE_H
+#define QKDE_H
+
+#include <QtCore/qglobal.h>
+#include <QtGui/QPalette>
+#include <QtGui/QIcon>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+#if defined(Q_WS_X11)
+
+
+QT_BEGIN_NAMESPACE
+
+// This namespace contains helper function to help KDE integration
+namespace QKde {
+ QString kdeHome();
+ QString kdeStyle();
+ QPalette kdePalette();
+ QIcon kdeIcon(const QString &name);
+}
+
+
+QT_END_NAMESPACE
+
+#endif // Q_WS_X11
+#endif // QKDE_H
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 7078dbf..b4c3787 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -132,8 +132,7 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
it = qAppPriv->widgetGestures.find(static_cast<QWidget*>(receiver));
if (it == qAppPriv->widgetGestures.end())
return false;
- QPanGesture *gesture = it.value().pan;
- if (this != gesture)
+ if (this != it.value().pan)
return false;
Qt::GestureState nextState = Qt::NoGesture;
switch(ev->gestureType) {
@@ -162,7 +161,7 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
d->totalOffset += d->lastOffset;
}
d->lastPosition = ev->position;
- gesture->updateState(nextState);
+ updateState(nextState);
return true;
}
#endif
@@ -248,6 +247,7 @@ void QPanGesture::reset()
d->panFinishedTimer = 0;
}
#endif
+ QGesture::reset();
}
/*!
@@ -273,6 +273,210 @@ QSize QPanGesture::lastOffset() const
return d->lastOffset;
}
+
+/*!
+ \class QPinchGesture
+ \since 4.6
+
+ \brief The QPinchGesture class represents a Pinch gesture,
+ providing additional information related to zooming and/or rotation.
+*/
+
+/*!
+ Creates a new Pinch gesture handler object and marks it as a child of \a
+ parent.
+
+ On some platform like Windows it's necessary to provide a non-null widget
+ as \a parent to get native gesture support.
+*/
+QPinchGesture::QPinchGesture(QWidget *parent)
+ : QGesture(*new QPinchGesturePrivate, parent)
+{
+ if (parent) {
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
+ qAppPriv->widgetGestures[parent].pinch = this;
+#ifdef Q_WS_WIN
+ qt_widget_private(parent)->winSetupGestures();
+#endif
+ }
+}
+
+/*! \internal */
+bool QPinchGesture::event(QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::ParentAboutToChange:
+ if (QWidget *w = qobject_cast<QWidget*>(parent())) {
+ QApplicationPrivate::instance()->widgetGestures[w].pinch = 0;
+#ifdef Q_WS_WIN
+ qt_widget_private(w)->winSetupGestures();
+#endif
+ }
+ break;
+ case QEvent::ParentChange:
+ if (QWidget *w = qobject_cast<QWidget*>(parent())) {
+ QApplicationPrivate::instance()->widgetGestures[w].pinch = this;
+#ifdef Q_WS_WIN
+ qt_widget_private(w)->winSetupGestures();
+#endif
+ }
+ break;
+ default:
+ break;
+ }
+ return QObject::event(event);
+}
+
+bool QPinchGesture::eventFilter(QObject *receiver, QEvent *event)
+{
+#ifdef Q_WS_WIN
+ Q_D(QPinchGesture);
+ if (receiver->isWidgetType() && event->type() == QEvent::NativeGesture) {
+ QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
+ QApplicationPrivate::WidgetStandardGesturesMap::iterator it;
+ it = qAppPriv->widgetGestures.find(static_cast<QWidget*>(receiver));
+ if (it == qAppPriv->widgetGestures.end())
+ return false;
+ if (this != it.value().pinch)
+ return false;
+ Qt::GestureState nextState = Qt::NoGesture;
+ switch(ev->gestureType) {
+ case QNativeGestureEvent::GestureBegin:
+ // next we might receive the first gesture update event, so we
+ // prepare for it.
+ d->state = Qt::NoGesture;
+ d->scaleFactor = d->lastScaleFactor = 1;
+ d->rotationAngle = d->lastRotationAngle = 0;
+ d->startCenterPoint = d->centerPoint = d->lastCenterPoint = QPoint();
+ d->initialDistance = 0;
+ return false;
+ case QNativeGestureEvent::Rotate:
+ d->lastRotationAngle = d->rotationAngle;
+ d->rotationAngle = -1 * GID_ROTATE_ANGLE_FROM_ARGUMENT(ev->argument);
+ nextState = Qt::GestureUpdated;
+ event->accept();
+ break;
+ case QNativeGestureEvent::Zoom:
+ if (d->initialDistance != 0) {
+ d->lastScaleFactor = d->scaleFactor;
+ int distance = int(qint64(ev->argument));
+ d->scaleFactor = (qreal) distance / d->initialDistance;
+ } else {
+ d->initialDistance = int(qint64(ev->argument));
+ }
+ nextState = Qt::GestureUpdated;
+ event->accept();
+ break;
+ case QNativeGestureEvent::GestureEnd:
+ if (state() == Qt::NoGesture)
+ return false; // some other gesture has ended
+ nextState = Qt::GestureFinished;
+ break;
+ default:
+ return false;
+ }
+ if (d->startCenterPoint.isNull())
+ d->startCenterPoint = d->centerPoint;
+ d->lastCenterPoint = d->centerPoint;
+ d->centerPoint = static_cast<QWidget*>(receiver)->mapFromGlobal(ev->position);
+ updateState(nextState);
+ return true;
+ }
+#endif
+ return QGesture::eventFilter(receiver, event);
+}
+
+/*! \internal */
+bool QPinchGesture::filterEvent(QEvent *event)
+{
+ Q_UNUSED(event);
+ return false;
+}
+
+/*! \internal */
+void QPinchGesture::reset()
+{
+ Q_D(QPinchGesture);
+ d->scaleFactor = d->lastScaleFactor = 0;
+ d->rotationAngle = d->lastRotationAngle = 0;
+ d->startCenterPoint = d->centerPoint = d->lastCenterPoint = QPoint();
+ QGesture::reset();
+}
+
+/*!
+ \property QPinchGesture::scaleFactor
+
+ Specifies a scale factor of the pinch gesture.
+*/
+qreal QPinchGesture::scaleFactor() const
+{
+ return d_func()->scaleFactor;
+}
+
+/*!
+ \property QPinchGesture::lastScaleFactor
+
+ Specifies a previous scale factor of the pinch gesture.
+*/
+qreal QPinchGesture::lastScaleFactor() const
+{
+ return d_func()->lastScaleFactor;
+}
+
+/*!
+ \property QPinchGesture::rotationAngle
+
+ Specifies a rotation angle of the gesture.
+*/
+qreal QPinchGesture::rotationAngle() const
+{
+ return d_func()->rotationAngle;
+}
+
+/*!
+ \property QPinchGesture::lastRotationAngle
+
+ Specifies a previous rotation angle of the gesture.
+*/
+qreal QPinchGesture::lastRotationAngle() const
+{
+ return d_func()->lastRotationAngle;
+}
+
+/*!
+ \property QPinchGesture::centerPoint
+
+ Specifies a center point of the gesture. The point can be used as a center
+ point that the object is rotated around.
+*/
+QPoint QPinchGesture::centerPoint() const
+{
+ return d_func()->centerPoint;
+}
+
+/*!
+ \property QPinchGesture::lastCenterPoint
+
+ Specifies a previous center point of the gesture.
+*/
+QPoint QPinchGesture::lastCenterPoint() const
+{
+ return d_func()->lastCenterPoint;
+}
+
+/*!
+ \property QPinchGesture::startCenterPoint
+
+ Specifies an initial center point of the gesture. Difference between the
+ startCenterPoint and the centerPoint is the distance at which pinching
+ fingers has shifted.
+*/
+QPoint QPinchGesture::startCenterPoint() const
+{
+ return d_func()->startCenterPoint;
+}
+
QT_END_NAMESPACE
#include "moc_qstandardgestures.cpp"
diff --git a/src/gui/kernel/qstandardgestures.h b/src/gui/kernel/qstandardgestures.h
index c734fba..adee740 100644
--- a/src/gui/kernel/qstandardgestures.h
+++ b/src/gui/kernel/qstandardgestures.h
@@ -66,11 +66,52 @@ public:
QPanGesture(QWidget *parent);
bool filterEvent(QEvent *event);
- void reset();
QSize totalOffset() const;
QSize lastOffset() const;
+protected:
+ void reset();
+
+private:
+ bool event(QEvent *event);
+ bool eventFilter(QObject *receiver, QEvent *event);
+
+ friend class QWidget;
+};
+
+class QPinchGesturePrivate;
+class Q_GUI_EXPORT QPinchGesture : public QGesture
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPinchGesture)
+
+ Q_PROPERTY(qreal scaleFactor READ scaleFactor)
+ Q_PROPERTY(qreal lastScaleFactor READ lastScaleFactor)
+
+ Q_PROPERTY(qreal rotationAngle READ rotationAngle)
+ Q_PROPERTY(qreal lastRotationAngle READ lastRotationAngle)
+
+ Q_PROPERTY(QPoint startCenterPoint READ startCenterPoint)
+ Q_PROPERTY(QPoint lastCenterPoint READ lastCenterPoint)
+ Q_PROPERTY(QPoint centerPoint READ centerPoint)
+
+public:
+ QPinchGesture(QWidget *parent);
+
+ bool filterEvent(QEvent *event);
+ void reset();
+
+ QPoint startCenterPoint() const;
+ QPoint lastCenterPoint() const;
+ QPoint centerPoint() const;
+
+ qreal scaleFactor() const;
+ qreal lastScaleFactor() const;
+
+ qreal rotationAngle() const;
+ qreal lastRotationAngle() const;
+
private:
bool event(QEvent *event);
bool eventFilter(QObject *receiver, QEvent *event);
diff --git a/src/gui/kernel/qstandardgestures_p.h b/src/gui/kernel/qstandardgestures_p.h
index 0fe24ee..43636d0 100644
--- a/src/gui/kernel/qstandardgestures_p.h
+++ b/src/gui/kernel/qstandardgestures_p.h
@@ -85,6 +85,31 @@ public:
#endif
};
+class QPinchGesturePrivate : public QGesturePrivate
+{
+ Q_DECLARE_PUBLIC(QPinchGesture)
+
+public:
+ QPinchGesturePrivate()
+ : scaleFactor(0), lastScaleFactor(0),
+ rotationAngle(0), lastRotationAngle(0)
+#ifdef Q_WS_WIN
+ ,initialDistance(0)
+#endif
+ {
+ }
+ qreal scaleFactor;
+ qreal lastScaleFactor;
+ qreal rotationAngle;
+ qreal lastRotationAngle;
+ QPoint startCenterPoint;
+ QPoint lastCenterPoint;
+ QPoint centerPoint;
+#ifdef Q_WS_WIN
+ int initialDistance;
+#endif
+};
+
QT_END_NAMESPACE
#endif // QSTANDARDGESTURES_P_H
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index 1ac51e0..44652d3 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -515,7 +515,8 @@ struct QX11Data
char *startupId;
- DesktopEnvironment desktopEnvironment;
+ DesktopEnvironment desktopEnvironment : 8;
+ uint desktopVersion : 8; /* Used only for KDE */
/* Warning: if you modify this list, modify the names of atoms in qapplication_x11.cpp as well! */
enum X11Atom {
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 7cfa111..510df7f 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -1160,6 +1160,8 @@ void QWidgetPrivate::show_sys()
data.window_state |= Qt::WindowMaximized;
}
+ winSetupGestures();
+
invalidateBuffer(q->rect());
}
#endif //Q_WS_WINCE
@@ -2058,8 +2060,11 @@ void QWidgetPrivate::winSetupGestures()
Q_Q(QWidget);
if (!q)
return;
- extern QApplicationPrivate* getQApplicationPrivateInternal();
- QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+ q->setAttribute(Qt::WA_DontCreateNativeAncestors);
+ q->setAttribute(Qt::WA_NativeWindow);
+ if (!q->isVisible())
+ return;
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
bool needh = false;
bool needv = false;
bool singleFingerPanEnabled = false;
@@ -2072,34 +2077,43 @@ void QWidgetPrivate::winSetupGestures()
QScrollBar *vbar = asa->verticalScrollBar();
Qt::ScrollBarPolicy hbarpolicy = asa->horizontalScrollBarPolicy();
Qt::ScrollBarPolicy vbarpolicy = asa->verticalScrollBarPolicy();
- needh = (hbarpolicy == Qt::ScrollBarAlwaysOn
- || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum()));
- needv = (vbarpolicy == Qt::ScrollBarAlwaysOn
- || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
+ needh = (hbarpolicy == Qt::ScrollBarAlwaysOn ||
+ (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum()));
+ needv = (vbarpolicy == Qt::ScrollBarAlwaysOn ||
+ (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled;
} else {
winid = q->winId();
}
if (qAppPriv->SetGestureConfig) {
- GESTURECONFIG gc[2];
+ GESTURECONFIG gc[3];
+ memset(gc, 0, sizeof(gc));
gc[0].dwID = GID_PAN;
- if (gestures.pan || needh || needv) {
+ if (gestures.pan) {
gc[0].dwWant = GC_PAN;
- gc[0].dwBlock = 0;
if (needv && singleFingerPanEnabled)
gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
+ else
+ gc[0].dwBlock |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
if (needh && singleFingerPanEnabled)
gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
+ else
+ gc[0].dwBlock |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
} else {
- gc[0].dwWant = 0;
gc[0].dwBlock = GC_PAN;
}
gc[1].dwID = GID_ZOOM;
- if (gestures.pinch) {
+ if (gestures.pinch)
gc[1].dwWant = GC_ZOOM;
- gc[1].dwBlock = 0;
- }
+ else
+ gc[1].dwBlock = GC_ZOOM;
+ gc[2].dwID = GID_ROTATE;
+ if (gestures.pinch)
+ gc[2].dwWant = GC_ROTATE;
+ else
+ gc[2].dwBlock = GC_ROTATE;
+
Q_ASSERT(winid);
qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0]));
}
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index 2a3d2f3..cf65af3 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -512,6 +512,13 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
dialog = popup = false; // force these flags off
data.crect.setRect(0, 0, sw, sh);
} else if (topLevel && !q->testAttribute(Qt::WA_Resized)) {
+ QDesktopWidget *desktopWidget = qApp->desktop();
+ if (desktopWidget->isVirtualDesktop()) {
+ QRect r = desktopWidget->screenGeometry();
+ sw = r.width();
+ sh = r.height();
+ }
+
int width = sw / 2;
int height = 4 * sh / 10;
if (extra) {
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 74456dd..b260f41 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -2542,6 +2542,9 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
qDebug() << " - QRasterPaintEngine::drawImage(), r=" << r << " sr=" << sr << " image=" << img.size() << "depth=" << img.depth();
#endif
+ if (r.isEmpty())
+ return;
+
Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state();
const bool aa = s->flags.antialiased || s->flags.bilinear;
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index ba28e75..c7feb25 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -63,7 +63,7 @@
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qrubberband.h>
-#include <private/qapplication_p.h>
+#include <../kernel/qkde_p.h>
#include <private/qcommonstylepixmaps_p.h>
#include <private/qmath_p.h>
#include <private/qstylehelper_p.h>
@@ -842,12 +842,6 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut
#ifdef Q_WS_X11 // These functions are used to parse the X11 freedesktop icon spec
-static int kdeVersion()
-{
- static int kdeVersion = qgetenv("KDE_SESSION_VERSION").toInt();
- return kdeVersion;
-}
-
void QCommonStylePrivate::lookupIconTheme() const
{
if (!themeName.isEmpty())
@@ -856,7 +850,7 @@ void QCommonStylePrivate::lookupIconTheme() const
QString dataDirs = QString::fromLocal8Bit(getenv("XDG_DATA_DIRS"));
if (dataDirs.isEmpty())
dataDirs = QLatin1String("/usr/local/share/:/usr/share/");
- dataDirs += QLatin1Char(':') + QApplicationPrivate::kdeHome() + QLatin1String("/share");
+ dataDirs += QLatin1Char(':') + QKde::kdeHome() + QLatin1String("/share");
dataDirs.prepend(QDir::homePath() + QLatin1String("/:"));
QStringList kdeDirs = QString::fromLocal8Bit(getenv("KDEDIRS")).split(QLatin1Char(':'), QString::SkipEmptyParts);
foreach (const QString &dirName, kdeDirs)
@@ -865,9 +859,10 @@ void QCommonStylePrivate::lookupIconTheme() const
QFileInfo fileInfo(QLatin1String("/usr/share/icons/default.kde"));
QDir dir(fileInfo.canonicalFilePath());
- QString kdeDefault = kdeVersion() >= 4 ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg");
+ QString kdeDefault = (X11->desktopEnvironment != DE_KDE || X11->desktopVersion >= 4)
+ ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg");
QString defaultTheme = fileInfo.exists() ? dir.dirName() : kdeDefault;
- QSettings settings(QApplicationPrivate::kdeHome() +
+ QSettings settings(QKde::kdeHome() +
QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
settings.beginGroup(QLatin1String("Icons"));
themeName = settings.value(QLatin1String("Theme"), defaultTheme).toString();
@@ -979,8 +974,15 @@ QPixmap QCommonStylePrivate::findIconHelper(int size,
return pixmap;
}
+/*! \internal
+ find a pixmap with the given size and name from the freedesktop theme.
+*/
QPixmap QCommonStylePrivate::findIcon(int size, const QString &name) const
{
+ QIcon icon = QKde::kdeIcon(name);
+ if (!icon.isNull())
+ return icon.pixmap(size);
+
QPixmap pixmap;
QString pixmapName = QLatin1String("$qt") + name + QString::number(size);
@@ -995,12 +997,17 @@ QPixmap QCommonStylePrivate::findIcon(int size, const QString &name) const
return pixmap;
}
+/*! \internal
+ create an Icon from the freedesktop theme.
+ */
QIcon QCommonStylePrivate::createIcon(const QString &name) const
{
- QIcon icon;
- icon.addPixmap(findIcon(16, name));
- icon.addPixmap(findIcon(24, name));
- icon.addPixmap(findIcon(32, name));
+ QIcon icon = QKde::kdeIcon(name);
+ if (icon.isNull()) {
+ icon.addPixmap(findIcon(16, name));
+ icon.addPixmap(findIcon(24, name));
+ icon.addPixmap(findIcon(32, name));
+ }
return icon;
}
/*!internal
@@ -1012,8 +1019,8 @@ from the KDE configuration file
int QCommonStylePrivate::lookupToolButtonStyle() const
{
int result = Qt::ToolButtonIconOnly;
- if (kdeVersion() >= 4) {
- QSettings settings(QApplicationPrivate::kdeHome() +
+ if (X11->desktopEnvironment == DE_KDE && X11->desktopVersion >= 4) {
+ QSettings settings(QKde::kdeHome() +
QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
settings.beginGroup(QLatin1String("Toolbar style"));
QString toolbarStyle = settings.value(QLatin1String("ToolButtonStyle"), QLatin1String("TextBesideIcon")).toString();
diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
index ee29b55..cad6903 100644
--- a/src/gui/widgets/qdockarealayout.cpp
+++ b/src/gui/widgets/qdockarealayout.cpp
@@ -1545,7 +1545,7 @@ void QDockAreaLayoutInfo::apply(bool animate)
QRect geo = w->geometry();
widgetAnimator.animate(w, r, animate);
- if (!w->isHidden()) {
+ if (!w->isHidden() && w->window()->isVisible()) {
QDockWidget *dw = qobject_cast<QDockWidget*>(w);
if (!r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) {
dw->lower();
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp
index 5810c81..e60f099 100644
--- a/src/gui/widgets/qdockwidget.cpp
+++ b/src/gui/widgets/qdockwidget.cpp
@@ -1390,7 +1390,7 @@ bool QDockWidget::event(QEvent *event)
break;
case QEvent::Show:
d->toggleViewAction->setChecked(true);
- emit visibilityChanged(true);
+ emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0);
break;
#endif
case QEvent::ApplicationLayoutDirectionChange:
diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp
index b4a0ef0..afd526a 100644
--- a/src/gui/widgets/qtoolbararealayout.cpp
+++ b/src/gui/widgets/qtoolbararealayout.cpp
@@ -1156,8 +1156,8 @@ QLayoutItem *QToolBarAreaLayout::unplug(const QList<int> &path, QToolBarAreaLayo
if (!next.skip()) {
newExtraSpace = next.pos - previous.pos - pick(line.o, previous.sizeHint());
previous.resize(line.o, next.pos - previous.pos);
+ break;
}
- break;
}
break;
}
diff --git a/src/network/access/qhttp.cpp b/src/network/access/qhttp.cpp
index faa2398..4c06848 100644
--- a/src/network/access/qhttp.cpp
+++ b/src/network/access/qhttp.cpp
@@ -1597,11 +1597,11 @@ QHttp::~QHttp()
This enum is used to specify the mode of connection to use:
- \value ConnectionModeHttp The connection is a regular Http connection to the server
- \value ConnectionModeHttps The Https protocol is used and the connection is encrypted using SSL.
+ \value ConnectionModeHttp The connection is a regular HTTP connection to the server
+ \value ConnectionModeHttps The HTTPS protocol is used and the connection is encrypted using SSL.
- When using the Https mode, care should be taken to connect to the sslErrors signal, and
- handle possible Ssl errors.
+ When using the HTTPS mode, care should be taken to connect to the sslErrors signal, and
+ handle possible SSL errors.
\sa QSslSocket
*/
@@ -2039,7 +2039,7 @@ int QHttp::setHost(const QString &hostName, quint16 port)
port \a port using the connection mode \a mode.
If port is 0, it will use the default port for the \a mode used
- (80 for Http and 443 fopr Https).
+ (80 for HTTP and 443 for HTTPS).
The function does not block; instead, it returns immediately. The request
is scheduled, and its execution is performed asynchronously. The
diff --git a/src/network/access/qnetworkcookie.h b/src/network/access/qnetworkcookie.h
index ef309a8..4bc3f3f 100644
--- a/src/network/access/qnetworkcookie.h
+++ b/src/network/access/qnetworkcookie.h
@@ -106,9 +106,6 @@ private:
};
Q_DECLARE_TYPEINFO(QNetworkCookie, Q_MOVABLE_TYPE);
-// ### Qt5 remove this include
-#include "qnetworkcookiejar.h"
-
#ifndef QT_NO_DEBUG_STREAM
class QDebug;
Q_NETWORK_EXPORT QDebug operator<<(QDebug, const QNetworkCookie &);
@@ -116,6 +113,9 @@ Q_NETWORK_EXPORT QDebug operator<<(QDebug, const QNetworkCookie &);
QT_END_NAMESPACE
+// ### Qt5 remove this include
+#include "qnetworkcookiejar.h"
+
Q_DECLARE_METATYPE(QNetworkCookie)
Q_DECLARE_METATYPE(QList<QNetworkCookie>)
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index 90fd9a5..6f2024f 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -341,4 +341,29 @@ QImage::Format QVGPixmapData::sourceFormat() const
return QImage::Format_ARGB32_Premultiplied;
}
+/*
+ \internal
+
+ Returns the VGImage that is storing the contents of \a pixmap.
+ Returns VG_INVALID_HANDLE if \a pixmap is not owned by the OpenVG
+ graphics system or \a pixmap is invalid.
+
+ This function is typically used to access the backing store
+ for a pixmap when executing raw OpenVG calls. It must only
+ be used when a QPainter is active and the OpenVG paint engine
+ is in use by the QPainter.
+
+ \sa {QtOpenVG Module}
+*/
+Q_OPENVG_EXPORT VGImage qPixmapToVGImage(const QPixmap& pixmap)
+{
+ QPixmapData *pd = pixmap.pixmapData();
+ if (pd->classId() == QPixmapData::OpenVGClass) {
+ QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
+ if (vgpd->isValid())
+ return vgpd->toVGImage();
+ }
+ return VG_INVALID_HANDLE;
+}
+
QT_END_NAMESPACE
diff --git a/src/qbase.pri b/src/qbase.pri
index 0ab04e6..9e2d26f 100644
--- a/src/qbase.pri
+++ b/src/qbase.pri
@@ -13,7 +13,7 @@ mac:!contains(QMAKE_EXT_C, .mm):QMAKE_EXT_C += .mm
#load up the headers info
CONFIG += qt_install_headers
HEADERS_PRI = $$QT_BUILD_TREE/include/$$TARGET/headers.pri
-include($$HEADERS_PRI)|clear(HEADERS_PRI)
+include($$HEADERS_PRI, "", true)|clear(HEADERS_PRI)
#version overriding
win32 {
diff --git a/src/script/qscriptable.cpp b/src/script/qscriptable.cpp
index 5da9e95..94468de 100644
--- a/src/script/qscriptable.cpp
+++ b/src/script/qscriptable.cpp
@@ -39,10 +39,10 @@
**
****************************************************************************/
-#ifndef QT_NO_QOBJECT
-
#include "qscriptable.h"
+#ifndef QT_NO_QOBJECT
+
#ifndef QT_NO_SCRIPT
#include "qscriptable_p.h"
diff --git a/src/script/qscriptable_p.h b/src/script/qscriptable_p.h
index 8ea65ed..1d297d9 100644
--- a/src/script/qscriptable_p.h
+++ b/src/script/qscriptable_p.h
@@ -55,7 +55,7 @@
// We mean it.
//
-#if !defined(QT_NO_QOBJECT) && !defined(QT_NO_SCRIPT)
+#ifndef QT_NO_SCRIPT
QT_BEGIN_NAMESPACE
@@ -79,6 +79,6 @@ public:
QT_END_NAMESPACE
-#endif // QT_NO_QOBJECT && QT_NO_SCRIPT
+#endif // QT_NO_SCRIPT
#endif
diff --git a/src/script/qscriptclassdata.cpp b/src/script/qscriptclassdata.cpp
index 08e7220..576a519 100644
--- a/src/script/qscriptclassdata.cpp
+++ b/src/script/qscriptclassdata.cpp
@@ -114,4 +114,4 @@ QScriptClassDataIterator::~QScriptClassDataIterator()
QT_END_NAMESPACE
-#endif
+#endif // QT_NO_SCRIPT
diff --git a/src/testlib/qabstracttestlogger.cpp b/src/testlib/qabstracttestlogger.cpp
index 6482ec9..6b4b375 100644
--- a/src/testlib/qabstracttestlogger.cpp
+++ b/src/testlib/qabstracttestlogger.cpp
@@ -43,8 +43,11 @@
#include "QtTest/private/qtestlog_p.h"
#include "QtTest/qtestassert.h"
+#include "QtCore/qbytearray.h"
+
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#ifndef Q_OS_WIN
#include <unistd.h>
@@ -106,4 +109,50 @@ void QAbstractTestLogger::stopLogging()
QTest::stream = 0;
}
+namespace QTest
+{
+
+extern void filter_unprintable(char *str);
+
+/*!
+ \fn int QTest::qt_asprintf(QTestCharBuffer *buf, const char *format, ...);
+ \internal
+ */
+int qt_asprintf(QTestCharBuffer *str, const char *format, ...)
+{
+ static const int MAXSIZE = 1024*1024*2;
+
+ Q_ASSERT(str);
+
+ int size = str->size();
+
+ va_list ap;
+ int res = 0;
+
+ for (;;) {
+ va_start(ap, format);
+ res = qvsnprintf(str->data(), size, format, ap);
+ va_end(ap);
+ str->data()[size - 1] = '\0';
+ if (res >= 0 && res < size) {
+ // We succeeded
+ break;
+ }
+ // buffer wasn't big enough, try again.
+ // Note, we're assuming that a result of -1 is always due to running out of space.
+ size *= 2;
+ if (size > MAXSIZE) {
+ break;
+ }
+ if (!str->reset(size))
+ break; // out of memory - take what we have
+ }
+
+ filter_unprintable(str->data());
+
+ return res;
+}
+
+}
+
QT_END_NAMESPACE
diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h
index 588184e..1834086 100644
--- a/src/testlib/qabstracttestlogger_p.h
+++ b/src/testlib/qabstracttestlogger_p.h
@@ -101,27 +101,26 @@ public:
struct QTestCharBuffer
{
- inline QTestCharBuffer()
- : buf(0)
- {}
+ enum { InitialSize = 512 };
- inline ~QTestCharBuffer()
+ inline QTestCharBuffer()
+ : _size(InitialSize), buf(staticBuf)
{
- delete[] buf;
- buf = 0;
+ staticBuf[0] = '\0';
}
- inline operator void*()
+ inline ~QTestCharBuffer()
{
- return buf;
+ if (buf != staticBuf)
+ qFree(buf);
}
- inline operator char*()
+ inline char *data()
{
return buf;
}
- inline operator char**()
+ inline char **buffer()
{
return &buf;
}
@@ -131,10 +130,43 @@ struct QTestCharBuffer
return buf;
}
+ inline int size() const
+ {
+ return _size;
+ }
+
+ inline bool reset(int newSize)
+ {
+ char *newBuf = 0;
+ if (buf == staticBuf) {
+ // if we point to our internal buffer, we need to malloc first
+ newBuf = reinterpret_cast<char *>(qMalloc(newSize));
+ } else {
+ // if we already malloc'ed, just realloc
+ newBuf = reinterpret_cast<char *>(qRealloc(buf, newSize));
+ }
+
+ // if the allocation went wrong (newBuf == 0), we leave the object as is
+ if (!newBuf)
+ return false;
+
+ _size = newSize;
+ buf = newBuf;
+ return true;
+ }
+
private:
+ int _size;
char* buf;
+ char staticBuf[InitialSize];
};
+namespace QTest
+{
+ int qt_asprintf(QTestCharBuffer *buf, const char *format, ...);
+}
+
+
QT_END_NAMESPACE
#endif
diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp
index 9cdf232..eaec02f 100644
--- a/src/testlib/qbenchmark.cpp
+++ b/src/testlib/qbenchmark.cpp
@@ -116,7 +116,7 @@ int QBenchmarkGlobalData::adjustMedianIterationCount()
QBenchmarkTestMethodData *QBenchmarkTestMethodData::current;
QBenchmarkTestMethodData::QBenchmarkTestMethodData()
-:resultAccepted(false), iterationCount(-1)
+:resultAccepted(false), runOnce(false), iterationCount(-1)
{
}
@@ -157,6 +157,11 @@ void QBenchmarkTestMethodData::setResult(qint64 value)
if (QBenchmarkGlobalData::current->iterationCount != -1)
accepted = true;
+ if (QBenchmarkTestMethodData::current->runOnce) {
+ iterationCount = 1;
+ accepted = true;
+ }
+
// Test the result directly without calling the measurer if the minimum time
// has been specifed on the command line with -minimumvalue.
else if (QBenchmarkGlobalData::current->walltimeMinimum != -1)
@@ -174,15 +179,23 @@ void QBenchmarkTestMethodData::setResult(qint64 value)
QBenchmarkResult(QBenchmarkGlobalData::current->context, value, iterationCount);
}
-/*! \internal
+/*!
+ \class QTest::QBenchmarkIterationController
+ \internal
+
The QBenchmarkIterationController class is used by the QBENCHMARK macro to
drive the benchmarking loop. It is repsonsible for starting and stopping
the timing measurements as well as calling the result reporting functions.
*/
-QTest::QBenchmarkIterationController::QBenchmarkIterationController()
+
+/*! \internal
+*/
+QTest::QBenchmarkIterationController::QBenchmarkIterationController(RunMode runMode)
{
QTest::beginBenchmarkMeasurement();
i = 0;
+ if (runMode == RunOnce)
+ QBenchmarkTestMethodData::current->runOnce = true;
}
/*! \internal
*/
@@ -195,6 +208,8 @@ QTest::QBenchmarkIterationController::~QBenchmarkIterationController()
*/
bool QTest::QBenchmarkIterationController::isDone()
{
+ if (QBenchmarkTestMethodData::current->runOnce)
+ return i > 0;
return i >= QTest::iterationCount();
}
diff --git a/src/testlib/qbenchmark.h b/src/testlib/qbenchmark.h
index c06bfc0..87d34e7 100644
--- a/src/testlib/qbenchmark.h
+++ b/src/testlib/qbenchmark.h
@@ -64,7 +64,8 @@ namespace QTest
class Q_TESTLIB_EXPORT QBenchmarkIterationController
{
public:
- QBenchmarkIterationController();
+ enum RunMode { RepeatUntilValidMeasurement, RunOnce };
+ QBenchmarkIterationController(RunMode runMode);
~QBenchmarkIterationController();
bool isDone();
void next();
@@ -74,7 +75,12 @@ public:
}
#define QBENCHMARK \
- for (QTest::QBenchmarkIterationController __iteration_controller; __iteration_controller.isDone() == false; __iteration_controller.next())
+ for (QTest::QBenchmarkIterationController __iteration_controller(QTest::QBenchmarkIterationController::RepeatUntilValidMeasurement); \
+ __iteration_controller.isDone() == false; __iteration_controller.next())
+
+#define QBENCHMARK_ONCE \
+ for (QTest::QBenchmarkIterationController __iteration_controller(QTest::QBenchmarkIterationController::RunOnce); \
+ __iteration_controller.isDone() == false; __iteration_controller.next())
QT_END_NAMESPACE
diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h
index 25f9cdc..185d656 100644
--- a/src/testlib/qbenchmark_p.h
+++ b/src/testlib/qbenchmark_p.h
@@ -171,6 +171,7 @@ public:
QBenchmarkResult result;
bool resultAccepted;
+ bool runOnce;
int iterationCount;
};
diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp
index e075b36..2515c51 100644
--- a/src/testlib/qplaintestlogger.cpp
+++ b/src/testlib/qplaintestlogger.cpp
@@ -180,7 +180,7 @@ namespace QTest {
: "";
const char *filler = (tag[0] && gtag[0]) ? ":" : "";
if (file) {
- QTest::qt_asprintf(buf, "%s: %s::%s(%s%s%s)%s%s\n"
+ QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n"
#ifdef Q_OS_WIN
"%s(%d) : failure location\n"
#else
@@ -189,14 +189,14 @@ namespace QTest {
, type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
msg[0] ? " " : "", msg, file, line);
} else {
- QTest::qt_asprintf(buf, "%s: %s::%s(%s%s%s)%s%s\n",
+ QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n",
type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
msg[0] ? " " : "", msg);
}
// In colored mode, printf above stripped our nonprintable control characters.
// Put them back.
- memcpy(buf, type, strlen(type));
- outputMessage(buf);
+ memcpy(buf.data(), type, strlen(type));
+ outputMessage(buf.data());
}
template <typename T>
@@ -207,7 +207,7 @@ namespace QTest {
int digits = 0;
qreal divisor = 1;
-
+
while (num / divisor >= 1) {
divisor *= 10;
++digits;
diff --git a/src/testlib/qtest_global.h b/src/testlib/qtest_global.h
index c40f0ad..b5b0fc0 100644
--- a/src/testlib/qtest_global.h
+++ b/src/testlib/qtest_global.h
@@ -82,7 +82,6 @@ namespace QTest
enum TestFailMode { Abort = 1, Continue = 2 };
int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format, ...);
- int qt_asprintf(char **str, const char *format, ...);
}
QT_END_NAMESPACE
diff --git a/src/testlib/qtestbasicstreamer.cpp b/src/testlib/qtestbasicstreamer.cpp
index aac57ba..89de7d8 100644
--- a/src/testlib/qtestbasicstreamer.cpp
+++ b/src/testlib/qtestbasicstreamer.cpp
@@ -68,39 +68,39 @@ QTestBasicStreamer::QTestBasicStreamer()
QTestBasicStreamer::~QTestBasicStreamer()
{}
-void QTestBasicStreamer::formatStart(const QTestElement *element, char **formatted) const
+void QTestBasicStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
return;
- QTest::qt_asprintf(formatted, "");
+ formatted->data()[0] = '\0';
}
-void QTestBasicStreamer::formatEnd(const QTestElement *element, char **formatted) const
+void QTestBasicStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
return;
- QTest::qt_asprintf(formatted, "");
+ formatted->data()[0] = '\0';
}
-void QTestBasicStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const
+void QTestBasicStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
return;
- QTest::qt_asprintf(formatted, "");
+ formatted->data()[0] = '\0';
}
-void QTestBasicStreamer::formatAfterAttributes(const QTestElement *element, char **formatted) const
+void QTestBasicStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
return;
- QTest::qt_asprintf(formatted, "");
+ formatted->data()[0] = '\0';
}
-void QTestBasicStreamer::formatAttributes(const QTestElement *, const QTestElementAttribute *attribute, char **formatted) const
+void QTestBasicStreamer::formatAttributes(const QTestElement *, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
{
if(!attribute || !formatted )
return;
- QTest::qt_asprintf(formatted, "");
+ formatted->data()[0] = '\0';
}
void QTestBasicStreamer::output(QTestElement *element) const
@@ -125,22 +125,22 @@ void QTestBasicStreamer::outputElements(QTestElement *element, bool) const
while (element) {
hasChildren = element->childElements();
- formatStart(element, buf);
- outputString(buf);
+ formatStart(element, &buf);
+ outputString(buf.data());
- formatBeforeAttributes(element, buf);
- outputString(buf);
+ formatBeforeAttributes(element, &buf);
+ outputString(buf.data());
outputElementAttributes(element, element->attributes());
- formatAfterAttributes(element, buf);
- outputString(buf);
+ formatAfterAttributes(element, &buf);
+ outputString(buf.data());
if(hasChildren)
outputElements(element->childElements(), true);
- formatEnd(element, buf);
- outputString(buf);
+ formatEnd(element, &buf);
+ outputString(buf.data());
element = element->previousElement();
}
@@ -150,8 +150,8 @@ void QTestBasicStreamer::outputElementAttributes(const QTestElement* element, QT
{
QTestCharBuffer buf;
while(attribute){
- formatAttributes(element, attribute, buf);
- outputString(buf);
+ formatAttributes(element, attribute, &buf);
+ outputString(buf.data());
attribute = attribute->nextElement();
}
}
diff --git a/src/testlib/qtestbasicstreamer.h b/src/testlib/qtestbasicstreamer.h
index 432dd22..932f5c3 100644
--- a/src/testlib/qtestbasicstreamer.h
+++ b/src/testlib/qtestbasicstreamer.h
@@ -53,6 +53,7 @@ QT_MODULE(Test)
class QTestElement;
class QTestElementAttribute;
class QTestLogger;
+struct QTestCharBuffer;
class QTestBasicStreamer
{
@@ -71,11 +72,11 @@ class QTestBasicStreamer
const QTestLogger *logger() const;
protected:
- virtual void formatStart(const QTestElement *element, char **formatted) const;
- virtual void formatEnd(const QTestElement *element, char **formatted) const;
- virtual void formatBeforeAttributes(const QTestElement *element, char **formatted) const;
- virtual void formatAfterAttributes(const QTestElement *element, char **formatted) const;
- virtual void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, char **formatted) const;
+ virtual void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
+ virtual void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
+ virtual void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
+ virtual void formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
+ virtual void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const;
virtual void outputElements(QTestElement *element, bool isChildElement = false) const;
virtual void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const;
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index ac4ca83..51e767c 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -351,6 +351,26 @@ QT_BEGIN_NAMESPACE
{Chapter 5: Writing a Benchmark}{Writing a Benchmark}
*/
+/*!
+ \macro QBENCHMARK_ONCE
+ \since 4.6
+
+ \relates QTest
+
+ This macro is used to measure the performance of code within a test.
+ The code to be benchmarked is contained within a code block following
+ this macro.
+
+ Unlike QBENCHMARK, the contents of the contained code block is only run
+ once. The elapsed time will be reported as "0" if it's to short to
+ be measured by the selected backend. (Use)
+
+ \sa {QTestLib Manual#Creating a Benchmark}{Creating a Benchmark},
+ {Chapter 5: Writing a Benchmark}{Writing a Benchmark}
+*/
+
+
+
/*! \enum QTest::SkipMode
This enum describes the modes for skipping tests during execution
@@ -820,43 +840,6 @@ void filter_unprintable(char *str)
/*! \internal
*/
-int qt_asprintf(char **str, const char *format, ...)
-{
- static const int MAXSIZE = 1024*1024*2;
-
- int size = 32;
- delete[] *str;
- *str = new char[size];
-
- va_list ap;
- int res = 0;
-
- for (;;) {
- va_start(ap, format);
- res = qvsnprintf(*str, size, format, ap);
- va_end(ap);
- (*str)[size - 1] = '\0';
- if (res >= 0 && res < size) {
- // We succeeded
- break;
- }
- // buffer wasn't big enough, try again.
- // Note, we're assuming that a result of -1 is always due to running out of space.
- size *= 2;
- if (size > MAXSIZE) {
- break;
- }
- delete[] *str;
- *str = new char[size];
- }
-
- filter_unprintable(*str);
-
- return res;
-}
-
-/*! \internal
- */
int qt_snprintf(char *str, int size, const char *format, ...)
{
va_list ap;
diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp
index e176201..b84f531 100644
--- a/src/testlib/qtestlightxmlstreamer.cpp
+++ b/src/testlib/qtestlightxmlstreamer.cpp
@@ -59,7 +59,7 @@ QTestLightXmlStreamer::QTestLightXmlStreamer()
QTestLightXmlStreamer::~QTestLightXmlStreamer()
{}
-void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **formatted) const
+void QTestLightXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
@@ -67,14 +67,14 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **form
switch(element->elementType()){
case QTest::LET_TestCase: {
QTestCharBuffer quotedTf;
- QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name));
+ QXmlTestLogger::xmlQuote(&quotedTf, element->attributeValue(QTest::AI_Name));
QTest::qt_asprintf(formatted, "<TestFunction name=\"%s\">\n", quotedTf.constData());
break;
}
case QTest::LET_Failure: {
QTestCharBuffer cdataDesc;
- QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description));
+ QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
QTest::qt_asprintf(formatted, " <Description><![CDATA[%s]]></Description>\n",
cdataDesc.constData());
@@ -84,8 +84,8 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **form
// assuming type and attribute names don't need quoting
QTestCharBuffer quotedFile;
QTestCharBuffer cdataDesc;
- QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
- QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description));
+ QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
+ QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n",
element->attributeValue(QTest::AI_Type),
@@ -100,8 +100,8 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **form
// assuming value and iterations don't need quoting
QTestCharBuffer quotedMetric;
QTestCharBuffer quotedTag;
- QXmlTestLogger::xmlQuote(quotedMetric, element->attributeValue(QTest::AI_Metric));
- QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag));
+ QXmlTestLogger::xmlQuote(&quotedMetric, element->attributeValue(QTest::AI_Metric));
+ QXmlTestLogger::xmlQuote(&quotedTag, element->attributeValue(QTest::AI_Tag));
QTest::qt_asprintf(formatted, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
element->attributeName(QTest::AI_Metric),
@@ -115,11 +115,11 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **form
break;
}
default:
- QTest::qt_asprintf(formatted, "");
+ formatted->data()[0] = '\0';
}
}
-void QTestLightXmlStreamer::formatEnd(const QTestElement *element, char **formatted) const
+void QTestLightXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
@@ -129,47 +129,47 @@ void QTestLightXmlStreamer::formatEnd(const QTestElement *element, char **format
QTest::qt_asprintf(formatted, "</Incident>\n</TestFunction>\n");
else
QTest::qt_asprintf(formatted, "</TestFunction>\n");
+ } else {
+ formatted->data()[0] = '\0';
}
- else
- QTest::qt_asprintf(formatted, "");
}
-void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const
+void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
- if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){
- QTestCharBuffer buf;
- QTestCharBuffer quotedFile;
- QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
-
- QTest::qt_asprintf(buf, "%s=\"%s\" %s=\"%s\"",
- element->attributeName(QTest::AI_File),
- quotedFile.constData(),
- element->attributeName(QTest::AI_Line),
- element->attributeValue(QTest::AI_Line));
-
- if( !element->childElements() )
- QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
- element->attributeValue(QTest::AI_Result), buf.constData());
- else
- QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n",
- element->attributeValue(QTest::AI_Result), buf.constData());
- }else{
- QTest::qt_asprintf(formatted, "");
+ if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)) {
+ QTestCharBuffer buf;
+ QTestCharBuffer quotedFile;
+ QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
+
+ QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"",
+ element->attributeName(QTest::AI_File),
+ quotedFile.constData(),
+ element->attributeName(QTest::AI_Line),
+ element->attributeValue(QTest::AI_Line));
+
+ if( !element->childElements() )
+ QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
+ element->attributeValue(QTest::AI_Result), buf.constData());
+ else
+ QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n",
+ element->attributeValue(QTest::AI_Result), buf.constData());
+ } else {
+ formatted->data()[0] = '\0';
}
}
void QTestLightXmlStreamer::output(QTestElement *element) const
{
QTestCharBuffer buf;
- QTest::qt_asprintf(buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
+ QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
qVersion(), QTEST_VERSION_STR );
- outputString(buf);
+ outputString(buf.constData());
- QTest::qt_asprintf(buf, "</Environment>\n");
- outputString(buf);
+ QTest::qt_asprintf(&buf, "</Environment>\n");
+ outputString(buf.constData());
QTestBasicStreamer::output(element);
}
diff --git a/src/testlib/qtestlightxmlstreamer.h b/src/testlib/qtestlightxmlstreamer.h
index 6dafdcc..e147e5c 100644
--- a/src/testlib/qtestlightxmlstreamer.h
+++ b/src/testlib/qtestlightxmlstreamer.h
@@ -59,9 +59,9 @@ class QTestLightXmlStreamer: public QTestBasicStreamer
QTestLightXmlStreamer();
~QTestLightXmlStreamer();
- void formatStart(const QTestElement *element, char **formatted) const;
- void formatEnd(const QTestElement *element, char **formatted) const;
- void formatBeforeAttributes(const QTestElement *element, char **formatted) const;
+ void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
+ void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
+ void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
void output(QTestElement *element) const;
};
diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp
index 1b6e674..c72d648 100644
--- a/src/testlib/qtestxmlstreamer.cpp
+++ b/src/testlib/qtestxmlstreamer.cpp
@@ -60,7 +60,7 @@ QTestXmlStreamer::QTestXmlStreamer()
QTestXmlStreamer::~QTestXmlStreamer()
{}
-void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted) const
+void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
@@ -68,20 +68,20 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
switch(element->elementType()){
case QTest::LET_TestCase: {
QTestCharBuffer quotedTf;
- QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name));
+ QXmlTestLogger::xmlQuote(&quotedTf, element->attributeValue(QTest::AI_Name));
QTest::qt_asprintf(formatted, "<TestFunction name=\"%s\">\n", quotedTf.constData());
break;
}
case QTest::LET_Failure: {
QTestCharBuffer cdataDesc;
- QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description));
+ QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
QTestCharBuffer location;
QTestCharBuffer quotedFile;
- QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
+ QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
- QTest::qt_asprintf(location, "%s=\"%s\" %s=\"%s\"",
+ QTest::qt_asprintf(&location, "%s=\"%s\" %s=\"%s\"",
element->attributeName(QTest::AI_File),
quotedFile.constData(),
element->attributeName(QTest::AI_Line),
@@ -89,7 +89,7 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
if (element->attribute(QTest::AI_Tag)) {
QTestCharBuffer cdataTag;
- QXmlTestLogger::xmlCdata(cdataTag, element->attributeValue(QTest::AI_Tag));
+ QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag));
QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n"
" <DataTag><![CDATA[%s]]></DataTag>\n"
" <Description><![CDATA[%s]]></Description>\n"
@@ -108,8 +108,8 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
// assuming type and attribute names don't need quoting
QTestCharBuffer quotedFile;
QTestCharBuffer cdataDesc;
- QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
- QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description));
+ QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
+ QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n",
element->attributeValue(QTest::AI_Type),
@@ -124,8 +124,8 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
// assuming value and iterations don't need quoting
QTestCharBuffer quotedMetric;
QTestCharBuffer quotedTag;
- QXmlTestLogger::xmlQuote(quotedMetric, element->attributeValue(QTest::AI_Metric));
- QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag));
+ QXmlTestLogger::xmlQuote(&quotedMetric, element->attributeValue(QTest::AI_Metric));
+ QXmlTestLogger::xmlQuote(&quotedTag, element->attributeValue(QTest::AI_Tag));
QTest::qt_asprintf(formatted, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
element->attributeName(QTest::AI_Metric),
@@ -139,23 +139,23 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
break;
}
default:
- QTest::qt_asprintf(formatted, "");
+ formatted->data()[0] = '\0';
}
}
-void QTestXmlStreamer::formatEnd(const QTestElement *element, char **formatted) const
+void QTestXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
if (element->elementType() == QTest::LET_TestCase) {
QTest::qt_asprintf(formatted, "</TestFunction>\n");
+ } else {
+ formatted->data()[0] = '\0';
}
- else
- QTest::qt_asprintf(formatted, "");
}
-void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const
+void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
@@ -163,9 +163,9 @@ void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char
if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){
QTestCharBuffer buf;
QTestCharBuffer quotedFile;
- QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
+ QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
- QTest::qt_asprintf(buf, "%s=\"%s\" %s=\"%s\"",
+ QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"",
element->attributeName(QTest::AI_File),
quotedFile.constData(),
element->attributeName(QTest::AI_Line),
@@ -174,12 +174,11 @@ void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char
if( !element->childElements() ) {
QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
element->attributeValue(QTest::AI_Result), buf.constData());
+ } else {
+ formatted->data()[0] = '\0';
}
- else {
- QTest::qt_asprintf(formatted, "");
- }
- }else{
- QTest::qt_asprintf(formatted, "");
+ } else {
+ formatted->data()[0] = '\0';
}
}
@@ -187,23 +186,23 @@ void QTestXmlStreamer::output(QTestElement *element) const
{
QTestCharBuffer buf;
QTestCharBuffer quotedTc;
- QXmlTestLogger::xmlQuote(quotedTc, QTestResult::currentTestObjectName());
+ QXmlTestLogger::xmlQuote(&quotedTc, QTestResult::currentTestObjectName());
- QTest::qt_asprintf(buf, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<TestCase name=\"%s\">\n",
+ QTest::qt_asprintf(&buf, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<TestCase name=\"%s\">\n",
quotedTc.constData());
- outputString(buf);
+ outputString(buf.constData());
- QTest::qt_asprintf(buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
+ QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
qVersion(), QTEST_VERSION_STR );
- outputString(buf);
+ outputString(buf.constData());
- QTest::qt_asprintf(buf, "</Environment>\n");
- outputString(buf);
+ QTest::qt_asprintf(&buf, "</Environment>\n");
+ outputString(buf.constData());
QTestBasicStreamer::output(element);
- QTest::qt_asprintf(buf, "</TestCase>\n");
- outputString(buf);
+ QTest::qt_asprintf(&buf, "</TestCase>\n");
+ outputString(buf.constData());
}
QT_END_NAMESPACE
diff --git a/src/testlib/qtestxmlstreamer.h b/src/testlib/qtestxmlstreamer.h
index a601f60..6e1ae84 100644
--- a/src/testlib/qtestxmlstreamer.h
+++ b/src/testlib/qtestxmlstreamer.h
@@ -59,9 +59,9 @@ class QTestXmlStreamer: public QTestBasicStreamer
QTestXmlStreamer();
~QTestXmlStreamer();
- void formatStart(const QTestElement *element, char **formatted) const;
- void formatEnd(const QTestElement *element, char **formatted) const;
- void formatBeforeAttributes(const QTestElement *element, char **formatted) const;
+ void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
+ void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
+ void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
void output(QTestElement *element) const;
};
diff --git a/src/testlib/qtestxunitstreamer.cpp b/src/testlib/qtestxunitstreamer.cpp
index d5d2631..932b70b 100644
--- a/src/testlib/qtestxunitstreamer.cpp
+++ b/src/testlib/qtestxunitstreamer.cpp
@@ -73,7 +73,7 @@ void QTestXunitStreamer::indentForElement(const QTestElement* element, char* buf
}
}
-void QTestXunitStreamer::formatStart(const QTestElement *element, char **formatted) const
+void QTestXunitStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
return;
@@ -85,8 +85,7 @@ void QTestXunitStreamer::formatStart(const QTestElement *element, char **formatt
if (element->elementType() == QTest::LET_Error) {
if (element->parentElement()->elementType() == QTest::LET_SystemError) {
QTest::qt_asprintf(formatted, "<![CDATA[");
- }
- else {
+ } else {
QTest::qt_asprintf(formatted, "%s<!--", indent);
}
return;
@@ -95,13 +94,13 @@ void QTestXunitStreamer::formatStart(const QTestElement *element, char **formatt
QTest::qt_asprintf(formatted, "%s<%s", indent, element->elementName());
}
-void QTestXunitStreamer::formatEnd(const QTestElement *element, char **formatted) const
+void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
{
- if(!element || !formatted )
+ if (!element || !formatted )
return;
- if(!element->childElements()){
- QTest::qt_asprintf(formatted, "");
+ if (!element->childElements()){
+ formatted->data()[0] = '\0';
return;
}
@@ -111,7 +110,7 @@ void QTestXunitStreamer::formatEnd(const QTestElement *element, char **formatted
QTest::qt_asprintf(formatted, "%s</%s>\n", indent, element->elementName());
}
-void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, char **formatted) const
+void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
{
if(!attribute || !formatted )
return;
@@ -136,15 +135,14 @@ void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTe
if (key) {
QTestCharBuffer quotedValue;
- QXmlTestLogger::xmlQuote(quotedValue, attribute->value());
+ QXmlTestLogger::xmlQuote(&quotedValue, attribute->value());
QTest::qt_asprintf(formatted, " %s=\"%s\"", key, quotedValue.constData());
- }
- else {
- QTest::qt_asprintf(formatted, "");
+ } else {
+ formatted->data()[0] = '\0';
}
}
-void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, char **formatted) const
+void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
return;
@@ -153,8 +151,7 @@ void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, char
if (element->elementType() == QTest::LET_Error) {
if (element->parentElement()->elementType() == QTest::LET_SystemError) {
QTest::qt_asprintf(formatted, "]]>\n");
- }
- else {
+ } else {
QTest::qt_asprintf(formatted, " -->\n");
}
return;
@@ -187,22 +184,22 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
hasChildren = element->childElements();
if(element->elementType() != QTest::LET_Benchmark){
- formatStart(element, buf);
- outputString(buf);
+ formatStart(element, &buf);
+ outputString(buf.data());
- formatBeforeAttributes(element, buf);
- outputString(buf);
+ formatBeforeAttributes(element, &buf);
+ outputString(buf.data());
outputElementAttributes(element, element->attributes());
- formatAfterAttributes(element, buf);
- outputString(buf);
+ formatAfterAttributes(element, &buf);
+ outputString(buf.data());
if(hasChildren)
outputElements(element->childElements(), true);
- formatEnd(element, buf);
- outputString(buf);
+ formatEnd(element, &buf);
+ outputString(buf.data());
}
element = element->previousElement();
}
diff --git a/src/testlib/qtestxunitstreamer.h b/src/testlib/qtestxunitstreamer.h
index 044307f..43ff03d 100644
--- a/src/testlib/qtestxunitstreamer.h
+++ b/src/testlib/qtestxunitstreamer.h
@@ -58,10 +58,10 @@ class QTestXunitStreamer: public QTestBasicStreamer
QTestXunitStreamer();
~QTestXunitStreamer();
- void formatStart(const QTestElement *element, char **formatted) const;
- void formatEnd(const QTestElement *element, char **formatted) const;
- void formatAfterAttributes(const QTestElement *element, char **formatted) const;
- void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, char **formatted) const;
+ void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
+ void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
+ void formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
+ void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const;
void output(QTestElement *element) const;
void outputElements(QTestElement *element, bool isChildElement = false) const;
diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp
index fca7bfc..494acb4 100644
--- a/src/testlib/qxmltestlogger.cpp
+++ b/src/testlib/qxmltestlogger.cpp
@@ -108,19 +108,19 @@ void QXmlTestLogger::startLogging()
if (xmlmode == QXmlTestLogger::Complete) {
QTestCharBuffer quotedTc;
- xmlQuote(quotedTc, QTestResult::currentTestObjectName());
- QTest::qt_asprintf(buf,
+ xmlQuote(&quotedTc, QTestResult::currentTestObjectName());
+ QTest::qt_asprintf(&buf,
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
"<TestCase name=\"%s\">\n", quotedTc.constData());
- outputString(buf);
+ outputString(buf.constData());
}
- QTest::qt_asprintf(buf,
+ QTest::qt_asprintf(&buf,
"<Environment>\n"
" <QtVersion>%s</QtVersion>\n"
" <QTestVersion>"QTEST_VERSION_STR"</QTestVersion>\n"
"</Environment>\n", qVersion());
- outputString(buf);
+ outputString(buf.constData());
}
void QXmlTestLogger::stopLogging()
@@ -136,9 +136,9 @@ void QXmlTestLogger::enterTestFunction(const char *function)
{
QTestCharBuffer buf;
QTestCharBuffer quotedFunction;
- xmlQuote(quotedFunction, function);
- QTest::qt_asprintf(buf, "<TestFunction name=\"%s\">\n", quotedFunction.constData());
- outputString(buf);
+ xmlQuote(&quotedFunction, function);
+ QTest::qt_asprintf(&buf, "<TestFunction name=\"%s\">\n", quotedFunction.constData());
+ outputString(buf.constData());
}
void QXmlTestLogger::leaveTestFunction()
@@ -219,12 +219,12 @@ void QXmlTestLogger::addIncident(IncidentTypes type, const char *description,
QTestCharBuffer cdataTag;
QTestCharBuffer cdataDescription;
- xmlQuote(quotedFile, file);
- xmlCdata(cdataGtag, gtag);
- xmlCdata(cdataTag, tag);
- xmlCdata(cdataDescription, description);
+ xmlQuote(&quotedFile, file);
+ xmlCdata(&cdataGtag, gtag);
+ xmlCdata(&cdataTag, tag);
+ xmlCdata(&cdataDescription, description);
- QTest::qt_asprintf(buf,
+ QTest::qt_asprintf(&buf,
QTest::incidentFormatString(QTest::isEmpty(description), notag),
QTest::xmlIncidentType2String(type),
quotedFile.constData(), line,
@@ -233,7 +233,7 @@ void QXmlTestLogger::addIncident(IncidentTypes type, const char *description,
cdataTag.constData(),
cdataDescription.constData());
- outputString(buf);
+ outputString(buf.constData());
}
void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
@@ -242,18 +242,18 @@ void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
QTestCharBuffer quotedMetric;
QTestCharBuffer quotedTag;
- xmlQuote(quotedMetric,
+ xmlQuote(&quotedMetric,
QBenchmarkGlobalData::current->measurer->metricText().toAscii().constData());
- xmlQuote(quotedTag, result.context.tag.toAscii().constData());
+ xmlQuote(&quotedTag, result.context.tag.toAscii().constData());
QTest::qt_asprintf(
- buf,
+ &buf,
QTest::benchmarkResultFormatString(),
quotedMetric.constData(),
quotedTag.constData(),
QByteArray::number(result.value).constData(), //no 64-bit qt_snprintf support
result.iterations);
- outputString(buf);
+ outputString(buf.constData());
}
void QXmlTestLogger::addMessage(MessageTypes type, const char *message,
@@ -270,12 +270,12 @@ void QXmlTestLogger::addMessage(MessageTypes type, const char *message,
QTestCharBuffer cdataTag;
QTestCharBuffer cdataDescription;
- xmlQuote(quotedFile, file);
- xmlCdata(cdataGtag, gtag);
- xmlCdata(cdataTag, tag);
- xmlCdata(cdataDescription, message);
+ xmlQuote(&quotedFile, file);
+ xmlCdata(&cdataGtag, gtag);
+ xmlCdata(&cdataTag, tag);
+ xmlCdata(&cdataDescription, message);
- QTest::qt_asprintf(buf,
+ QTest::qt_asprintf(&buf,
QTest::messageFormatString(QTest::isEmpty(message), notag),
QTest::xmlMessageType2String(type),
quotedFile.constData(), line,
@@ -284,7 +284,7 @@ void QXmlTestLogger::addMessage(MessageTypes type, const char *message,
cdataTag.constData(),
cdataDescription.constData());
- outputString(buf);
+ outputString(buf.constData());
}
/*
@@ -292,10 +292,11 @@ void QXmlTestLogger::addMessage(MessageTypes type, const char *message,
XML characters as necessary so that dest is suitable for use in an XML
quoted attribute string.
*/
-int QXmlTestLogger::xmlQuote(char* dest, char const* src, size_t n)
+int QXmlTestLogger::xmlQuote(QTestCharBuffer* destBuf, char const* src, size_t n)
{
if (n == 0) return 0;
+ char *dest = destBuf->data();
*dest = 0;
if (!src) return 0;
@@ -351,10 +352,12 @@ int QXmlTestLogger::xmlQuote(char* dest, char const* src, size_t n)
Copy up to n characters from the src string into dest, escaping any
special strings such that dest is suitable for use in an XML CDATA section.
*/
-int QXmlTestLogger::xmlCdata(char* dest, char const* src, size_t n)
+int QXmlTestLogger::xmlCdata(QTestCharBuffer *destBuf, char const* src, size_t n)
{
if (!n) return 0;
+ char *dest = destBuf->data();
+
if (!src || n == 1) {
*dest = 0;
return 0;
@@ -394,25 +397,23 @@ int QXmlTestLogger::xmlCdata(char* dest, char const* src, size_t n)
return (dest-begin);
}
-typedef int (*StringFormatFunction)(char*,char const*,size_t);
+typedef int (*StringFormatFunction)(QTestCharBuffer*,char const*,size_t);
/*
A wrapper for string functions written to work with a fixed size buffer so they can be called
with a dynamically allocated buffer.
*/
-int allocateStringFn(char** str, char const* src, StringFormatFunction func)
+int allocateStringFn(QTestCharBuffer* str, char const* src, StringFormatFunction func)
{
static const int MAXSIZE = 1024*1024*2;
- int size = 32;
- delete[] *str;
- *str = new char[size];
+ int size = str->size();
int res = 0;
for (;;) {
- res = func(*str, src, size);
- (*str)[size - 1] = '\0';
+ res = func(str, src, size);
+ str->data()[size - 1] = '\0';
if (res < size) {
// We succeeded or fatally failed
break;
@@ -422,19 +423,19 @@ int allocateStringFn(char** str, char const* src, StringFormatFunction func)
if (size > MAXSIZE) {
break;
}
- delete[] *str;
- *str = new char[size];
+ if (!str->reset(size))
+ break; // ran out of memory - bye
}
return res;
}
-int QXmlTestLogger::xmlQuote(char** str, char const* src)
+int QXmlTestLogger::xmlQuote(QTestCharBuffer* str, char const* src)
{
return allocateStringFn(str, src, QXmlTestLogger::xmlQuote);
}
-int QXmlTestLogger::xmlCdata(char** str, char const* src)
+int QXmlTestLogger::xmlCdata(QTestCharBuffer* str, char const* src)
{
return allocateStringFn(str, src, QXmlTestLogger::xmlCdata);
}
diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h
index a7cc00a..e14504c 100644
--- a/src/testlib/qxmltestlogger_p.h
+++ b/src/testlib/qxmltestlogger_p.h
@@ -79,10 +79,10 @@ public:
void addMessage(MessageTypes type, const char *message,
const char *file = 0, int line = 0);
- static int xmlCdata(char** dest, char const* src);
- static int xmlQuote(char** dest, char const* src);
- static int xmlCdata(char* dest, char const* src, size_t n);
- static int xmlQuote(char* dest, char const* src, size_t n);
+ static int xmlCdata(QTestCharBuffer *dest, char const* src);
+ static int xmlQuote(QTestCharBuffer *dest, char const* src);
+ static int xmlCdata(QTestCharBuffer *dest, char const* src, size_t n);
+ static int xmlQuote(QTestCharBuffer *dest, char const* src, size_t n);
private:
XmlMode xmlmode;
diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp
index f789980..14576e2 100644
--- a/src/tools/uic/uic.cpp
+++ b/src/tools/uic/uic.cpp
@@ -184,7 +184,7 @@ DomUI *Uic::parseUiFile(QXmlStreamReader &reader)
if (reader.hasError()) {
delete ui;
ui = 0;
- fprintf(stderr, qPrintable(QString::fromLatin1("uic: Error in line %1, column %2 : %3\n")
+ fprintf(stderr, "%s\n", qPrintable(QString::fromLatin1("uic: Error in line %1, column %2 : %3")
.arg(reader.lineNumber()).arg(reader.columnNumber())
.arg(reader.errorString())));
}
diff --git a/src/xmlpatterns/query.pri b/src/xmlpatterns/query.pri
index e09a618..fab1940 100644
--- a/src/xmlpatterns/query.pri
+++ b/src/xmlpatterns/query.pri
@@ -11,4 +11,4 @@ include($$PWD/parser/parser.pri)
include($$PWD/projection/projection.pri)
include($$PWD/type/type.pri)
include($$PWD/utils/utils.pri)
-include($$PWD/qobjectmodel/qobjectmodel.pri)
+include($$PWD/qobjectmodel/qobjectmodel.pri, "", true)
diff --git a/src/xmlpatterns/xmlpatterns.pro b/src/xmlpatterns/xmlpatterns.pro
index fb6aa1a..bb8e452 100644
--- a/src/xmlpatterns/xmlpatterns.pro
+++ b/src/xmlpatterns/xmlpatterns.pro
@@ -22,10 +22,9 @@ include($$PWD/janitors/janitors.pri)
include($$PWD/parser/parser.pri)
include($$PWD/projection/projection.pri)
include($$PWD/schema/schema.pri)
-include($$PWD/schematron/schematron.pri)
include($$PWD/type/type.pri)
include($$PWD/utils/utils.pri)
-include($$PWD/qobjectmodel/qobjectmodel.pri)
+include($$PWD/qobjectmodel/qobjectmodel.pri, "", true)
wince*: {
# The Microsoft MIPS compiler crashes if /Og is specified