diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-08-31 00:16:40 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-08-31 00:16:40 (GMT) |
commit | 9dade8d2e57655019ed4dc2fcdc4e226401138a2 (patch) | |
tree | 6aa3520f525b2ab923b4238079f1012756fa2488 /src/corelib | |
parent | e1dd37f6b54881aef3b9e1e686dc56bb96fc14ed (diff) | |
parent | d23863952b0c13ccd8b2989d24153d94b3d3f83d (diff) | |
download | Qt-9dade8d2e57655019ed4dc2fcdc4e226401138a2.zip Qt-9dade8d2e57655019ed4dc2fcdc4e226401138a2.tar.gz Qt-9dade8d2e57655019ed4dc2fcdc4e226401138a2.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Conflicts:
src/gui/graphicsview/qgraphicsitem.cpp
src/gui/graphicsview/qgraphicsitem.h
src/gui/graphicsview/qgraphicsitem_p.h
src/gui/graphicsview/qgraphicsscene.cpp
Diffstat (limited to 'src/corelib')
35 files changed, 814 insertions, 322 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 617f4db..49bd8e9 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -161,7 +161,9 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer) -QUnifiedTimer::QUnifiedTimer() : QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), consistentTiming(false) +QUnifiedTimer::QUnifiedTimer() : + QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), + currentAnimationIdx(0), consistentTiming(false) { } @@ -200,21 +202,19 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event) } } else if (event->timerId() == animationTimer.timerId()) { const int delta = lastTick - oldLastTick; - //we copy the list so that if it is changed we still get to - //call setCurrentTime on all animations. - const QList<QAbstractAnimation*> currentAnimations = animations; - for (int i = 0; i < currentAnimations.count(); ++i) { - QAbstractAnimation *animation = currentAnimations.at(i); + for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) { + QAbstractAnimation *animation = animations.at(currentAnimationIdx); int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta); animation->setCurrentTime(elapsed); } + currentAnimationIdx = 0; } } void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation) { - if (animations.contains(animation) ||animationsToStart.contains(animation)) + if (animations.contains(animation) || animationsToStart.contains(animation)) return; animationsToStart << animation; startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer @@ -222,8 +222,17 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation) void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation) { - animations.removeAll(animation); - animationsToStart.removeAll(animation); + Q_ASSERT(animations.count(animation) + animationsToStart.count(animation) <= 1); + + int idx = animations.indexOf(animation); + if (idx != -1) { + animations.removeAt(idx); + // this is needed if we unregister an animation while its running + if (idx <= currentAnimationIdx) + --currentAnimationIdx; + } else { + animationsToStart.removeOne(animation); + } startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer } @@ -250,28 +259,33 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) } state = newState; - QPointer<QAbstractAnimation> guard(q); + QWeakPointer<QAbstractAnimation> guard(q); - guard->updateState(oldState, newState); + q->updateState(oldState, newState); + if (!guard) + return; //this is to be safe if updateState changes the state if (state == oldState) return; // Notify state change - if (guard) - emit guard->stateChanged(oldState, newState); + emit q->stateChanged(oldState, newState); + if (!guard) + return; - switch (state) - { + switch (state) { case QAbstractAnimation::Paused: case QAbstractAnimation::Running: //this ensures that the value is updated now that the animation is running - if(oldState == QAbstractAnimation::Stopped && guard) - guard->setCurrentTime(currentTime); + if(oldState == QAbstractAnimation::Stopped) { + q->setCurrentTime(currentTime); + if (!guard) + return; + } // Register timer if our parent is not running. - if (state == QAbstractAnimation::Running && guard) { + if (state == QAbstractAnimation::Running) { if (!group || group->state() == QAbstractAnimation::Stopped) { QUnifiedTimer::instance()->registerAnimation(q); } @@ -283,7 +297,10 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) case QAbstractAnimation::Stopped: // Leave running state. int dura = q->duration(); - if (deleteWhenStopped && guard) + if (!guard) + return; + + if (deleteWhenStopped) q->deleteLater(); QUnifiedTimer::instance()->unregisterAnimation(q); @@ -291,8 +308,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) if (dura == -1 || loopCount < 0 || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount)) || (oldDirection == QAbstractAnimation::Backward && oldCurrentTime == 0)) { - if (guard) - emit q->finished(); + emit q->finished(); } break; } diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 32189f5..bcd7354 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -141,6 +141,7 @@ private: QTime time; int lastTick; int timingInterval; + int currentAnimationIdx; bool consistentTiming; QList<QAbstractAnimation*> animations, animationsToStart; }; diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 35d65d0..49862d2 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -92,8 +92,6 @@ #include "qanimationgroup.h" #include "qpropertyanimation_p.h" -#include <QtCore/qmath.h> -#include <QtCore/qmutex.h> #include <private/qmutexpool_p.h> #ifndef QT_NO_ANIMATION @@ -102,50 +100,38 @@ QT_BEGIN_NAMESPACE void QPropertyAnimationPrivate::updateMetaProperty() { - if (!target || propertyName.isEmpty()) + if (!target || propertyName.isEmpty()) { + propertyType = QVariant::Invalid; + propertyIndex = -1; return; - - if (!hasMetaProperty && !property.isValid()) { - const QMetaObject *mo = target->metaObject(); - propertyIndex = mo->indexOfProperty(propertyName); - if (propertyIndex != -1) { - hasMetaProperty = true; - property = mo->property(propertyIndex); - propertyType = property.userType(); - } else { - if (!target->dynamicPropertyNames().contains(propertyName)) - qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); - } } - if (property.isValid()) + propertyType = targetValue->property(propertyName).userType(); + propertyIndex = targetValue->metaObject()->indexOfProperty(propertyName); + if (propertyIndex == -1 && !targetValue->dynamicPropertyNames().contains(propertyName)) + qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); + + if (propertyType != QVariant::Invalid) convertValues(propertyType); } void QPropertyAnimationPrivate::updateProperty(const QVariant &newValue) { - if (!target || state == QAbstractAnimation::Stopped) + if (state == QAbstractAnimation::Stopped) return; - if (hasMetaProperty) { - if (newValue.userType() == propertyType) { - //no conversion is needed, we directly call the QObject::qt_metacall - void *data = const_cast<void*>(newValue.constData()); - target->qt_metacall(QMetaObject::WriteProperty, propertyIndex, &data); - } else { - property.write(target, newValue); - } - } else { - target->setProperty(propertyName.constData(), newValue); + if (!target) { + q_func()->stop(); //the target was destroyed we need to stop the animation + return; } -} -void QPropertyAnimationPrivate::_q_targetDestroyed() -{ - Q_Q(QPropertyAnimation); - //we stop here so that this animation is removed from the global hash - q->stop(); - target = 0; + if (propertyIndex != -1 && newValue.userType() == propertyType) { + //no conversion is needed, we directly call the QObject::qt_metacall + void *data = const_cast<void*>(newValue.constData()); + targetValue->qt_metacall(QMetaObject::WriteProperty, propertyIndex, &data); + } else { + targetValue->setProperty(propertyName.constData(), newValue); + } } /*! @@ -187,14 +173,13 @@ QPropertyAnimation::~QPropertyAnimation() */ QObject *QPropertyAnimation::targetObject() const { - Q_D(const QPropertyAnimation); - return d->target; + return d_func()->target.data(); } void QPropertyAnimation::setTargetObject(QObject *target) { Q_D(QPropertyAnimation); - if (d->target == target) + if (d->targetValue == target) return; if (d->state != QAbstractAnimation::Stopped) { @@ -202,15 +187,7 @@ void QPropertyAnimation::setTargetObject(QObject *target) return; } - //we need to get notified when the target is destroyed - if (d->target) - disconnect(d->target, SIGNAL(destroyed()), this, SLOT(_q_targetDestroyed())); - - if (target) - connect(target, SIGNAL(destroyed()), SLOT(_q_targetDestroyed())); - - d->target = target; - d->hasMetaProperty = false; + d->target = d->targetValue = target; d->updateMetaProperty(); } @@ -236,7 +213,6 @@ void QPropertyAnimation::setPropertyName(const QByteArray &propertyName) } d->propertyName = propertyName; - d->hasMetaProperty = false; d->updateMetaProperty(); } @@ -273,7 +249,7 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState, { Q_D(QPropertyAnimation); - if (!d->target) { + if (!d->target && oldState == Stopped) { qWarning("QPropertyAnimation::updateState: Changing state of an animation without target"); return; } @@ -286,14 +262,16 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState, typedef QPair<QObject *, QByteArray> QPropertyAnimationPair; typedef QHash<QPropertyAnimationPair, QPropertyAnimation*> QPropertyAnimationHash; static QPropertyAnimationHash hash; - QPropertyAnimationPair key(d->target, d->propertyName); + //here we need to use value because we need to know to which pointer + //the animation was referring in case stopped because the target was destroyed + QPropertyAnimationPair key(d->targetValue, d->propertyName); if (newState == Running) { d->updateMetaProperty(); animToStop = hash.value(key, 0); hash.insert(key, this); // update the default start value if (oldState == Stopped) { - d->setDefaultStartEndValue(d->target->property(d->propertyName.constData())); + d->setDefaultStartEndValue(d->targetValue->property(d->propertyName.constData())); //let's check if we have a start value and an end value if (d->direction == Forward && !startValue().isValid() && !d->defaultStartEndValue.isValid()) qWarning("QPropertyAnimation::updateState: starting an animation without start value"); diff --git a/src/corelib/animation/qpropertyanimation.h b/src/corelib/animation/qpropertyanimation.h index e12508d..56fb4b1 100644 --- a/src/corelib/animation/qpropertyanimation.h +++ b/src/corelib/animation/qpropertyanimation.h @@ -76,7 +76,6 @@ protected: void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); private: - Q_PRIVATE_SLOT(d_func(), void _q_targetDestroyed()) Q_DISABLE_COPY(QPropertyAnimation) Q_DECLARE_PRIVATE(QPropertyAnimation) }; diff --git a/src/corelib/animation/qpropertyanimation_p.h b/src/corelib/animation/qpropertyanimation_p.h index ffa6114..3777aa0 100644 --- a/src/corelib/animation/qpropertyanimation_p.h +++ b/src/corelib/animation/qpropertyanimation_p.h @@ -54,7 +54,6 @@ // #include "qpropertyanimation.h" -#include <QtCore/qmetaobject.h> #include "private/qvariantanimation_p.h" @@ -67,20 +66,18 @@ class QPropertyAnimationPrivate : public QVariantAnimationPrivate Q_DECLARE_PUBLIC(QPropertyAnimation) public: QPropertyAnimationPrivate() - : target(0), propertyType(0), propertyIndex(0), hasMetaProperty(false) + : targetValue(0), propertyType(0), propertyIndex(-1) { } - void _q_targetDestroyed(); - - QObject *target; + QWeakPointer<QObject> target; + //we use targetValue to be able to unregister the target from the global hash + QObject *targetValue; //for the QProperty - QMetaProperty property; int propertyType; int propertyIndex; - bool hasMetaProperty; QByteArray propertyName; void updateProperty(const QVariant &); void updateMetaProperty(); diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h index ce625f1..da120df 100644 --- a/src/corelib/animation/qvariantanimation_p.h +++ b/src/corelib/animation/qvariantanimation_p.h @@ -78,10 +78,7 @@ public: void setDefaultStartEndValue(const QVariant &value); - int duration; - QEasingCurve easing; - QVariantAnimation::KeyValues keyValues; QVariant currentValue; QVariant defaultStartEndValue; @@ -91,6 +88,9 @@ public: QVariantAnimation::KeyValue start, end; } currentInterval; + QEasingCurve easing; + int duration; + QVariantAnimation::KeyValues keyValues; QVariantAnimation::Interpolator interpolator; void setCurrentValueForProgress(const qreal progress); diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index d7ae78f..7a24ecc 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1903,12 +1903,12 @@ QSysInfo::SymbianVersion QSysInfo::symbianVersion() */ /*! - T *q_check_ptr(T *pointer) + \fn T *q_check_ptr(T *pointer) \relates <QtGlobal> - Users Q_CHECK_PTR on \a pointer, then returns \a pointer. + Users Q_CHECK_PTR on \a pointer, then returns \a pointer. - This can be used as an inline version of Q_CHECK_PTR. + This can be used as an inline version of Q_CHECK_PTR. */ /*! diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 87f5cb2..d26728d 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -265,15 +265,6 @@ namespace QT_NAMESPACE {} # define Q_OS_WIN #endif -#if defined(Q_OS_WIN32) -# ifndef WINVER -# define WINVER 0x0500 -# endif -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0500 -# endif -#endif - #if defined(Q_OS_DARWIN) # define Q_OS_MAC /* Q_OS_MAC is mostly for compatibility, but also more clear */ # define Q_OS_MACX /* Q_OS_MACX is only for compatibility.*/ @@ -2399,6 +2390,10 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf(); #endif #if defined(Q_OS_SYMBIAN) + +//Symbian does not support data imports from a DLL +#define Q_NO_DATA_RELOCATION + QT_END_NAMESPACE // forward declare std::exception #ifdef __cplusplus diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 657e367..134cbcc 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2445,7 +2445,7 @@ \value ImhNone No hints. \value ImhHiddenText Characters should be hidden, as is typically used when entering passwords. This is automatically set when setting QLineEdit::echoMode to \c Password. - \value ImhNumbersOnly Only number input is allowed. + \value ImhDigitsOnly Only number input is allowed. \value ImhUppercaseOnly Only upper case letter input is allowed. \value ImhLowercaseOnly Only lower case letter input is allowed. \value ImhNoAutoUppercase The input method should not try to automatically switch to upper case @@ -2456,6 +2456,9 @@ \value ImhNoPredictiveText Do not use predictive text (i.e. dictionary lookup) while typing. \value ImhDialableCharactersOnly Only characters suitable for phone dialling are allowed. + \omitvalue ImhFormattedNumbersOnly + \omitvalue ImhExclusiveInputMask + \note If several flags ending with \c Only are ORed together, the resulting character set will consist of the union of the specified sets. For instance specifying \c ImhNumbersOnly and \c ImhUppercaseOnly would yield a set consisting of numbers and uppercase letters. diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h index 6e3f242..dd722f9 100644 --- a/src/corelib/global/qt_windows.h +++ b/src/corelib/global/qt_windows.h @@ -53,6 +53,13 @@ #endif #endif +#if defined(Q_CC_MINGW) +// mingw's windows.h does not set _WIN32_WINNT, resulting breaking compilation +#ifndef WINVER +#define WINVER 0x500 +#endif +#endif + #include <windows.h> #ifdef _WIN32_WCE diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index a7919d3..ec20e4a 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -46,9 +46,6 @@ #ifndef QT_NO_FSFILEENGINE -#ifndef QT_NO_REGEXP -# include "qregexp.h" -#endif #include "qfile.h" #include "qdir.h" #include "qdatetime.h" @@ -71,7 +68,7 @@ QT_BEGIN_NAMESPACE -#ifdef Q_OS_SYMBIAN +#if defined(Q_OS_SYMBIAN) /*! \internal @@ -409,7 +406,7 @@ bool QFSFileEngine::copy(const QString &newName) QString oldNative(QDir::toNativeSeparators(d->filePath)); TPtrC oldPtr(qt_QString2TPtrC(oldNative)); QFileInfo fi(newName); - QString absoluteNewName = fi.absolutePath() + QDir::separator() + fi.fileName(); + QString absoluteNewName = fi.absoluteFilePath(); QString newNative(QDir::toNativeSeparators(absoluteNewName)); TPtrC newPtr(qt_QString2TPtrC(newNative)); TRAPD (err, @@ -422,8 +419,10 @@ bool QFSFileEngine::copy(const QString &newName) } ) // End TRAP delete fm; + // ### Add error reporting on failure return (err == KErrNone); #else + Q_UNUSED(newName); // ### Add copy code for Unix here setError(QFile::UnspecifiedError, QLatin1String("Not implemented!")); return false; @@ -457,10 +456,9 @@ bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) con { QString dirName = name; if (createParentDirectories) { -#if defined(Q_OS_SYMBIAN) - dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName)); -#else dirName = QDir::cleanPath(dirName); +#if defined(Q_OS_SYMBIAN) + dirName = QDir::toNativeSeparators(dirName); #endif for(int oldslash = -1, slash=0; slash != -1; oldslash = slash) { slash = dirName.indexOf(QDir::separator(), oldslash+1); @@ -493,10 +491,9 @@ bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) co { QString dirName = name; if (recurseParentDirectories) { -#if defined(Q_OS_SYMBIAN) - dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName)); -#else dirName = QDir::cleanPath(dirName); +#if defined(Q_OS_SYMBIAN) + dirName = QDir::toNativeSeparators(dirName); #endif for(int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) { QByteArray chunk = QFile::encodeName(dirName.left(slash)); @@ -537,12 +534,12 @@ QString QFSFileEngine::currentPath(const QString &) QString result; QT_STATBUF st; #if defined(Q_OS_SYMBIAN) - char currentName[PATH_MAX+1]; - if (::getcwd(currentName, PATH_MAX)) - result = QDir::fromNativeSeparators(QFile::decodeName(QByteArray(currentName))); + char nativeCurrentName[PATH_MAX+1]; + if (::getcwd(nativeCurrentName, PATH_MAX)) + result = QDir::fromNativeSeparators(QFile::decodeName(QByteArray(nativeCurrentName))); if (result.isEmpty()) { # if defined(QT_DEBUG) - qWarning("QDir::currentPath: getcwd() failed"); + qWarning("QFSFileEngine::currentPath: getcwd() failed"); # endif } else #endif @@ -559,7 +556,7 @@ QString QFSFileEngine::currentPath(const QString &) result = QFile::decodeName(QByteArray(currentName)); # if defined(QT_DEBUG) if (result.isNull()) - qWarning("QDir::currentPath: getcwd() failed"); + qWarning("QFSFileEngine::currentPath: getcwd() failed"); # endif #endif } else { @@ -568,10 +565,10 @@ QString QFSFileEngine::currentPath(const QString &) // try to create it (can happen with application private dirs) // Ignore mkdir failures; we want to be consistent with Open C // current path regardless. - ::mkdir(QFile::encodeName(currentName), 0777); + QT_MKDIR(QFile::encodeName(nativeCurrentName), 0777); #else # if defined(QT_DEBUG) - qWarning("QDir::currentPath: stat(\".\") failed"); + qWarning("QFSFileEngine::currentPath: stat(\".\") failed"); # endif #endif } @@ -607,11 +604,14 @@ QString QFSFileEngine::rootPath() QString QFSFileEngine::tempPath() { -#ifdef Q_OS_SYMBIAN +#if defined(Q_OS_SYMBIAN) # ifdef Q_WS_S60 TFileName symbianPath = PathInfo::PhoneMemoryRootPath(); QString temp = QDir::fromNativeSeparators(qt_TDesC2QString(symbianPath)); temp += QLatin1String( "temp/"); + + // Just to verify that folder really exist on hardware + QT_MKDIR(QFile::encodeName(temp), 0777); # else # warning No fallback implementation of QFSFileEngine::tempPath() return QString(); @@ -632,14 +632,16 @@ QFileInfoList QFSFileEngine::drives() RFs rfs = qt_s60GetRFs(); TInt err = rfs.DriveList(driveList); if (err == KErrNone) { + char driveName[] = "A:/"; + for (char i = 0; i < KMaxDrives; i++) { if (driveList[i]) { - ret.append(QString("%1:/").arg(QChar('A' + i))); + driveName[0] = 'A' + i; + ret.append(QFileInfo(QLatin1String(driveName))); } } - } - else { - qWarning("QDir::drives: Getting drives failed"); + } else { + qWarning("QFSFileEngine::drives: Getting drives failed"); } #else ret.append(QFileInfo(rootPath())); @@ -680,22 +682,16 @@ bool QFSFileEnginePrivate::isSymlink() const #if defined(Q_OS_SYMBIAN) static bool _q_isSymbianHidden(const QString &path, bool isDir) { - bool retval = false; RFs rfs = qt_s60GetRFs(); QFileInfo fi(path); QString absPath = fi.absoluteFilePath(); - if (isDir && absPath.at(absPath.size()-1) != QChar('/')) { - absPath += QChar('/'); - } + if (isDir && !absPath.endsWith(QLatin1Char('/'))) + absPath.append(QLatin1Char('/')); QString native(QDir::toNativeSeparators(absPath)); TPtrC ptr(qt_QString2TPtrC(native)); TUint attributes; TInt err = rfs.Att(ptr, attributes); - if (err == KErrNone && (attributes & KEntryAttHidden)) { - retval = true; - } - - return retval; + return (err == KErrNone && (attributes & KEntryAttHidden)); } #endif @@ -805,16 +801,16 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const ret |= ExistsFlag; #if defined(Q_OS_SYMBIAN) if (d->filePath == QLatin1String("/") - || (d->filePath.at(0).isLetter() - && d->filePath.mid(1,d->filePath.length()) == QLatin1String(":/"))) + || (d->filePath.length() == 3 && d->filePath.at(0).isLetter() + && d->filePath.at(1) == QLatin1Char(':') && d->filePath.at(2) == QLatin1Char('/'))) { ret |= RootFlag; - - // In Symbian, all symlinks have hidden attribute for some reason; - // lets make them visible for better compatibility with other platforms. - // If somebody actually wants a hidden link, then they are out of luck. - if (!(ret & RootFlag) && !d->isSymlink()) - if(_q_isSymbianHidden(d->filePath, ret & DirectoryType)) - ret |= HiddenFlag; + } else { + // In Symbian, all symlinks have hidden attribute for some reason; + // lets make them visible for better compatibility with other platforms. + // If somebody actually wants a hidden link, then they are out of luck. + if (!d->isSymlink() && _q_isSymbianHidden(d->filePath, ret & DirectoryType)) + ret |= HiddenFlag; + } #else if (d->filePath == QLatin1String("/")) { ret |= RootFlag; @@ -825,7 +821,7 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const # if !defined(QWS) && defined(Q_OS_MAC) || _q_isMacHidden(d->filePath) # endif - ) { + ) { ret |= HiddenFlag; } } @@ -834,12 +830,12 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const return ret; } -#ifdef Q_OS_SYMBIAN -static QString symbianFileName(QAbstractFileEngine::FileName file, const QFSFileEngine *engine, - const QFSFileEnginePrivate * const d) +#if defined(Q_OS_SYMBIAN) +QString QFSFileEngine::fileName(FileName file) const { + Q_D(const QFSFileEngine); const QLatin1Char slashChar('/'); - if(file == QAbstractFileEngine::BaseName) { + if(file == BaseName) { int slash = d->filePath.lastIndexOf(slashChar); if(slash == -1) { int colon = d->filePath.lastIndexOf(QLatin1Char(':')); @@ -848,7 +844,7 @@ static QString symbianFileName(QAbstractFileEngine::FileName file, const QFSFile return d->filePath; } return d->filePath.mid(slash + 1); - } else if(file == QAbstractFileEngine::PathName) { + } else if(file == PathName) { if(!d->filePath.size()) return d->filePath; @@ -864,7 +860,7 @@ static QString symbianFileName(QAbstractFileEngine::FileName file, const QFSFile slash++; return d->filePath.left(slash); } - } else if(file == QAbstractFileEngine::AbsoluteName || file == QAbstractFileEngine::AbsolutePathName) { + } else if(file == AbsoluteName || file == AbsolutePathName) { QString ret; if (!isRelativePathSymbian(d->filePath)) { if (d->filePath.size() > 2 && d->filePath.at(1) == QLatin1Char(':') @@ -892,7 +888,7 @@ static QString symbianFileName(QAbstractFileEngine::FileName file, const QFSFile ret[0] = ret.at(0).toUpper(); } - if (file == QAbstractFileEngine::AbsolutePathName) { + if (file == AbsolutePathName) { int slash = ret.lastIndexOf(slashChar); if (slash < 0) return ret; @@ -902,12 +898,12 @@ static QString symbianFileName(QAbstractFileEngine::FileName file, const QFSFile return ret.left(slash > 0 ? slash : 1); } return ret; - } else if(file == QAbstractFileEngine::CanonicalName || file == QAbstractFileEngine::CanonicalPathName) { - if (!(engine->fileFlags(QAbstractFileEngine::ExistsFlag) & QAbstractFileEngine::ExistsFlag)) + } else if(file == CanonicalName || file == CanonicalPathName) { + if (!(fileFlags(ExistsFlag) & ExistsFlag)) return QString(); - QString ret = QFSFileEnginePrivate::canonicalized(symbianFileName(QAbstractFileEngine::AbsoluteName, engine, d)); - if (!ret.isEmpty() && file == QAbstractFileEngine::CanonicalPathName) { + QString ret = QFSFileEnginePrivate::canonicalized(fileName(AbsoluteName)); + if (file == CanonicalPathName && !ret.isEmpty()) { int slash = ret.lastIndexOf(slashChar); if (slash == -1) ret = QDir::fromNativeSeparators(QDir::currentPath()); @@ -916,7 +912,7 @@ static QString symbianFileName(QAbstractFileEngine::FileName file, const QFSFile ret = ret.left(slash); } return ret; - } else if(file == QAbstractFileEngine::LinkName) { + } else if(file == LinkName) { if (d->isSymlink()) { char s[PATH_MAX+1]; int len = readlink(d->nativeFilePath.constData(), s, PATH_MAX); @@ -939,19 +935,17 @@ static QString symbianFileName(QAbstractFileEngine::FileName file, const QFSFile } } return QString(); - } else if(file == QAbstractFileEngine::BundleName) { + } else if(file == BundleName) { return QString(); } return d->filePath; } -#endif + +#else QString QFSFileEngine::fileName(FileName file) const { Q_D(const QFSFileEngine); -#ifdef Q_OS_SYMBIAN - return symbianFileName(file, this, d); -#else if (file == BundleName) { #if !defined(QWS) && defined(Q_OS_MAC) QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(d->filePath), @@ -1004,7 +998,7 @@ QString QFSFileEngine::fileName(FileName file) const return QString(); QString ret = QFSFileEnginePrivate::canonicalized(fileName(AbsoluteName)); - if (!ret.isEmpty() && file == CanonicalPathName) { + if (file == CanonicalPathName && !ret.isEmpty()) { int slash = ret.lastIndexOf(QLatin1Char('/')); if (slash == -1) ret = QDir::currentPath(); @@ -1085,19 +1079,16 @@ QString QFSFileEngine::fileName(FileName file) const return QString(); } return d->filePath; -#endif // Q_OS_SYMBIAN } +#endif // Q_OS_SYMBIAN bool QFSFileEngine::isRelativePath() const { Q_D(const QFSFileEngine); -#ifdef Q_OS_SYMBIAN +#if defined(Q_OS_SYMBIAN) return isRelativePathSymbian(d->filePath); #else - int len = d->filePath.length(); - if (len == 0) - return true; - return d->filePath[0] != QLatin1Char('/'); + return d->filePath.length() ? d->filePath[0] != QLatin1Char('/') : true; #endif } @@ -1134,9 +1125,7 @@ QString QFSFileEngine::owner(FileOwner own) const if (pw) return QFile::decodeName(QByteArray(pw->pw_name)); } else if (own == OwnerGroup) { -#ifdef Q_OS_SYMBIAN - return QString(); -#endif +#if !defined(Q_OS_SYMBIAN) struct group *gr = 0; #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) size_max = sysconf(_SC_GETGR_R_SIZE_MAX); @@ -1154,12 +1143,12 @@ QString QFSFileEngine::owner(FileOwner own) const || errno != ERANGE) break; } - #else gr = getgrgid(ownerId(own)); #endif if (gr) return QFile::decodeName(QByteArray(gr->gr_name)); +#endif } return QString(); } diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index a8de17b..4e142a9 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -123,6 +123,9 @@ typedef struct _REPARSE_DATA_BUFFER { # ifndef IO_REPARSE_TAG_SYMLINK # define IO_REPARSE_TAG_SYMLINK (0xA000000CL) # endif +# ifndef FSCTL_GET_REPARSE_POINT +# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) +# endif #endif QT_BEGIN_NAMESPACE @@ -1289,6 +1292,8 @@ static QString readSymLink(const QString &link) qFree(rdb); CloseHandle(handle); } +#else + Q_UNUSED(link); #endif // Q_OS_WINCE return result; } diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 764304d..f4bf5cc 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1646,7 +1646,8 @@ bool QProcess::waitForBytesWritten(int msecs) has been emitted, or until \a msecs milliseconds have passed. Returns true if the process finished; otherwise returns false (if - the operation timed out or if an error occurred). + the operation timed out, if an error occurred, or if this QProcess + is already finished). This function can operate without an event loop. It is useful when writing non-GUI applications and when performing diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 8612e03..de483ed 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -2118,12 +2118,12 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, Custom types registered using qRegisterMetaType() and qRegisterMetaTypeStreamOperators() can be stored using QSettings. - \section1 Key Syntax + \section1 Section and Key Syntax Setting keys can contain any Unicode characters. The Windows registry and INI files use case-insensitive keys, whereas the Carbon Preferences API on Mac OS X uses case-sensitive keys. To - avoid portability problems, follow these two simple rules: + avoid portability problems, follow these simple rules: \list 1 \o Always refer to the same key using the same case. For example, @@ -2134,7 +2134,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, example, if you have a key called "MainWindow", don't try to save another key as "mainwindow". - \o Do not use slashes ('/' and '\\') in key names; the + \o Do not use slashes ('/' and '\\') in section or key names; the backslash character is used to separate sub keys (see below). On windows '\\' are converted by QSettings to '/', which makes them identical. @@ -3199,8 +3199,8 @@ bool QSettings::isWritable() const Note that the Windows registry and INI files use case-insensitive keys, whereas the Carbon Preferences API on Mac OS X uses - case-sensitive keys. To avoid portability problems, see the \l{Key - Syntax} rules. + case-sensitive keys. To avoid portability problems, see the + \l{Section and Key Syntax} rules. Example: @@ -3234,8 +3234,8 @@ void QSettings::setValue(const QString &key, const QVariant &value) Note that the Windows registry and INI files use case-insensitive keys, whereas the Carbon Preferences API on Mac OS X uses - case-sensitive keys. To avoid portability problems, see the \l{Key - Syntax} rules. + case-sensitive keys. To avoid portability problems, see the + \l{Section and Key Syntax} rules. \sa setValue(), value(), contains() */ @@ -3269,8 +3269,8 @@ void QSettings::remove(const QString &key) Note that the Windows registry and INI files use case-insensitive keys, whereas the Carbon Preferences API on Mac OS X uses - case-sensitive keys. To avoid portability problems, see the \l{Key - Syntax} rules. + case-sensitive keys. To avoid portability problems, see the + \l{Section and Key Syntax} rules. \sa value(), setValue() */ @@ -3331,8 +3331,8 @@ bool QSettings::event(QEvent *event) Note that the Windows registry and INI files use case-insensitive keys, whereas the Carbon Preferences API on Mac OS X uses - case-sensitive keys. To avoid portability problems, see the \l{Key - Syntax} rules. + case-sensitive keys. To avoid portability problems, see the + \l{Section and Key Syntax} rules. Example: diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 3db0564..adfcf5e 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -514,10 +514,6 @@ QTemporaryFile::QTemporaryFile() { Q_D(QTemporaryFile); d->templateName = QDir::tempPath() + QLatin1String("/qt_temp.XXXXXX"); -#ifdef Q_OS_SYMBIAN - //Just to verify that folder really exist on hardware - fileEngine()->mkdir(QDir::tempPath(), true); -#endif } /*! diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 3b7059b..1ba3000 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -599,6 +599,118 @@ void QAbstractItemModelPrivate::rowsInserted(const QModelIndex &parent, } } +void QAbstractItemModelPrivate::itemsAboutToBeMoved(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation) +{ + Q_Q(QAbstractItemModel); + QVector<QPersistentModelIndexData *> persistent_moved_explicitly; + QVector<QPersistentModelIndexData *> persistent_moved_in_source; + QVector<QPersistentModelIndexData *> persistent_moved_in_destination; + + QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator it; + const QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator begin = persistent.indexes.constBegin(); + const QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator end = persistent.indexes.constEnd(); + + const bool sameParent = (srcParent == destinationParent); + const bool movingUp = (srcFirst > destinationChild); + + for ( it = begin; it != end; ++it) { + QPersistentModelIndexData *data = *it; + const QModelIndex &index = data->index; + const QModelIndex &parent = index.parent(); + const bool isSourceIndex = (parent == srcParent); + const bool isDestinationIndex = (parent == destinationParent); + + int childPosition; + if (orientation == Qt::Vertical) + childPosition = index.row(); + else + childPosition = index.column(); + + if (!index.isValid() || !(isSourceIndex || isDestinationIndex ) ) + continue; + + if (!sameParent && isDestinationIndex) { + if (childPosition >= destinationChild) + persistent_moved_in_destination.append(data); + continue; + } + + if (sameParent && movingUp && childPosition < destinationChild) + continue; + + if (sameParent && !movingUp && childPosition < srcFirst ) + continue; + + if (!sameParent && childPosition < srcFirst) + continue; + + if (sameParent && (childPosition > srcLast) && (childPosition >= destinationChild )) + continue; + + if ((childPosition <= srcLast) && (childPosition >= srcFirst)) { + persistent_moved_explicitly.append(data); + } else { + persistent_moved_in_source.append(data); + } + } + persistent.moved.push(persistent_moved_explicitly); + persistent.moved.push(persistent_moved_in_source); + persistent.moved.push(persistent_moved_in_destination); +} + +/*! + \internal + + Moves persistent indexes \a indexes by amount \a change. The change will be either a change in row value or a change in + column value depending on the value of \a orientation. The indexes may also be moved to a different parent if \a parent + differs from the existing parent for the index. +*/ +void QAbstractItemModelPrivate::movePersistentIndexes(QVector<QPersistentModelIndexData *> indexes, int change, const QModelIndex &parent, Qt::Orientation orientation) +{ + QVector<QPersistentModelIndexData *>::const_iterator it; + const QVector<QPersistentModelIndexData *>::const_iterator begin = indexes.constBegin(); + const QVector<QPersistentModelIndexData *>::const_iterator end = indexes.constEnd(); + + for (it = begin; it != end; ++it) + { + QPersistentModelIndexData *data = *it; + + int row = data->index.row(); + int column = data->index.column(); + + if (Qt::Vertical == orientation) + row += change; + else + column += change; + + persistent.indexes.erase(persistent.indexes.find(data->index)); + data->index = q_func()->index(row, column, parent); + if (data->index.isValid()) { + persistent.insertMultiAtEnd(data->index, data); + } else { + qWarning() << "QAbstractItemModel::endMoveRows: Invalid index (" << row << "," << column << ") in model" << q_func(); + } + } +} + +void QAbstractItemModelPrivate::itemsMoved(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation) +{ + QVector<QPersistentModelIndexData *> moved_in_destination = persistent.moved.pop(); + QVector<QPersistentModelIndexData *> moved_in_source = persistent.moved.pop(); + QVector<QPersistentModelIndexData *> moved_explicitly = persistent.moved.pop(); + + const bool sameParent = (sourceParent == destinationParent); + const bool movingUp = (sourceFirst > destinationChild); + + const int explicit_change = (!sameParent || movingUp) ? destinationChild - sourceFirst : destinationChild - sourceLast - 1 ; + const int source_change = (!sameParent || !movingUp) ? -1*(sourceLast - sourceFirst + 1) : sourceLast - sourceFirst + 1 ; + const int destination_change = sourceLast - sourceFirst + 1; + + movePersistentIndexes(moved_explicitly, explicit_change, destinationParent, orientation); + movePersistentIndexes(moved_in_source, source_change, sourceParent, orientation); + movePersistentIndexes(moved_in_destination, destination_change, destinationParent, orientation); +} + void QAbstractItemModelPrivate::rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last) { @@ -1227,7 +1339,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \endlist - \sa layoutAboutToBeChanged(), dataChanged(), headerDataChanged(), reset(), + \sa layoutAboutToBeChanged(), dataChanged(), headerDataChanged(), modelReset(), changePersistentIndex() */ @@ -1370,6 +1482,70 @@ QAbstractItemModel::~QAbstractItemModel() */ /*! + \fn void QAbstractItemModel::rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) + \since 4.6 + + This signal is emitted after rows have been moved within the + model. The items between \a sourceStart and \a sourceEnd + inclusive, under the given \a sourceParent item have been moved to \a destinationParent + starting at the row \a destinationRow. + + \bold{Note:} Components connected to this signal use it to adapt to changes + in the model's dimensions. It can only be emitted by the QAbstractItemModel + implementation, and cannot be explicitly emitted in subclass code. + + \sa beginMoveRows() +*/ + +/*! + \fn void QAbstractItemModel::rowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) + \since 4.6 + + This signal is emitted just before rows are moved within the + model. The items that will be moved are those between \a sourceStart and \a sourceEnd + inclusive, under the given \a sourceParent item. They will be moved to \a destinationParent + starting at the row \a destinationRow. + + \bold{Note:} Components connected to this signal use it to adapt to changes + in the model's dimensions. It can only be emitted by the QAbstractItemModel + implementation, and cannot be explicitly emitted in subclass code. + + \sa beginMoveRows() +*/ + +/*! + \fn void QAbstractItemModel::columnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn) + \since 4.6 + + This signal is emitted after columns have been moved within the + model. The items between \a sourceStart and \a sourceEnd + inclusive, under the given \a sourceParent item have been moved to \a destinationParent + starting at the column \a destinationColumn. + + \bold{Note:} Components connected to this signal use it to adapt to changes + in the model's dimensions. It can only be emitted by the QAbstractItemModel + implementation, and cannot be explicitly emitted in subclass code. + + \sa beginMoveRows() +*/ + +/*! + \fn void QAbstractItemModel::columnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn) + \since 4.6 + + This signal is emitted just before columns are moved within the + model. The items that will be moved are those between \a sourceStart and \a sourceEnd + inclusive, under the given \a sourceParent item. They will be moved to \a destinationParent + starting at the column \a destinationColumn. + + \bold{Note:} Components connected to this signal use it to adapt to changes + in the model's dimensions. It can only be emitted by the QAbstractItemModel + implementation, and cannot be explicitly emitted in subclass code. + + \sa beginMoveRows() +*/ + +/*! \fn void QAbstractItemModel::columnsInserted(const QModelIndex &parent, int start, int end) This signal is emitted after columns have been inserted into the model. The @@ -2284,6 +2460,123 @@ void QAbstractItemModel::endRemoveRows() } /*! + Returns whether a move operation is valid. + + A move operation is not allowed if it moves a continuous range of rows to a destination within + itself, or if it attempts to move a row to one of its own descendants. + + \internal +*/ +bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int start, int end, const QModelIndex &destinationParent, int destinationStart, Qt::Orientation orientation) +{ + Q_Q(QAbstractItemModel); + // Don't move the range within itself. + if ( ( destinationParent == srcParent ) + && ( destinationStart >= start ) + && ( destinationStart <= end + 1) ) + return false; + + QModelIndex destinationAncestor = destinationParent; + int pos = (Qt::Vertical == orientation) ? destinationAncestor.row() : destinationAncestor.column(); + forever { + if (destinationAncestor == srcParent) { + if (pos >= start && pos <= end) + return false; + break; + } + + if (!destinationAncestor.isValid()) + break; + + pos = (Qt::Vertical == orientation) ? destinationAncestor.row() : destinationAncestor.column(); + destinationAncestor = destinationAncestor.parent(); + } + + return true; +} + +/*! + Begins a row move operation. + + When reimplementing a subclass, this method simplifies moving + entities in your model. This method is responsible for moving + persistent indexes in the model, which you would otherwise be + required to do yourself. + + Using beginMoveRows and endMoveRows is an alternative to emitting + layoutAboutToBeChanged and layoutChanged directly along with + changePersistentIndexes. layoutAboutToBeChanged is emitted by + this method for compatibility reasons. + + The \a sourceParent index corresponds to the parent from which the + rows are moved; \a sourceFirst and \a sourceLast are the row + numbers of the rows to be moved. The \a destinationParent index + corresponds to the parent into which the rows are moved. The \a + destinationChild is the row to which the rows will be moved. That + is, the index at row \a sourceFirst in \a sourceParent will become + row \a destinationChild in \a destinationParent. Its siblings will + be moved correspondingly. + + Note that \a sourceParent and \a destinationParent may be the + same, in which case you must ensure that the \a destinationChild is + not within the range of \a sourceFirst and \a sourceLast. You + must also ensure that you do not attempt to move a row to one of + its own chilren or ancestors. This method returns false if either + condition is true, in which case you should abort your move + operation. + + \sa endMoveRows() + + \since 4.6 +*/ +bool QAbstractItemModel::beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild) +{ + Q_ASSERT(sourceFirst >= 0); + Q_ASSERT(sourceLast >= sourceFirst); + Q_ASSERT(destinationChild >= 0); + Q_D(QAbstractItemModel); + + if (!d->allowMove(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Vertical)) { + return false; + } + + d->changes.push(QAbstractItemModelPrivate::Change(sourceParent, sourceFirst, sourceLast)); + int destinationLast = destinationChild + (sourceLast - sourceFirst); + d->changes.push(QAbstractItemModelPrivate::Change(destinationParent, destinationChild, destinationLast)); + + d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Vertical); + emit rowsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild); + emit layoutAboutToBeChanged(); + return true; +} + +/*! + Ends a row move operation. + + When implementing a subclass, you must call this + function \e after moving data within the model's underlying data + store. + + layoutChanged is emitted by this method for compatibility reasons. + + \sa beginMoveRows() + + \since 4.6 +*/ +void QAbstractItemModel::endMoveRows() +{ + Q_D(QAbstractItemModel); + + QAbstractItemModelPrivate::Change insertChange = d->changes.pop(); + QAbstractItemModelPrivate::Change removeChange = d->changes.pop(); + + d->itemsMoved(removeChange.parent, removeChange.first, removeChange.last, insertChange.parent, insertChange.first, Qt::Vertical); + + emit rowsMoved(removeChange.parent, removeChange.first, removeChange.last, insertChange.parent, insertChange.first); + emit layoutChanged(); +} + +/*! Begins a column insertion operation. When reimplementing insertColumns() in a subclass, you must call this @@ -2406,9 +2699,108 @@ void QAbstractItemModel::endRemoveColumns() } /*! + Begins a column move operation. + + When reimplementing a subclass, this method simplifies moving + entities in your model. This method is responsible for moving + persistent indexes in the model, which you would otherwise be + required to do yourself. + + Using beginMoveColumns and endMoveColumns is an alternative to + emitting layoutAboutToBeChanged and layoutChanged directly along + with changePersistentIndexes. layoutAboutToBeChanged is emitted + by this method for compatibility reasons. + + The \a sourceParent index corresponds to the parent from which the + columns are moved; \a sourceFirst and \a sourceLast are the column + numbers of the columns to be moved. The \a destinationParent index + corresponds to the parent into which the columns are moved. The \a + destinationChild is the column to which the columns will be + moved. That is, the index at column \a sourceFirst in \a + sourceParent will become column \a destinationChild in \a + destinationParent. Its siblings will be moved correspondingly. + + Note that \a sourceParent and \a destinationParent may be the + same, in which case you must ensure that the \a destinationChild + is not within the range of \a sourceFirst and \a sourceLast. You + must also ensure that you do not attempt to move a row to one of + its own chilren or ancestors. This method returns false if either + condition is true, in which case you should abort your move + operation. + + \sa endMoveColumns() + + \since 4.6 +*/ +bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild) +{ + Q_ASSERT(sourceFirst >= 0); + Q_ASSERT(sourceLast >= sourceFirst); + Q_ASSERT(destinationChild >= 0); + Q_D(QAbstractItemModel); + + if (!d->allowMove(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal)) { + return false; + } + + d->changes.push(QAbstractItemModelPrivate::Change(sourceParent, sourceFirst, sourceLast)); + int destinationLast = destinationChild + (sourceLast - sourceFirst); + d->changes.push(QAbstractItemModelPrivate::Change(destinationParent, destinationChild, destinationLast)); + + d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal); + + emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild); + emit layoutAboutToBeChanged(); + return true; +} + +/*! + Ends a column move operation. + + When implementing a subclass, you must call this + function \e after moving data within the model's underlying data + store. + + layoutChanged is emitted by this method for compatibility reasons. + + \sa beginMoveColumns() + + \since 4.6 +*/ +void QAbstractItemModel::endMoveColumns() +{ + Q_D(QAbstractItemModel); + + QAbstractItemModelPrivate::Change insertChange = d->changes.pop(); + QAbstractItemModelPrivate::Change removeChange = d->changes.pop(); + + d->itemsMoved(removeChange.parent, removeChange.first, removeChange.last, insertChange.parent, insertChange.first, Qt::Horizontal); + + emit columnsMoved(removeChange.parent, removeChange.first, removeChange.last, insertChange.parent, insertChange.first); + emit layoutChanged(); +} + +/*! Resets the model to its original state in any attached views. - The view to which the model is attached to will be reset as well. + \note Use beginResetModel() and endResetModel() instead whenever possible. + Use this method only if there is no way to call beginResetModel() before invalidating the model. + Otherwise it could lead to unexcpected behaviour, especially when used with proxy models. +*/ +void QAbstractItemModel::reset() +{ + Q_D(QAbstractItemModel); + emit modelAboutToBeReset(); + d->invalidatePersistentIndexes(); + emit modelReset(); +} + +/*! + Begins a model reset operation. + + A reset operation resets the model to its current state in any attached views. + + \note Any views attached to this model will be reset as well. When a model is reset it means that any previous data reported from the model is now invalid and has to be queried for again. This also means that @@ -2418,12 +2810,29 @@ void QAbstractItemModel::endRemoveColumns() call this function rather than emit dataChanged() to inform other components when the underlying data source, or its structure, has changed. - \sa modelAboutToBeReset(), modelReset() + You must call this function before resetting any internal data structures in your model + or proxy model. + + \sa modelAboutToBeReset(), modelReset(), endResetModel() + \since 4.6 */ -void QAbstractItemModel::reset() +void QAbstractItemModel::beginResetModel() { - Q_D(QAbstractItemModel); emit modelAboutToBeReset(); +} + +/*! + Completes a model reset operation. + + You must call this function after resetting any internal data structure in your model + or proxy model. + + \sa beginResetModel() + \since 4.6 +*/ +void QAbstractItemModel::endResetModel() +{ + Q_D(QAbstractItemModel); d->invalidatePersistentIndexes(); emit modelReset(); } @@ -2895,7 +3304,7 @@ bool QAbstractListModel::dropMimeData(const QMimeData *data, Qt::DropAction acti This signal is emitted when reset() is called, before the model's internal state (e.g. persistent model indexes) has been invalidated. - \sa reset(), modelReset() + \sa beginResetModel(), modelReset() */ /*! @@ -2905,7 +3314,7 @@ bool QAbstractListModel::dropMimeData(const QMimeData *data, Qt::DropAction acti This signal is emitted when reset() is called, after the model's internal state (e.g. persistent model indexes) has been invalidated. - \sa reset(), modelAboutToBeReset() + \sa endResetModel(), modelAboutToBeReset() */ /*! diff --git a/src/corelib/kernel/qabstractitemmodel.h b/src/corelib/kernel/qabstractitemmodel.h index 00f6cb2..1ca6cbe 100644 --- a/src/corelib/kernel/qabstractitemmodel.h +++ b/src/corelib/kernel/qabstractitemmodel.h @@ -252,6 +252,13 @@ private: // can only be emitted by QAbstractItemModel void modelAboutToBeReset(); void modelReset(); + void rowsAboutToBeMoved( const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow ); + void rowsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row ); + + void columnsAboutToBeMoved( const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn ); + void columnsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column ); + + public Q_SLOTS: virtual bool submit(); virtual void revert(); @@ -272,14 +279,23 @@ protected: void beginRemoveRows(const QModelIndex &parent, int first, int last); void endRemoveRows(); + bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow); + void endMoveRows(); + void beginInsertColumns(const QModelIndex &parent, int first, int last); void endInsertColumns(); void beginRemoveColumns(const QModelIndex &parent, int first, int last); void endRemoveColumns(); + bool beginMoveColumns(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn); + void endMoveColumns(); + void reset(); + void beginResetModel(); + void endResetModel(); + void changePersistentIndex(const QModelIndex &from, const QModelIndex &to); void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to); QModelIndexList persistentIndexList() const; diff --git a/src/corelib/kernel/qabstractitemmodel_p.h b/src/corelib/kernel/qabstractitemmodel_p.h index e81e627..aae3cba 100644 --- a/src/corelib/kernel/qabstractitemmodel_p.h +++ b/src/corelib/kernel/qabstractitemmodel_p.h @@ -80,6 +80,7 @@ class Q_CORE_EXPORT QAbstractItemModelPrivate : public QObjectPrivate public: QAbstractItemModelPrivate() : QObjectPrivate(), supportedDragActions(-1), roleNames(defaultRoleNames()) {} void removePersistentIndexData(QPersistentModelIndexData *data); + void movePersistentIndexes(QVector<QPersistentModelIndexData *> indexes, int change, const QModelIndex &parent, Qt::Orientation orientation); void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last); void rowsInserted(const QModelIndex &parent, int first, int last); void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last); @@ -91,6 +92,10 @@ public: static QAbstractItemModel *staticEmptyModel(); static bool variantLessThan(const QVariant &v1, const QVariant &v2); + void itemsAboutToBeMoved(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation); + void itemsMoved(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation); + bool allowMove(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation); + inline QModelIndex createIndex(int row, int column, void *data = 0) const { return q_func()->createIndex(row, column, data); } @@ -132,6 +137,8 @@ public: Change(const QModelIndex &p, int f, int l) : parent(p), first(f), last(l) {} QModelIndex parent; int first, last; + + bool isValid() { return first >= 0 && last >= 0; } }; QStack<Change> changes; diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp index 957b92c..a263cc4 100644 --- a/src/corelib/kernel/qcore_symbian_p.cpp +++ b/src/corelib/kernel/qcore_symbian_p.cpp @@ -175,10 +175,6 @@ Q_CORE_EXPORT TLibraryFunction qt_resolveS60PluginFunc(int ordinal) return qt_s60_plugin_resolver()->resolve(ordinal); } -/*! -\internal -Provides global access to a shared RFs. -*/ class QS60RFsSession { public: diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 6d88d92..854abef 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -393,43 +393,61 @@ QString qAppName() application's initialization and finalization, as well as system-wide and application-wide settings. - The command line arguments which QCoreApplication's constructor - should be called with are accessible using arguments(). The - event loop is started with a call to exec(). Long running + \section1 The Event Loop and Event Handling + + The event loop is started with a call to exec(). Long running operations can call processEvents() to keep the application responsive. Some Qt classes, such as QString, can be used without a QCoreApplication object. However, in general, we recommend that you create a QCoreApplication or a QApplication object in your \c - main() function as early as possible. The application will enter - the event loop when exec() is called. exit() will not return - until the event loop exits, e.g., when quit() is called. + main() function as early as possible. exit() will not return + until the event loop exits; e.g., when quit() is called. + + Several static convenience functions are also provided. The + QCoreApplication object is available from instance(). Events can + be sent or posted using sendEvent(), postEvent(), and + sendPostedEvents(). Pending events can be removed with + removePostedEvents() or flushed with flush(). + + The class provides a quit() slot and an aboutToQuit() signal. + + \section1 Application and Library Paths An application has an applicationDirPath() and an - applicationFilePath(). Translation files can be added or removed + applicationFilePath(). Library paths (see QLibrary) can be retrieved + with libraryPaths() and manipulated by setLibraryPaths(), addLibraryPath(), + and removeLibraryPath(). + + \section1 Internationalization and Translations + + Translation files can be added or removed using installTranslator() and removeTranslator(). Application strings can be translated using translate(). The QObject::tr() and QObject::trUtf8() functions are implemented in terms of translate(). - The class provides a quit() slot and an aboutToQuit() signal. + \section1 Accessing Command Line Arguments - Several static convenience functions are also provided. The - QCoreApplication object is available from instance(). Events can - be sent or posted using sendEvent(), postEvent(), and - sendPostedEvents(). Pending events can be removed with - removePostedEvents() or flushed with flush(). Library paths (see - QLibrary) can be retrieved with libraryPaths() and manipulated by - setLibraryPaths(), addLibraryPath(), and removeLibraryPath(). - - On Unix/Linux Qt is configured to use the system local settings by - default. This can cause a conflict when using POSIX functions, for - instance, when converting between data types such as floats and - strings, since the notation may differ between locales. To get - around this problem call the POSIX function setlocale(LC_NUMERIC,"C") - right after initializing QApplication or QCoreApplication to reset - the locale that is used for number formatting to "C"-locale. + The command line arguments which are passed to QCoreApplication's + constructor should be accessed using the arguments() function. + Note that some arguments supplied by the user may have been + processed and removed by QCoreApplication. + + In cases where command line arguments need to be obtained using the + argv() function, you must convert them from the local string encoding + using QString::fromLocal8Bit(). + + \section1 Locale Settings + + On Unix/Linux Qt is configured to use the system locale settings by + default. This can cause a conflict when using POSIX functions, for + instance, when converting between data types such as floats and + strings, since the notation may differ between locales. To get + around this problem, call the POSIX function \c{setlocale(LC_NUMERIC,"C")} + right after initializing QApplication or QCoreApplication to reset + the locale that is used for number formatting to "C"-locale. \sa QApplication, QAbstractEventDispatcher, QEventLoop, {Semaphores Example}, {Wait Conditions Example} @@ -1011,7 +1029,7 @@ void QCoreApplication::exit(int returnCode) The event is \e not deleted when the event has been sent. The normal approach is to create the event on the stack, for example: - \snippet doc/src/snippets/code/src.corelib.kernel.qcoreapplication.cpp 0 + \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 0 \sa postEvent(), notify() */ @@ -1534,7 +1552,7 @@ bool QCoreApplication::event(QEvent *e) Example: - \snippet doc/src/snippets/code/src.corelib.kernel.qcoreapplication.cpp 1 + \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 1 \sa exit(), aboutToQuit(), QApplication::lastWindowClosed() */ @@ -1975,9 +1993,9 @@ char **QCoreApplication::argv() \warning On Unix, this list is built from the argc and argv parameters passed to the constructor in the main() function. The string-data in argv is interpreted using QString::fromLocal8Bit(); hence it is not possible to - pass i.e. Japanese command line arguments on a system that runs in a latin1 - locale. Most modern Unix systems do not have this limitation, as they are - Unicode based. + pass, for example, Japanese command line arguments on a system that runs in a + Latin1 locale. Most modern Unix systems do not have this limitation, as they are + Unicode-based. On NT-based Windows, this limitation does not apply either. On Windows, the arguments() are not built from the contents of argv/argc, as @@ -2153,7 +2171,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMutex, libraryPathMutex, (QMutex::Recursive)) If you want to iterate over the list, you can use the \l foreach pseudo-keyword: - \snippet doc/src/snippets/code/src.corelib.kernel.qcoreapplication.cpp 2 + \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 2 \sa setLibraryPaths(), addLibraryPath(), removeLibraryPath(), QLibrary, {How to Create Qt Plugins} @@ -2300,7 +2318,7 @@ void QCoreApplication::removeLibraryPath(const QString &path) A function with the following signature that can be used as an event filter: - \snippet doc/src/snippets/code/src.corelib.kernel.qcoreapplication.cpp 3 + \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 3 \sa setEventFilter() */ @@ -2489,7 +2507,7 @@ int QCoreApplication::loopLevel() } #endif -/*! +/* \fn void QCoreApplication::watchUnixSignal(int signal, bool watch) \internal */ @@ -2513,7 +2531,7 @@ int QCoreApplication::loopLevel() The function specified by \a ptr should take no arguments and should return nothing. For example: - \snippet doc/src/snippets/code/src.corelib.kernel.qcoreapplication.cpp 4 + \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 4 Note that for an application- or module-wide cleanup, qAddPostRoutine() is often not suitable. For example, if the @@ -2527,7 +2545,7 @@ int QCoreApplication::loopLevel() parent-child mechanism to call a cleanup function at the right time: - \snippet doc/src/snippets/code/src.corelib.kernel.qcoreapplication.cpp 5 + \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 5 By selecting the right parent object, this can often be made to clean up the module's data at the right moment. @@ -2541,7 +2559,7 @@ int QCoreApplication::loopLevel() translation functions, \c tr() and \c trUtf8(), with these signatures: - \snippet doc/src/snippets/code/src.corelib.kernel.qcoreapplication.cpp 6 + \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 6 This macro is useful if you want to use QObject::tr() or QObject::trUtf8() in classes that don't inherit from QObject. @@ -2550,7 +2568,7 @@ int QCoreApplication::loopLevel() class definition (before the first \c{public:} or \c{protected:}). For example: - \snippet doc/src/snippets/code/src.corelib.kernel.qcoreapplication.cpp 7 + \snippet doc/src/snippets/code/src_corelib_kernel_qcoreapplication.cpp 7 The \a context parameter is normally the class name, but it can be any string. diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 3d26160..5771feb 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -613,16 +613,26 @@ static const QMetaObject *QMetaObject_findMetaObject(const QMetaObject *self, co if (strcmp(self->d.stringdata, name) == 0) return self; if (self->d.extradata) { +#ifdef Q_NO_DATA_RELOCATION + const QMetaObjectAccessor *e; + Q_ASSERT(priv(self->d.data)->revision >= 2); +#else const QMetaObject **e; if (priv(self->d.data)->revision < 2) { e = (const QMetaObject**)(self->d.extradata); - } else { + } else +#endif + { const QMetaObjectExtraData *extra = (const QMetaObjectExtraData*)(self->d.extradata); e = extra->objects; } if (e) { while (*e) { +#ifdef Q_NO_DATA_RELOCATION + if (const QMetaObject *m =QMetaObject_findMetaObject(&((*e)()), name)) +#else if (const QMetaObject *m =QMetaObject_findMetaObject((*e), name)) +#endif return m; ++e; } diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h index d843deb..572e727 100644 --- a/src/corelib/kernel/qmetaobject_p.h +++ b/src/corelib/kernel/qmetaobject_p.h @@ -102,6 +102,7 @@ enum MetaObjectFlags { DynamicMetaObject = 0x01 }; +class QMutex; struct QMetaObjectPrivate { @@ -121,13 +122,17 @@ struct QMetaObjectPrivate static int indexOfSignalRelative(const QMetaObject **baseObject, const char* name); static int originalClone(const QMetaObject *obj, int local_method_index); +#ifndef QT_NO_QOBJECT //defined in qobject.cpp static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type = 0, int *types = 0); static bool disconnect(const QObject *sender, int signal_index, const QObject *receiver, int method_index); - + static inline bool disconnectHelper(QObjectPrivate::Connection *c, + const QObject *receiver, int method_index, + QMutex *senderMutex); +#endif }; #ifndef UTILS_H diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 2117a2d..6a451d5 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -240,18 +240,20 @@ static void computeOffsets(const QMetaObject *metaobject, int *signalOffset, int } } -/*! \internal +/* This vector contains the all connections from an object. - Each object may have one vector containing the lists of connections for a given signal. - The index in the vector correspond to the signal index. - The signal index is the one returned by QObjectPrivate::signalIndex (not QMetaObject::indexOfSignal). + Each object may have one vector containing the lists of + connections for a given signal. The index in the vector correspond + to the signal index. The signal index is the one returned by + QObjectPrivate::signalIndex (not QMetaObject::indexOfSignal). Negative index means connections to all signals. This vector is protected by the object mutex (signalSlotMutexes()) - Each Connection is also part of a 'senders' linked list. The mutex of the receiver must be locked when touching - the pointers of this linked list. + Each Connection is also part of a 'senders' linked list. The mutex + of the receiver must be locked when touching the pointers of this + linked list. */ class QObjectConnectionListVector : public QVector<QObjectPrivate::ConnectionList> { @@ -289,7 +291,7 @@ bool QObjectPrivate::isSender(const QObject *receiver, const char *signal) const QMutexLocker locker(signalSlotLock(q)); if (connectionLists) { if (signal_index < connectionLists->count()) { - const QObjectPrivate::Connection *c = + const QObjectPrivate::Connection *c = connectionLists->at(signal_index).first; while (c) { @@ -358,7 +360,7 @@ void QObjectPrivate::cleanConnectionLists() if (connectionLists->dirty && !connectionLists->inUse) { // remove broken connections for (int signal = -1; signal < connectionLists->count(); ++signal) { - QObjectPrivate::ConnectionList &connectionList = + QObjectPrivate::ConnectionList &connectionList = (*connectionLists)[signal]; // Set to the last entry in the connection list that was *not* @@ -381,8 +383,8 @@ void QObjectPrivate::cleanConnectionLists() } } - // Correct the connection list's last pointer. As - // conectionList.last could equal last, this could be a noop + // Correct the connection list's last pointer. + // As conectionList.last could equal last, this could be a noop connectionList.last = last; } connectionLists->dirty = false; @@ -904,7 +906,7 @@ QObject::~QObject() if (d->connectionLists) { ++d->connectionLists->inUse; for (int signal = -1; signal < d->connectionLists->count(); ++signal) { - QObjectPrivate::ConnectionList &connectionList = + QObjectPrivate::ConnectionList &connectionList = (*d->connectionLists)[signal]; while (QObjectPrivate::Connection *c = connectionList.first) { @@ -1089,10 +1091,9 @@ QObjectPrivate::Connection::~Connection() \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 4 - (\l QLayoutItem is not a QObject.) - - Consider using qobject_cast<Type *>(object) instead. The method - is both faster and safer. + If you need to determine whether an object is an instance of a particular + class for the purpose of casting it, consider using qobject_cast<Type *>(object) + instead. \sa metaObject(), qobject_cast() */ @@ -1170,7 +1171,7 @@ static QObject *qChildHelper(const char *objName, const char *inheritsClass, more than one, the first one found is returned. */ QObject* QObject::child(const char *objName, const char *inheritsClass, - bool recursiveSearch) const + bool recursiveSearch) const { Q_D(const QObject); return qChildHelper(objName, inheritsClass, recursiveSearch, d->children); @@ -1389,7 +1390,7 @@ bool QObject::eventFilter(QObject * /* watched */, QEvent * /* event */) /*! If \a block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). - If \a block is false, no such blocking will occur. + If \a block is false, no such blocking will occur. The return value is the previous value of signalsBlocked(). @@ -1681,12 +1682,12 @@ void QObject::killTimer(int id) #ifdef QT3_SUPPORT static void objSearch(QObjectList &result, - const QObjectList &list, - const char *inheritsClass, - bool onlyWidgets, - const char *objName, - QRegExp *rx, - bool recurse) + const QObjectList &list, + const char *inheritsClass, + bool onlyWidgets, + const char *objName, + QRegExp *rx, + bool recurse) { for (int i = 0; i < list.size(); ++i) { QObject *obj = list.at(i); @@ -1756,9 +1757,9 @@ static void objSearch(QObjectList &result, */ QObjectList QObject::queryList(const char *inheritsClass, - const char *objName, - bool regexpMatch, - bool recursiveSearch) const + const char *objName, + bool regexpMatch, + bool recursiveSearch) const { Q_D(const QObject); QObjectList list; @@ -1910,7 +1911,7 @@ QObjectList QObject::queryList(const char *inheritsClass, \internal */ void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re, - const QMetaObject &mo, QList<void*> *list) + const QMetaObject &mo, QList<void*> *list) { if (!parent || !list) return; @@ -2459,7 +2460,7 @@ QObject *QObject::sender() const { Q_D(const QObject); - QMutexLocker(signalSlotLock(this)); + QMutexLocker locker(signalSlotLock(this)); if (!d->currentSender) return 0; @@ -2518,7 +2519,7 @@ int QObject::receivers(const char *signal) const QMutexLocker locker(signalSlotLock(this)); if (d->connectionLists) { if (signal_index < d->connectionLists->count()) { - const QObjectPrivate::Connection *c = + const QObjectPrivate::Connection *c = d->connectionLists->at(signal_index).first; while (c) { receivers += c->receiver ? 1 : 0; @@ -3010,7 +3011,7 @@ bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index, if (type & Qt::UniqueConnection) { QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists; if (connectionLists && connectionLists->count() > signal_index) { - const QObjectPrivate::Connection *c2 = + const QObjectPrivate::Connection *c2 = (*connectionLists)[signal_index].first; while (c2) { @@ -3078,16 +3079,52 @@ bool QMetaObject::disconnect(const QObject *sender, int signal_index, } /*! \internal + Helper function to remove the connection from the senders list and setting the receivers to 0 + */ +bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c, + const QObject *receiver, int method_index, + QMutex *senderMutex) +{ + bool success = false; + while (c) { + if (c->receiver + && (receiver == 0 || (c->receiver == receiver + && (method_index < 0 || c->method == method_index)))) { + bool needToUnlock = false; + QMutex *receiverMutex = 0; + if (!receiver) { + receiverMutex = signalSlotLock(c->receiver); + // need to relock this receiver and sender in the correct order + needToUnlock = QOrderedMutexLocker::relock(senderMutex, receiverMutex); + } + if (c->receiver) { + *c->prev = c->next; + if (c->next) + c->next->prev = c->prev; + } + + if (needToUnlock) + receiverMutex->unlock(); + + c->receiver = 0; + + success = true; + } + c = c->nextConnectionList; + } + return success; +} + +/*! \internal Same as the QMetaObject::disconnect, but \a signal_index must be the result of QObjectPrivate::signalIndex */ bool QMetaObjectPrivate::disconnect(const QObject *sender, int signal_index, - const QObject *receiver, int method_index) + const QObject *receiver, int method_index) { if (!sender) return false; QObject *s = const_cast<QObject *>(sender); - QObject *r = const_cast<QObject *>(receiver); QMutex *senderMutex = signalSlotLock(sender); QMutex *receiverMutex = receiver ? signalSlotLock(receiver) : 0; @@ -3104,60 +3141,19 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, int signal_index, if (signal_index < 0) { // remove from all connection lists for (signal_index = -1; signal_index < connectionLists->count(); ++signal_index) { - QObjectPrivate::Connection *c = + QObjectPrivate::Connection *c = (*connectionLists)[signal_index].first; - while (c) { - if (c->receiver - && (r == 0 || (c->receiver == r - && (method_index < 0 || c->method == method_index)))) { - QMutex *m = signalSlotLock(c->receiver); - bool needToUnlock = false; - if (!receiverMutex && senderMutex != m) { - // need to relock this receiver and sender in the correct order - needToUnlock = QOrderedMutexLocker::relock(senderMutex, m); - } - if (c->receiver) { - *c->prev = c->next; - if (c->next) c->next->prev = c->prev; - } - - if (needToUnlock) - m->unlock(); - - c->receiver = 0; - - success = true; - connectionLists->dirty = true; - } - c = c->nextConnectionList; + if (disconnectHelper(c, receiver, method_index, senderMutex)) { + success = true; + connectionLists->dirty = true; } } } else if (signal_index < connectionLists->count()) { - QObjectPrivate::Connection *c = + QObjectPrivate::Connection *c = (*connectionLists)[signal_index].first; - while (c) { - if (c->receiver - && (r == 0 || (c->receiver == r - && (method_index < 0 || c->method == method_index)))) { - QMutex *m = signalSlotLock(c->receiver); - bool needToUnlock = false; - if (!receiverMutex && senderMutex != m) { - // need to relock this receiver and sender in the correct order - needToUnlock = QOrderedMutexLocker::relock(senderMutex, m); - } - if (c->receiver) { - *c->prev = c->next; - if (c->next) c->next->prev = c->prev; - } - - if (needToUnlock) - m->unlock(); - c->receiver = 0; - - success = true; - connectionLists->dirty = true; - } - c = c->nextConnectionList; + if (disconnectHelper(c, receiver, method_index, senderMutex)) { + success = true; + connectionLists->dirty = true; } } @@ -3490,7 +3486,8 @@ int QObjectPrivate::signalIndex(const char *signalName) const \a signal_index must be the index returned by QObjectPrivate::signalIndex; */ -bool QObjectPrivate::isSignalConnected(int signal_index) const { +bool QObjectPrivate::isSignalConnected(int signal_index) const +{ if (signal_index < (int)sizeof(connectedSignals) * 8 && !qt_signal_spy_callback_set.signal_begin_callback && !qt_signal_spy_callback_set.signal_end_callback) { @@ -3720,7 +3717,7 @@ void QObject::dumpObjectInfo() qDebug(" signal: %s", signal.signature()); // receivers - const QObjectPrivate::Connection *c = + const QObjectPrivate::Connection *c = d->connectionLists->at(signal_index).first; while (c) { if (!c->receiver) { diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index aa538bc..d85faee 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -381,7 +381,7 @@ inline QList<T> qFindChildren(const QObject *o, const QRegExp &re) #endif // Q_MOC_RUN -template <class T> inline const char * qobject_interface_iid() +template <class T> inline const char * qobject_interface_iid() { return 0; } template <class T> inline T qobject_cast_helper(QObject *object, T) @@ -465,7 +465,7 @@ inline T qobject_cast(const QObject *object) } -template <class T> inline const char * qobject_interface_iid() +template <class T> inline const char * qobject_interface_iid() { return 0; } #ifndef Q_MOC_RUN diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 421617a..3f990a3 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -150,6 +150,7 @@ inline void qYouForgotTheQ_OBJECT_Macro(T1, T2) {} public: \ Q_OBJECT_CHECK \ static const QMetaObject staticMetaObject; \ + static const QMetaObject &getStaticMetaObject(); \ virtual const QMetaObject *metaObject() const; \ virtual void *qt_metacast(const char *); \ QT_TR_FUNCTIONS \ @@ -161,6 +162,7 @@ private: #define Q_GADGET \ public: \ static const QMetaObject staticMetaObject; \ + static const QMetaObject &getStaticMetaObject(); \ private: #else // Q_MOC_RUN #define slots slots @@ -444,9 +446,15 @@ struct Q_CORE_EXPORT QMetaObject }; +typedef const QMetaObject& (*QMetaObjectAccessor)(); + struct QMetaObjectExtraData { +#ifdef Q_NO_DATA_RELOCATION + const QMetaObjectAccessor *objects; +#else const QMetaObject **objects; +#endif int (*static_metacall)(QMetaObject::Call, int, void **); }; diff --git a/src/corelib/statemachine/qabstracttransition_p.h b/src/corelib/statemachine/qabstracttransition_p.h index 328be16..33e4474 100644 --- a/src/corelib/statemachine/qabstracttransition_p.h +++ b/src/corelib/statemachine/qabstracttransition_p.h @@ -75,7 +75,7 @@ public: static QAbstractTransitionPrivate *get(QAbstractTransition *q); bool callEventTest(QEvent *e); - void callOnTransition(QEvent *e); + virtual void callOnTransition(QEvent *e); QState *sourceState() const; QStateMachine *machine() const; void emitTriggered(); diff --git a/src/corelib/statemachine/qsignalevent.h b/src/corelib/statemachine/qsignalevent.h index 7e5d888..de166f4 100644 --- a/src/corelib/statemachine/qsignalevent.h +++ b/src/corelib/statemachine/qsignalevent.h @@ -70,6 +70,8 @@ private: QObject *m_sender; int m_signalIndex; QList<QVariant> m_arguments; + + friend class QSignalTransitionPrivate; }; #endif //QT_NO_STATEMACHINE diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp index e34448f..fb28c08 100644 --- a/src/corelib/statemachine/qsignaltransition.cpp +++ b/src/corelib/statemachine/qsignaltransition.cpp @@ -245,6 +245,23 @@ bool QSignalTransition::event(QEvent *e) return QAbstractTransition::event(e); } +void QSignalTransitionPrivate::callOnTransition(QEvent *e) +{ + Q_Q(QSignalTransition); + + QSignalEvent *se = static_cast<QSignalEvent *>(e); + int savedSignalIndex; + if (e->type() == QEvent::Signal) { + savedSignalIndex = se->m_signalIndex; + se->m_signalIndex = originalSignalIndex; + } + + q->onTransition(e); + + if (e->type() == QEvent::Signal) + se->m_signalIndex = savedSignalIndex; +} + QT_END_NAMESPACE #endif //QT_NO_STATEMACHINE diff --git a/src/corelib/statemachine/qsignaltransition_p.h b/src/corelib/statemachine/qsignaltransition_p.h index 21082ab..69bbcc9 100644 --- a/src/corelib/statemachine/qsignaltransition_p.h +++ b/src/corelib/statemachine/qsignaltransition_p.h @@ -69,9 +69,12 @@ public: void unregister(); void maybeRegister(); + virtual void callOnTransition(QEvent *e); + QObject *sender; QByteArray signal; int signalIndex; + int originalSignalIndex; }; QT_END_NAMESPACE diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index d6946de..e5bca2c 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1408,6 +1408,7 @@ void QStateMachinePrivate::registerSignalTransition(QSignalTransition *transitio signal.remove(0, 1); const QMetaObject *meta = sender->metaObject(); int signalIndex = meta->indexOfSignal(signal); + int originalSignalIndex = signalIndex; if (signalIndex == -1) { signalIndex = meta->indexOfSignal(QMetaObject::normalizedSignature(signal)); if (signalIndex == -1) { @@ -1416,6 +1417,11 @@ void QStateMachinePrivate::registerSignalTransition(QSignalTransition *transitio return; } } + // The signal index we actually want to connect to is the one + // that is going to be sent, i.e. the non-cloned original index. + while (meta->method(signalIndex).attributes() & QMetaMethod::Cloned) + --signalIndex; + QVector<int> &connectedSignalIndexes = connections[sender]; if (connectedSignalIndexes.size() <= signalIndex) connectedSignalIndexes.resize(signalIndex+1); @@ -1435,6 +1441,7 @@ void QStateMachinePrivate::registerSignalTransition(QSignalTransition *transitio } ++connectedSignalIndexes[signalIndex]; QSignalTransitionPrivate::get(transition)->signalIndex = signalIndex; + QSignalTransitionPrivate::get(transition)->originalSignalIndex = originalSignalIndex; #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": added signal transition from" << transition->sourceState() << ": ( sender =" << sender << ", signal =" << signal diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 82b462e..12ee413 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -39,6 +39,10 @@ ** ****************************************************************************/ +//#define WINVER 0x0500 +#define _WIN32_WINNT 0x0400 + + #include "qthread.h" #include "qthread_p.h" #include "qthreadstorage.h" diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index 3103ba1..2da768b 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -76,8 +76,8 @@ static TPtrC defaultFormatSpec(TExtendedLocale&) return TPtrC(KNullDesC); } -/*! - Definition of struct for mapping Symbian to ISO locale +/* + Definition of struct for mapping Symbian to ISO locale */ struct symbianToISO { int symbian_language; @@ -85,8 +85,8 @@ struct symbianToISO { }; -/*! - Mapping from Symbian to ISO locale +/* + Mapping from Symbian to ISO locale */ static const symbianToISO symbian_to_iso_list[] = { { ELangEnglish, "en_GB" }, diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index ef6cc39..5296bae 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -170,7 +170,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn bool QScopedPointer::operator==(const QScopedPointer<T> &other) const + \fn bool QScopedPointer::operator==(const QScopedPointer<T, Cleanup> &other) const Equality operator. Returns true if the scoped pointer \a other is pointing to the same object as this pointer, otherwise returns false. @@ -178,7 +178,7 @@ QT_BEGIN_NAMESPACE /*! - \fn bool QScopedPointer::operator!=(const QScopedPointer<T> &other) const + \fn bool QScopedPointer::operator!=(const QScopedPointer<T, Cleanup> &other) const Inequality operator. Returns true if the scoped pointer \a other is not pointing to the same object as this pointer, otherwise returns false. diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 90ca34f..e4f7ba9 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -511,7 +511,7 @@ public: QWeakPointer<T> toWeakRef() const; protected: - inline QSharedPointer(Qt::Initialization i) : BaseClass(i) {} + inline explicit QSharedPointer(Qt::Initialization i) : BaseClass(i) {} public: static inline QSharedPointer<T> create() diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index a93a638..9be57c5 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -44,6 +44,12 @@ #include <QtCore/qstring.h> +#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) +# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0) +# include <QtCore/qmap.h> +# endif +#endif + #include <string.h> QT_BEGIN_HEADER |