summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-08-10 06:56:35 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-08-10 06:56:35 (GMT)
commitf61ec84fc296c6f70011e30788ee511d6b6a18c6 (patch)
tree54b3b81ac83570e65dc9b44b6756005f6ba1efde /src
parentcc0a411e5e874aa224c26298a109973cb15ea291 (diff)
parentd13418effc5f00474541ae513a30c9a42c2a1cb3 (diff)
downloadQt-f61ec84fc296c6f70011e30788ee511d6b6a18c6.zip
Qt-f61ec84fc296c6f70011e30788ee511d6b6a18c6.tar.gz
Qt-f61ec84fc296c6f70011e30788ee511d6b6a18c6.tar.bz2
Merge commit 'qt/master-stable'
Conflicts: src/corelib/kernel/qobject.cpp src/corelib/tools/qsharedpointer_impl.h src/gui/widgets/qdatetimeedit.cpp src/gui/widgets/qlinecontrol.cpp src/gui/widgets/qlineedit.cpp tests/auto/qcssparser/qcssparser.pro tests/auto/qicoimageformat/tst_qicoimageformat.cpp tests/auto/qmultiscreen/qmultiscreen.pro tests/auto/qresourceengine/qresourceengine.pro tests/auto/qresourceengine/tst_qresourceengine.cpp tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qprocess_unix.cpp12
-rw-r--r--src/corelib/kernel/qobject.cpp16
-rw-r--r--src/corelib/kernel/qobject_p.h2
-rw-r--r--src/corelib/kernel/qvariant.cpp16
-rw-r--r--src/corelib/kernel/qvariant.h1
-rw-r--r--src/corelib/tools/qsharedpointer.cpp54
-rw-r--r--src/corelib/tools/qsharedpointer.h1
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h100
-rw-r--r--src/gui/dialogs/qcolordialog.cpp2
-rw-r--r--src/gui/dialogs/qfiledialog.cpp14
-rw-r--r--src/gui/dialogs/qfiledialog_win.cpp28
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp19
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp9
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp12
-rw-r--r--src/gui/itemviews/qitemdelegate.cpp8
-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/itemviews/qstandarditemmodel.cpp18
-rw-r--r--src/gui/itemviews/qstyleditemdelegate.cpp7
-rw-r--r--src/gui/kernel/kernel.pri6
-rw-r--r--src/gui/kernel/qapplication_p.h15
-rw-r--r--src/gui/kernel/qapplication_win.cpp13
-rw-r--r--src/gui/kernel/qapplication_x11.cpp202
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm54
-rw-r--r--src/gui/kernel/qdesktopwidget_x11.cpp26
-rw-r--r--src/gui/kernel/qevent_p.h10
-rw-r--r--src/gui/kernel/qgesture.cpp50
-rw-r--r--src/gui/kernel/qgesture.h2
-rw-r--r--src/gui/kernel/qkde.cpp159
-rw-r--r--src/gui/kernel/qkde_p.h76
-rw-r--r--src/gui/kernel/qstandardgestures.cpp74
-rw-r--r--src/gui/kernel/qt_x11_p.h3
-rw-r--r--src/gui/kernel/qwidget.cpp24
-rw-r--r--src/gui/kernel/qwidget_mac.mm6
-rw-r--r--src/gui/kernel/qwidget_p.h1
-rw-r--r--src/gui/kernel/qwidget_win.cpp56
-rw-r--r--src/gui/math3d/qquaternion.h29
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp3
-rw-r--r--src/gui/styles/qcommonstyle.cpp39
-rw-r--r--src/gui/styles/qmacstyle_mac.mm12
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp8
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp58
-rw-r--r--src/gui/widgets/qabstractscrollarea.h2
-rw-r--r--src/gui/widgets/qabstractscrollarea_p.h5
-rw-r--r--src/gui/widgets/qdockarealayout.cpp2
-rw-r--r--src/gui/widgets/qdockwidget.cpp2
-rw-r--r--src/gui/widgets/qlinecontrol.cpp4
-rw-r--r--src/gui/widgets/qlinecontrol_p.h5
-rw-r--r--src/gui/widgets/qlineedit.cpp11
-rw-r--r--src/gui/widgets/qlineedit.h3
-rw-r--r--src/gui/widgets/qlineedit_p.cpp15
-rw-r--r--src/gui/widgets/qlineedit_p.h3
-rw-r--r--src/gui/widgets/qmainwindowlayout.cpp3
-rw-r--r--src/gui/widgets/qmenu.cpp41
-rw-r--r--src/gui/widgets/qmenubar.cpp3
-rw-r--r--src/gui/widgets/qtextedit.cpp24
-rw-r--r--src/gui/widgets/qtextedit.h1
-rw-r--r--src/gui/widgets/qtextedit_p.h4
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp1
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.h2
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp2
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.h2
-rw-r--r--src/network/access/qhttpnetworkheader.cpp3
-rw-r--r--src/network/access/qhttpnetworkreply_p.h1
-rw-r--r--src/network/access/qhttpnetworkrequest.cpp4
-rw-r--r--src/qt3support/network/q3http.cpp2
-rw-r--r--src/qt3support/network/q3http.h5
-rw-r--r--src/qt3support/network/q3network.cpp2
-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.cpp47
-rw-r--r--src/testlib/qabstracttestlogger_p.h52
-rw-r--r--src/testlib/qplaintestlogger.cpp22
-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.cpp37
-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/bootstrap/bootstrap.pro2
-rw-r--r--src/tools/uic/uic.cpp6
89 files changed, 1420 insertions, 960 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 607b734..168eac2 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -162,7 +162,17 @@ private:
QMap<int, QProcessInfo *> children;
};
-Q_GLOBAL_STATIC(QProcessManager, processManager)
+
+Q_GLOBAL_STATIC(QMutex, processManagerGlobalMutex)
+
+static QProcessManager *processManager() {
+ // The constructor of QProcessManager should be called only once
+ // so we cannot use Q_GLOBAL_STATIC directly for QProcessManager
+ QMutex *mutex = processManagerGlobalMutex();
+ QMutexLocker locker(mutex);
+ static QProcessManager processManager;
+ return &processManager;
+}
QProcessManager::QProcessManager()
{
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index e6947a0..0f8548a 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -56,6 +56,7 @@
#include <qvarlengtharray.h>
#include <qset.h>
#include <qsemaphore.h>
+#include <qsharedpointer.h>
#include <private/qorderedmutexlocker_p.h>
#include <private/qmutexpool_p.h>
@@ -794,6 +795,18 @@ QObject::~QObject()
QObjectPrivate::clearGuards(this);
}
+ if (d->sharedRefcount) {
+ if (d->sharedRefcount->strongref > 0) {
+ qWarning("QObject: shared QObject was deleted directly. The program is malformed and may crash.");
+ // but continue deleting, it's too late to stop anyway
+ }
+
+ // indicate to all QWeakPointers that this QObject has now been deleted
+ d->sharedRefcount->strongref = 0;
+ if (!d->sharedRefcount->weakref.deref())
+ delete d->sharedRefcount;
+ }
+
QT_TRY {
emit destroyed(this);
if (d->declarativeData)
@@ -814,6 +827,7 @@ QObject::~QObject()
#endif
}
+
{
QMutex *signalSlotMutex = 0;
QT_TRY {
@@ -878,9 +892,9 @@ QObject::~QObject()
if (senderLists)
senderLists->dirty = true;
+ node = node->next;
if (needToUnlock)
m->unlock();
- node = node->next;
}
}
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index e58ee6c..5d17bfd 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -67,6 +67,7 @@ QT_BEGIN_NAMESPACE
class QVariant;
class QThreadData;
class QObjectConnectionListVector;
+namespace QtSharedPointer { struct ExternalRefCountData; }
/* mirrored in QtTestLib, DON'T CHANGE without prior warning */
struct QSignalSpyCallbackSet
@@ -187,6 +188,7 @@ public:
// plus QPointer, which keeps a separate list
QDeclarativeData *declarativeData;
QGuard<QObject> *objectGuards;
+ QAtomicPointer<QtSharedPointer::ExternalRefCountData> sharedRefcount;
int *deleteWatch;
};
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 5016d3b..a7e4135 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -170,6 +170,9 @@ static void construct(QVariant::Private *x, const void *copy)
case QMetaType::Float:
x->data.f = copy ? *static_cast<const float*>(copy) : 0.0f;
break;
+ case QMetaType::QObjectStar:
+ x->data.o = copy ? *static_cast<QObject *const*>(copy) : 0;
+ break;
case QVariant::LongLong:
#if defined(Q_CC_RVCT)
// Using trinary operator with 64bit constants crashes when ran on Symbian device
@@ -284,6 +287,7 @@ static void clear(QVariant::Private *d)
case QVariant::ULongLong:
case QVariant::Double:
case QMetaType::Float:
+ case QMetaType::QObjectStar:
break;
case QVariant::Invalid:
case QVariant::UserType:
@@ -353,6 +357,7 @@ static bool isNull(const QVariant::Private *d)
case QVariant::Bool:
case QVariant::Double:
case QMetaType::Float:
+ case QMetaType::QObjectStar:
break;
}
return d->is_null;
@@ -446,6 +451,8 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
return a->data.d == b->data.d;
case QMetaType::Float:
return a->data.f == b->data.f;
+ case QMetaType::QObjectStar:
+ return a->data.o == b->data.o;
case QVariant::Date:
return *v_cast<QDate>(a) == *v_cast<QDate>(b);
case QVariant::Time:
@@ -1075,6 +1082,9 @@ static void streamDebug(QDebug dbg, const QVariant &v)
case QMetaType::Float:
dbg.nospace() << qVariantValue<float>(v);
break;
+ case QMetaType::QObjectStar:
+ dbg.nospace() << qVariantValue<QObject *>(v);
+ break;
case QVariant::Double:
dbg.nospace() << v.toDouble();
break;
@@ -1388,7 +1398,7 @@ void QVariant::create(int type, const void *copy)
QVariant::~QVariant()
{
- if (d.type > Char && d.type != QMetaType::Float && (!d.is_shared || !d.data.shared->ref.deref()))
+ if (d.type > Char && d.type != QMetaType::Float && d.type != QMetaType::QObjectStar && (!d.is_shared || !d.data.shared->ref.deref()))
handler->clear(&d);
}
@@ -1404,7 +1414,7 @@ QVariant::QVariant(const QVariant &p)
{
if (d.is_shared) {
d.data.shared->ref.ref();
- } else if (p.d.type > Char && p.d.type != QMetaType::Float) {
+ } else if (p.d.type > Char && p.d.type != QMetaType::Float && p.d.type != QMetaType::QObjectStar) {
handler->construct(&d, p.constData());
d.is_null = p.d.is_null;
}
@@ -1760,7 +1770,7 @@ QVariant& QVariant::operator=(const QVariant &variant)
if (variant.d.is_shared) {
variant.d.data.shared->ref.ref();
d = variant.d;
- } else if (variant.d.type > Char && variant.d.type != QMetaType::Float) {
+ } else if (variant.d.type > Char && variant.d.type != QMetaType::Float && variant.d.type != QMetaType::QObjectStar) {
d.type = variant.d.type;
handler->construct(&d, variant.constData());
d.is_null = variant.d.is_null;
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index a68939d..4489e95 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -358,6 +358,7 @@ class Q_CORE_EXPORT QVariant
float f;
qlonglong ll;
qulonglong ull;
+ QObject *o;
void *ptr;
PrivateShared *shared;
} data;
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index f7b014e..4fecc9a 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -370,7 +370,7 @@
Returns a weak reference object that shares the pointer referenced
by this object.
- \sa QWeakPointer::QWeakPointer(const QSharedPointer<T> &)
+ \sa QWeakPointer::QWeakPointer()
*/
/*!
@@ -558,7 +558,7 @@
qDebug() << "The value has already been deleted";
\endcode
- \sa QSharedPointer::QSharedPointer(const QWeakPointer<T> &)
+ \sa QSharedPointer::QSharedPointer()
*/
/*!
@@ -869,6 +869,56 @@
#include <qset.h>
#include <qmutex.h>
+#if !defined(QT_NO_QOBJECT)
+#include "../kernel/qobject_p.h"
+
+/*!
+ \internal
+ This function is called for a just-created QObject \a obj, to enable
+ the use of QSharedPointer and QWeakPointer.
+
+ When QSharedPointer is active in a QObject, the object must not be deleted
+ directly: the lifetime is managed by the QSharedPointer object. In that case,
+ the deleteLater() and parent-child relationship in QObject only decrease
+ the strong reference count, instead of deleting the object.
+*/
+void QtSharedPointer::ExternalRefCountData::setQObjectShared(const QObject *obj, bool)
+{
+ Q_ASSERT(obj);
+ QObjectPrivate *d = QObjectPrivate::get(const_cast<QObject *>(obj));
+
+ if (d->sharedRefcount)
+ qFatal("QSharedPointer: pointer %p already has reference counting", obj);
+ d->sharedRefcount = this;
+
+ // QObject decreases the refcount too, so increase it up
+ weakref.ref();
+}
+
+QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::getAndRef(const QObject *obj)
+{
+ Q_ASSERT(obj);
+ QObjectPrivate *d = QObjectPrivate::get(const_cast<QObject *>(obj));
+ ExternalRefCountData *that = d->sharedRefcount;
+ if (that) {
+ that->weakref.ref();
+ return that;
+ }
+
+ // we can create the refcount data because it doesn't exist
+ ExternalRefCountData *x = new ExternalRefCountData(Qt::Uninitialized);
+ x->strongref = -1;
+ x->weakref = 2; // the QWeakPointer that called us plus the QObject itself
+ if (!d->sharedRefcount.testAndSetRelease(0, x)) {
+ delete x;
+ d->sharedRefcount->weakref.ref();
+ }
+ return d->sharedRefcount;
+}
+#endif
+
+
+
#if !defined(QT_NO_MEMBER_TEMPLATES)
//# define QT_SHARED_POINTER_BACKTRACE_SUPPORT
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index abd83ad..2f86ce7 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -115,6 +115,7 @@ public:
QWeakPointer<T> operator=(const QWeakPointer<T> &other);
QWeakPointer<T> operator=(const QSharedPointer<T> &other);
+ T *data() const;
void clear();
QSharedPointer<T> toStrongRef() const;
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 25373b3..76a5abb 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -94,7 +94,6 @@ namespace QtSharedPointer {
template <class T> class InternalRefCount;
template <class T> class ExternalRefCount;
- template <class X, class T> QSharedPointer<X> strongRefFromWeakHelper(const QWeakPointer<T> &, X*);
template <class X, class Y> QSharedPointer<X> copyAndSetPointer(X * ptr, const QSharedPointer<Y> &src);
// used in debug mode to verify the reuse of pointers
@@ -137,21 +136,10 @@ namespace QtSharedPointer {
inline T *operator->() const { return data(); }
protected:
- inline Basic() : value(0) { }
+ inline Basic(T *ptr = 0) : value(ptr) { }
+ inline Basic(Qt::Initialization) { }
// ~Basic();
- inline void verifyReconstruction(const T *ptr)
- {
- Q_ASSERT_X(!ptr || value != ptr, "QSharedPointer",
- "QSharedPointer violation: you cannot create two QSharedPointer objects "
- "from the same pointer");
-
- // make use of the "ptr" variable in the no-op statement below
- // since this function is in a public header, we don't
- // want warnings on "unused variables" to show up everywhere
- ptr = 0;
- }
-
inline void internalConstruct(T *ptr)
{
value = ptr;
@@ -168,13 +156,24 @@ namespace QtSharedPointer {
struct ExternalRefCountData
{
- QAtomicInt weakref;
- QAtomicInt strongref;
+ QBasicAtomicInt weakref;
+ QBasicAtomicInt strongref;
- inline ExternalRefCountData() : weakref(1), strongref(1) { }
- virtual inline ~ExternalRefCountData() { Q_ASSERT(!weakref); Q_ASSERT(!strongref); }
+ inline ExternalRefCountData()
+ {
+ QBasicAtomicInt proto = Q_BASIC_ATOMIC_INITIALIZER(1);
+ weakref = strongref = proto;
+ }
+ inline ExternalRefCountData(Qt::Initialization) { }
+ virtual inline ~ExternalRefCountData() { Q_ASSERT(!weakref); Q_ASSERT(strongref <= 0); }
virtual inline bool destroy() { return false; }
+
+#ifndef QT_NO_QOBJECT
+ Q_CORE_EXPORT static ExternalRefCountData *getAndRef(const QObject *);
+ Q_CORE_EXPORT void setQObjectShared(const QObject *, bool enable);
+#endif
+ inline void setQObjectShared(...) { }
};
// sizeof(ExternalRefCount) = 12 (32-bit) / 16 (64-bit)
@@ -309,9 +308,10 @@ namespace QtSharedPointer {
#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
internalConstruct<void (*)(T *)>(ptr, normalDeleter);
#else
- Q_ASSERT(!d);
if (ptr)
d = new Data;
+ else
+ d = 0;
internalFinishConstruction(ptr);
#endif
}
@@ -319,9 +319,10 @@ namespace QtSharedPointer {
template <typename Deleter>
inline void internalConstruct(T *ptr, Deleter deleter)
{
- Q_ASSERT(!d);
if (ptr)
d = ExternalRefCountWithCustomDeleter<T, Deleter>::create(ptr, deleter);
+ else
+ d = 0;
internalFinishConstruction(ptr);
}
@@ -335,15 +336,20 @@ namespace QtSharedPointer {
inline void internalFinishConstruction(T *ptr)
{
Basic<T>::internalConstruct(ptr);
+ if (ptr) d->setQObjectShared(ptr, true);
#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
if (ptr) internalSafetyCheckAdd2(d, ptr);
#endif
}
inline ExternalRefCount() : d(0) { }
- inline ~ExternalRefCount() { if (d && !deref()) delete d; }
+ inline ExternalRefCount(Qt::Initialization i) : Basic<T>(i) { }
inline ExternalRefCount(const ExternalRefCount<T> &other) : Basic<T>(other), d(other.d)
{ if (d) ref(); }
+ template <class X>
+ inline ExternalRefCount(const ExternalRefCount<X> &other) : Basic<T>(other.value), d(other.d)
+ { if (d) ref(); }
+ inline ~ExternalRefCount() { if (d && !deref()) delete d; }
template <class X>
inline void internalCopy(const ExternalRefCount<X> &other)
@@ -357,23 +363,19 @@ namespace QtSharedPointer {
delete this->value;
}
- private:
#if defined(Q_NO_TEMPLATE_FRIENDS)
public:
#else
template <class X> friend class ExternalRefCount;
template <class X> friend class QWeakPointer;
template <class X, class Y> friend QSharedPointer<X> copyAndSetPointer(X * ptr, const QSharedPointer<Y> &src);
- template <class X, class Y> friend QSharedPointer<X> QtSharedPointer::strongRefFromWeakHelper(const QWeakPointer<Y> &src, X *);
#endif
inline void internalSet(Data *o, T *actual)
{
- if (d == o) return;
if (o) {
- Basic<T>::verifyReconstruction(actual);
-
// increase the strongref, but never up from zero
+ // or less (-1 is used by QWeakPointer on untracked QObject)
register int tmp = o->strongref;
while (tmp > 0) {
// try to increment from "tmp" to "tmp + 1"
@@ -382,7 +384,7 @@ namespace QtSharedPointer {
tmp = o->strongref; // failed, try again
}
- if (tmp)
+ if (tmp > 0)
o->weakref.ref();
else
o = 0;
@@ -393,7 +395,6 @@ namespace QtSharedPointer {
this->value = d && d->strongref ? actual : 0;
}
- protected:
Data *d;
private:
@@ -409,7 +410,8 @@ public:
inline QSharedPointer() { }
// inline ~QSharedPointer() { }
- inline explicit QSharedPointer(T *ptr) { BaseClass::internalConstruct(ptr); }
+ inline explicit QSharedPointer(T *ptr) : BaseClass(Qt::Uninitialized)
+ { internalConstruct(ptr); }
template <typename Deleter>
inline QSharedPointer(T *ptr, Deleter d) { BaseClass::internalConstruct(ptr, d); }
@@ -421,13 +423,9 @@ public:
return *this;
}
- inline QSharedPointer(const QWeakPointer<T> &other)
- { *this = QtSharedPointer::strongRefFromWeakHelper(other, static_cast<T*>(0)); }
- inline QSharedPointer<T> &operator=(const QWeakPointer<T> &other)
- { *this = QtSharedPointer::strongRefFromWeakHelper(other, static_cast<T*>(0)); return *this; }
-
template <class X>
- inline QSharedPointer(const QSharedPointer<X> &other) { *this = other; }
+ inline QSharedPointer(const QSharedPointer<X> &other) : BaseClass(other)
+ { }
template <class X>
inline QSharedPointer<T> &operator=(const QSharedPointer<X> &other)
@@ -438,12 +436,12 @@ public:
}
template <class X>
- inline QSharedPointer(const QWeakPointer<X> &other)
- { *this = QtSharedPointer::strongRefFromWeakHelper(other, static_cast<T *>(0)); }
+ inline QSharedPointer(const QWeakPointer<X> &other) : BaseClass(Qt::Uninitialized)
+ { this->d = 0; *this = other; }
template <class X>
inline QSharedPointer<T> &operator=(const QWeakPointer<X> &other)
- { *this = strongRefFromWeakHelper(other, static_cast<T *>(0)); return *this; }
+ { internalSet(other.d, other.value); return *this; }
template <class X>
QSharedPointer<X> staticCast() const
@@ -475,10 +473,13 @@ public:
QWeakPointer<T> toWeakRef() const;
+protected:
+ inline QSharedPointer(Qt::Initialization i) : BaseClass(i) {}
+
public:
static inline QSharedPointer<T> create()
{
- QSharedPointer<T> result;
+ QSharedPointer<T> result(Qt::Uninitialized);
result.internalCreate();
// now initialize the data
@@ -508,6 +509,15 @@ public:
inline QWeakPointer() : d(0), value(0) { }
inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; }
+
+ // special constructor that is enabled only if X derives from QObject
+ template <class X>
+ inline QWeakPointer(X *ptr) : d(ptr ? d->getAndRef(ptr) : 0), value(ptr)
+ { }
+ template <class X>
+ inline QWeakPointer &operator=(X *ptr)
+ { return *this = QWeakPointer(ptr); }
+
inline QWeakPointer(const QWeakPointer<T> &o) : d(o.d), value(o.value)
{ if (d) d->weakref.ref(); }
inline QWeakPointer<T> &operator=(const QWeakPointer<T> &o)
@@ -559,7 +569,7 @@ public:
template <class X>
inline bool operator==(const QSharedPointer<X> &o) const
- { return d == o.d && value == static_cast<const T *>(o.data()); }
+ { return d == o.d; }
template <class X>
inline bool operator!=(const QSharedPointer<X> &o) const
@@ -574,7 +584,7 @@ private:
#if defined(Q_NO_TEMPLATE_FRIENDS)
public:
#else
- template <class X, class Y> friend QSharedPointer<X> QtSharedPointer::strongRefFromWeakHelper(const QWeakPointer<Y> &src, X *);
+ template <class X> friend class QSharedPointer;
#endif
inline void internalSet(Data *o, T *actual)
@@ -651,14 +661,6 @@ namespace QtSharedPointer {
result.internalSet(src.d, ptr);
return result;
}
- template <class X, class T>
- Q_INLINE_TEMPLATE QSharedPointer<X> strongRefFromWeakHelper
- (const QT_PREPEND_NAMESPACE(QWeakPointer<T>) &src, X *)
- {
- QSharedPointer<X> result;
- result.internalSet(src.d, src.value);
- return result;
- }
}
// cast operators
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index aee592c..0357a7a 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -1836,8 +1836,8 @@ QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent)
QColorDialog::~QColorDialog()
{
- Q_D(QColorDialog);
#if defined(Q_WS_MAC)
+ Q_D(QColorDialog);
if (d->delegate) {
d->releaseCocoaColorPanelDelegate();
QColorDialogPrivate::sharedColorPanelAvailable = true;
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index 3f7da57..03b4789 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -396,6 +396,9 @@ QList<QUrl> QFileDialog::sidebarUrls() const
static const qint32 QFileDialogMagic = 0xbe;
+const char *qt_file_dialog_filter_reg_exp =
+"^(.*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
+
/*!
\since 4.3
Saves the state of the dialog's layout, history and current directory.
@@ -1018,8 +1021,13 @@ void QFileDialog::setNameFilters(const QStringList &filters)
if (testOption(HideNameFilterDetails)) {
QStringList strippedFilters;
+ QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
for (int i = 0; i < cleanedFilters.count(); ++i) {
- strippedFilters.append(cleanedFilters[i].mid(0, cleanedFilters[i].indexOf(QLatin1String(" ("))));
+ QString filterName;
+ int index = r.indexIn(cleanedFilters[i]);
+ if (index >= 0)
+ filterName = r.cap(1);
+ strippedFilters.append(filterName.simplified());
}
d->qFileDialogUi->fileTypeCombo->addItems(strippedFilters);
} else {
@@ -2871,10 +2879,6 @@ void QFileDialogPrivate::_q_goToDirectory(const QString &path)
}
}
-const char *qt_file_dialog_filter_reg_exp =
-"(\\W|[a-zA-Z0-9 -]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
-
-
// Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)"
QStringList qt_clean_filter_list(const QString &filter)
{
diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp
index 9bf82c3..114456d 100644
--- a/src/gui/dialogs/qfiledialog_win.cpp
+++ b/src/gui/dialogs/qfiledialog_win.cpp
@@ -59,7 +59,10 @@
#endif
#include <shlobj.h>
-
+//At some point we can hope that mingw will support that interface
+#if !defined(Q_WS_WINCE) && !defined(Q_CC_MINGW)
+#include <shobjidl.h>
+#endif
#include <objbase.h>
#if defined(__IFileDialog_INTERFACE_DEFINED__) \
@@ -173,15 +176,22 @@ static QStringList qt_win_make_filters_list(const QString &filter)
}
// Makes a NUL-oriented Windows filter from a Qt filter.
-static QString qt_win_filter(const QString &filter)
+static QString qt_win_filter(const QString &filter, bool hideFiltersDetails)
{
QStringList filterLst = qt_win_make_filters_list(filter);
QStringList::Iterator it = filterLst.begin();
QString winfilters;
+ QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
for (; it != filterLst.end(); ++it) {
QString subfilter = *it;
if (!subfilter.isEmpty()) {
- winfilters += subfilter;
+ if (hideFiltersDetails) {
+ int index = r.indexIn(subfilter);
+ if (index >= 0)
+ winfilters += r.cap(1);
+ } else {
+ winfilters += subfilter;
+ }
winfilters += QChar();
winfilters += qt_win_extract_filter(subfilter);
winfilters += QChar();
@@ -295,9 +305,10 @@ QString qt_win_get_open_file_name(const QFileDialogArgs &args,
modal_widget.setParent(args.parent, Qt::Window);
QApplicationPrivate::enterModal(&modal_widget);
+ bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection,
args.directory, args.caption,
- qt_win_filter(args.filter),
+ qt_win_filter(args.filter, hideFiltersDetails),
QFileDialog::ExistingFile,
args.options);
if (idx)
@@ -354,7 +365,7 @@ QString qt_win_get_save_file_name(const QFileDialogArgs &args,
modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
modal_widget.setParent(args.parent, Qt::Window);
QApplicationPrivate::enterModal(&modal_widget);
-
+ bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
// This block is used below for the lpstrDefExt member.
// Note that the current MSDN docs document this member wrong.
// It should rather be documented as "the default extension if no extension was given and if the
@@ -374,7 +385,7 @@ QString qt_win_get_save_file_name(const QFileDialogArgs &args,
OPENFILENAME *ofn = qt_win_make_OFN(args.parent, args.selection,
args.directory, args.caption,
- qt_win_filter(args.filter),
+ qt_win_filter(args.filter, hideFiltersDetails),
QFileDialog::AnyFile,
args.options);
@@ -441,6 +452,8 @@ static bool qt_win_set_IFileDialogOptions(IFileDialog *pfd,
QString subfilter = *it;
if (!subfilter.isEmpty()) {
offsets<<currentOffset;
+ //Here the COMMON_ITEM_DIALOG API always add the details for the filter (e.g. *.txt)
+ //so we don't need to handle the flag HideNameFilterDetails.
winfilters += subfilter; // The name of the filter.
winfilters += QChar();
currentOffset += subfilter.size()+1;
@@ -638,9 +651,10 @@ QStringList qt_win_get_open_file_names(const QFileDialogArgs &args,
modal_widget.setParent(args.parent, Qt::Window);
QApplicationPrivate::enterModal(&modal_widget);
+ bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection,
args.directory, args.caption,
- qt_win_filter(args.filter),
+ qt_win_filter(args.filter, hideFiltersDetails),
QFileDialog::ExistingFiles,
args.options);
if (idx)
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index d529976..52f333b 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -9963,20 +9963,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/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index e1f9f62..5d8bce5 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -2224,8 +2224,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);
@@ -2328,8 +2327,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();
@@ -3662,8 +3660,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/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 9ad9da7..e63d1aa 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -961,7 +961,8 @@ void QAbstractItemView::reset()
d->currentIndexSet = false;
setState(NoState);
setRootIndex(QModelIndex());
- d->selectionModel->reset();
+ if (d->selectionModel)
+ d->selectionModel->reset();
}
/*!
@@ -2653,7 +2654,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;
}
@@ -2680,6 +2681,7 @@ void QAbstractItemView::keyboardSearch(const QString &search)
QModelIndex current = start;
QModelIndexList match;
QModelIndex firstMatch;
+ QModelIndex startMatch;
QModelIndexList previous;
do {
match = d->model->match(current, Qt::DisplayRole, searchString);
@@ -2696,6 +2698,12 @@ void QAbstractItemView::keyboardSearch(const QString &search)
if (row >= d->model->rowCount(firstMatch.parent()))
row = 0;
current = firstMatch.sibling(row, firstMatch.column());
+
+ //avoid infinite loop if all the matching items are disabled.
+ if (!startMatch.isValid())
+ startMatch = firstMatch;
+ else if (startMatch == firstMatch)
+ break;
}
} while (current != start && firstMatch.isValid());
}
diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp
index 82d75ba..1d97340 100644
--- a/src/gui/itemviews/qitemdelegate.cpp
+++ b/src/gui/itemviews/qitemdelegate.cpp
@@ -1296,8 +1296,14 @@ bool QItemDelegate::editorEvent(QEvent *event,
return false;
}
- Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
+ Qt::CheckState state;
+ if ( flags & Qt::ItemIsTristate ) {
+ state = static_cast<Qt::CheckState>( (value.toInt() + 1) % 3 );
+ } else {
+ state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
? Qt::Unchecked : Qt::Checked);
+ }
+
return model->setData(index, state, Qt::CheckStateRole);
}
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/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp
index 25acbc4..535f903 100644
--- a/src/gui/itemviews/qstandarditemmodel.cpp
+++ b/src/gui/itemviews/qstandarditemmodel.cpp
@@ -1742,15 +1742,17 @@ QList<QStandardItem*> QStandardItem::takeRow(int row)
if (d->model)
d->model->d_func()->rowsAboutToBeRemoved(this, row, row);
QList<QStandardItem*> items;
- int index = d->childIndex(row, 0);
- int col_count = d->columnCount();
- for (int column = 0; column < col_count; ++column) {
- QStandardItem *ch = d->children.at(index + column);
- if (ch)
- ch->d_func()->setParentAndModel(0, 0);
- items.append(ch);
+ int index = d->childIndex(row, 0); // Will return -1 if there are no columns
+ if (index != -1) {
+ int col_count = d->columnCount();
+ for (int column = 0; column < col_count; ++column) {
+ QStandardItem *ch = d->children.at(index + column);
+ if (ch)
+ ch->d_func()->setParentAndModel(0, 0);
+ items.append(ch);
+ }
+ d->children.remove(index, col_count);
}
- d->children.remove(index, col_count);
d->rows--;
if (d->model)
d->model->d_func()->rowsRemoved(this, row, 1);
diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp
index f64a8ea..c739812 100644
--- a/src/gui/itemviews/qstyleditemdelegate.cpp
+++ b/src/gui/itemviews/qstyleditemdelegate.cpp
@@ -746,8 +746,13 @@ bool QStyledItemDelegate::editorEvent(QEvent *event,
return false;
}
- Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
+ Qt::CheckState state;
+ if ( flags & Qt::ItemIsTristate ) {
+ state = static_cast<Qt::CheckState>( (value.toInt() + 1) % 3 );
+ } else {
+ state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
? Qt::Unchecked : Qt::Checked);
+ }
return model->setData(index, state, Qt::CheckStateRole);
}
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 1766ecd..531c283 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -121,7 +121,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 \
@@ -135,7 +136,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_p.h b/src/gui/kernel/qapplication_p.h
index 0cd93b9..dc8ea6c 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -235,6 +235,8 @@ typedef struct tagGESTUREINFO
# define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
# define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
+# define GC_ZOOM 0x00000001
+
typedef struct tagGESTURECONFIG
{
DWORD dwID;
@@ -248,11 +250,12 @@ typedef struct tagGESTURECONFIG
class QPanGesture;
class QPinchGesture;
-struct StandardGestures
+struct QStandardGestures
{
QPanGesture *pan;
QPinchGesture *pinch;
- StandardGestures() : pan(0), pinch(0) { }
+
+ QStandardGestures() : pan(0), pinch(0) { }
};
@@ -282,7 +285,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
@@ -519,6 +521,9 @@ public:
QTouchEvent::DeviceType deviceType,
const QList<QTouchEvent::TouchPoint> &touchPoints);
+ typedef QMap<QWidget*, QStandardGestures> WidgetStandardGesturesMap;
+ WidgetStandardGesturesMap widgetGestures;
+
#if defined(Q_WS_WIN)
static PtrRegisterTouchWindow RegisterTouchWindow;
static PtrGetTouchInputInfo GetTouchInputInfo;
@@ -528,10 +533,6 @@ public:
QList<QTouchEvent::TouchPoint> appAllTouchPoints;
bool translateTouchEvent(const MSG &msg);
- typedef QMap<QWidget*, StandardGestures> WidgetStandardGesturesMap;
- WidgetStandardGesturesMap widgetGestures;
- ulong lastGestureId;
-
PtrGetGestureInfo GetGestureInfo;
PtrGetGestureExtraArgs GetGestureExtraArgs;
PtrCloseGestureInfoHandle CloseGestureInfoHandle;
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 2bded5c..bdee6ec 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -815,8 +815,6 @@ void qt_init(QApplicationPrivate *priv, int)
ptrSetProcessDPIAware();
#endif
- priv->lastGestureId = 0;
-
priv->GetGestureInfo =
(PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"),
"GetGestureInfo");
@@ -3718,13 +3716,8 @@ bool QETWidget::translateCloseEvent(const MSG &)
bool QETWidget::translateGestureEvent(const MSG &msg)
{
GESTUREINFO gi;
+ memset(&gi, 0, sizeof(GESTUREINFO));
gi.cbSize = sizeof(GESTUREINFO);
- gi.dwFlags = 0;
- gi.ptsLocation.x = 0;
- gi.ptsLocation.y = 0;
- gi.dwID = 0;
- gi.dwInstanceID = 0;
- gi.dwSequenceID = 0;
QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
BOOL bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi);
@@ -3747,7 +3740,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg)
event.gestureType = QNativeGestureEvent::GestureEnd;
break;
case GID_ZOOM:
- event.gestureType = QNativeGestureEvent::Pinch;
+ event.gestureType = QNativeGestureEvent::Zoom;
break;
case GID_PAN:
event.gestureType = QNativeGestureEvent::Pan;
@@ -3758,6 +3751,7 @@ bool QETWidget::translateGestureEvent(const MSG &msg)
default:
break;
}
+ qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam);
if (event.gestureType != QNativeGestureEvent::None)
qt_sendSpontaneousEvent(widget, &event);
} else {
@@ -3765,7 +3759,6 @@ bool QETWidget::translateGestureEvent(const MSG &msg)
if (dwErr > 0)
qWarning() << "translateGestureEvent: error = " << dwErr;
}
- qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam);
return true;
}
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/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 1d352cb..8c6f394 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -50,6 +50,7 @@
#include <private/qdnd_p.h>
#include <private/qmacinputcontext_p.h>
#include <private/qmultitouch_mac_p.h>
+#include <private/qevent_p.h>
#include <qscrollarea.h>
#include <qhash.h>
@@ -868,32 +869,65 @@ extern "C" {
- (void)magnifyWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "magnifyWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::Zoom;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qNGEvent.percentage = [event magnification];
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)rotateWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "rotateWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::Rotate;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qNGEvent.percentage = [event rotation];
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)swipeWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "swipeWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::Swipe;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qNGEvent.direction = QSize(-[event deltaX], -[event deltaY]);
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)beginGestureWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "beginGestureWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::GestureBegin;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)endGestureWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "endGestureWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::GestureEnd;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qApp->sendEvent(qwidget, &qNGEvent);
}
#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
diff --git a/src/gui/kernel/qdesktopwidget_x11.cpp b/src/gui/kernel/qdesktopwidget_x11.cpp
index 5bc4c0c..ad47709 100644
--- a/src/gui/kernel/qdesktopwidget_x11.cpp
+++ b/src/gui/kernel/qdesktopwidget_x11.cpp
@@ -285,26 +285,36 @@ const QRect QDesktopWidget::availableGeometry(int screen) const
if (d->workareas[screen].isValid())
return d->workareas[screen];
- if ((d->screenCount == 1 || !isVirtualDesktop())
- && X11->isSupportedByWM(ATOM(_NET_WORKAREA))) {
+ if (X11->isSupportedByWM(ATOM(_NET_WORKAREA))) {
+ int x11Screen = isVirtualDesktop() ? DefaultScreen(X11->display) : screen;
+
Atom ret;
int format, e;
unsigned char *data = 0;
unsigned long nitems, after;
e = XGetWindowProperty(X11->display,
- QX11Info::appRootWindow(screen),
- ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL,
- &ret, &format, &nitems, &after, &data);
+ QX11Info::appRootWindow(x11Screen),
+ ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL,
+ &ret, &format, &nitems, &after, &data);
+ QRect workArea;
if (e == Success && ret == XA_CARDINAL &&
format == 32 && nitems == 4) {
long *workarea = (long *) data;
- d->workareas[screen].setRect(workarea[0], workarea[1],
- workarea[2], workarea[3]);
+ workArea = QRect(workarea[0], workarea[1], workarea[2], workarea[3]);
} else {
- d->workareas[screen] = screenGeometry(screen);
+ workArea = screenGeometry(screen);
+ }
+
+ if (isVirtualDesktop()) {
+ // intersect the workarea (which spawns all Xinerama screens) with the rect for the
+ // requested screen
+ workArea &= screenGeometry(screen);
}
+
+ d->workareas[screen] = workArea;
+
if (data)
XFree(data);
} else {
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 92c4fc1..b21b35c 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -127,11 +127,13 @@ public:
GestureBegin,
GestureEnd,
Pan,
- Pinch
+ Zoom,
+ Rotate,
+ Swipe
};
QNativeGestureEvent()
- : QEvent(QEvent::NativeGesture), gestureType(None)
+ : QEvent(QEvent::NativeGesture), gestureType(None), percentage(0), direction(0, 0)
#ifdef Q_WS_WIN
, sequenceId(0)
#endif
@@ -139,8 +141,10 @@ public:
}
Type gestureType;
-#ifdef Q_WS_WIN
+ float percentage;
QPoint position;
+ QSize direction;
+#ifdef Q_WS_WIN
ulong sequenceId;
#endif
};
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index 32ac4f8..38e8851 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -97,7 +97,7 @@ private:
This is a base class, to create a custom gesture type, you should subclass
it and implement its pure virtual functions.
- \sa QPanGesture, QTapAndHoldGesture
+ \sa QPanGesture
*/
/*! \fn bool QGesture::filterEvent(QEvent *event)
@@ -197,11 +197,44 @@ Qt::GestureState QGesture::state() const
}
/*!
- Sets this gesture's recognition state to \a state.
+ Sets this gesture's recognition state to \a state and emits appropriate
+ signals.
+
+ This functions emits the signals according to the old state and the new
+ \a state, and it should be called after all the internal properties have been
+ initialized.
+
+ \sa started, triggered, finished, cancelled
*/
-void QGesture::setState(Qt::GestureState state)
+void QGesture::updateState(Qt::GestureState state)
{
- d_func()->state = state;
+ Q_D(QGesture);
+ if (d->state == state) {
+ if (state == Qt::GestureUpdated)
+ emit triggered();
+ return;
+ }
+ const Qt::GestureState oldState = d->state;
+ d->state = state;
+ if (state != Qt::NoGesture && oldState > state) {
+ // comparing the state as ints: state should only be changed from
+ // started to (optionally) updated and to finished.
+ qWarning("QGesture::updateState: incorrect new state");
+ return;
+ }
+ if (oldState == Qt::NoGesture)
+ emit started();
+ if (state == Qt::GestureUpdated)
+ emit triggered();
+ else if (state == Qt::GestureFinished)
+ emit finished();
+ else if (state == Qt::NoGesture)
+ emit cancelled();
+
+ if (state == Qt::GestureFinished) {
+ // gesture is finished, so we reset the internal state.
+ d->state = Qt::NoGesture;
+ }
}
/*!
@@ -238,14 +271,13 @@ QGraphicsItem* QGesture::graphicsItem() const
Resets the internal state of the gesture. This function might be called by
the filterEvent() implementation in a derived class, or by the user to
- cancel a gesture. The base class implementation emits the cancelled()
- signal if the state() of the gesture wasn't empty.
+ cancel a gesture. The base class implementation calls
+ updateState(Qt::NoGesture) which emits the cancelled()
+ signal if the state() of the gesture indicated it was active.
*/
void QGesture::reset()
{
- if (state() != Qt::NoGesture)
- emit cancelled();
- setState(Qt::NoGesture);
+ updateState(Qt::NoGesture);
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h
index 0735160..7da37c4 100644
--- a/src/gui/kernel/qgesture.h
+++ b/src/gui/kernel/qgesture.h
@@ -81,7 +81,7 @@ protected:
QGesture(QGesturePrivate &dd, QObject *parent);
bool eventFilter(QObject*, QEvent*);
- void setState(Qt::GestureState state);
+ void updateState(Qt::GestureState state);
Q_SIGNALS:
void started();
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 4753416..7078dbf 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -46,11 +46,12 @@
#include <qscrollbar.h>
#include <private/qapplication_p.h>
#include <private/qevent_p.h>
+#include <private/qwidget_p.h>
QT_BEGIN_NAMESPACE
#ifdef Q_WS_WIN
-QApplicationPrivate* getQApplicationPrivateInternal();
+QWidgetPrivate *qt_widget_private(QWidget *widget);
#endif
/*!
@@ -71,32 +72,38 @@ QApplicationPrivate* getQApplicationPrivateInternal();
QPanGesture::QPanGesture(QWidget *parent)
: QGesture(*new QPanGesturePrivate, parent)
{
-#ifdef Q_WS_WIN
if (parent) {
- QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
qAppPriv->widgetGestures[parent].pan = this;
- }
+#ifdef Q_WS_WIN
+ qt_widget_private(parent)->winSetupGestures();
#endif
+ }
}
/*! \internal */
bool QPanGesture::event(QEvent *event)
{
-#ifdef Q_WS_WIN
- QApplicationPrivate* getQApplicationPrivateInternal();
switch (event->type()) {
case QEvent::ParentAboutToChange:
- if (QWidget *w = qobject_cast<QWidget*>(parent()))
- getQApplicationPrivateInternal()->widgetGestures[w].pan = 0;
+ if (QWidget *w = qobject_cast<QWidget*>(parent())) {
+ QApplicationPrivate::instance()->widgetGestures[w].pan = 0;
+#ifdef Q_WS_WIN
+ qt_widget_private(w)->winSetupGestures();
+#endif
+ }
break;
case QEvent::ParentChange:
- if (QWidget *w = qobject_cast<QWidget*>(parent()))
- getQApplicationPrivateInternal()->widgetGestures[w].pan = this;
+ if (QWidget *w = qobject_cast<QWidget*>(parent())) {
+ QApplicationPrivate::instance()->widgetGestures[w].pan = this;
+#ifdef Q_WS_WIN
+ qt_widget_private(w)->winSetupGestures();
+#endif
+ }
break;
default:
break;
}
-#endif
#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
Q_D(QPanGesture);
@@ -106,9 +113,7 @@ bool QPanGesture::event(QEvent *event)
killTimer(d->panFinishedTimer);
d->panFinishedTimer = 0;
d->lastOffset = QSize(0, 0);
- setState(Qt::GestureFinished);
- emit triggered();
- setState(Qt::NoGesture);
+ updateState(Qt::GestureFinished);
}
}
#endif
@@ -119,38 +124,37 @@ bool QPanGesture::event(QEvent *event)
bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
{
#ifdef Q_WS_WIN
+ Q_D(QPanGesture);
if (receiver->isWidgetType() && event->type() == QEvent::NativeGesture) {
QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
- QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
QApplicationPrivate::WidgetStandardGesturesMap::iterator it;
it = qAppPriv->widgetGestures.find(static_cast<QWidget*>(receiver));
if (it == qAppPriv->widgetGestures.end())
return false;
QPanGesture *gesture = it.value().pan;
- if (!gesture)
+ if (this != gesture)
return false;
- Qt::GestureState nextState = state();
+ 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.
- setState(Qt::GestureStarted);
+ d->state = Qt::NoGesture;
return false;
case QNativeGestureEvent::Pan:
nextState = Qt::GestureUpdated;
+ event->accept();
break;
case QNativeGestureEvent::GestureEnd:
- if (state() != QNativeGestureEvent::Pan)
+ if (state() == Qt::NoGesture)
return false; // some other gesture has ended
- setState(Qt::GestureFinished);
nextState = Qt::GestureFinished;
break;
default:
return false;
}
- QPanGesturePrivate *d = gesture->d_func();
- if (state() == Qt::GestureStarted) {
- d->lastPosition = ev->position;
+ if (state() == Qt::NoGesture) {
d->lastOffset = d->totalOffset = QSize();
} else {
d->lastOffset = QSize(ev->position.x() - d->lastPosition.x(),
@@ -158,14 +162,7 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
d->totalOffset += d->lastOffset;
}
d->lastPosition = ev->position;
-
- if (state() == Qt::GestureStarted)
- emit gesture->started();
- emit gesture->triggered();
- if (state() == Qt::GestureFinished)
- emit gesture->finished();
- event->accept();
- gesture->setState(nextState);
+ gesture->updateState(nextState);
return true;
}
#endif
@@ -185,7 +182,6 @@ bool QPanGesture::filterEvent(QEvent *event)
d->lastOffset = d->totalOffset = QSize();
} else if (event->type() == QEvent::TouchEnd) {
if (state() != Qt::NoGesture) {
- setState(Qt::GestureFinished);
if (!ev->touchPoints().isEmpty()) {
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
const QPoint pos = p.pos().toPoint();
@@ -194,10 +190,8 @@ bool QPanGesture::filterEvent(QEvent *event)
d->lastOffset = QSize(pos.x() - lastPos.x(), pos.y() - lastPos.y());
d->totalOffset = QSize(pos.x() - startPos.x(), pos.y() - startPos.y());
}
- emit triggered();
- emit finished();
+ updateState(Qt::GestureFinished);
}
- setState(Qt::NoGesture);
reset();
} else if (event->type() == QEvent::TouchUpdate) {
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
@@ -208,11 +202,7 @@ bool QPanGesture::filterEvent(QEvent *event)
d->totalOffset = QSize(pos.x() - startPos.x(), pos.y() - startPos.y());
if (d->totalOffset.width() > 10 || d->totalOffset.height() > 10 ||
d->totalOffset.width() < -10 || d->totalOffset.height() < -10) {
- if (state() == Qt::NoGesture)
- setState(Qt::GestureStarted);
- else
- setState(Qt::GestureUpdated);
- emit triggered();
+ updateState(Qt::GestureUpdated);
}
}
#ifdef Q_OS_MAC
@@ -231,16 +221,14 @@ bool QPanGesture::filterEvent(QEvent *event)
d->lastOffset = wev->orientation() == Qt::Horizontal ? QSize(offset, 0) : QSize(0, offset);
if (state() == Qt::NoGesture) {
- setState(Qt::GestureStarted);
d->totalOffset = d->lastOffset;
} else {
- setState(Qt::GestureUpdated);
d->totalOffset += d->lastOffset;
}
killTimer(d->panFinishedTimer);
d->panFinishedTimer = startTimer(200);
- emit triggered();
+ updateState(Qt::GestureUpdated);
#endif
return true;
}
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.cpp b/src/gui/kernel/qwidget.cpp
index a8157d5..b0564bd 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -3573,27 +3573,27 @@ bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh)
}
}
#endif
+ int mw = minw, mh = minh;
+ if (mw == QWIDGETSIZE_MAX)
+ mw = 0;
+ if (mh == QWIDGETSIZE_MAX)
+ mh = 0;
if (minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX) {
qWarning("QWidget::setMinimumSize: (%s/%s) "
"The largest allowed size is (%d,%d)",
q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX,
QWIDGETSIZE_MAX);
- minw = qMin<int>(minw, QWIDGETSIZE_MAX);
- minh = qMin<int>(minh, QWIDGETSIZE_MAX);
+ minw = mw = qMin<int>(minw, QWIDGETSIZE_MAX);
+ minh = mh = qMin<int>(minh, QWIDGETSIZE_MAX);
}
if (minw < 0 || minh < 0) {
qWarning("QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) "
"are not possible",
q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh);
- minw = qMax(minw, 0);
- minh = qMax(minh, 0);
+ minw = mw = qMax(minw, 0);
+ minh = mh = qMax(minh, 0);
}
createExtra();
- int mw = minw, mh = minh;
- if (mw == QWIDGETSIZE_MAX)
- mw = 0;
- if (mh == QWIDGETSIZE_MAX)
- mh = 0;
if (extra->minw == mw && extra->minh == mh)
return false;
extra->minw = mw;
@@ -8120,10 +8120,12 @@ void QWidget::changeEvent(QEvent * event)
case QEvent::FontChange:
case QEvent::StyleChange: {
+ Q_D(QWidget);
update();
updateGeometry();
+ if (d->layout)
+ d->layout->invalidate();
#ifdef Q_WS_QWS
- Q_D(QWidget);
if (isWindow())
d->data.fstrut_dirty = true;
#endif
@@ -11287,8 +11289,6 @@ Q_GUI_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget)
}
-
-
#ifndef QT_NO_GRAPHICSVIEW
/*!
\since 4.5
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 070110d..6e4d069 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -3180,6 +3180,12 @@ void QWidgetPrivate::show_sys()
#ifndef QT_MAC_USE_COCOA
SizeWindow(window, q->width(), q->height(), true);
#endif
+
+#ifdef QT_MAC_USE_COCOA
+ // Make sure that we end up sending a repaint event to
+ // the widget if the window has been visible one before:
+ [qt_mac_get_contentview_for(window) setNeedsDisplay:YES];
+#endif
if(qt_mac_is_macsheet(q)) {
qt_event_request_showsheet(q);
} else if(qt_mac_is_macdrawer(q)) {
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 1122154..f4cd61a 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -577,6 +577,7 @@ public:
#endif
void grabMouseWhileInWindow();
void registerTouchWindow();
+ void winSetupGestures();
#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
// This is new stuff
uint needWindowChange : 1;
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index d5ce40b..49254ef 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -56,6 +56,10 @@
#include "private/qbackingstore_p.h"
#include "private/qwindowsurface_raster_p.h"
+#include "qscrollbar.h"
+#include "qabstractscrollarea.h"
+#include <private/qabstractscrollarea_p.h>
+
#include <qdebug.h>
#include <private/qapplication_p.h>
@@ -2053,6 +2057,58 @@ void QWidgetPrivate::registerTouchWindow()
QApplicationPrivate::RegisterTouchWindow(q->effectiveWinId(), 0);
}
+void QWidgetPrivate::winSetupGestures()
+{
+ Q_Q(QWidget);
+ if (!q)
+ return;
+ extern QApplicationPrivate* getQApplicationPrivateInternal();
+ QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+ bool needh = false;
+ bool needv = false;
+ bool singleFingerPanEnabled = false;
+ QStandardGestures gestures = qAppPriv->widgetGestures[q];
+ WId winid = 0;
+
+ if (QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea*>(q)) {
+ winid = asa->viewport()->winId();
+ QScrollBar *hbar = asa->horizontalScrollBar();
+ 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()));
+ singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled;
+ } else {
+ winid = q->winId();
+ }
+ if (qAppPriv->SetGestureConfig) {
+ GESTURECONFIG gc[2];
+ gc[0].dwID = GID_PAN;
+ if (gestures.pan || needh || needv) {
+ gc[0].dwWant = GC_PAN;
+ gc[0].dwBlock = 0;
+ if (needv && singleFingerPanEnabled)
+ gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
+ if (needh && singleFingerPanEnabled)
+ gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
+ } else {
+ gc[0].dwWant = 0;
+ gc[0].dwBlock = GC_PAN;
+ }
+
+ gc[1].dwID = GID_ZOOM;
+ if (gestures.pinch) {
+ gc[1].dwWant = GC_ZOOM;
+ gc[1].dwBlock = 0;
+ }
+ Q_ASSERT(winid);
+ qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0]));
+ }
+}
+
QT_END_NAMESPACE
#ifdef Q_WS_WINCE
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index 55c871d..9a1b590 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -198,24 +198,17 @@ inline QQuaternion &QQuaternion::operator*=(qreal factor)
inline const QQuaternion operator*(const QQuaternion &q1, const QQuaternion& q2)
{
- // Algorithm from:
- // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q53
- float x = q1.wp * q2.xp +
- q1.xp * q2.wp +
- q1.yp * q2.zp -
- q1.zp * q2.yp;
- float y = q1.wp * q2.yp +
- q1.yp * q2.wp +
- q1.zp * q2.xp -
- q1.xp * q2.zp;
- float z = q1.wp * q2.zp +
- q1.zp * q2.wp +
- q1.xp * q2.yp -
- q1.yp * q2.xp;
- float w = q1.wp * q2.wp -
- q1.xp * q2.xp -
- q1.yp * q2.yp -
- q1.zp * q2.zp;
+ float ww = (q1.zp + q1.xp) * (q2.xp + q2.yp);
+ float yy = (q1.wp - q1.yp) * (q2.wp + q2.zp);
+ float zz = (q1.wp + q1.yp) * (q2.wp - q2.zp);
+ float xx = ww + yy + zz;
+ float qq = 0.5 * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp));
+
+ float w = qq - ww + (q1.zp - q1.yp) * (q2.yp - q2.zp);
+ float x = qq - xx + (q1.xp + q1.wp) * (q2.xp + q2.wp);
+ float y = qq - yy + (q1.wp - q1.xp) * (q2.yp + q2.zp);
+ float z = qq - zz + (q1.zp + q1.yp) * (q2.wp - q2.xp);
+
return QQuaternion(w, x, y, z, 1);
}
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 4aaa799..fa9534f 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -2539,6 +2539,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 bfcb7c9..3420ad1 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/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index 2f93034..235cba6 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -5510,9 +5510,15 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
break;
}
case SC_SpinBoxEditField:
- ret.setRect(fw, fw,
- spin->rect.width() - spinner_w - fw * 2 - spinBoxSep,
- spin->rect.height() - fw * 2);
+ if (spin->buttonSymbols == QAbstractSpinBox::NoButtons) {
+ ret.setRect(fw, fw,
+ spin->rect.width() - fw * 2,
+ spin->rect.height() - fw * 2);
+ } else {
+ ret.setRect(fw, fw,
+ spin->rect.width() - fw * 2 - spinBoxSep - spinner_w,
+ spin->rect.height() - fw * 2);
+ }
ret = visualRect(spin->direction, spin->rect, ret);
break;
default:
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 2efa4a7..5f6d4ab 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -2891,8 +2891,8 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
bool customUp = true, customDown = true;
QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton);
- bool upRuleMatch = upRule.hasGeometry();
- bool downRuleMatch = downRule.hasGeometry();
+ bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
+ bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition();
if (rule.hasNativeBorder() && !upRuleMatch && !downRuleMatch) {
rule.drawBackgroundImage(p, spinOpt.rect);
customUp = (opt->subControls & QStyle::SC_SpinBoxUp)
@@ -5167,8 +5167,8 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp
QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton);
bool ruleMatch = rule.hasBox() || !rule.hasNativeBorder();
- bool upRuleMatch = upRule.hasGeometry();
- bool downRuleMatch = downRule.hasGeometry();
+ bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
+ bool downRuleMatch = downRule.hasGeometry() || upRule.hasPosition();
if (ruleMatch || upRuleMatch || downRuleMatch) {
switch (sc) {
case SC_SpinBoxFrame:
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 391e095..c72c36c 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE
QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate()
:hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded),
viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0),
- xoffset(0), yoffset(0), viewportFilter(0)
+ xoffset(0), yoffset(0), viewportFilter(0), panGesture(0)
#ifdef Q_WS_WIN
, singleFingerPanEnabled(false)
#endif
@@ -294,33 +294,18 @@ void QAbstractScrollAreaPrivate::init()
q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layoutChildren();
+
+ panGesture = new QPanGesture(q);
+ QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered()));
}
-void QAbstractScrollAreaPrivate::setupGestures()
+#ifdef Q_WS_WIN
+void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on)
{
-#ifdef Q_OS_WIN
- if (!viewport)
- return;
- QApplicationPrivate* getQApplicationPrivateInternal();
- QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
- bool needh = (hbarpolicy == Qt::ScrollBarAlwaysOn
- || (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum()));
-
- bool needv = (vbarpolicy == Qt::ScrollBarAlwaysOn
- || (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
- if (qAppPriv->SetGestureConfig && (needh || needv)) {
- GESTURECONFIG gc[1];
- gc[0].dwID = GID_PAN;
- gc[0].dwWant = GC_PAN;
- gc[0].dwBlock = 0;
- if (needv && singleFingerPanEnabled)
- gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
- if (needh && singleFingerPanEnabled)
- gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
- qAppPriv->SetGestureConfig(viewport->winId(), 0, 1, gc, sizeof(gc));
- }
-#endif // Q_OS_WIN
+ singleFingerPanEnabled = on;
+ winSetupGestures();
}
+#endif // Q_WS_WIN
void QAbstractScrollAreaPrivate::layoutChildren()
{
@@ -1278,7 +1263,11 @@ void QAbstractScrollAreaPrivate::_q_vslide(int y)
void QAbstractScrollAreaPrivate::_q_showOrHideScrollBars()
{
layoutChildren();
- setupGestures();
+#ifdef Q_OS_WIN
+ // Need to re-subscribe to gestures as the content changes to make sure we
+ // enable/disable panning when needed.
+ winSetupGestures();
+#endif // Q_OS_WIN
}
QPoint QAbstractScrollAreaPrivate::contentsOffset() const
@@ -1343,6 +1332,25 @@ void QAbstractScrollArea::setupViewport(QWidget *viewport)
Q_UNUSED(viewport);
}
+void QAbstractScrollAreaPrivate::_q_gestureTriggered()
+{
+ Q_Q(QAbstractScrollArea);
+ QPanGesture *g = qobject_cast<QPanGesture*>(q->sender());
+ if (!g)
+ return;
+ QScrollBar *hBar = q->horizontalScrollBar();
+ QScrollBar *vBar = q->verticalScrollBar();
+ QSize delta = g->lastOffset();
+ if (!delta.isNull()) {
+ if (QApplication::isRightToLeft())
+ delta.rwidth() *= -1;
+ int newX = hBar->value() - delta.width();
+ int newY = vBar->value() - delta.height();
+ hbar->setValue(newX);
+ vbar->setValue(newY);
+ }
+}
+
QT_END_NAMESPACE
#include "moc_qabstractscrollarea.cpp"
diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h
index 3ec41d1..9178629 100644
--- a/src/gui/widgets/qabstractscrollarea.h
+++ b/src/gui/widgets/qabstractscrollarea.h
@@ -128,8 +128,10 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_hslide(int))
Q_PRIVATE_SLOT(d_func(), void _q_vslide(int))
Q_PRIVATE_SLOT(d_func(), void _q_showOrHideScrollBars())
+ Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered())
friend class QStyleSheetStyle;
+ friend class QWidgetPrivate;
};
#endif // QT_NO_SCROLLAREA
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index f8ea843..a54ba1c 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_SCROLLAREA
+class QPanGesture;
class QScrollBar;
class QAbstractScrollAreaScrollBarContainer;
class Q_AUTOTEST_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate
@@ -100,10 +101,12 @@ public:
{ return q_func()->viewportEvent(event); }
QScopedPointer<QObject> viewportFilter;
+ virtual void _q_gestureTriggered();
+ QPanGesture *panGesture;
#ifdef Q_WS_WIN
bool singleFingerPanEnabled;
+ void setSingleFingerPanEnabled(bool on = true);
#endif
- void setupGestures();
};
class QAbstractScrollAreaFilter : public QObject
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/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index 64832c8..f4a2348 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -257,6 +257,7 @@ void QLineControl::setSelection(int start, int length)
m_cursor = m_selstart;
}
emit selectionChanged();
+ emitCursorPositionChanged();
}
void QLineControl::_q_clipboardChanged()
@@ -1704,8 +1705,7 @@ void QLineControl::processKeyEvent(QKeyEvent* event)
if (passwordEchoEditing())
updatePasswordEchoEditing(false);
- // ### TODO this needs to be fixed.
- // setEditFocus(false);
+ emit editFocusChange(false);
} else if (!m_deleteAllTimer) {
m_deleteAllTimer = startTimer(750);
}
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
index 9cad857..ad4e4e4 100644
--- a/src/gui/widgets/qlinecontrol_p.h
+++ b/src/gui/widgets/qlinecontrol_p.h
@@ -343,6 +343,9 @@ Q_SIGNALS:
void editingFinished();
void updateNeeded(const QRect &);
+#ifdef QT_KEYPAD_NAVIGATION
+ void editFocusChange(bool);
+#endif
protected:
virtual void timerEvent(QTimerEvent *event);
@@ -638,7 +641,7 @@ inline void QLineControl::setCursorPosition(int pos)
{
if (pos < 0)
pos = 0;
- if (pos < m_text.length())
+ if (pos <= m_text.length())
moveCursor(pos);
}
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 8ab30fa..5b04616 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1693,12 +1693,10 @@ void QLineEdit::focusInEvent(QFocusEvent *e)
d->clickCausedFocus = 1;
}
#ifdef QT_KEYPAD_NAVIGATION
- if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason))
+ if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason)){
#endif
- {
- int cft = QApplication::cursorFlashTime();
- d->control->setCursorBlinkPeriod(cft/2);
- }
+ int cft = QApplication::cursorFlashTime();
+ d->control->setCursorBlinkPeriod(cft/2);
QStyleOptionFrameV2 opt;
initStyleOption(&opt);
if((!hasSelectedText() && d->control->preeditAreaText().isEmpty())
@@ -1709,7 +1707,8 @@ void QLineEdit::focusInEvent(QFocusEvent *e)
qt_mac_secure_keyboard(true);
#endif
#ifdef QT_KEYPAD_NAVIGATION
- d->control->setCancelText(d->control->text());
+ d->control->setCancelText(d->control->text());
+ }
#endif
#ifndef QT_NO_COMPLETER
if (d->control->completer()) {
diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h
index daac6a7..32ef6a4 100644
--- a/src/gui/widgets/qlineedit.h
+++ b/src/gui/widgets/qlineedit.h
@@ -273,6 +273,9 @@ private:
#ifndef QT_NO_COMPLETER
Q_PRIVATE_SLOT(d_func(), void _q_completionHighlighted(QString))
#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ Q_PRIVATE_SLOT(d_func(), void _q_editFocusChange(bool))
+#endif
};
#endif // QT_NO_LINEEDIT
diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp
index f0ec8ad..d907233 100644
--- a/src/gui/widgets/qlineedit_p.cpp
+++ b/src/gui/widgets/qlineedit_p.cpp
@@ -126,6 +126,14 @@ void QLineEditPrivate::_q_cursorPositionChanged(int from, int to)
emit q->cursorPositionChanged(from, to);
}
+#ifdef QT_KEYPAD_NAVIGATION
+void QLineEditPrivate::_q_editFocusChange(bool e)
+{
+ Q_Q(QLineEdit);
+ q->setEditFocus(e);
+}
+#endif
+
void QLineEditPrivate::init(const QString& txt)
{
Q_Q(QLineEdit);
@@ -142,6 +150,10 @@ void QLineEditPrivate::init(const QString& txt)
q, SIGNAL(returnPressed()));
QObject::connect(control, SIGNAL(editingFinished()),
q, SIGNAL(editingFinished()));
+#ifdef QT_KEYPAD_NAVIGATION
+ QObject::connect(control, SIGNAL(editFocusChange(bool)),
+ q, SLOT(_q_editFocusChange(bool)));
+#endif
// for now, going completely overboard with updates.
QObject::connect(control, SIGNAL(selectionChanged()),
@@ -149,6 +161,9 @@ void QLineEditPrivate::init(const QString& txt)
QObject::connect(control, SIGNAL(displayTextChanged(const QString &)),
q, SLOT(update()));
+
+ QObject::connect(control, SIGNAL(updateNeeded(const QRect &)),
+ q, SLOT(update()));
control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter));
#ifndef QT_NO_CURSOR
q->setCursor(Qt::IBeamCursor);
diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h
index b09c3f0..b21820c 100644
--- a/src/gui/widgets/qlineedit_p.h
+++ b/src/gui/widgets/qlineedit_p.h
@@ -126,6 +126,9 @@ public:
void _q_deleteSelected();
void _q_textEdited(const QString &);
void _q_cursorPositionChanged(int, int);
+#ifdef QT_KEYPAD_NAVIGATION
+ void _q_editFocusChange(bool);
+#endif
#ifndef QT_NO_COMPLETER
void _q_completionHighlighted(QString);
diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp
index 3936a67..55afa70 100644
--- a/src/gui/widgets/qmainwindowlayout.cpp
+++ b/src/gui/widgets/qmainwindowlayout.cpp
@@ -1988,6 +1988,9 @@ void QMainWindowLayout::timerEvent(QTimerEvent *e)
if (movingSeparatorOrigin == movingSeparatorPos)
return;
+ //when moving the separator, we need to update the previous position
+ parentWidget()->update(layoutState.dockAreaLayout.separatorRegion());
+
layoutState = savedState;
layoutState.dockAreaLayout.separatorMove(movingSeparator, movingSeparatorOrigin,
movingSeparatorPos);
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 6465975..1ba6fdc 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -205,6 +205,8 @@ void QMenuPrivate::updateActionRects() const
Q_Q(const QMenu);
if (!itemsDirty)
return;
+
+ q->ensurePolished();
//let's reinitialize the buffer
actionRects.resize(actions.count());
@@ -226,13 +228,17 @@ void QMenuPrivate::updateActionRects() const
dh = popupGeometry(QApplication::desktop()->screenNumber(q)).height(),
y = 0;
QStyle *style = q->style();
- const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, 0, q),
- vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, 0, q),
- icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
- const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);
-
- const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, 0, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();
+ QStyleOption opt;
+ opt.init(q);
+ const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q),
+ vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q),
+ icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q);
+ const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q);
+ const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);
+
+ const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();
const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin));
+ const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
//for compatability now - will have to refactor this away..
tabWidth = 0;
@@ -308,7 +314,7 @@ void QMenuPrivate::updateActionRects() const
max_column_width = qMax(min_column_width, qMax(max_column_width, sz.width()));
//wrapping
if (!scroll &&
- y+sz.height()+vmargin > dh - (style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q) * 2)) {
+ y+sz.height()+vmargin > dh - (deskFw * 2)) {
ncols++;
y = vmargin;
}
@@ -323,7 +329,7 @@ void QMenuPrivate::updateActionRects() const
//calculate position
const int base_y = vmargin + fw + topmargin +
(scroll ? scroll->scrollOffset : 0) +
- (tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q) : 0);
+ tearoffHeight;
int x = hmargin + fw + leftmargin;
y = base_y;
@@ -332,7 +338,7 @@ void QMenuPrivate::updateActionRects() const
if (rect.isNull())
continue;
if (!scroll &&
- y+rect.height() > dh - (style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q) * 2)) {
+ y+rect.height() > dh - deskFw * 2) {
x += max_column_width + hmargin;
y = base_y;
}
@@ -1708,12 +1714,9 @@ QRect QMenu::actionGeometry(QAction *act) const
QSize QMenu::sizeHint() const
{
Q_D(const QMenu);
- ensurePolished();
d->updateActionRects();
QSize s;
- QStyleOption opt(0);
- opt.init(this);
for (int i = 0; i < d->actionRects.count(); ++i) {
const QRect &rect = d->actionRects.at(i);
if (rect.isNull())
@@ -1726,15 +1729,11 @@ QSize QMenu::sizeHint() const
// Note that the action rects calculated above already include
// the top and left margins, so we only need to add margins for
// the bottom and right.
- if (const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this)) {
- s.rwidth() += fw;
- s.rheight() += fw;
- }
-
- s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this);
- s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this);
-
- s += QSize(d->rightmargin, d->bottommargin);
+ QStyleOption opt(0);
+ opt.init(this);
+ const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, this);
+ s.rwidth() += style()->pixelMetric(QStyle::PM_MenuHMargin, &opt, this) + fw + d->rightmargin;
+ s.rheight() += style()->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) + fw + d->bottommargin;
return style()->sizeFromContents(QStyle::CT_Menu, &opt,
s.expandedTo(QApplication::globalStrut()), this);
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index eaf03b3..a0a2f57 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -272,6 +272,9 @@ QRect QMenuBarPrivate::actionRect(QAction *act) const
//makes sure the geometries are up-to-date
const_cast<QMenuBarPrivate*>(this)->updateGeometries();
+ if (index >= actionRects.count())
+ return QRect(); // that can happen in case of native menubar
+
QRect ret = actionRects.at(index);
return QStyle::visualRect(q->layoutDirection(), q->rect(), ret);
}
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index e5c4d4f..57f43c6 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -119,7 +119,7 @@ QTextEditPrivate::QTextEditPrivate()
showCursorOnInitialShow = true;
inDrag = false;
#ifdef Q_WS_WIN
- singleFingerPanEnabled = true;
+ setSingleFingerPanEnabled(true);
#endif
}
@@ -188,8 +188,6 @@ void QTextEditPrivate::init(const QString &html)
#ifndef QT_NO_CURSOR
viewport->setCursor(Qt::IBeamCursor);
#endif
- panGesture = new QPanGesture(q);
- QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered()));
}
void QTextEditPrivate::_q_repaintContents(const QRectF &contentsRect)
@@ -2631,26 +2629,6 @@ void QTextEdit::ensureCursorVisible()
d->control->ensureCursorVisible();
}
-void QTextEditPrivate::_q_gestureTriggered()
-{
- Q_Q(QTextEdit);
- QPanGesture *g = qobject_cast<QPanGesture*>(q->sender());
- if (!g)
- return;
- QScrollBar *hBar = q->horizontalScrollBar();
- QScrollBar *vBar = q->verticalScrollBar();
- QSize delta = g->lastOffset();
- if (!delta.isNull()) {
- if (QApplication::isRightToLeft())
- delta.rwidth() *= -1;
- int newX = hBar->value() - delta.width();
- int newY = vBar->value() - delta.height();
- hbar->setValue(newX);
- vbar->setValue(newY);
- }
-}
-
-
/*!
\enum QTextEdit::KeyboardAction
diff --git a/src/gui/widgets/qtextedit.h b/src/gui/widgets/qtextedit.h
index 9e10e07..617822a 100644
--- a/src/gui/widgets/qtextedit.h
+++ b/src/gui/widgets/qtextedit.h
@@ -414,7 +414,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_currentCharFormatChanged(const QTextCharFormat &))
Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars())
Q_PRIVATE_SLOT(d_func(), void _q_ensureVisible(const QRectF &))
- Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered())
friend class QTextEditControl;
friend class QTextDocument;
friend class QTextControl;
diff --git a/src/gui/widgets/qtextedit_p.h b/src/gui/widgets/qtextedit_p.h
index cf87a86..85b6f7c 100644
--- a/src/gui/widgets/qtextedit_p.h
+++ b/src/gui/widgets/qtextedit_p.h
@@ -70,7 +70,6 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_TEXTEDIT
class QMimeData;
-class QPanGesture;
class QTextEditPrivate : public QAbstractScrollAreaPrivate
{
Q_DECLARE_PUBLIC(QTextEdit)
@@ -130,9 +129,6 @@ public:
QString anchorToScrollToWhenVisible;
- void _q_gestureTriggered();
- QPanGesture *panGesture;
-
#ifdef QT_KEYPAD_NAVIGATION
QBasicTimer deleteAllTimer;
#endif
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index e5b6e0d..3478e51 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -55,6 +55,7 @@
//#define DEBUG_AUDIO 1
+static CRITICAL_SECTION waveInCriticalSection;
QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat):
settings(audioFormat)
diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h
index 32464f0..aa0d0b3 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.h
+++ b/src/multimedia/audio/qaudioinput_win32_p.h
@@ -68,8 +68,6 @@
#include <QtMultimedia/qaudioengine.h>
-static CRITICAL_SECTION waveInCriticalSection;
-
class QAudioInputPrivate : public QAbstractAudioInput
{
Q_OBJECT
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index f681936..dbf0a66 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -54,6 +54,8 @@
//#define DEBUG_AUDIO 1
+static CRITICAL_SECTION waveOutCriticalSection;
+
QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat):
settings(audioFormat)
{
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h
index 91f14f5..50a3992 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.h
+++ b/src/multimedia/audio/qaudiooutput_win32_p.h
@@ -67,8 +67,6 @@
#include <QtMultimedia/qaudioengine.h>
-static CRITICAL_SECTION waveOutCriticalSection;
-
class QAudioOutputPrivate : public QAbstractAudioOutput
{
Q_OBJECT
diff --git a/src/network/access/qhttpnetworkheader.cpp b/src/network/access/qhttpnetworkheader.cpp
index 5af9764..88cc484 100644
--- a/src/network/access/qhttpnetworkheader.cpp
+++ b/src/network/access/qhttpnetworkheader.cpp
@@ -41,6 +41,7 @@
#include "qhttpnetworkheader_p.h"
+#ifndef QT_NO_HTTP
QT_BEGIN_NAMESPACE
@@ -121,3 +122,5 @@ bool QHttpNetworkHeaderPrivate::operator==(const QHttpNetworkHeaderPrivate &othe
QT_END_NAMESPACE
+
+#endif
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h
index fe49799..819aeb5 100644
--- a/src/network/access/qhttpnetworkreply_p.h
+++ b/src/network/access/qhttpnetworkreply_p.h
@@ -52,6 +52,7 @@
//
// We mean it.
//
+#include <qplatformdefs.h>
#ifndef QT_NO_HTTP
#ifndef QT_NO_COMPRESS
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp
index 0f330af..b1db0b7 100644
--- a/src/network/access/qhttpnetworkrequest.cpp
+++ b/src/network/access/qhttpnetworkrequest.cpp
@@ -42,6 +42,8 @@
#include "qhttpnetworkrequest_p.h"
#include "private/qnoncontiguousbytedevice_p.h"
+#ifndef QT_NO_HTTP
+
QT_BEGIN_NAMESPACE
QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op,
@@ -260,3 +262,5 @@ int QHttpNetworkRequest::minorVersion() const
QT_END_NAMESPACE
+#endif
+
diff --git a/src/qt3support/network/q3http.cpp b/src/qt3support/network/q3http.cpp
index dba4e88..9b5c33f 100644
--- a/src/qt3support/network/q3http.cpp
+++ b/src/qt3support/network/q3http.cpp
@@ -42,7 +42,7 @@
#include <qplatformdefs.h>
#include "q3http.h"
-#ifndef QT_NO_NETWORKPROTOCOL_HTTP
+#ifndef QT_NO_HTTP
#include "q3socket.h"
#include "qtextstream.h"
diff --git a/src/qt3support/network/q3http.h b/src/qt3support/network/q3http.h
index 93ab00e..5311764 100644
--- a/src/qt3support/network/q3http.h
+++ b/src/qt3support/network/q3http.h
@@ -52,8 +52,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Qt3Support)
-
-#ifndef QT_NO_NETWORKPROTOCOL_HTTP
+#ifndef QT_NO_HTTP
class Q3Socket;
class QTimerEvent;
@@ -269,7 +268,7 @@ private:
friend class Q3HttpPGHRequest;
};
-#endif // QT_NO_NETWORKPROTOCOL_HTTP
+#endif // QT_NO_HTTP
QT_END_NAMESPACE
diff --git a/src/qt3support/network/q3network.cpp b/src/qt3support/network/q3network.cpp
index 3a6a6f0..1f918d1 100644
--- a/src/qt3support/network/q3network.cpp
+++ b/src/qt3support/network/q3network.cpp
@@ -63,7 +63,7 @@ void q3InitNetworkProtocols()
#ifndef QT_NO_NETWORKPROTOCOL_FTP
Q3NetworkProtocol::registerNetworkProtocol( QLatin1String("ftp"), new Q3NetworkProtocolFactory< Q3Ftp > );
#endif
-#ifndef QT_NO_NETWORKPROTOCOL_HTTP
+#ifndef QT_NO_HTTP
Q3NetworkProtocol::registerNetworkProtocol( QLatin1String("http"), new Q3NetworkProtocolFactory< Q3Http > );
#endif
}
diff --git a/src/script/qscriptable.cpp b/src/script/qscriptable.cpp
index 455cc98..a33b5ae 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..2fa535e 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,48 @@ void QAbstractTestLogger::stopLogging()
QTest::stream = 0;
}
+namespace QTest
+{
+
+extern void filter_unprintable(char *str);
+
+/*! \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/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp
index c529d3e..a2be00f 100644
--- a/src/testlib/qplaintestlogger.cpp
+++ b/src/testlib/qplaintestlogger.cpp
@@ -156,11 +156,13 @@ namespace QTest {
static void outputMessage(const char *str)
{
#if defined(Q_OS_WINCE)
- int length = strlen(str);
- for (int pos = 0; pos < length; pos +=255) {
- QString uniText = QString::fromLatin1(str + pos, 255);
- OutputDebugString((wchar_t*)uniText.utf16());
- }
+ QString strUtf16 = QString::fromLatin1(str);
+ const int maxOutputLength = 255;
+ do {
+ QString tmp = strUtf16.left(maxOutputLength);
+ OutputDebugString((wchar_t*)tmp.utf16());
+ strUtf16.remove(0, maxOutputLength);
+ } while (!strUtf16.isEmpty());
if (QTestLog::outputFileName())
#elif defined(Q_OS_WIN)
EnterCriticalSection(&outputCriticalSection);
@@ -198,7 +200,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
@@ -207,14 +209,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>
@@ -225,7 +227,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 24dae2e..5bb2e43 100644
--- a/src/testlib/qtest_global.h
+++ b/src/testlib/qtest_global.h
@@ -83,7 +83,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..cabbf34 100644
--- a/src/testlib/qtestbasicstreamer.h
+++ b/src/testlib/qtestbasicstreamer.h
@@ -53,6 +53,7 @@ QT_MODULE(Test)
class QTestElement;
class QTestElementAttribute;
class QTestLogger;
+class 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 e6508f2..65a6e89 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -825,43 +825,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/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index d8a1f96..396e9ae 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -89,7 +89,7 @@ win32:SOURCES += ../../corelib/io/qfsfileengine_win.cpp \
../../corelib/io/qfsfileengine_iterator_win.cpp
macx: {
- QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3 #enables weak linking for 10.3 (exported)
+ QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported)
SOURCES += ../../corelib/kernel/qcore_mac.cpp
LIBS += -framework CoreServices
}
diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp
index bbb3af7..14576e2 100644
--- a/src/tools/uic/uic.cpp
+++ b/src/tools/uic/uic.cpp
@@ -184,9 +184,9 @@ DomUI *Uic::parseUiFile(QXmlStreamReader &reader)
if (reader.hasError()) {
delete ui;
ui = 0;
- fprintf(stderr, "uic: Error in line %llu, column %llu : %s\n",
- reader.lineNumber(), reader.columnNumber(),
- reader.errorString().toAscii().constData());
+ fprintf(stderr, "%s\n", qPrintable(QString::fromLatin1("uic: Error in line %1, column %2 : %3")
+ .arg(reader.lineNumber()).arg(reader.columnNumber())
+ .arg(reader.errorString())));
}
return ui;