diff options
Diffstat (limited to 'src')
46 files changed, 608 insertions, 309 deletions
diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index e4c9d42..621c836 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -1535,9 +1535,10 @@ HRESULT WINAPI QAxClientSite::SetBorderSpace(LPCBORDERWIDTHS pborderwidths) HRESULT WINAPI QAxClientSite::SetActiveObject(IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName) { AX_DEBUG(QAxClientSite::SetActiveObject); - - if (pszObjName && widget) - widget->setWindowTitle(QString::fromWCharArray(pszObjName)); + + Q_UNUSED(pszObjName); + // we are ignoring the name of the object, as suggested by MSDN documentation + // for IOleInPlaceUIWindow::SetActiveObject(). if (m_spInPlaceActiveObject) { if (!inPlaceModelessEnabled) 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 93cc30f..fbefe7a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2382,6 +2382,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/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index db0c696..de483ed 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -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/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 5e8848b..1ba3000 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -2498,25 +2498,32 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star /*! 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. + 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. + 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 destinationRow 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 destinationRow - 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 destinationRow 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. + 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() @@ -2694,25 +2701,32 @@ 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. + 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. + 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 destinationColumn 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 destinationColumn - 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 destinationColumn 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. + 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() 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 183809e..854abef 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1029,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() */ @@ -1552,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() */ @@ -2171,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} @@ -2318,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() */ @@ -2507,7 +2507,7 @@ int QCoreApplication::loopLevel() } #endif -/*! +/* \fn void QCoreApplication::watchUnixSignal(int signal, bool watch) \internal */ @@ -2531,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 @@ -2545,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. @@ -2559,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. @@ -2568,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/qobject.cpp b/src/corelib/kernel/qobject.cpp index 1f35c73..e080bd6 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) { @@ -1169,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); @@ -1388,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(). @@ -1680,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); @@ -1755,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; @@ -1909,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; @@ -2517,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; @@ -3009,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) { @@ -3080,7 +3082,7 @@ bool QMetaObject::disconnect(const QObject *sender, int signal_index, 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; @@ -3103,7 +3105,7 @@ 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 @@ -3132,7 +3134,7 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender, int signal_index, } } } else if (signal_index < connectionLists->count()) { - QObjectPrivate::Connection *c = + QObjectPrivate::Connection *c = (*connectionLists)[signal_index].first; while (c) { if (c->receiver @@ -3489,7 +3491,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) { @@ -3719,7 +3722,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/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/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 5f64698..50644ff 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -990,6 +990,8 @@ QGraphicsOpacityEffect::~QGraphicsOpacityEffect() fully transparent and 1.0 is fully opaque. By default, the opacity is 0.7. + + \sa setOpacityMask() */ qreal QGraphicsOpacityEffect::opacity() const { @@ -1006,6 +1008,10 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity) return; d->opacity = opacity; + if ((d->isFullyTransparent = qFuzzyIsNull(d->opacity))) + d->isFullyOpaque = 0; + else + d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1); emit opacityChanged(opacity); } @@ -1017,6 +1023,45 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity) */ /*! + \property QGraphicsOpacityEffect::opacityMask + \brief the opacity mask of the effect. + + An opacity mask allows you apply opacity to portions of an element. + + For example: + + \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 2 + + There is no opacity mask by default. + + \sa setOpacity() +*/ +QBrush QGraphicsOpacityEffect::opacityMask() const +{ + Q_D(const QGraphicsOpacityEffect); + return d->opacityMask; +} + +void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask) +{ + Q_D(QGraphicsOpacityEffect); + if (d->opacityMask == mask) + return; + + d->opacityMask = mask; + d->hasOpacityMask = (mask.style() != Qt::NoBrush); + + emit opacityMaskChanged(mask); +} + +/*! + \fn void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush &mask) + + This signal is emitted whenever the effect's opacity mask changes. + The \a mask parameter holds the effect's new opacity mask. +*/ + +/*! \reimp */ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *source) @@ -1024,11 +1069,11 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour Q_D(QGraphicsOpacityEffect); // Transparent; nothing to draw. - if (qFuzzyIsNull(d->opacity)) + if (d->isFullyTransparent) return; // Opaque; draw directly without going through a pixmap. - if (qFuzzyIsNull(d->opacity - 1)) { + if (d->isFullyOpaque && !d->hasOpacityMask) { source->draw(painter); return; } @@ -1039,13 +1084,55 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour QPoint offset; if (source->isPixmap()) { // No point in drawing in device coordinates (pixmap will be scaled anyways). - const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); - painter->drawPixmap(offset, pixmap); + if (!d->hasOpacityMask) { + const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); + painter->drawPixmap(offset, pixmap); + } else { + QRectF srcBrect = source->boundingRect(); + QPixmap pixmap(srcBrect.size().toSize()); + pixmap.fill(Qt::transparent); + + QPainter pixmapPainter(&pixmap); + pixmapPainter.setRenderHints(painter->renderHints()); + pixmapPainter.translate(-srcBrect.topLeft()); + source->draw(&pixmapPainter); + pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + pixmapPainter.fillRect(srcBrect, d->opacityMask); + pixmapPainter.end(); + + painter->drawPixmap(srcBrect.topLeft(), pixmap); + } } else { // Draw pixmap in device coordinates to avoid pixmap scaling; - const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); - painter->setWorldTransform(QTransform()); - painter->drawPixmap(offset, pixmap); + if (!d->hasOpacityMask) { + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); + painter->setWorldTransform(QTransform()); + painter->drawPixmap(offset, pixmap); + } else { + QTransform worldTransform = painter->worldTransform(); + + // Calculate source bounding rect in logical and device coordinates. + QRectF srcBrect = source->boundingRect(); + QRect srcDeviceBrect = worldTransform.mapRect(srcBrect).toAlignedRect(); + srcDeviceBrect &= source->deviceRect(); + + offset = srcDeviceBrect.topLeft(); + worldTransform *= QTransform::fromTranslate(-srcDeviceBrect.x(), -srcDeviceBrect.y()); + + QPixmap pixmap(srcDeviceBrect.size()); + pixmap.fill(Qt::transparent); + + QPainter pixmapPainter(&pixmap); + pixmapPainter.setRenderHints(painter->renderHints()); + pixmapPainter.setWorldTransform(worldTransform); + source->draw(&pixmapPainter); + pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + pixmapPainter.fillRect(srcBrect, d->opacityMask); + pixmapPainter.end(); + + painter->setWorldTransform(QTransform()); + painter->drawPixmap(offset, pixmap); + } } painter->restore(); diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index fef6531..a53357b 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -46,6 +46,7 @@ #include <QtCore/qpoint.h> #include <QtCore/qrect.h> #include <QtGui/qcolor.h> +#include <QtGui/qbrush.h> QT_BEGIN_HEADER @@ -274,17 +275,21 @@ class Q_GUI_EXPORT QGraphicsOpacityEffect: public QGraphicsEffect { Q_OBJECT Q_PROPERTY(int opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) + Q_PROPERTY(QBrush opacityMask READ opacityMask WRITE setOpacityMask NOTIFY opacityMaskChanged) public: QGraphicsOpacityEffect(QObject *parent = 0); ~QGraphicsOpacityEffect(); qreal opacity() const; + QBrush opacityMask() const; public Q_SLOTS: void setOpacity(qreal opacity); + void setOpacityMask(const QBrush &mask); Q_SIGNALS: void opacityChanged(qreal opacity); + void opacityMaskChanged(const QBrush &mask); protected: void draw(QPainter *painter, QGraphicsEffectSource *source); diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index 6ce5cda..c902b67 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -164,10 +164,15 @@ class QGraphicsOpacityEffectPrivate : public QGraphicsEffectPrivate { Q_DECLARE_PUBLIC(QGraphicsOpacityEffect) public: - QGraphicsOpacityEffectPrivate() : opacity(qreal(0.7)) {} + QGraphicsOpacityEffectPrivate() + : opacity(qreal(0.7)), isFullyTransparent(0), isFullyOpaque(0), hasOpacityMask(0) {} ~QGraphicsOpacityEffectPrivate() {} qreal opacity; + QBrush opacityMask; + uint isFullyTransparent : 1; + uint isFullyOpaque : 1; + uint hasOpacityMask : 1; }; QT_END_NAMESPACE diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 8860677..765f76b 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -10270,10 +10270,8 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter) info->widget, info->opacity, info->effectTransform, info->wasDirtySceneTransform, info->drawItem); } else { - QTransform effectTransform = painter->worldTransform(); - effectTransform *= info->painter->worldTransform().inverted(); - if (info->effectTransform) - effectTransform *= *info->effectTransform; + QTransform effectTransform = info->painter->worldTransform().inverted(); + effectTransform *= painter->worldTransform(); scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion, info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform, info->drawItem); diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 7dbc996..7fd471b 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -673,8 +673,8 @@ void QGraphicsScenePrivate::removePopup(QGraphicsWidget *widget, bool itemIsDyin if (focusItem && popupWidgets.isEmpty()) { QFocusEvent event(QEvent::FocusIn, Qt::PopupFocusReason); sendEvent(focusItem, &event); - } else { - ungrabKeyboard((QGraphicsItem *)widget, itemIsDying); + } else if (keyboardGrabberItems.contains(static_cast<QGraphicsItem *>(widget))) { + ungrabKeyboard(static_cast<QGraphicsItem *>(widget), itemIsDying); } if (!itemIsDying && widget->isVisible()) { widget->hide(); diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 658b8e0..155474f 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -322,6 +322,8 @@ QPixmap::QPixmap(const char * const xpm[]) QPixmap::~QPixmap() { + if (data->is_cached && data->ref == 1) + QImagePixmapCleanupHooks::executePixmapHooks(this); } /*! diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 9626193..8d98223 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -1080,8 +1080,17 @@ Qt::FocusReason QFocusEvent::reason() const rect() that is the bounding rectangle of that region. Both are provided because many widgets can't make much use of region(), and rect() can be much faster than region().boundingRect(). + + \section1 Automatic Clipping + Painting is clipped to region() during the processing of a paint - event. + event. This clipping is performed by Qt's paint system and is + independent of any clipping that may be applied to a QPainter used to + draw on the paint device. + + As a result, the value returned by QPainter::clipRegion() on + a newly-constructed QPainter will not reflect the clip region that is + used by the paint system. \sa QPainter, QWidget::update(), QWidget::repaint(), QWidget::paintEvent() diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index fb5f934..38b09ee 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11846,10 +11846,9 @@ const QList<QAction*>& QWidget::softKeys() const \preliminary \since 4.6 - Sets the softkey \a softkey to this widget's list of softkeys, + Sets the softkey \a softKey to this widget's list of softkeys. Setting 0 as softkey will clear all the existing softkeys set - to the widget - A QWidget can have 0 or more softkeys + to the widget. A QWidget can have 0 or more softkeys. \sa softKeys(), setSoftKeys() */ @@ -11866,8 +11865,8 @@ void QWidget::setSoftKey(QAction *softKey) } /*! - Sets the list of softkeys \a softkeys to this widget's list of softkeys, - A QWidget can have 0 or more softkeys + Sets the list of softkeys \a softKeys to this widget's list of softkeys. + A QWidget can have 0 or more softkeys. \sa softKeys(), setSoftKey() */ diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 36ffcbe..eb87052 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1450,7 +1450,7 @@ static const qreal inv_dist_to_plane = 1. / 1024.; value of 1024 corresponds to the projection factor used by QTransform::rotate() for the x and y axes. - If \a distToPlane is zero, then the returned QTransform + If \a distanceToPlane is zero, then the returned QTransform is formed by simply dropping the third row and third column of the QMatrix4x4. This is suitable for implementing orthographic projections where the z co-ordinate should diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index b05a1e9..12d4948 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -67,6 +67,7 @@ #include "qtoolbar.h" #include "qtoolbutton.h" #include "qtreeview.h" +#include "qfocusframe.h" #include "private/qtoolbarextension_p.h" #include "private/qcombobox_p.h" @@ -86,6 +87,8 @@ const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFl static const QByteArray propertyKeyLayouts = "layouts"; static const QByteArray propertyKeyCurrentlayout = "currentlayout"; +static const qreal goldenRatio = 1.618; + const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { // *** generated layout data *** {240,320,1,14,true,"QVGA Landscape Mirrored"}, @@ -508,11 +511,6 @@ void QS60StylePrivate::deleteBackground() } } -int QS60StylePrivate::focusRectPenWidth() -{ - return pixelMetric(QS60Style::PM_DefaultFrameWidth); -} - void QS60StylePrivate::setCurrentLayout(int index) { m_pmPointer = data[index]; @@ -950,13 +948,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom const QS60StylePrivate::SkinElements handleElement = horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical; QS60StylePrivate::drawSkinElement(handleElement, painter, sliderHandle, flags); - - if (optionSlider->state & State_HasFocus) { - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*optionSlider); - fropt.rect = subElementRect(SE_SliderFocusRect, optionSlider, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); - } } break; #endif // QT_NO_SLIDER @@ -991,17 +982,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom drawPrimitive(PE_IndicatorSpinDown, &buttonOption, painter, widget); painter->restore(); } - - if (cmb->subControls & SC_ComboBoxEditField) { - if (cmb->state & State_HasFocus && !cmb->editable) { - QStyleOptionFocusRect focus; - focus.QStyleOption::operator=(*cmb); - focus.rect = cmbxEditField; - focus.state |= State_FocusAtBorder; - focus.backgroundColor = cmb->palette.highlight().color(); - drawPrimitive(PE_FrameFocusRect, &focus, painter, widget); - } - } } break; #endif // QT_NO_COMBOBOX @@ -1079,13 +1059,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom } } } - if (toolBtn->state & State_HasFocus) { - QStyleOptionFocusRect fr; - fr.QStyleOption::operator=(*toolBtn); - const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); - fr.rect.adjust(frameWidth, frameWidth, -frameWidth, -frameWidth); - drawPrimitive(PE_FrameFocusRect, &fr, painter, widget); - } if (toolBtn->features & QStyleOptionToolButton::Arrow) { QStyle::PrimitiveElement pe; @@ -1209,13 +1182,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom groupBox->palette, groupBox->state & State_Enabled, groupBox->text, textColor.isValid() ? QPalette::NoRole : QPalette::WindowText); painter->restore(); - - if (groupBox->state & State_HasFocus) { - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*groupBox); - fropt.rect = textRect; - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); - } } // Draw checkbox @@ -1249,12 +1215,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); drawControl(CE_PushButtonLabel, &subopt, painter, widget); - if (btn->state & State_HasFocus) { - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*btn); - fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); - } } break; case CE_PushButtonBevel: @@ -1612,18 +1572,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, if (verticalTabs) painter->restore(); - if (optionTab.state & State_HasFocus) { - const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth); - const int leftBorder = optionTab.rect.left(); - const int rightBorder = optionTab.rect.right() - 1; - - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*tab); - fropt.rect.setRect(leftBorder + 1 + OFFSET, optionTab.rect.y() + OFFSET, - rightBorder - leftBorder - 2*OFFSET, optionTab.rect.height() - 2*OFFSET); - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); - } - painter->restore(); } break; @@ -1875,11 +1823,48 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } else if (qobject_cast<const QFrame *>(widget)) { QCommonStyle::drawControl(element, option, painter, widget); } - if (option->state & State_HasFocus) - drawPrimitive(PE_FrameFocusRect, option, painter, widget); break; case CE_MenuScroller: break; + case CE_FocusFrame: + { + // The pen width should nearly fill the layoutspacings around the widget + const int penWidth = + qMin(pixelMetric(QS60Style::PM_LayoutVerticalSpacing), pixelMetric(QS60Style::PM_LayoutHorizontalSpacing)) + - 2; // But keep 1 pixel distance to the focus widget and 1 pixel to the adjacent widgets + +#ifdef QT_KEYPAD_NAVIGATION + bool editFocus = false; + if (const QFocusFrame *focusFrame = qobject_cast<const QFocusFrame*>(widget)) { + if (focusFrame->widget() && focusFrame->widget()->hasEditFocus()) + editFocus = true; + } + const qreal opacity = editFocus ? 0.65 : 0.45; // Trial and error factors. Feel free to improve. +#else + const qreal opacity = 0.5; +#endif + // Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred. + const qreal rectAdjustment = (penWidth % 2) ? -.5 : 0; + + // Make sure that the pen stroke is inside the rect + const QRectF adjustedRect = + QRectF(option->rect).adjusted( + rectAdjustment + penWidth, + rectAdjustment + penWidth, + -rectAdjustment - penWidth, + -rectAdjustment - penWidth + ); + + const qreal roundRectRadius = penWidth * goldenRatio; + + painter->save(); + painter->setRenderHint(QPainter::Antialiasing); + painter->setOpacity(opacity); + painter->setPen(QPen(option->palette.color(QPalette::Highlight), penWidth)); + painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius); + painter->restore(); + } + break; default: QCommonStyle::drawControl(element, option, painter, widget); } @@ -1901,9 +1886,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, painter, option->rect, flags); - - if (lineEdit->state & State_HasFocus) - drawPrimitive(PE_FrameFocusRect, lineEdit, painter, widget); } break; #endif // QT_NO_LINEEDIT @@ -2030,50 +2012,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif //QT_NO_COMBOBOX break; #endif //QT_NO_SPINBOX - case PE_FrameFocusRect: -// Calendar widget and combox both do not use styled itemDelegate - if (widget && !(false -#ifndef QT_NO_CALENDARWIDGET - || qobject_cast<const QCalendarWidget *>(widget->parent()) -#endif //QT_NO_CALENDARWIDGET -#ifndef QT_NO_COMBOBOX - || qobject_cast<const QComboBoxListView *>(widget) -#endif //QT_NO_COMBOBOX - )) { - // no focus selection for touch - if (option->state & State_HasFocus && !QS60StylePrivate::isTouchSupported()) { - painter->save(); - const int penWidth = QS60StylePrivate::focusRectPenWidth(); -#ifdef QT_KEYPAD_NAVIGATION - const Qt::PenStyle penStyle = widget->hasEditFocus() ? Qt::SolidLine :Qt::DashLine; - const qreal opacity = widget->hasEditFocus() ? 0.6 : 0.4; -#else - const Qt::PenStyle penStyle = Qt::SolidLine; - const qreal opacity = 0.5; -#endif - painter->setRenderHint(QPainter::Antialiasing); - painter->setOpacity(opacity); - // Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred. - const qreal rectAdjustment = penWidth % 2?.5:0; - // Also we try to stay inside the option->rect, with penWidth > 1. Therefore these +1/-1 - const QRectF adjustedRect = QRectF(option->rect).adjusted( - rectAdjustment + penWidth - 1, - rectAdjustment + penWidth - 1, - -rectAdjustment - penWidth + 1, - -rectAdjustment - penWidth + 1); - const qreal roundRectRadius = penWidth * 1.5; -#ifdef QT_KEYPAD_NAVIGATION - if (penStyle != Qt::SolidLine) { - painter->setPen(QPen(option->palette.color(QPalette::HighlightedText), penWidth, Qt::SolidLine)); - painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius); - } -#endif - painter->setPen(QPen((option->palette.color(QPalette::Text), penWidth, penStyle))); - painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius); - painter->restore(); - } - } - break; case PE_Widget: if (QS60StylePrivate::drawsOwnThemeBackground(widget) #ifndef QT_NO_COMBOBOX @@ -2118,8 +2056,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti Q_ASSERT(false); break; case PE_Frame: - if (const QStyleOptionFrameV3 *frame = qstyleoption_cast<const QStyleOptionFrameV3 *>(option)) - drawPrimitive(PE_FrameFocusRect, frame, painter, widget); break; #ifndef QT_NO_ITEMVIEWS case PE_PanelItemViewItem: @@ -2668,16 +2604,6 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con } ret = visualRect(opt->direction, opt->rect, ret); break; - case SE_FrameContents: - if (QS60StylePrivate::isTouchSupported()) { - return QCommonStyle::subElementRect(element, opt, widget); - } else if (const QStyleOptionFrameV2 *f = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) { - // We shrink the frame contents by focusFrameWidth, so that we can draw the frame around it in keypad navigation mode. - const int frameWidth = QS60StylePrivate::focusRectPenWidth(); - ret = opt->rect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); - ret = visualRect(opt->direction, opt->rect, ret); - } - break; default: ret = QCommonStyle::subElementRect(element, opt, widget); } @@ -2778,6 +2704,38 @@ QVariant QS60Style::styleProperty(const char *name) const return d->styleProperty_specific(name); } +bool QS60Style::event(QEvent *e) +{ +#ifdef QT_KEYPAD_NAVIGATION + if (QS60StylePrivate::isTouchSupported()) + return false; + Q_D(QS60Style); + switch (e->type()) { + case QEvent::FocusIn: + if (QWidget *focusWidget = QApplication::focusWidget()) { + if (!d->m_focusFrame) + d->m_focusFrame = new QFocusFrame(focusWidget); + d->m_focusFrame->setWidget(focusWidget); + } else if (d->m_focusFrame) { + d->m_focusFrame->setWidget(0); + } + break; + case QEvent::FocusOut: + if (d->m_focusFrame) + d->m_focusFrame->setWidget(0); + break; + case QEvent::EnterEditFocus: + case QEvent::LeaveEditFocus: + if (d->m_focusFrame) + d->m_focusFrame->update(); + break; + default: + break; + } +#endif + return false; +} + QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const { diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index a03803b..c01c40a 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -80,6 +80,8 @@ public: void setStyleProperty(const char *name, const QVariant &value); QVariant styleProperty(const char *name) const; + bool event(QEvent *e); + #ifndef Q_WS_S60 static QStringList partKeys(); static QStringList colorListKeys(); diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 2e661c0..ed0abfa 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -292,6 +292,8 @@ public: }; }; +class QFocusFrame; + // Private class #ifdef Q_OS_SYMBIAN NONSHARABLE_CLASS (QS60StylePrivate) @@ -430,8 +432,6 @@ public: //access to theme palette static QPalette* themePalette(); - static int focusRectPenWidth(); - static const layoutHeader m_layoutHeaders[]; static const short data[][MAX_PIXELMETRICS]; @@ -499,6 +499,8 @@ private: // defined theme palette static QPalette *m_themePalette; QPalette m_originalPalette; + + QPointer<QFocusFrame> m_focusFrame; }; QT_END_NAMESPACE diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index bc218cd..1cf47cc 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1350,9 +1350,6 @@ void QS60StyleModeSpecifics::colorGroupAndIndex( } } -/*! - Constructs a QS60Style object. -*/ QS60Style::QS60Style() : QCommonStyle(*new QS60StylePrivate) { diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 7acb3a6..da71ced 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -214,6 +214,7 @@ enum PseudoElement { PseudoElement_ViewItemText, PseudoElement_ViewItemIndicator, PseudoElement_ScrollAreaCorner, + PseudoElement_TabBarTabCloseButton, NumPseudoElements }; @@ -223,7 +224,7 @@ struct PseudoElementInfo { }; static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = { - { QStyle::SC_None, "", }, + { QStyle::SC_None, "" }, { QStyle::SC_None, "down-arrow" }, { QStyle::SC_None, "up-arrow" }, { QStyle::SC_None, "left-arrow" }, @@ -300,8 +301,9 @@ static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = { { QStyle::SC_None, "item" }, { QStyle::SC_None, "icon" }, { QStyle::SC_None, "text" }, - { QStyle::SC_None, "indicator" } , - { QStyle::SC_None, "corner" } + { QStyle::SC_None, "indicator" }, + { QStyle::SC_None, "corner" }, + { QStyle::SC_None, "close-button" }, }; @@ -4370,6 +4372,12 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op case PE_IndicatorSpinPlus: pseudoElement = PseudoElement_SpinBoxUpArrow; break; +#ifndef QT_NO_TABBAR + case PE_IndicatorTabClose: + if (w) + w = w->parentWidget(); //match on the QTabBar instead of the CloseButton + pseudoElement = PseudoElement_TabBarTabCloseButton; +#endif default: break; @@ -5104,6 +5112,18 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi #endif // QT_NO_TABWIDGET s = QLatin1String("alignment"); break; +#ifndef QT_NO_TABBAR + case SH_TabBar_CloseButtonPosition: + rule = renderRule(w, opt, PseudoElement_TabBarTabCloseButton); + if (rule.hasPosition()) { + Qt::Alignment align = rule.position()->position; + if (align & Qt::AlignLeft || align & Qt::AlignTop) + return QTabBar::LeftSide; + if (align & Qt::AlignRight || align & Qt::AlignBottom) + return QTabBar::RightSide; + } + break; +#endif case SH_TabBar_ElideMode: s = QLatin1String("tabbar-elide-mode"); break; case SH_TabBar_PreferNoArrows: s = QLatin1String("tabbar-prefer-no-arrows"); break; case SH_ComboBox_PopupFrameStyle: diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 058041b..fe90010 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -126,8 +126,13 @@ QFontDatabaseS60StoreImplementation::QFontDatabaseS60StoreImplementation() } QFontDatabaseS60StoreImplementation::~QFontDatabaseS60StoreImplementation() { - qDeleteAll(m_extensions); - // TODO m_store cleanup removed because it was crashing + typedef QHash<QString, const QFontEngineS60Extensions *>::iterator iterator; + for (iterator p = m_extensions.begin(); p != m_extensions.end(); ++p) { + m_store->ReleaseFont((*p)->fontOwner()); + delete *p; + } + + delete m_store; m_heap->Close(); } @@ -140,7 +145,7 @@ const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(c const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, spec); Q_ASSERT(err == KErrNone && font); CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font); - m_extensions.insert(typeface, new QFontEngineS60Extensions(bitmapFont->OpenFont())); + m_extensions.insert(typeface, new QFontEngineS60Extensions(font, bitmapFont->OpenFont())); } return m_extensions.value(typeface); } diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index eba21e8..ed6b1c1 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -54,10 +54,11 @@ QT_BEGIN_NAMESPACE -QFontEngineS60Extensions::QFontEngineS60Extensions(COpenFont *font) +QFontEngineS60Extensions::QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font) : m_font(font) , m_cmap(0) , m_symbolCMap(false) + , m_fontOwner(fontOwner) { TAny *shapingExtension = NULL; m_font->ExtendedInterface(KUidOpenFontShapingExtension, shapingExtension); @@ -109,6 +110,12 @@ QPainterPath QFontEngineS60Extensions::glyphOutline(glyph_t glyph) const return result; } +CFont *QFontEngineS60Extensions::fontOwner() const +{ + return m_fontOwner; +} + + // duplicated from qfontengine_xyz.cpp static inline unsigned int getChar(const QChar *str, int &i, const int len) { diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h index 0c1be8c..bbbc3d6 100644 --- a/src/gui/text/qfontengine_s60_p.h +++ b/src/gui/text/qfontengine_s60_p.h @@ -69,11 +69,12 @@ QT_BEGIN_NAMESPACE class QFontEngineS60Extensions { public: - QFontEngineS60Extensions(COpenFont *font); + QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font); QByteArray getSfntTable(uint tag) const; const unsigned char *cmap() const; QPainterPath glyphOutline(glyph_t glyph) const; + CFont *fontOwner() const; private: COpenFont *m_font; @@ -82,6 +83,7 @@ private: mutable const unsigned char *m_cmap; mutable bool m_symbolCMap; mutable QByteArray m_cmapTable; + CFont* m_fontOwner; }; class QFontEngineS60 : public QFontEngine diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index cc9b014..f2aabd2 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -219,6 +219,11 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) pex->transferMode(BrushDrawingMode); +#ifndef QT_OPENGL_ES_2 + if (pex->inRenderText) + glPushAttrib(GL_ENABLE_BIT | GL_VIEWPORT_BIT | GL_SCISSOR_BIT); +#endif + glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); @@ -268,6 +273,11 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glViewport(0, 0, pex->width, pex->height); pex->updateDepthScissorTest(); + +#ifndef QT_OPENGL_ES_2 + if (pex->inRenderText) + glPopAttrib(); +#endif } void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) @@ -836,6 +846,11 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) glEnable(GL_STENCIL_TEST); prepareForDraw(currentBrush->isOpaque()); + +#ifndef QT_OPENGL_ES_2 + if (inRenderText) + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), zValueForRenderText()); +#endif composite(vertexCoordinateArray.boundingRect()); glDisable(GL_STENCIL_TEST); @@ -873,9 +888,21 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(QGL2PEXVertexArray& ve glEnable(GL_STENCIL_TEST); // For some reason, this has to happen _after_ the simple shader is use()'d glDisable(GL_BLEND); +#ifndef QT_OPENGL_ES_2 + if (inRenderText) { + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_DEPTH_TEST); + } +#endif + // Draw the vertecies into the stencil buffer: drawVertexArrays(vertexArray, GL_TRIANGLE_FAN); +#ifndef QT_OPENGL_ES_2 + if (inRenderText) + glPopAttrib(); +#endif + // Enable color writes & disable stencil writes glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } @@ -981,9 +1008,19 @@ void QGL2PaintEngineExPrivate::drawVertexArrays(QGL2PEXVertexArray& vertexArray, glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); } - - - +float QGL2PaintEngineExPrivate::zValueForRenderText() const +{ +#ifndef QT_OPENGL_ES_2 + // Get the z translation value from the model view matrix and + // transform it using the ortogonal projection with z-near = 0, + // and z-far = 1, which is used in QGLWidget::renderText() + GLdouble model[4][4]; + glGetDoublev(GL_MODELVIEW_MATRIX, &model[0][0]); + return -2 * model[3][2] - 1; +#else + return 0; +#endif +} /////////////////////////////////// Public Methods ////////////////////////////////////////// @@ -1002,8 +1039,8 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush) if (brush.style() == Qt::NoBrush) return; - - ensureActive(); + if (!d->inRenderText) + ensureActive(); d->setBrush(&brush); d->fill(path); d->setBrush(&(state()->brush)); // reset back to the state's brush @@ -1104,7 +1141,9 @@ void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, c QGLContext *ctx = d->ctx; glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); QGLTexture *texture = - ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption); + ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption + | QGLContext::CanFlipNativePixmapBindOption); GLfloat top = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.top()) : src.top(); GLfloat bottom = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.bottom()) : src.bottom(); @@ -1154,7 +1193,8 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem { Q_D(QGL2PaintEngineEx); - ensureActive(); + if (!d->inRenderText) + ensureActive(); QOpenGL2PaintEngineState *s = state(); const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); @@ -1203,6 +1243,8 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte if (cache->width() == 0 || cache->height() == 0) return; + if (inRenderText) + transferMode(BrushDrawingMode); transferMode(TextDrawingMode); if (glyphType == QFontEngineGlyphCache::Raster_A8) @@ -1241,6 +1283,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte prepareForDraw(false); // Text always causes src pixels to be transparent +#ifndef QT_OPENGL_ES_2 + if (inRenderText) + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), zValueForRenderText()); +#endif + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT); if (vertexCoordinateArray.data() != oldVertexCoordinateDataPtr) @@ -1286,12 +1333,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) glViewport(0, 0, d->width, d->height); -// glClearColor(0.0, 1.0, 0.0, 1.0); -// glClear(GL_COLOR_BUFFER_BIT); -// d->ctx->swapBuffers(); -// qDebug("You should see green now"); -// sleep(5); - d->brushTextureDirty = true; d->brushUniformsDirty = true; d->matrixDirty = true; @@ -1304,10 +1345,12 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->use_system_clip = !systemClip().isEmpty(); - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - glDepthFunc(GL_LEQUAL); - glDepthMask(false); + if (!d->inRenderText) { + glDisable(GL_DEPTH_TEST); + glDisable(GL_SCISSOR_TEST); + glDepthFunc(GL_LEQUAL); + glDepthMask(false); + } #if !defined(QT_OPENGL_ES_2) glDisable(GL_MULTISAMPLE); @@ -1612,7 +1655,11 @@ void QGL2PaintEngineExPrivate::regenerateDepthClip() void QGL2PaintEngineExPrivate::systemStateChanged() { Q_Q(QGL2PaintEngineEx); - use_system_clip = !systemClip.isEmpty(); + + if (q->paintDevice()->devType() == QInternal::Widget) + use_system_clip = false; + else + use_system_clip = !systemClip.isEmpty(); glDisable(GL_DEPTH_TEST); q->state()->depthTestEnabled = false; @@ -1728,6 +1775,12 @@ QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const return s; } +void QGL2PaintEngineEx::setRenderTextActive(bool active) +{ + Q_D(QGL2PaintEngineEx); + d->inRenderText = active; +} + QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &other) : QPainterState(other) { diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 66e7a51..68447bc 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -141,6 +141,8 @@ public: QPixmapFilter *createPixmapFilter(int type) const; + void setRenderTextActive(bool); + private: Q_DISABLE_COPY(QGL2PaintEngineEx) }; @@ -156,7 +158,8 @@ public: ctx(0), currentBrush(0), inverseScale(1), - shaderManager(0) + shaderManager(0), + inRenderText(false) { } ~QGL2PaintEngineExPrivate(); @@ -191,6 +194,8 @@ public: inline void useSimpleShader(); inline QColor premultiplyColor(QColor c, GLfloat opacity); + float zValueForRenderText() const; + QGL2PaintEngineEx* q; QGLDrawable drawable; int width, height; @@ -240,6 +245,7 @@ public: GLuint lastTexture; bool needsSync; + bool inRenderText; }; QT_END_NAMESPACE diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 02991d9..f3265b4 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1607,7 +1607,13 @@ Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg() would mirror the image and automatically generate mipmaps. This option helps preserve this default behavior. - \omitvalue MemoryManagedBindOption + \omitvalue CanFlipNativePixmapBindOption Used by x11 from pixmap to choose + wether or not it can bind the pixmap upside down or not. + + \omitvalue MemoryManagedBindOption Used by paint engines to + indicate that the pixmap should be memory managed along side with + the pixmap/image that it stems from, e.g. installing destruction + hooks in them. \omitvalue InternalBindOption */ @@ -1666,7 +1672,6 @@ QGLContext::QGLContext(const QGLFormat &format) QGLContext::~QGLContext() { - Q_D(QGLContext); // remove any textures cached in this context QGLTextureCache::instance()->removeContextTextures(this); QGLTextureCache::deleteIfEmpty(); // ### thread safety @@ -2179,6 +2184,9 @@ GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format) The \a format parameter sets the internal format for the texture. The default format is \c GL_RGBA. + The binding \a options are a set of options used to decide how to + bind the texture to the context. + The texture that is generated is cached, so multiple calls to bindTexture() with the same QImage will return the same texture id. @@ -2229,7 +2237,7 @@ GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint forma \overload Generates and binds a 2D GL texture to the current context, based - on \a image. + on \a pixmap. */ GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, BindOptions options) { @@ -4070,6 +4078,10 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, bool auto_swap = autoBufferSwap(); QPaintEngine *engine = paintEngine(); +#ifndef QT_OPENGL_ES + if (engine->type() == QPaintEngine::OpenGL2) + static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(true); +#endif QPainter *p; bool reuse_painter = false; if (engine->isActive()) { @@ -4095,6 +4107,13 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, setAutoBufferSwap(false); // disable glClear() as a result of QPainter::begin() d->glcx->d_func()->clear_on_painter_begin = false; + if (engine->type() == QPaintEngine::OpenGL2) { + qt_save_gl_state(); +#ifndef QT_OPENGL_ES_2 + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +#endif + } p = new QPainter(this); } @@ -4118,7 +4137,13 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, delete p; setAutoBufferSwap(auto_swap); d->glcx->d_func()->clear_on_painter_begin = true; + if (engine->type() == QPaintEngine::OpenGL2) + qt_restore_gl_state(); } +#ifndef QT_OPENGL_ES + if (engine->type() == QPaintEngine::OpenGL2) + static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(false); +#endif } /*! \overload @@ -4151,6 +4176,10 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con win_y = height - win_y; // y is inverted QPaintEngine *engine = paintEngine(); +#ifndef QT_OPENGL_ES + if (engine->type() == QPaintEngine::OpenGL2) + static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(true); +#endif QPainter *p; bool reuse_painter = false; #ifndef QT_OPENGL_ES @@ -4169,6 +4198,8 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con setAutoBufferSwap(false); // disable glClear() as a result of QPainter::begin() d->glcx->d_func()->clear_on_painter_begin = false; + if (engine->type() == QPaintEngine::OpenGL2) + qt_save_gl_state(); p = new QPainter(this); } @@ -4207,9 +4238,15 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con } else { p->end(); delete p; + if (engine->type() == QPaintEngine::OpenGL2) + qt_restore_gl_state(); setAutoBufferSwap(auto_swap); d->glcx->d_func()->clear_on_painter_begin = true; } +#ifndef QT_OPENGL_ES + if (engine->type() == QPaintEngine::OpenGL2) + static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(false); +#endif } QGLFormat QGLWidget::format() const @@ -4254,8 +4291,12 @@ GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format) return d->glcx->bindTexture(image, target, format, QGLContext::DefaultBindOption); } +/*! + \overload - + The binding \a options are a set of options used to decide how to + bind the texture to the context. + */ GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options) { Q_D(QGLWidget); @@ -4291,6 +4332,15 @@ GLuint QGLWidget::bindTexture(const QPixmap &pixmap, GLenum target, GLint format return d->glcx->bindTexture(pixmap, target, format, QGLContext::DefaultBindOption); } +/*! + \overload + + Generates and binds a 2D GL texture to the current context, based + on \a pixmap. The generated texture id is returned and can be used in + + The binding \a options are a set of options used to decide how to + bind the texture to the context. + */ GLuint QGLWidget::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, QGLContext::BindOptions options) { @@ -4427,10 +4477,10 @@ QPaintEngine *QGLWidget::paintEngine() const #elif defined(QT_OPENGL_ES_2) return qt_gl_2_engine(); #else - if (!qt_gl_preferGL2Engine()) - return qt_gl_engine(); - else + if (qt_gl_preferGL2Engine()) return qt_gl_2_engine(); + else + return qt_gl_engine(); #endif } diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 13ad668..96a8b08 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -289,16 +289,20 @@ public: virtual void swapBuffers() const; enum BindOption { - NoBindOption = 0x0000, - InvertedYBindOption = 0x0001, - MipmapBindOption = 0x0002, - PremultipliedAlphaBindOption = 0x0004, - LinearFilteringBindOption = 0x0008, - - MemoryManagedBindOption = 0x1000, // internal flag - - DefaultBindOption = LinearFilteringBindOption | InvertedYBindOption | MipmapBindOption, - InternalBindOption = MemoryManagedBindOption | PremultipliedAlphaBindOption + NoBindOption = 0x0000, + InvertedYBindOption = 0x0001, + MipmapBindOption = 0x0002, + PremultipliedAlphaBindOption = 0x0004, + LinearFilteringBindOption = 0x0008, + + MemoryManagedBindOption = 0x0010, // internal flag + CanFlipNativePixmapBindOption = 0x0020, // internal flag + + DefaultBindOption = LinearFilteringBindOption + | InvertedYBindOption + | MipmapBindOption, + InternalBindOption = MemoryManagedBindOption + | PremultipliedAlphaBindOption }; Q_DECLARE_FLAGS(BindOptions, BindOption) @@ -407,6 +411,7 @@ private: Q_DISABLE_COPY(QGLContext) }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QGLContext::BindOptions); class Q_OPENGL_EXPORT QGLWidget : public QWidget { diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index aca60bc..a34ea37 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -1633,7 +1633,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData *pmd, con GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT, // QGLContext::bindTexture() can't return an inverted texture, but QPainter::drawPixmap() can: - GLX_Y_INVERTED_EXT, options & QGLContext::InvertedYBindOption ? GLX_DONT_CARE : False, + GLX_Y_INVERTED_EXT, options & QGLContext::CanFlipNativePixmapBindOption ? GLX_DONT_CARE : False, XNone }; configList = glXChooseFBConfig(x11Info.display(), x11Info.screen(), configAttribs, &configCount); @@ -1694,8 +1694,9 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData *pmd, con glBindTexture(GL_TEXTURE_2D, textureId); - if (!((hasAlpha && RGBAConfigInverted) || (!hasAlpha && RGBConfigInverted))); + if (!((hasAlpha && RGBAConfigInverted) || (!hasAlpha && RGBConfigInverted))) options &= ~QGLContext::InvertedYBindOption; + QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, options); if (texture->options & QGLContext::InvertedYBindOption) pixmapData->flags |= QX11PixmapData::InvertedWhenBoundToTexture; diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index b982a19..f40cdc9 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -490,12 +490,13 @@ void QGLWidgetPrivate::recreateEglSurface(bool force) } -QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData* pd, const qint64 key, bool canInvert) +QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData* pd, const qint64 key, + QGLContext::BindOptions options) { Q_Q(QGLContext); // The EGL texture_from_pixmap has no facility to invert the y coordinate - if (!canInvert) + if (!(options & QGLContext::CanFlipNativePixmapBindOption)) return 0; Q_ASSERT(pd->classId() == QPixmapData::X11Class); @@ -623,7 +624,10 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmapData* pd, cons return 0; } - QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, canInvert, true); + // Always inverted because the opposite is not supported... + options |= QGLContext::InvertedYBindOption; + + QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, options); pixmapData->flags |= QX11PixmapData::InvertedWhenBoundToTexture; // We assume the cost of bound pixmaps is zero diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 52363cb..2b38e3d 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -516,12 +516,12 @@ void QGLFramebufferObjectPrivate::init(const QSize &sz, QGLFramebufferObject::At framebuffer objects more portable. \endlist + When using a QPainter to paint to a QGLFramebufferObject you should take + care that the QGLFramebufferObject is created with the CombinedDepthStencil + attachment for QPainter to be able to render correctly. Note that you need to create a QGLFramebufferObject with more than one sample per pixel for primitives to be antialiased when drawing using a - QPainter, unless if the QPainter::HighQualityAntialiasing render hint is - set. The QPainter::HighQualityAntialiasing render hint will enable - antialiasing as long as the \c{GL_ARB_fragment_program} extension is - present. To create a multisample framebuffer object you should use one of + QPainter. To create a multisample framebuffer object you should use one of the constructors that take a QGLFramebufferObject parameter, and set the QGLFramebufferObject::samples() property to a non-zero value. @@ -896,7 +896,7 @@ QPaintEngine *QGLFramebufferObject::paintEngine() const return qt_buffer_2_engine(); #else Q_D(const QGLFramebufferObject); - if (d->ctx->d_func()->internal_context || qt_gl_preferGL2Engine()) + if (qt_gl_preferGL2Engine()) return qt_buffer_2_engine(); else return qt_buffer_engine(); diff --git a/src/plugins/s60/src/qdesktopservices_3_2.cpp b/src/plugins/s60/src/qdesktopservices_3_2.cpp index fab1237..e8f4a27 100644 --- a/src/plugins/s60/src/qdesktopservices_3_2.cpp +++ b/src/plugins/s60/src/qdesktopservices_3_2.cpp @@ -50,6 +50,7 @@ EXPORT_C QString localizedDirectoryName(QString& rawPath) { QString ret; + std::exception dummy; // voodoo fix for "Undefined symbol typeinfo for std::exception" in armv5 build TRAPD(err, QT_TRYCATCH_LEAVING( diff --git a/src/s60installs/qt_libs.pro b/src/s60installs/s60installs.pro index f24a03f..0314958 100644 --- a/src/s60installs/qt_libs.pro +++ b/src/s60installs/s60installs.pro @@ -5,7 +5,8 @@ symbian: { load(data_caging_paths) SUBDIRS= - TARGET = "QtLibs pre-release" + # WARNING: Changing TARGET name will break Symbian SISX upgrade functionality + TARGET = "Qt for S60" TARGET.UID3 = 0x2001E61C VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} diff --git a/src/script/api/qscriptcontextinfo.cpp b/src/script/api/qscriptcontextinfo.cpp index e59b773..890ed9d 100644 --- a/src/script/api/qscriptcontextinfo.cpp +++ b/src/script/api/qscriptcontextinfo.cpp @@ -50,6 +50,9 @@ #include <QtCore/qmetaobject.h> #include "CodeBlock.h" #include "JSFunction.h" +#if ENABLE(JIT) +#include "MacroAssemblerCodeRef.h" +#endif QT_BEGIN_NAMESPACE @@ -154,7 +157,7 @@ QScriptContextInfoPrivate::QScriptContextInfoPrivate(const QScriptContext *conte lineNumber = -1; columnNumber = -1; - const JSC::ExecState *frame = QScriptEnginePrivate::frameForContext(context); + JSC::CallFrame *frame = const_cast<JSC::CallFrame *>(QScriptEnginePrivate::frameForContext(context)); // Get the line number: @@ -171,8 +174,13 @@ QScriptContextInfoPrivate::QScriptContextInfoPrivate(const QScriptContext *conte JSC::Instruction *returnPC = aboveFrame->returnPC(); JSC::CodeBlock *codeBlock = frame->codeBlock(); if (returnPC && codeBlock) { - lineNumber = codeBlock->lineNumberForBytecodeOffset(const_cast<JSC::ExecState *>(frame), - returnPC - codeBlock->instructions().begin() -1); +#if ENABLE(JIT) + unsigned bytecodeOffset = codeBlock->getBytecodeIndex(frame, JSC::ReturnAddressPtr(returnPC)); +#else + unsigned bytecodeOffset = returnPC - codeBlock->instructions().begin(); +#endif + bytecodeOffset--; //because returnPC is on the next instruction. We want the current one + lineNumber = codeBlock->lineNumberForBytecodeOffset(const_cast<JSC::ExecState *>(frame), bytecodeOffset); } } } else { diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 596fd8f..46c6abb 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2259,8 +2259,11 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSV if (calledAsConstructor) flags |= CalledAsConstructorContext; + //build a frame JSC::CallFrame *newCallFrame = exec; - if (callee == 0 || !(exec->callee() == callee && exec->returnPC() != 0)) { + if (callee == 0 //called from public QScriptEngine::pushContext + || exec->returnPC() == 0 || (contextFlags(exec) & NativeContext) //called from native-native call + || (exec->codeBlock() && exec->callee() != callee)) { //the interpreter did not build a frame for us. //We need to check if the Interpreter might have already created a frame for function called from JS. JSC::Interpreter *interp = exec->interpreter(); JSC::Register *oldEnd = interp->registerFile().end(); @@ -2278,6 +2281,9 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSV newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, flags, argc, callee); } else { setContextFlags(newCallFrame, flags); +#if ENABLE(JIT) + exec->registers()[JSC::RegisterFile::Callee] = JSC::JSValue(callee); //JIT let the callee set the 'callee' +#endif if (calledAsConstructor) { //update the new created this JSC::Register* thisRegister = newCallFrame->registers() - JSC::RegisterFile::CallFrameHeaderSize - newCallFrame->argumentCount(); @@ -3783,4 +3789,15 @@ QScriptSyntaxCheckResult &QScriptSyntaxCheckResult::operator=(const QScriptSynta return *this; } +#ifdef QT_BUILD_INTERNAL +Q_AUTOTEST_EXPORT bool qt_script_isJITEnabled() +{ +#if ENABLE(JIT) + return true; +#else + return false; +#endif +} +#endif + QT_END_NAMESPACE diff --git a/src/script/utils/qscriptdate.cpp b/src/script/utils/qscriptdate.cpp index a6abe4a..2445ebf 100644 --- a/src/script/utils/qscriptdate.cpp +++ b/src/script/utils/qscriptdate.cpp @@ -330,7 +330,7 @@ static qsreal getLocalTZA() /*! \internal - Converts the QDateTime \dt to an ECMA Date value (in UTC form). + Converts the QDateTime \a dt to an ECMA Date value (in UTC form). */ qsreal FromDateTime(const QDateTime &dt) { diff --git a/src/src.pro b/src/src.pro index feb6a9c..1801d55 100644 --- a/src/src.pro +++ b/src/src.pro @@ -6,8 +6,7 @@ win32:SRC_SUBDIRS += src_winmain wince*:{ SRC_SUBDIRS += src_corelib src_xml src_gui src_sql src_network src_testlib } else:symbian { - SRC_SUBDIRS += src_s60main src_corelib src_xml src_gui src_network src_sql src_testlib - SRC_SUBDIRS += $$QT_SOURCE_TREE/src/s60installs/qt_libs.pro + SRC_SUBDIRS += src_s60main src_corelib src_xml src_gui src_network src_sql src_testlib src_s60installs } else { SRC_SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_uic src_corelib src_xml src_network src_gui src_sql src_testlib !vxworks:contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_qt3support @@ -37,6 +36,8 @@ SRC_SUBDIRS += src_plugins src_s60main.subdir = $$QT_SOURCE_TREE/src/s60main src_s60main.target = sub-s60main +src_s60installs.subdir = $$QT_SOURCE_TREE/src/s60installs +src_s60installs.target = sub-s60installs src_winmain.subdir = $$QT_SOURCE_TREE/src/winmain src_winmain.target = sub-winmain src_tools_bootstrap.subdir = $$QT_SOURCE_TREE/src/tools/bootstrap diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index cc6fa88..95e8386 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -302,13 +302,18 @@ void Generator::generateCode() } } if (!extraList.isEmpty()) { + fprintf(out, "#ifdef Q_NO_DATA_RELOCATION\n"); + fprintf(out, "static const QMetaObjectAccessor qt_meta_extradata_%s[] = {\n ", qualifiedClassNameIdentifier.constData()); + for (int i = 0; i < extraList.count(); ++i) { + fprintf(out, " %s::getStaticMetaObject,\n", extraList.at(i).constData()); + } + fprintf(out, "#else\n"); fprintf(out, "static const QMetaObject *qt_meta_extradata_%s[] = {\n ", qualifiedClassNameIdentifier.constData()); for (int i = 0; i < extraList.count(); ++i) { - if (i) - fprintf(out, ",\n "); - fprintf(out, " &%s::staticMetaObject", extraList.at(i).constData()); + fprintf(out, " &%s::staticMetaObject,\n", extraList.at(i).constData()); } - fprintf(out, ",0\n};\n\n"); + fprintf(out, "#endif //Q_NO_DATA_RELOCATION\n"); + fprintf(out, " 0\n};\n\n"); } if (isConstructible || !extraList.isEmpty()) { @@ -328,7 +333,6 @@ void Generator::generateCode() // // Finally create and initialize the static meta object // - if (isQt) fprintf(out, "const QMetaObject QObject::staticQtMetaObject = {\n"); else @@ -348,11 +352,22 @@ void Generator::generateCode() fprintf(out, "&qt_meta_extradata2_%s }\n", qualifiedClassNameIdentifier.constData()); fprintf(out, "};\n"); - if (isQt || !cdef->hasQObject) + if(isQt) + return; + +// +// Generate static meta object accessor (needed for symbian, because DLLs do not support data imports. +// + fprintf(out, "\n#ifdef Q_NO_DATA_RELOCATION\n"); + fprintf(out, "const QMetaObject &%s::getStaticMetaObject() { return staticMetaObject; }\n", cdef->qualified.constData()); + fprintf(out, "#endif //Q_NO_DATA_RELOCATION\n"); + + if (!cdef->hasQObject) return; fprintf(out, "\nconst QMetaObject *%s::metaObject() const\n{\n return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;\n}\n", cdef->qualified.constData()); + // // Generate smart cast function // |