diff options
author | Sami Lempinen <sami.lempinen@nokia.com> | 2011-07-05 07:10:56 (GMT) |
---|---|---|
committer | Sami Lempinen <sami.lempinen@nokia.com> | 2011-07-05 07:10:56 (GMT) |
commit | 89260bad8fddcbbfe54b3c5238ef370a620ab9e6 (patch) | |
tree | 31aac7993c1b06634e83e802a16fb1be87615c10 /src/corelib | |
parent | bad513727833e207f7f8ca0d7c07c44c1addfb57 (diff) | |
parent | 601b12b7879e9a743ef9e516470219aae73e611d (diff) | |
download | Qt-89260bad8fddcbbfe54b3c5238ef370a620ab9e6.zip Qt-89260bad8fddcbbfe54b3c5238ef370a620ab9e6.tar.gz Qt-89260bad8fddcbbfe54b3c5238ef370a620ab9e6.tar.bz2 |
Merge remote-tracking branch 'qt/4.8'
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qurl.cpp | 1 | ||||
-rw-r--r-- | src/corelib/kernel/qabstractitemmodel.cpp | 37 | ||||
-rw-r--r-- | src/corelib/kernel/qabstractitemmodel.h | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_mac.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_mac_p.h | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 17 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 6 | ||||
-rw-r--r-- | src/corelib/thread/qthread_p.h | 21 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 9 | ||||
-rw-r--r-- | src/corelib/tools/qpoint.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstringbuilder.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstringbuilder.h | 2 |
12 files changed, 75 insertions, 30 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 8813656..d551009 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5466,6 +5466,7 @@ void QUrl::removeAllEncodedQueryItems(const QByteArray &key) if (end < d->query.size()) ++end; // remove additional '%' d->query.remove(pos, end - pos); + query = d->query.constData(); //required if remove detach; } else { pos = end + 1; } diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index b7ac6aa..ddf1fbb 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -1348,6 +1348,26 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, */ /*! + \since 4.8 + + This slot is called just after the internal data of a model is cleared + while it is being reset. + + This slot is provided the convenience of subclasses of concrete proxy + models, such as subclasses of QSortFilterProxyModel which maintain extra + data. + + \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 10 + + \sa modelAboutToBeReset(), modelReset() +*/ +void QAbstractItemModel::resetInternalData() +{ + +} + + +/*! Constructs an abstract item model with the given \a parent. */ QAbstractItemModel::QAbstractItemModel(QObject *parent) @@ -1747,18 +1767,19 @@ QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const Returns true if the data and action can be handled by the model; otherwise returns false. - Although the specified \a row, \a column and \a parent indicate the - location of an item in the model where the operation ended, it is the - responsibility of the view to provide a suitable location for where the - data should be inserted. + The specified \a row, \a column and \a parent indicate the location of an + item in the model where the operation ended. It is the responsibility of + the model to complete the action at the correct location. For instance, a drop action on an item in a QTreeView can result in new items either being inserted as children of the item specified by \a row, \a column, and \a parent, or as siblings of the item. - When row and column are -1 it means that it is up to the model to decide - where to place the data. This can occur in a tree when data is dropped on - a parent. Models will usually append the data to the parent in this case. + When \a row and \a column are -1 it means that the dropped data should be + considered as dropped directly on \a parent. Usually this will mean + appending the data as child items of \a parent. If \a row and column are + greater than or equal zero, it means that the drop occurred just before the + specified \a row and \a column in the specified \a parent. \sa supportedDropActions(), {Using drag and drop with item views} */ @@ -2888,6 +2909,7 @@ void QAbstractItemModel::reset() Q_D(QAbstractItemModel); emit modelAboutToBeReset(); d->invalidatePersistentIndexes(); + QMetaObject::invokeMethod(this, "resetInternalData"); emit modelReset(); } @@ -2930,6 +2952,7 @@ void QAbstractItemModel::endResetModel() { Q_D(QAbstractItemModel); d->invalidatePersistentIndexes(); + QMetaObject::invokeMethod(this, "resetInternalData"); emit modelReset(); } diff --git a/src/corelib/kernel/qabstractitemmodel.h b/src/corelib/kernel/qabstractitemmodel.h index c7af7a2..eab1475 100644 --- a/src/corelib/kernel/qabstractitemmodel.h +++ b/src/corelib/kernel/qabstractitemmodel.h @@ -303,6 +303,9 @@ protected: void setRoleNames(const QHash<int,QByteArray> &roleNames); +protected Q_SLOTS: + void resetInternalData(); + private: Q_DECLARE_PRIVATE(QAbstractItemModel) Q_DISABLE_COPY(QAbstractItemModel) diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp index e705c31..490031f 100644 --- a/src/corelib/kernel/qcore_mac.cpp +++ b/src/corelib/kernel/qcore_mac.cpp @@ -87,6 +87,7 @@ QCFString::operator CFStringRef() const } +#ifndef QT_NO_CORESERVICES void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding, int len) { if(len == -1) @@ -135,5 +136,6 @@ OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec) ret = FSGetCatalogInfo(&fsref, kFSCatInfoNone, 0, 0, spec, 0); return ret; } +#endif // QT_NO_CORESERVICES QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 4b8c16f..df269ec 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -148,12 +148,15 @@ private: QString string; }; + +#ifndef QT_NO_CORESERVICES Q_CORE_EXPORT void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding = 0, int len = -1); Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr); Q_CORE_EXPORT OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref); // Don't use this function, it won't work in 10.5 (Leopard) and up Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec); +#endif // QT_NO_CORESERVICES QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index dd46bc5..18a5eae 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1288,20 +1288,7 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority) // delete the event on exceptions to protect against memory leaks till the event is // properly owned in the postEventList QScopedPointer<QEvent> eventDeleter(event); - if (data->postEventList.isEmpty() || data->postEventList.last().priority >= priority) { - // optimization: we can simply append if the last event in - // the queue has higher or equal priority - data->postEventList.append(QPostEvent(receiver, event, priority)); - } else { - // insert event in descending priority order, using upper - // bound for a given priority (to ensure proper ordering - // of events with the same priority) - QPostEventList::iterator begin = data->postEventList.begin() - + data->postEventList.insertionOffset, - end = data->postEventList.end(); - QPostEventList::iterator at = qUpperBound(begin, end, priority); - data->postEventList.insert(at, QPostEvent(receiver, event, priority)); - } + data->postEventList.addEvent(QPostEvent(receiver, event, priority)); eventDeleter.take(); event->posted = true; ++receiver->d_func()->postedEvents; @@ -1461,7 +1448,7 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type // cannot send deferred delete if (!event_type && !receiver) { // don't lose the event - data->postEventList.append(pe); + data->postEventList.addEvent(pe); const_cast<QPostEvent &>(pe).event = 0; } continue; diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index b88643d..67dbadb 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1482,7 +1482,7 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData continue; if (pe.receiver == q) { // move this post event to the targetList - targetData->postEventList.append(pe); + targetData->postEventList.addEvent(pe); const_cast<QPostEvent &>(pe).event = 0; ++eventsMoved; } @@ -2939,7 +2939,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal, \a receiver. Returns true if the connection is successfully broken; otherwise returns false. - This function provides the same posibilities like + This function provides the same possibilities like disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) but uses QMetaMethod to represent the signal and the method to be disconnected. @@ -2957,7 +2957,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal, QMetaMethod() may be used as wildcard in the meaning "any signal" or "any slot in receiving object". In the same way 0 can be used for \a receiver in the meaning "any receiving object". In this case - method shoud also be QMetaMethod(). \a sender parameter should be never 0. + method should also be QMetaMethod(). \a sender parameter should be never 0. \sa disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) */ diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 13df3e6..461d93d 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -93,6 +93,8 @@ inline bool operator<(const QPostEvent &pe, int priority) return priority < pe.priority; } +// This class holds the list of posted events. +// The list has to be kept sorted by priority class QPostEventList : public QList<QPostEvent> { public: @@ -109,6 +111,25 @@ public: inline QPostEventList() : QList<QPostEvent>(), recursion(0), startOffset(0), insertionOffset(0) { } + + void addEvent(const QPostEvent &ev) { + int priority = ev.priority; + if (isEmpty() || last().priority >= priority) { + // optimization: we can simply append if the last event in + // the queue has higher or equal priority + append(ev); + } else { + // insert event in descending priority order, using upper + // bound for a given priority (to ensure proper ordering + // of events with the same priority) + QPostEventList::iterator at = qUpperBound(begin() + insertionOffset, end(), priority); + insert(at, ev); + } + } +private: + //hides because they do not keep that list sorted. addEvent must be used + using QList<QPostEvent>::append; + using QList<QPostEvent>::insert; }; #ifndef QT_NO_THREAD diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index ca8cc8a..d791529 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -48,6 +48,11 @@ static QSystemLocale *QSystemLocale_globalSystemLocale(); QT_END_NAMESPACE #endif +#if !defined(QWS) && defined(Q_OS_MAC) +# include "private/qcore_mac_p.h" +# include <CoreFoundation/CoreFoundation.h> +#endif + #include "qplatformdefs.h" #include "qdatastream.h" @@ -65,10 +70,6 @@ QT_END_NAMESPACE # include "qt_windows.h" # include <time.h> #endif -#if !defined(QWS) && defined(Q_OS_MAC) -# include "private/qcore_mac_p.h" -# include <CoreFoundation/CoreFoundation.h> -#endif #include "private/qnumeric_p.h" #include "private/qsystemlibrary_p.h" diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index c0cf219..9f03606 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -93,7 +93,7 @@ public: private: friend class QTransform; // ### Qt 5; remove the ifdef and just have the same order on all platforms. -#if defined(Q_OS_MAC) +#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES) int yp; int xp; #else diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 45de6bc..1cc7e5d 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -162,6 +162,8 @@ void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out } #endif if (len == -1) { + if (!a) + return; while (*a) *out++ = QLatin1Char(*a++); } else { diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 709d84a..594ab2f 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -352,6 +352,8 @@ template <> struct QConcatenable<const char *> : private QAbstractConcatenable #endif static inline void appendTo(const char *a, char *&out) { + if (!a) + return; while (*a) *out++ = *a++; } |