/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions ** contained in the either Technology Preview License Agreement or the ** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QCOMBOBOX_H #define QCOMBOBOX_H #include #include #include #include QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Gui) #ifndef QT_NO_COMBOBOX class QAbstractItemView; class QLineEdit; class QComboBoxPrivate; class QCompleter; class Q_GUI_EXPORT QComboBox : public QWidget { Q_OBJECT Q_ENUMS(InsertPolicy) Q_ENUMS(SizeAdjustPolicy) Q_PROPERTY(bool editable READ isEditable WRITE setEditable) Q_PROPERTY(int count READ count) Q_PROPERTY(QString currentText READ currentText) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems) Q_PROPERTY(int maxCount READ maxCount WRITE setMaxCount) Q_PROPERTY(InsertPolicy insertPolicy READ insertPolicy WRITE setInsertPolicy) Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy) Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength) Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) #ifndef QT_NO_COMPLETER Q_PROPERTY(bool autoCompletion READ autoCompletion WRITE setAutoCompletion DESIGNABLE false) Q_PROPERTY(Qt::CaseSensitivity autoCompletionCaseSensitivity READ autoCompletionCaseSensitivity WRITE setAutoCompletionCaseSensitivity DESIGNABLE false) #endif // QT_NO_COMPLETER Q_PROPERTY(bool duplicatesEnabled READ duplicatesEnabled WRITE setDuplicatesEnabled) Q_PROPERTY(bool frame READ hasFrame WRITE setFrame) Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn) public: explicit QComboBox(QWidget *parent = 0); ~QComboBox(); int maxVisibleItems() const; void setMaxVisibleItems(int maxItems); int count() const; void setMaxCount(int max); int maxCount() const; #ifndef QT_NO_COMPLETER bool autoCompletion() const; void setAutoCompletion(bool enable); Qt::CaseSensitivity autoCompletionCaseSensitivity() const; void setAutoCompletionCaseSensitivity(Qt::CaseSensitivity sensitivity); #endif bool duplicatesEnabled() const; void setDuplicatesEnabled(bool enable); void setFrame(bool); bool hasFrame() const; inline int findText(const QString &text, Qt::MatchFlags flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const { return findData(text, Qt::DisplayRole, flags); } int findData(const QVariant &data, int role = Qt::UserRole, Qt::MatchFlags flags = Qt::MatchExactly|Qt::MatchCaseSensitive) const; enum InsertPolicy { NoInsert, InsertAtTop, InsertAtCurrent, InsertAtBottom, InsertAfterCurrent, InsertBeforeCurrent, InsertAlphabetically #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN) , NoInsertion = NoInsert, AtTop = InsertAtTop, AtCurrent = InsertAtCurrent, AtBottom = InsertAtBottom, AfterCurrent = InsertAfterCurrent, BeforeCurrent = InsertBeforeCurrent #endif }; #ifdef QT3_SUPPORT typedef InsertPolicy Policy; #endif InsertPolicy insertPolicy() const; void setInsertPolicy(InsertPolicy policy); enum SizeAdjustPolicy { AdjustToContents, AdjustToContentsOnFirstShow, AdjustToMinimumContentsLength, // ### Qt 5: remove AdjustToMinimumContentsLengthWithIcon }; SizeAdjustPolicy sizeAdjustPolicy() const; void setSizeAdjustPolicy(SizeAdjustPolicy policy); int minimumContentsLength() const; void setMinimumContentsLength(int characters); QSize iconSize() const; void setIconSize(const QSize &size); bool isEditable() const; void setEditable(bool editable); void setLineEdit(QLineEdit *edit); QLineEdit *lineEdit() const; #ifndef QT_NO_VALIDATOR void setValidator(const QValidator *v); const QValidator *validator() const; #endif #ifndef QT_NO_COMPLETER void setCompleter(QCompleter *c); QCompleter *completer() const; #endif QAbstractItemDelegate *itemDelegate() const; void setItemDelegate(QAbstractItemDelegate *delegate); QAbstractItemModel *model() const; void setModel(QAbstractItemModel *model); QModelIndex rootModelIndex() const; void setRootModelIndex(const QModelIndex &index); int modelColumn() const; void setModelColumn(int visibleColumn); int currentIndex() const; QString currentText() const; QString itemText(int index) const; QIcon itemIcon(int index) const; QVariant itemData(int index, int role = Qt::UserRole) const; inline void addItem(const QString &text, const QVariant &userData = QVariant()); inline void addItem(const QIcon &icon, const QString &text, const QVariant &userData = QVariant()); inline void addItems(const QStringList &texts) { insertItems(count(), texts); } inline void insertItem(int index, const QString &text, const QVariant &userData = QVariant()); void insertItem(int index, const QIcon &icon, const QString &text, const QVariant &userData = QVariant()); void insertItems(int index, const QStringList &texts); void insertSeparator(int index); void removeItem(int index); void setItemText(int index, const QString &text); void setItemIcon(int index, const QIcon &icon); void setItemData(int index, const QVariant &value, int role = Qt::UserRole); QAbstractItemView *view() const; void setView(QAbstractItemView *itemView); QSize sizeHint() const; QSize minimumSizeHint() const; virtual void showPopup(); virtual void hidePopup(); bool event(QEvent *event); public Q_SLOTS: void clear(); void clearEditText(); void setEditText(const QString &text); void setCurrentIndex(int index); Q_SIGNALS: void editTextChanged(const QString &); void activated(int index); void activated(const QString &); void highlighted(int index); void highlighted(const QString &); void currentIndexChanged(int index); void currentIndexChanged(const QString &); protected: void focusInEvent(QFocusEvent *e); void focusOutEvent(QFocusEvent *e); void changeEvent(QEvent *e); void resizeEvent(QResizeEvent *e); void paintEvent(QPaintEvent *e); void showEvent(QShowEvent *e); void hideEvent(QHideEvent *e); void mousePressEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e); void keyPressEvent(QKeyEvent *e); void keyReleaseEvent(QKeyEvent *e); void wheelEvent(QWheelEvent *e); void contextMenuEvent(QContextMenuEvent *e); void inputMethodEvent(QInputMethodEvent *); QVariant inputMethodQuery(Qt::InputMethodQuery) const; void initStyleOption(QStyleOptionComboBox *option) const; #ifdef QT3_SUPPORT public: QT3_SUPPORT_CONSTRUCTOR QComboBox(QWidget *parent, const char *name); QT3_SUPPORT_CONSTRUCTOR QComboBox(bool rw, QWidget *parent, const char *name = 0); inline QT3_SUPPORT int currentItem() const { return currentIndex(); } inline QT3_SUPPORT void setCurrentItem(int index) { setCurrentIndex(index); } inline QT3_SUPPORT InsertPolicy insertionPolicy() const { return insertPolicy(); } inline QT3_SUPPORT void setInsertionPolicy(InsertPolicy policy) { setInsertPolicy(policy); } inline QT3_SUPPORT bool editable() const { return isEditable(); } inline QT3_SUPPORT void popup() { showPopup(); } inline QT3_SUPPORT void setCurrentText(const QString& text) { int i = findText(text); if (i != -1) setCurrentIndex(i); else if (isEditable()) setEditText(text); else setItemText(currentIndex(), text); } inline QT3_SUPPORT QString text(int index) const { return itemText(index); } inline QT3_SUPPORT QPixmap pixmap(int index) const { return itemIcon(index).pixmap(iconSize(), isEnabled() ? QIcon::Normal : QIcon::Disabled); } inline QT3_SUPPORT void insertStringList(const QStringList &list, int index = -1) { insertItems((index < 0 ? count() : index), list); } inline QT3_SUPPORT void insertItem(const QString &text, int index = -1) { insertItem((index < 0 ? count() : index), text); } inline QT3_SUPPORT void insertItem(const QPixmap &pix, int index = -1) { insertItem((index < 0 ? count() : index), QIcon(pix), QString()); } inline QT3_SUPPORT void insertItem(const QPixmap &pix, const QString &text, int index = -1) { insertItem((index < 0 ? count() : index), QIcon(pix), text); } inline QT3_SUPPORT void changeItem(const QString &text, int index) { setItemText(index, text); } inline QT3_SUPPORT void changeItem(const QPixmap &pix, int index) { setItemIcon(index, QIcon(pix)); } inline QT3_SUPPORT void changeItem(const QPixmap &pix, const QString &text, int index) { setItemIcon(index, QIcon(pix)); setItemText(index, text); } inline QT3_SUPPORT void clearValidator() { setValidator(0); } inline QT3_SUPPORT void clearEdit() { clearEditText(); } Q_SIGNALS: QT_MOC_COMPAT void textChanged(const QString &); #endif protected: QComboBox(QComboBoxPrivate &, QWidget *); private: Q_DECLARE_PRIVATE(QComboBox) Q_DISABLE_COPY(QComboBox) Q_PRIVATE_SLOT(d_func(), void _q_itemSelected(const QModelIndex &item)) Q_PRIVATE_SLOT(d_func(), void _q_emitHighlighted(const QModelIndex &)) Q_PRIVATE_SLOT(d_func(), void _q_emitCurrentIndexChanged(const QModelIndex &index)) Q_PRIVATE_SLOT(d_func(), void _q_returnPressed()) Q_PRIVATE_SLOT(d_func(), void _q_resetButton()) Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &, const QModelIndex &)) Q_PRIVATE_SLOT(d_func(), void _q_rowsAboutToBeInserted(const QModelIndex & parent, int start, int end)) Q_PRIVATE_SLOT(d_func(), void _q_rowsInserted(const QModelIndex & parent, int start, int end)) Q_PRIVATE_SLOT(d_func(), void _q_rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end)) Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex & parent, int start, int end)) Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed()) Q_PRIVATE_SLOT(d_func(), void _q_modelReset()) #ifdef QT_KEYPAD_NAVIGATION Q_PRIVATE_SLOT(d_func(), void _q_completerActivated()) #endif }; inline void QComboBox::addItem(const QString &atext, const QVariant &auserData) { insertItem(count(), atext, auserData); } inline void QComboBox::addItem(const QIcon &aicon, const QString &atext, const QVariant &auserData) { insertItem(count(), aicon, atext, auserData); } inline void QComboBox::insertItem(int aindex, const QString &atext, const QVariant &auserData) { insertItem(aindex, QIcon(), atext, auserData); } #endif // QT_NO_COMBOBOX QT_END_NAMESPACE QT_END_HEADER #endif // QCOMBOBOX_H one of x86 and x86_64, pick that one. If it contains both then use the compiler default. Make a similiar decision for PowerPC-based systems. Note that this logic assumes that Qt has been configured with an architecture that is usable on the system. Reviewed-by: Marius Storm-Olsen --- mkspecs/features/mac/default_post.prf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index ea9e9bd..210a704 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -1,2 +1,18 @@ load(default_post) !no_objective_c:CONFIG += objective_c + +# Pick a suitable default architecture for qmake-based applications. +# If the Qt package contains one of x86 and x86_64, pick that one. If it +# contains both then use the compiler default. Make a similiar decision for +# PowerPC-based systems. Note that this logic assumes that Qt has been +# configured with an architecture that is usable on the system. +message(hei $$QT_CONFIG ) +qt:!isEmpty(QT_CONFIG) { + contains(QMAKE_HOST.arch, ppc) { + !contains(QT_CONFIG, ppc64):contains(QT_CONFIG, ppc):CONFIG += ppc + contains(QT_CONFIG, ppc64):!contains(QT_CONFIG, ppc):CONFIG += ppc64 + } else { + !contains(QT_CONFIG, x86_64):contains(QT_CONFIG, x86):CONFIG += x86 + contains(QT_CONFIG, x86_64):!contains(QT_CONFIG, x86):CONFIG += x86_64 + } +} -- cgit v0.12 From c090e68c25f6c5ffeac33ba81e50147800200b59 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 13 Aug 2009 13:06:03 +0200 Subject: Fix to autotest of QDockWidget Mac needs a bit more time to update the widgets when they are redocked --- tests/auto/qdockwidget/tst_qdockwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp index e0548a7..686f62f 100644 --- a/tests/auto/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp @@ -598,7 +598,7 @@ void tst_QDockWidget::visibilityChanged() QCOMPARE(spy.count(), 0); mw.addDockWidget(Qt::RightDockWidgetArea, &dw2); - qApp->processEvents(); + QTest::qWait(200); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); } -- cgit v0.12 From 200f20d1503b6739f05916b606168da67726ffa6 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Thu, 13 Aug 2009 13:08:46 +0200 Subject: Remove yet another forgotten debug message. --- mkspecs/features/mac/default_post.prf | 1 - 1 file changed, 1 deletion(-) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 210a704..4999762 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -6,7 +6,6 @@ load(default_post) # contains both then use the compiler default. Make a similiar decision for # PowerPC-based systems. Note that this logic assumes that Qt has been # configured with an architecture that is usable on the system. -message(hei $$QT_CONFIG ) qt:!isEmpty(QT_CONFIG) { contains(QMAKE_HOST.arch, ppc) { !contains(QT_CONFIG, ppc64):contains(QT_CONFIG, ppc):CONFIG += ppc -- cgit v0.12 From f8d84ba4bfc71550879c117f96289ce80d74b7db Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Thu, 13 Aug 2009 15:05:18 +0200 Subject: Doc - Some cleanup on the documentation of QWebElement Reviewed-By: Simon Hausmann --- src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp | 378 +++++++++++++--------- 1 file changed, 220 insertions(+), 158 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp index 1dfb409..dd90f39 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp @@ -53,45 +53,57 @@ public: /*! \class QWebElement \since 4.6 - \brief The QWebElement class provides convenient access to DOM elements in a QWebFrame. + \brief The QWebElement class provides convenient access to DOM elements in + a QWebFrame. - QWebElement is the main class to easily access to the document model. - The document model is represented by a tree-like structure of DOM elements. - The root of the tree is called the document element and can be accessed using QWebFrame::documentElement(). - You can reach specific elements using findAll() and findFirst(); the elements - are identified through CSS selectors. + A QWebElement object allows easy access to the document model, represented + by a tree-like structure of DOM elements. The root of the tree is called + the document element and can be accessed using + QWebFrame::documentElement(). + + Specific elements can be accessed using findAll() and findFirst(). These + elements are identified using CSS selectors. The code snippet below + demonstrates the use of findAll(). \snippet webkitsnippets/webelement/main.cpp FindAll - The first list contains all \c span elements in the document. The second list contains - \c span elements that are children of \c p, classified with \c intro. + The first list contains all \c span elements in the document. The second + list contains \c span elements that are children of \c p, classified with + \c intro. - Using findFirst() is more efficient than calling findAll() and extracting the first element - only in the returned list. + Using findFirst() is more efficient than calling findAll(), and extracting + the first element only in the list returned. - Alternatively you can manually traverse the document using firstChild() and nextSibling(): + Alternatively you can traverse the document manually using firstChild() and + nextSibling(): \snippet webkitsnippets/webelement/main.cpp Traversing with QWebElement - The underlying content of QWebElement is explicitly shared. Creating a copy of a QWebElement - does not create a copy of the content. Instead, both instances point to the same element. + The underlying content of QWebElement is explicitly shared. Creating a copy + of a QWebElement does not create a copy of the content. Instead, both + instances point to the same element. - The element's attributes can be read using attribute() and modified with setAttribute(). + The element's attributes can be read using attribute() and modified with + setAttribute(). - The contents of child elements can be converted to plain text with toPlainText() and to - XHTML using toInnerXml(). To also include the element's tag in the output, use toOuterXml(). + The contents of child elements can be converted to plain text with + toPlainText(); to XHTML using toInnerXml(). To include the element's tag in + the output, use toOuterXml(). - It is possible to replace the contents using setPlainText() and setInnerXml(). To replace - the element itself and its contents, use setOuterXml(). + It is possible to replace the contents of child elements using + setPlainText() and setInnerXml(). To replace the element itself and its + contents, use setOuterXml(). - In the JavaScript DOM interfaces, elements can have additional functions depending on their - type. For example an HTML form element can be triggered to submit the entire form to the - web server using the submit() function. A list of these special functions can be obtained - in QWebElement using functions(); they can be invoked using callFunction(). + In the JavaScript DOM interfaces, elements can have additional functions + depending on their type. For example, an HTML form element can be triggered + to submit the entire form to the web server using the submit() function. A + list of these special functions can be obtained in QWebElement using + functions(); they can be invoked using callFunction(). - Similarly element specific properties can be obtained using scriptableProperties() and - read/written using scriptableProperty()/setScriptableProperty(). + Similarly, element specific properties can be obtained using + scriptableProperties() and read or written using scriptableProperty() or + setScriptableProperty(). */ /*! @@ -156,7 +168,7 @@ QWebElement &QWebElement::operator=(const QWebElement &other) } /*! - Destroys the element. The underlying DOM element is not destroyed. + Destroys the element. However, the underlying DOM element is not destroyed. */ QWebElement::~QWebElement() { @@ -176,7 +188,7 @@ bool QWebElement::operator!=(const QWebElement& o) const } /*! - Returns true if the element is a null element; false otherwise. + Returns true if the element is a null element; otherwise returns false. */ bool QWebElement::isNull() const { @@ -184,13 +196,16 @@ bool QWebElement::isNull() const } /*! - Returns a new list of child elements matching the given CSS selector \a selectorQuery. - If there are no matching elements, an empty list is returned. + Returns a new list of child elements matching the given CSS selector + \a selectorQuery. If there are no matching elements, an empty list is + returned. - \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} syntax is - used for the query. + \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} + syntax is used for the query. \note This search is performed recursively. + + \sa findFirst() */ QList QWebElement::findAll(const QString &selectorQuery) const { @@ -212,12 +227,15 @@ QList QWebElement::findAll(const QString &selectorQuery) const } /*! - Returns the first child element that matches the given CSS selector \a selectorQuery. + Returns the first child element that matches the given CSS selector + \a selectorQuery. - \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} syntax is - used for the query. + \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} + syntax is used for the query. \note This search is performed recursively. + + \sa findAll() */ QWebElement QWebElement::findFirst(const QString &selectorQuery) const { @@ -231,6 +249,8 @@ QWebElement QWebElement::findFirst(const QString &selectorQuery) const Replaces the existing content of this element with \a text. This is equivalent to setting the HTML innerText property. + + \sa toPlainText() */ void QWebElement::setPlainText(const QString &text) { @@ -245,6 +265,8 @@ void QWebElement::setPlainText(const QString &text) element. This is equivalent to reading the HTML innerText property. + + \sa setPlainText() */ QString QWebElement::toPlainText() const { @@ -254,11 +276,13 @@ QString QWebElement::toPlainText() const } /*! - Replaces the contents of this element as well as its own tag with \a markup. - The string may contain HTML or XML tags, which is parsed and formatted - before insertion into the document. + Replaces the contents of this element as well as its own tag with + \a markup. The string may contain HTML or XML tags, which is parsed and + formatted before insertion into the document. \note This is currently only implemented for (X)HTML elements. + + \sa toOuterXml(), toInnerXml(), setInnerXml() */ void QWebElement::setOuterXml(const QString &markup) { @@ -272,9 +296,11 @@ void QWebElement::setOuterXml(const QString &markup) /*! Returns this element converted to XML, including the start and the end - tag of this element and its attributes. + tags as well as its attributes. - \note This is currently only implemented for (X)HTML elements. + \note This is currently implemented for (X)HTML elements only. + + \sa setOuterXml(), setInnerXml(), toInnerXml() */ QString QWebElement::toOuterXml() const { @@ -285,11 +311,13 @@ QString QWebElement::toOuterXml() const } /*! - Replaces the content of this element with \a markup. - The string may contain HTML or XML tags, which is parsed and formatted - before insertion into the document. + Replaces the contents of this element with \a markup. The string may + contain HTML or XML tags, which is parsed and formatted before insertion + into the document. - \note This is currently only implemented for (X)HTML elements. + \note This is currently implemented for (X)HTML elements only. + + \sa toInnerXml(), toOuterXml(), setOuterXml() */ void QWebElement::setInnerXml(const QString &markup) { @@ -302,10 +330,11 @@ void QWebElement::setInnerXml(const QString &markup) } /*! - Returns the XML between the start and the end tag of this - element. + Returns the XML content between the element's start and end tags. - \note This is currently only implemented for (X)HTML elements. + \note This is currently implemented for (X)HTML elements only. + + \sa setInnerXml(), setOuterXml(), toOuterXml() */ QString QWebElement::toInnerXml() const { @@ -316,8 +345,10 @@ QString QWebElement::toInnerXml() const } /*! - Adds an attribute called \a name with the value \a value. If an attribute - with the same name exists, its value is replaced by \a value. + Adds an attribute with the given \a name and \a value. If an attribute with + the same name exists, its value is replaced by \a value. + + \sa attribute(), attributeNS(), setAttributeNS() */ void QWebElement::setAttribute(const QString &name, const QString &value) { @@ -328,9 +359,11 @@ void QWebElement::setAttribute(const QString &name, const QString &value) } /*! - Adds an attribute called \a name in the namespace described with \a namespaceUri - with the value \a value. If an attribute with the same name exists, its value is - replaced by \a value. + Adds an attribute with the given \a name in \a namespaceUri with \a value. + If an attribute with the same name exists, its value is replaced by + \a value. + + \sa attributeNS(), attribute(), setAttribute() */ void QWebElement::setAttributeNS(const QString &namespaceUri, const QString &name, const QString &value) { @@ -341,8 +374,10 @@ void QWebElement::setAttributeNS(const QString &namespaceUri, const QString &nam } /*! - Returns the attributed called \a name. If the attribute does not exist \a defaultValue is - returned. + Returns the attribute with the given \a name. If the attribute does not + exist, \a defaultValue is returned. + + \sa setAttribute(), setAttributeNS(), attributeNS() */ QString QWebElement::attribute(const QString &name, const QString &defaultValue) const { @@ -355,8 +390,10 @@ QString QWebElement::attribute(const QString &name, const QString &defaultValue) } /*! - Returns the attributed called \a name in the namespace described with \a namespaceUri. - If the attribute does not exist \a defaultValue is returned. + Returns the attribute with the given \a name in \a namespaceUri. If the + attribute does not exist, \a defaultValue is returned. + + \sa setAtributeNS(), setAttribute(), attribute() */ QString QWebElement::attributeNS(const QString &namespaceUri, const QString &name, const QString &defaultValue) const { @@ -369,7 +406,10 @@ QString QWebElement::attributeNS(const QString &namespaceUri, const QString &nam } /*! - Returns true if this element has an attribute called \a name; otherwise returns false. + Returns true if this element has an attribute with the given \a name; + otherwise returns false. + + \sa attribute(), setAttribute() */ bool QWebElement::hasAttribute(const QString &name) const { @@ -379,8 +419,10 @@ bool QWebElement::hasAttribute(const QString &name) const } /*! - Returns true if this element has an attribute called \a name in the namespace described - with \a namespaceUri; otherwise returns false. + Returns true if this element has an attribute with the given \a name, in + \a namespaceUri; otherwise returns false. + + \sa attributeNS(), setAttributeNS() */ bool QWebElement::hasAttributeNS(const QString &namespaceUri, const QString &name) const { @@ -390,7 +432,9 @@ bool QWebElement::hasAttributeNS(const QString &namespaceUri, const QString &nam } /*! - Removes the attribute called \a name from this element. + Removes the attribute with the given \a name from this element. + + \sa attribute(), setAttribute(), hasAttribute() */ void QWebElement::removeAttribute(const QString &name) { @@ -401,8 +445,10 @@ void QWebElement::removeAttribute(const QString &name) } /*! - Removes the attribute called \a name in the namespace described with \a namespaceUri - from this element. + Removes the attribute with the given \a name, in \a namespaceUri, from this + element. + + \sa attributeNS(), setAttributeNS(), hasAttributeNS() */ void QWebElement::removeAttributeNS(const QString &namespaceUri, const QString &name) { @@ -413,7 +459,10 @@ void QWebElement::removeAttributeNS(const QString &namespaceUri, const QString & } /*! - Returns true if the element has any attributes defined; otherwise returns false; + Returns true if the element has any attributes defined; otherwise returns + false; + + \sa attribute(), setAttribute() */ bool QWebElement::hasAttributes() const { @@ -424,6 +473,8 @@ bool QWebElement::hasAttributes() const /*! Returns the geometry of this element, relative to its containing frame. + + \sa tagName() */ QRect QWebElement::geometry() const { @@ -434,6 +485,8 @@ QRect QWebElement::geometry() const /*! Returns the tag name of this element. + + \sa geometry() */ QString QWebElement::tagName() const { @@ -443,7 +496,8 @@ QString QWebElement::tagName() const } /*! - Returns the namespace prefix of the element or an empty string if the element has no namespace prefix. + Returns the namespace prefix of the element. If the element has no\ + namespace prefix, empty string is returned. */ QString QWebElement::prefix() const { @@ -453,8 +507,8 @@ QString QWebElement::prefix() const } /*! - If the element uses namespaces, this function returns the local name of the element; - otherwise it returns an empty string. + Returns the local name of the element. If the element does not use + namespaces, an empty string is returned. */ QString QWebElement::localName() const { @@ -464,7 +518,8 @@ QString QWebElement::localName() const } /*! - Returns the namespace URI of this element or an empty string if the element has no namespace URI. + Returns the namespace URI of this element. If the element has no namespace + URI, an empty string is returned. */ QString QWebElement::namespaceUri() const { @@ -474,8 +529,8 @@ QString QWebElement::namespaceUri() const } /*! - Returns the parent element of this element or a null element if this element - is the root document element. + Returns the parent element of this elemen. If this element is the root + document element, a null element is returned. */ QWebElement QWebElement::parent() const { @@ -485,9 +540,9 @@ QWebElement QWebElement::parent() const } /*! - Returns the first child element of this element. + Returns the element's first child. - \sa lastChild() previousSibling() nextSibling() + \sa lastChild(), previousSibling(), nextSibling() */ QWebElement QWebElement::firstChild() const { @@ -503,9 +558,9 @@ QWebElement QWebElement::firstChild() const } /*! - Returns the last child element of this element. + Returns the element's last child. - \sa firstChild() previousSibling() nextSibling() + \sa firstChild(), previousSibling(), nextSibling() */ QWebElement QWebElement::lastChild() const { @@ -521,9 +576,9 @@ QWebElement QWebElement::lastChild() const } /*! - Returns the next sibling element of this element. + Returns the element's next sibling. - \sa firstChild() previousSibling() lastChild() + \sa firstChild(), previousSibling(), lastChild() */ QWebElement QWebElement::nextSibling() const { @@ -539,9 +594,9 @@ QWebElement QWebElement::nextSibling() const } /*! - Returns the previous sibling element of this element. + Returns the element's previous sibling. - \sa firstChild() nextSibling() lastChild() + \sa firstChild(), nextSibling(), lastChild() */ QWebElement QWebElement::previousSibling() const { @@ -557,7 +612,7 @@ QWebElement QWebElement::previousSibling() const } /*! - Returns the document this element belongs to. + Returns the document which this element belongs to. */ QWebElement QWebElement::document() const { @@ -570,8 +625,8 @@ QWebElement QWebElement::document() const } /*! - Returns the web frame this elements is a part of. If the element is - a null element null is returned. + Returns the web frame which this element is a part of. If the element is a + null element, null is returned. */ QWebFrame *QWebElement::webFrame() const { @@ -647,7 +702,7 @@ static bool setupScriptObject(WebCore::Element* element, ScriptObject& object, S } /*! - Executes the \a scriptSource with this element as the `this' object. + Executes \a scriptSource with this element as \c this object. \sa callFunction() */ @@ -680,9 +735,10 @@ QVariant QWebElement::evaluateScript(const QString& scriptSource) /*! Calls the function with the given \a name and \a arguments. - The underlying DOM element that QWebElement wraps may have dedicated functions depending - on its type. For example a form element can have the "submit" function, that would submit - the form to the destination specified in the HTML. + The underlying DOM element that QWebElement wraps may have dedicated + functions, depending on its type. For example, a form element can have the + \c submit function, that would submit the form to the destination specified + in the HTML. \sa functions() */ @@ -713,7 +769,7 @@ QVariant QWebElement::callFunction(const QString &name, const QVariantList &argu /*! Returns a list of function names this element supports. - The function names returned are the same functions that are callable from the DOM + The function names returned are the same functions callable from the DOM element's JavaScript binding. \sa callFunction() @@ -763,14 +819,14 @@ QStringList QWebElement::functions() const } /*! - Returns the value of the element's \a name property. + Returns the value of the element's \a name property. If no such property + exists, an invalid QVariant is returned. - If no such property exists, the returned variant is invalid. + The return value's property has the same value as the corresponding + property in the element's JavaScript binding with the same name. - The return property has the same value as the corresponding property - in the element's JavaScript binding with the same name. - - Information about all available properties is provided through scriptProperties(). + Information about all available properties is provided through + scriptProperties(). \sa setScriptableProperty(), scriptableProperties() */ @@ -797,10 +853,11 @@ QVariant QWebElement::scriptableProperty(const QString &name) const /*! Sets the value of the element's \a name property to \a value. - Information about all available properties is provided through scriptProperties(). + Information about all available properties is provided through + scriptProperties(). - Setting the property will affect the corresponding property - in the element's JavaScript binding with the same name. + Setting the property will affect the corresponding property in the + element's JavaScript binding with the same name. \sa scriptableProperty(), scriptableProperties() */ @@ -827,8 +884,8 @@ void QWebElement::setScriptableProperty(const QString &name, const QVariant &val /*! Returns a list of property names this element supports. - The function names returned are the same properties that are accessible from the DOM - element's JavaScript binding. + The function names returned are the same properties that are accessible + from the DOM element's JavaScript binding. \sa setScriptableProperty(), scriptableProperty() */ @@ -894,10 +951,12 @@ QStringList QWebElement::scriptableProperties() const This enum describes how QWebElement's styleProperty resolves the given property name. - \value IgnoreCascadingStyles Return the property value as it is defined - in the element, without respecting style inheritance and other CSS rules. - \value RespectCascadingStyles The property's value is determined using - the inheritance and importance rules defined in the document's stylesheet. + \value IgnoreCascadingStyles Return the property value as it is defined in + the element, without respecting style inheritance and other CSS + rules. + \value RespectCascadingStyles The property's value is determined using the + inheritance and importance rules defined in the document's + stylesheet. */ /*! @@ -907,17 +966,17 @@ QStringList QWebElement::scriptableProperties() const This enum describes the priority newly set CSS properties should have when set using QWebElement::setStyleProperty(). - \value NormalStylePriority Define the property without important - priority even if "!important" is explicitly set in \a value. - \value DeclaredStylePriority Define the property respecting the - priority specified in \a value. - \value ImportantStylePriority Define the property to have - an important priority, this is equal to appending "!important" to the value. + \value NormalStylePriority Define the property without important priority + even if "!important" is explicitly set in \a value. + \value DeclaredStylePriority Define the property respecting the priority + specified in \a value. + \value ImportantStylePriority Define the property to have an important + priority. This is equal to appending "!important" to the value. */ /*! - Returns the value of the style named \a name or an empty string if such one - does not exist. + Returns the value of the style with the given \a name. If a style with + \name does not exist, an empty string is returned. If \a rule is IgnoreCascadingStyles, the value defined inside the element (inline in CSS terminology) is returned. @@ -925,14 +984,17 @@ QStringList QWebElement::scriptableProperties() const if \a rule is RespectCascadingStyles, the actual style applied to the element is returned. - In CSS, the cascading part has to do with which CSS rule has priority and - is thus applied. Generally speaking, the last defined rule has priority, - thus an inline style rule has priority over an embedded block style rule, - which in return has priority over an external style rule. + In CSS, the cascading part depends on which CSS rule has priority and is + thus applied. Generally, the last defined rule has priority. Thus, an + inline style rule has priority over an embedded block style rule, which + in return has priority over an external style rule. + + If the "!important" declaration is set on one of those, the declaration + receives highest priority, unless other declarations also use the + "!important" declaration. Then, the last "!important" declaration takes + predecence. - If the !important declaration is set on one of those, the declaration gets - highest priority, unless other declarations also use the !important - declaration, in which the last !important declaration takes predecence. + \sa setStyleProperty() */ QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const { @@ -981,9 +1043,9 @@ QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const } /*! - Sets the value of the style named \a name to \a value. + Sets the value of the style with the given \a name to \a value. - Setting a value, doesn't necessarily mean that it will become the applied + Setting a value, does not necessarily mean that it will become the applied value, due to the fact that the style property's value might have been set earlier with priority in external or embedded style declarations. @@ -998,7 +1060,8 @@ QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const Using NormalStylePriority as \a priority, the property will have normal priority, and any "!important" declaration will be ignored. On the other hand, using ImportantStylePriority sets the important priority even when - not explicit passed in \a value. + it is not explicitly passed in \a value. + By using DeclaredStylePriority as \a priority the property will respect the priority specified in \a value. */ @@ -1035,7 +1098,8 @@ void QWebElement::setStyleProperty(const QString &name, const QString &value, St } /*! - Returns the computed value for style named \a name or an empty string if the style has no such name. + Returns the computed value for style with the given \a name. If a style + with \name does not exist, an empty string is returned. */ QString QWebElement::computedStyleProperty(const QString &name) const { @@ -1083,7 +1147,8 @@ QStringList QWebElement::classes() const } /*! - Returns true if this element has a class called \a name; otherwise returns false. + Returns true if this element has a class with the given \a name; otherwise + returns false. */ bool QWebElement::hasClass(const QString &name) const { @@ -1092,7 +1157,7 @@ bool QWebElement::hasClass(const QString &name) const } /*! - Adds the specified class \a name to the element. + Adds the specified class with the given \a name to the element. */ void QWebElement::addClass(const QString &name) { @@ -1105,7 +1170,7 @@ void QWebElement::addClass(const QString &name) } /*! - Removes the specified class \a name from the element. + Removes the specified class with the given \a name from the element. */ void QWebElement::removeClass(const QString &name) { @@ -1118,8 +1183,8 @@ void QWebElement::removeClass(const QString &name) } /*! - Adds the specified class \a name if it is not present, - removes it if it is already present. + Adds the specified class with the given \a name if it is not present. If + the class is already present, it will be removed. */ void QWebElement::toggleClass(const QString &name) { @@ -1134,11 +1199,11 @@ void QWebElement::toggleClass(const QString &name) } /*! - Appends \a element as the element's last child. + Appends the given \a element as the element's last child. - If \a element is the child of another element, it is re-parented - to this element. If \a element is a child of this element, then - its position in the list of children is changed. + If \a element is the child of another element, it is re-parented to this + element. If \a element is a child of this element, then its position in + the list of children is changed. Calling this function on a null element does nothing. @@ -1178,9 +1243,9 @@ void QWebElement::appendInside(const QString &markup) /*! Prepends \a element as the element's first child. - If \a element is the child of another element, it is re-parented - to this element. If \a element is a child of this element, then - its position in the list of children is changed. + If \a element is the child of another element, it is re-parented to this + element. If \a element is a child of this element, then its position in + the list of children is changed. Calling this function on a null element does nothing. @@ -1227,10 +1292,10 @@ void QWebElement::prependInside(const QString &markup) /*! - Inserts \a element before this element. + Inserts the given \a element before this element. - If \a element is the child of another element, it is re-parented - to the parent of this element. + If \a element is the child of another element, it is re-parented to the + parent of this element. Calling this function on a null element does nothing. @@ -1274,10 +1339,10 @@ void QWebElement::prependOutside(const QString &markup) } /*! - Inserts \a element after this element. + Inserts the given \a element after this element. - If \a element is the child of another element, it is re-parented - to the parent of this element. + If \a element is the child of another element, it is re-parented to the + parent of this element. Calling this function on a null element does nothing. @@ -1342,11 +1407,10 @@ QWebElement QWebElement::clone() const } /*! - Removes this element from the document and returns a reference - to this. + Removes this element from the document and returns a reference to it. - The element is still valid after removal, and can be inserted into - other parts of the document. + The element is still valid after removal, and can be inserted into other + parts of the document. \sa removeChildren(), removeFromDocument() */ @@ -1362,8 +1426,7 @@ QWebElement &QWebElement::takeFromDocument() } /*! - Removes this element from the document and makes this - a null element. + Removes this element from the document and makes it a null element. \sa removeChildren(), takeFromDocument() */ @@ -1414,9 +1477,10 @@ static RefPtr findInsertionPoint(PassRefPtr root) } /*! - Enclose the contents of this element in \a element as the child - of the deepest descendant element within the structure of the - first element provided. + Encloses the contents of this element with \a element. This element becomes + the child of the deepest descendant within \a element. + + ### illustration \sa encloseWith() */ @@ -1446,9 +1510,8 @@ void QWebElement::encloseContentsWith(const QWebElement &element) } /*! - Enclose the contents of this element in the result of parsing - \a markup as the child of the deepest descendant element within - the structure of the first element provided. + Encloses the contents of this element with the result of parsing \a markup. + This element becomes the child of the deepest descendant within \a markup. \sa encloseWith() */ @@ -1490,9 +1553,8 @@ void QWebElement::encloseContentsWith(const QString &markup) } /*! - Enclose this element in \a element as the child of the deepest - descendant element within the structure of the first element - provided. + Encloses this element with \a element. This element becomes the child of + the deepest descendant within \a element. \sa replace() */ @@ -1523,8 +1585,8 @@ void QWebElement::encloseWith(const QWebElement &element) } /*! - Enclose this element in the result of parsing \a markup, - as the last child. + Encloses this element with the result of parsing \a markup. This element + becomes the child of the deepest descendant within \a markup. \sa replace() */ @@ -1569,8 +1631,7 @@ void QWebElement::encloseWith(const QString &markup) /*! Replaces this element with \a element. - It is not possible to replace the , , or - elements using this method. + This method will not replace the , or elements. \sa encloseWith() */ @@ -1586,8 +1647,7 @@ void QWebElement::replace(const QWebElement &element) /*! Replaces this element with the result of parsing \a markup. - It is not possible to replace the , , or - elements using this method. + This method will not replace the , or elements. \sa encloseWith() */ @@ -1603,11 +1663,13 @@ void QWebElement::replace(const QString &markup) /*! \fn inline bool QWebElement::operator==(const QWebElement& o) const; - Returns true if this element points to the same underlying DOM object than \a o; otherwise returns false. + Returns true if this element points to the same underlying DOM object as + \a o; otherwise returns false. */ /*! \fn inline bool QWebElement::operator!=(const QWebElement& o) const; - Returns true if this element points to a different underlying DOM object than \a o; otherwise returns false. + Returns true if this element points to a different underlying DOM object + than \a o; otherwise returns false. */ -- cgit v0.12 From be4c288579314e2c11bd284d03a45007c2d3b300 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 13 Aug 2009 15:08:24 +0200 Subject: qdoc: Disabled reporting the NOTIFY signal until I know what it broke. Task-number: 259071 --- tools/qdoc3/cppcodeparser.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index ca12e92..ebe5ec9 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -1724,9 +1724,6 @@ bool CppCodeParser::matchProperty(InnerNode *parent) value = "?"; } - /* - Task 259071 requires work here. See gui/widgets/qdatetime.h, for example. - */ if (key == "READ") tre->addPropertyFunction(property, value, PropertyNode::Getter); else if (key == "WRITE") @@ -1737,9 +1734,11 @@ bool CppCodeParser::matchProperty(InnerNode *parent) property->setDesignable(value.toLower() == "true"); else if (key == "RESET") tre->addPropertyFunction(property, value, PropertyNode::Resetter); +#if 0 else if (key == "NOTIFY") { tre->addPropertyFunction(property, value, PropertyNode::Notifier); } +#endif } match(Tok_RightParen); return true; -- cgit v0.12 From e9b6e85b43bd233f16668dcb91da36e6dc31d4ff Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 13 Aug 2009 15:27:41 +0200 Subject: Fix auto test xmlpatternsschemats by adjusting build dependencies. --- tests/auto/auto.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index d7f27bd..dd188cd 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -444,6 +444,7 @@ SUBDIRS += checkxmlfiles \ xmlpatternsdiagnosticsts.depends = xmlpatternsxqts xmlpatternsview.depends = xmlpatternsxqts xmlpatternsxslts.depends = xmlpatternsxqts +xmlpatternsschemats.depends = xmlpatternsxqts } unix:!embedded:contains(QT_CONFIG, dbus):SUBDIRS += \ -- cgit v0.12 From 547af9bf8a2ec074a698f0b92ec9e2a1a935eb14 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 13 Aug 2009 15:30:59 +0200 Subject: Fix qmake warnings Removed the src/common.pri includes Reviewed-by: Trust Me --- tools/xmlpatterns/xmlpatterns.pro | 2 -- tools/xmlpatternsvalidator/xmlpatternsvalidator.pro | 2 -- 2 files changed, 4 deletions(-) diff --git a/tools/xmlpatterns/xmlpatterns.pro b/tools/xmlpatterns/xmlpatterns.pro index 9c1aac1..1c5ab2c 100644 --- a/tools/xmlpatterns/xmlpatterns.pro +++ b/tools/xmlpatterns/xmlpatterns.pro @@ -27,5 +27,3 @@ HEADERS = main.h \ qapplicationargumentparser.cpp \ qcoloringmessagehandler_p.h \ qcoloroutput_p.h - -include(../src/common.pri) diff --git a/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro b/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro index dd5bd37..8491129 100644 --- a/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro +++ b/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro @@ -15,5 +15,3 @@ CONFIG -= app_bundle SOURCES = main.cpp HEADERS = main.h - -include(../src/common.pri) -- cgit v0.12 From ff01481900f1d19d392c8ed8fe0f3b5c85751b8e Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Thu, 13 Aug 2009 12:20:52 +0200 Subject: Fix focus proxy deletion bugs/crashes in QGraphicsItem. This change would have been much simpler if either QGraphicsItem inherited QObject, or if we had some similar QPointer-like class that supported QGraphicsItem. The issue is this: Each item can delegate another item to be its focus proxy. That item can be a parent or child, or something completely unrelated. Either of the two items can be deleted independently. The former solution was to store backpointers in a map in the scene. Problem is, the items may not be in a scene when this happens, they may be removed from the scene, and the items may be moved between two scenes. The bad part about this fix is that it adds another pointer to QGraphicsItemPrivate. Reviewed-by: Shane Kearns --- src/gui/graphicsview/qgraphicsitem.cpp | 29 +++++++++++++----- src/gui/graphicsview/qgraphicsitem_p.h | 2 ++ src/gui/graphicsview/qgraphicsscene.cpp | 6 +--- src/gui/graphicsview/qgraphicsscene_p.h | 1 - tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 42 ++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 14 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index c3e5501..537dab7 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1196,10 +1196,12 @@ QGraphicsItem::~QGraphicsItem() Q_ASSERT(d_ptr->children.isEmpty()); } - if (d_ptr->scene) + if (d_ptr->scene) { d_ptr->scene->d_func()->removeItemHelper(this); - else + } else { + d_ptr->resetFocusProxy(); d_ptr->setParentItemHelper(0); + } if (d_ptr->transformData) { for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) { @@ -2613,13 +2615,11 @@ void QGraphicsItem::setFocusProxy(QGraphicsItem *item) } QGraphicsItem *lastFocusProxy = d_ptr->focusProxy; + if (lastFocusProxy) + lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy); d_ptr->focusProxy = item; - if (d_ptr->scene) { - if (lastFocusProxy) - d_ptr->scene->d_func()->focusProxyReverseMap.remove(lastFocusProxy, this); - if (item) - d_ptr->scene->d_func()->focusProxyReverseMap.insert(item, this); - } + if (item) + item->d_ptr->focusProxyRefs << &d_ptr->focusProxy; } /*! @@ -4626,6 +4626,19 @@ void QGraphicsItemPrivate::clearSubFocus() /*! \internal + Sets the focusProxy pointer to 0 for all items that have this item as their + focusProxy. ### Qt 5: Use QPointer instead. +*/ +void QGraphicsItemPrivate::resetFocusProxy() +{ + for (int i = 0; i < focusProxyRefs.size(); ++i) + *focusProxyRefs.at(i) = 0; + focusProxyRefs.clear(); +} + +/*! + \internal + Tells us if it is a proxy widget */ bool QGraphicsItemPrivate::isProxyWidget() const diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 982cdfc..c654d4f 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -398,6 +398,7 @@ public: void setSubFocus(); void clearSubFocus(); + void resetFocusProxy(); inline QTransform transformToParent() const; inline void ensureSortedChildren(); @@ -419,6 +420,7 @@ public: int siblingIndex; int depth; QGraphicsItem *focusProxy; + QList focusProxyRefs; QGraphicsItem *subFocusItem; Qt::InputMethodHints imHints; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index bdd1ac6..2178850 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -494,11 +494,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) item->d_func()->scene = 0; // Unregister focus proxy. - QMultiHash::iterator it = focusProxyReverseMap.find(item); - while (it != focusProxyReverseMap.end() && it.key() == item) { - it.value()->d_ptr->focusProxy = 0; - it = focusProxyReverseMap.erase(it); - } + item->d_ptr->resetFocusProxy(); // Remove from parent, or unregister from toplevels. if (QGraphicsItem *parentItem = item->parentItem()) { diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 8b53306..836522d 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -131,7 +131,6 @@ public: QGraphicsWidget *activeWindow; int activationRefCount; void setFocusItemHelper(QGraphicsItem *item, Qt::FocusReason focusReason); - QMultiHash focusProxyReverseMap; QList popupWidgets; void addPopup(QGraphicsWidget *widget); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index eadf8b7..a623b50 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -280,6 +280,7 @@ private slots: void autoDetectFocusProxy(); void subFocus(); void reverseCreateAutoFocusProxy(); + void focusProxyDeletion(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -7516,5 +7517,46 @@ void tst_QGraphicsItem::reverseCreateAutoFocusProxy() QVERIFY(text2->hasFocus()); } +void tst_QGraphicsItem::focusProxyDeletion() +{ + QGraphicsRectItem *rect = new QGraphicsRectItem; + QGraphicsRectItem *rect2 = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)rect2); + + delete rect2; + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0); + + rect2 = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + delete rect; // don't crash + + rect = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + QGraphicsScene *scene = new QGraphicsScene; + scene->addItem(rect); + scene->addItem(rect2); + delete rect2; + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0); + + rect2 = new QGraphicsRectItem; + QTest::ignoreMessage(QtWarningMsg, "QGraphicsItem::setFocusProxy: focus proxy must be in same scene"); + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0); + scene->addItem(rect2); + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)rect2); + delete rect; // don't crash + + rect = new QGraphicsRectItem; + rect2 = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)rect2); + scene->addItem(rect); + scene->addItem(rect2); + rect->setFocusProxy(rect2); + delete scene; // don't crash +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From a55a7e06727610683a61461adfd144046d669b46 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 13 Aug 2009 15:52:51 +0200 Subject: clucene compiles on Windows CE now reimplmenting some missing C functions Task-number: 214990 Reviewed-by: kh --- src/3rdparty/clucene/src/CLucene/StdHeader.cpp | 2 ++ src/3rdparty/clucene/src/CLucene/StdHeader.h | 10 ++++++++++ src/3rdparty/clucene/src/CLucene/config/define_std.h | 3 +++ src/3rdparty/clucene/src/CLucene/config/repl_tchar.h | 20 ++++++++++++++++++++ src/3rdparty/clucene/src/CLucene/util/Misc.cpp | 10 ++++++++++ .../clucene/src/CLucene/util/fileinputstream.cpp | 5 +++++ 6 files changed, 50 insertions(+) diff --git a/src/3rdparty/clucene/src/CLucene/StdHeader.cpp b/src/3rdparty/clucene/src/CLucene/StdHeader.cpp index 9813a58..d64c51f 100644 --- a/src/3rdparty/clucene/src/CLucene/StdHeader.cpp +++ b/src/3rdparty/clucene/src/CLucene/StdHeader.cpp @@ -17,8 +17,10 @@ #if defined(_CLCOMPILER_MSVC) && defined(_DEBUG) # define CRTDBG_MAP_ALLOC # include +#ifndef UNDER_CE # include #endif +#endif CL_NS_USE(util) diff --git a/src/3rdparty/clucene/src/CLucene/StdHeader.h b/src/3rdparty/clucene/src/CLucene/StdHeader.h index d267d03..fbb3fd9 100644 --- a/src/3rdparty/clucene/src/CLucene/StdHeader.h +++ b/src/3rdparty/clucene/src/CLucene/StdHeader.h @@ -58,8 +58,10 @@ extern int _lucene_counter_break; //can set a watch on this #if defined(_CL_HAVE_UNISTD_H) #include #elif defined(_CL_HAVE_IO_H) && defined(_CL_HAVE_DIRECT_H) +#ifndef UNDER_CE #include #include +#endif #else #error "Neither unistd.h or (io.h & direct.h) were available" #endif @@ -75,7 +77,11 @@ extern int _lucene_counter_break; //can set a watch on this #if defined(_CL_STAT_MACROS_BROKEN) #error "Haven't implemented STAT_MACROS_BROKEN fix yet" #elif defined(_CL_HAVE_SYS_STAT_H) +#ifdef UNDER_CE + #include +#else #include +#endif #else #error "Haven't implemented platforms with no sys/stat.h" #endif @@ -179,13 +185,17 @@ extern int _lucene_counter_break; //can set a watch on this #include "CLucene/config/repl_tchar.h" #if defined(_CL_HAVE_ERRNO_H) +#ifndef UNDER_CE #include +#endif #else #error "Haven't implemented platforms with no errno.h" #endif #if defined(_CL_HAVE_FCNTL_H) +#ifndef UNDER_CE #include +#endif #else #error "Haven't implemented platforms with no fcntl.h" #endif diff --git a/src/3rdparty/clucene/src/CLucene/config/define_std.h b/src/3rdparty/clucene/src/CLucene/config/define_std.h index 3f92117..22a0790 100644 --- a/src/3rdparty/clucene/src/CLucene/config/define_std.h +++ b/src/3rdparty/clucene/src/CLucene/config/define_std.h @@ -72,6 +72,9 @@ #else #define _CL_HAVE_UNISTD_H #endif +#ifdef UNDER_CE +#undef _CL_HAVE_SYS_TIMEB_H +#endif //////////////////////////////////////////////// //now for individual functions. some compilers diff --git a/src/3rdparty/clucene/src/CLucene/config/repl_tchar.h b/src/3rdparty/clucene/src/CLucene/config/repl_tchar.h index d562cc8..ba8aef5 100644 --- a/src/3rdparty/clucene/src/CLucene/config/repl_tchar.h +++ b/src/3rdparty/clucene/src/CLucene/config/repl_tchar.h @@ -93,6 +93,26 @@ #endif #else //HAVE_TCHAR_H #include + +#ifdef UNDER_CE +#include +#define _i64tot i64tot +inline TCHAR* i64tot(__int64 value, TCHAR* str, int radix) +{ + QT_USE_NAMESPACE + _tcscpy(str, (TCHAR *) QString::number(value, radix).utf16()); + return str; +} + +#define _tcstoi64 tcstoi64 +inline __int64 tcstoi64(const TCHAR *nptr, TCHAR **endptr, int base) +{ + QT_USE_NAMESPACE + bool ok; + return QString::fromUtf16((ushort*) nptr).toInt(&ok, base); +} + +#endif //some tchar headers miss these... #ifndef _tcstoi64 diff --git a/src/3rdparty/clucene/src/CLucene/util/Misc.cpp b/src/3rdparty/clucene/src/CLucene/util/Misc.cpp index cb2efe2..42e3fd0 100644 --- a/src/3rdparty/clucene/src/CLucene/util/Misc.cpp +++ b/src/3rdparty/clucene/src/CLucene/util/Misc.cpp @@ -24,10 +24,15 @@ # include #endif +#ifdef UNDER_CE +#include +#endif + CL_NS_DEF(util) uint64_t Misc::currentTimeMillis() { +#ifndef UNDER_CE #if defined(_CLCOMPILER_MSVC) || defined(__MINGW32__) || defined(__BORLANDC__) struct _timeb tstruct; _ftime(&tstruct); @@ -41,6 +46,11 @@ uint64_t Misc::currentTimeMillis() return (((uint64_t) tstruct.tv_sec) * 1000) + tstruct.tv_usec / 1000; #endif +#else //UNDER_CE + QT_USE_NAMESPACE + QTime t = QTime::currentTime(); + return t.second() * 1000 + t.msec(); +#endif //UNDER_CE } // #pragma mark -- char related utils diff --git a/src/3rdparty/clucene/src/CLucene/util/fileinputstream.cpp b/src/3rdparty/clucene/src/CLucene/util/fileinputstream.cpp index 3803dfd..9125d84 100644 --- a/src/3rdparty/clucene/src/CLucene/util/fileinputstream.cpp +++ b/src/3rdparty/clucene/src/CLucene/util/fileinputstream.cpp @@ -25,7 +25,10 @@ */ #include "jstreamsconfig.h" #include "fileinputstream.h" + +#ifndef UNDER_CE #include +#endif #include namespace jstreams { @@ -39,7 +42,9 @@ FileInputStream::FileInputStream(const char *filepath, int32_t buffersize) { error = "Could not read file '"; error += filepath; error += "': "; +#ifndef UNDER_CE error += strerror(errno); +#endif status = Error; return; } -- cgit v0.12 From b4db217bf195bda7ade32bda79be65b5d31e1c0e Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 13 Aug 2009 15:54:51 +0200 Subject: Assistant compiles on Windows CE no official support Task-number: 214990 Reviewed-by: kh --- tools/assistant/compat/mainwindow.cpp | 2 ++ tools/assistant/tools/assistant/remotecontrol.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/tools/assistant/compat/mainwindow.cpp b/tools/assistant/compat/mainwindow.cpp index 353efdb..13b555e 100644 --- a/tools/assistant/compat/mainwindow.cpp +++ b/tools/assistant/compat/mainwindow.cpp @@ -401,6 +401,7 @@ QString MainWindow::urlifyFileName(const QString &fileName) return name; } +#ifndef QT_NO_PRINTER class PrintThread : public QThread { QPrinter _printer; @@ -436,6 +437,7 @@ protected: _document = 0; } }; +#endif //QT_NO_PRINTER void MainWindow::on_actionFilePrint_triggered() { diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index b72d7e8..7867ba0 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -78,6 +78,8 @@ void StdInListenerWin::run() bool ok = true; char chBuf[4096]; DWORD dwRead; + +#ifndef Q_WS_WINCE HANDLE hStdin, hStdinDup; hStdin = GetStdHandle(STD_INPUT_HANDLE); @@ -89,6 +91,10 @@ void StdInListenerWin::run() 0, false, DUPLICATE_SAME_ACCESS); CloseHandle(hStdin); +#else + HANDLE hStdinDup; + hStdinDup = stdin; +#endif while (ok) { ok = ReadFile(hStdinDup, chBuf, 4096, &dwRead, NULL); -- cgit v0.12 From 1e6e479037670518630b3c234bd47ed39fa08dd2 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 13 Aug 2009 15:55:57 +0200 Subject: fixing autotests for Windows CE (deployment - QHelp) Task-number: 214990 Reviewed-by: Joerg --- tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro | 16 +++++++++++++++- tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp | 2 ++ tests/auto/qhelpenginecore/tst_qhelpenginecore.pro | 17 ++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro index 7cd8d51..889aac9 100644 --- a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro +++ b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro @@ -3,6 +3,20 @@ SOURCES += tst_qhelpcontentmodel.cpp CONFIG += help -DEFINES += SRCDIR=\\\"$$PWD\\\" DEFINES += QT_USE_USING_NAMESPACE !contains(QT_BUILD_PARTS, tools): DEFINES += QT_NO_BUILD_TOOLS + +wince*: { + DEFINES += SRCDIR=\\\"./\\\" + QT += network + addFiles.sources = $$PWD/data/*.* + addFiles.path = data + clucene.sources = $$QT_BUILD_TREE/lib/QtCLucene*.dll + + DEPLOYMENT += addFiles + DEPLOYMENT += clucene + + DEPLOYMENT_PLUGIN += qsqlite +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} \ No newline at end of file diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp index 499c367..d765c25 100644 --- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp +++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp @@ -98,6 +98,8 @@ void tst_QHelpEngineCore::init() // defined in profile m_path = QLatin1String(SRCDIR); + m_path = QFileInfo(m_path).absoluteFilePath(); + m_colFile = m_path + QLatin1String("/data/col.qhc"); if (QFile::exists(m_colFile)) QDir::current().remove(m_colFile); diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro b/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro index 11fca8e..27ebd0f 100644 --- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro +++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro @@ -3,6 +3,21 @@ SOURCES += tst_qhelpenginecore.cpp CONFIG += help QT += sql -DEFINES += SRCDIR=\\\"$$PWD\\\" + DEFINES += QT_USE_USING_NAMESPACE !contains(QT_BUILD_PARTS, tools): DEFINES += QT_NO_BUILD_TOOLS + +wince*: { + DEFINES += SRCDIR=\\\"./\\\" + QT += network + addFiles.sources = $$PWD/data/*.* + addFiles.path = data + clucene.sources = $$QT_BUILD_TREE/lib/QtCLucene*.dll + + DEPLOYMENT += addFiles + DEPLOYMENT += clucene + + DEPLOYMENT_PLUGIN += qsqlite +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} -- cgit v0.12 From 9f13cde554e1a56fade3b9b298b264c54b1ef4b9 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 13 Aug 2009 16:20:27 +0200 Subject: Use the correct font for QLineEdit We don't get a FontChange event initially, so the control ended up with the default font instead. Reviewed-by: Andreas --- src/gui/widgets/qlineedit_p.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp index 5950d85..08fce9b 100644 --- a/src/gui/widgets/qlineedit_p.cpp +++ b/src/gui/widgets/qlineedit_p.cpp @@ -138,6 +138,7 @@ void QLineEditPrivate::init(const QString& txt) { Q_Q(QLineEdit); control = new QLineControl(txt); + control->setFont(q->font()); QObject::connect(control, SIGNAL(textChanged(const QString &)), q, SIGNAL(textChanged(const QString &))); QObject::connect(control, SIGNAL(textEdited(const QString &)), -- cgit v0.12 From e2bb75e66f7ef9dda6fae489ebbb30ffb5e9e37e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 13 Aug 2009 16:57:51 +0200 Subject: Fix coverity warnings for unreachable code, break missing and uninitialized members in constructors --- src/corelib/kernel/qvariant.cpp | 1 + src/gui/kernel/qkde.cpp | 2 -- src/gui/styles/qcommonstyle.cpp | 3 +-- src/gui/widgets/qmainwindow.cpp | 4 +--- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index dfed4db..b26cfdd 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -658,6 +658,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result, break; case QVariant::Url: *str = v_cast(d)->toString(); + break; default: return false; } diff --git a/src/gui/kernel/qkde.cpp b/src/gui/kernel/qkde.cpp index 23de838..98bf0a0 100644 --- a/src/gui/kernel/qkde.cpp +++ b/src/gui/kernel/qkde.cpp @@ -139,8 +139,6 @@ QString QKde::kdeStyle() return QLatin1String("plastique"); else return QLatin1String("windows"); - - return QString(); } /*!\internal diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index d4940d6..cce35b7 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -5196,8 +5196,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget ret = Qt::ToolButtonIconOnly; #ifdef Q_WS_X11 { - Q_D(const QCommonStyle); - static int buttonStyle = d->lookupToolButtonStyle(); + static int buttonStyle = d_func()->lookupToolButtonStyle(); return buttonStyle; } #endif diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 9243217..88059a0 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -73,7 +73,7 @@ class QMainWindowPrivate : public QWidgetPrivate Q_DECLARE_PUBLIC(QMainWindow) public: inline QMainWindowPrivate() - : layout(0), toolButtonStyle(Qt::ToolButtonIconOnly) + : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) #ifdef Q_WS_MAC , useHIToolBar(false) #endif @@ -107,8 +107,6 @@ void QMainWindowPrivate::init() layout = new QMainWindowLayout(q); const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); iconSize = QSize(metric, metric); - explicitIconSize = false; - q->setAttribute(Qt::WA_Hover); } -- cgit v0.12 From a2cc46c89e73d089f333423f8382eb7582699e39 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 12 Aug 2009 11:52:15 +0200 Subject: Internal doc: explain how QSharedPointer works --- src/corelib/tools/qsharedpointer.cpp | 266 ++++++++++++++++++++++++++++++++ src/corelib/tools/qsharedpointer_impl.h | 57 ++++--- 2 files changed, 305 insertions(+), 18 deletions(-) diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index e3e1db6..60c7db4 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -107,6 +107,249 @@ cases, since they have the same functionality. See \l{QWeakPointer#tracking-qobject} for more information. + \section1 Optional pointer tracking + + A feature of QSharedPointer that can be enabled at compile-time for + debugging purposes is a pointer tracking mechanism. When enabled, + QSharedPointer registers in a global set all the pointers that it tracks. + This allows one to catch mistakes like assigning the same pointer to two + QSharedPointer objects. + + This function is enabled by defining the \tt{QT_SHAREDPOINTER_TRACK_POINTERS} + macro before including the QSharedPointer header. + + It is safe to use this feature even with code compiled without the + feature. QSharedPointer will ensure that the pointer is removed from the + tracker even from code compiled without pointer tracking. + + Note, however, that the pointer tracking feature has limitations on + multiple- or virtual-inheritance (that is, in cases where two different + pointer addresses can refer to the same object). In that case, if a + pointer is cast to a different type and its value changes, + QSharedPointer's pointer tracking mechanism mail fail to detect that the + object being tracked is the same. + + \omit + \secton1 QSharedPointer internals + + QSharedPointer is in reality implemented by two ancestor classes: + QtSharedPointer::Basic and QtSharedPointer::ExternalRefCount. The reason + for having that split is now mostly legacy: in the beginning, + QSharedPointer was meant to support both internal reference counting and + external reference counting. + + QtSharedPointer::Basic implements the basic functionality that is shared + between internal- and external-reference counting. That is, it's mostly + the accessor functions into QSharedPointer. Those are all inherited by + QSharedPointer, which adds another level of shared functionality (the + constructors and assignment operators). The Basic class has one member + variable, which is the actual pointer being tracked. + + QtSharedPointer::ExternalRefCount implements the actual reference + counting and introduces the d-pointer for QSharedPointer. That d-pointer + itself is shared with with other QSharedPointer objects as well as + QWeakPointer. + + The reason for keeping the pointer value itself outside the d-pointer is + because of multiple inheritance needs. If you have two QSharedPointer + objects of different pointer types, but pointing to the same object in + memory, it could happen that the pointer values are different. The \tt + differentPointers autotest exemplifies this problem. The same thing could + happen in the case of virtual inheritance: a pointer of class matching + the virtual base has different address compared to the pointer of the + complete object. See the \tt virtualBaseDifferentPointers autotest for + this problem. + + The d pointer is of type QtSharedPointer::ExternalRefCountData for simple + QSharedPointer objects, but could be of a derived type in some cases. It + is basically a reference-counted reference-counter. + + \section2 d-pointer + \section3 QtSharedPointer::ExternalRefCountData + + This class is basically a reference-counted reference-counter. It has two + members: \tt strongref and \tt weakref. The strong reference counter is + controlling the lifetime of the object tracked by QSharedPointer. a + positive value indicates that the object is alive. It's also the number + of QSharedObject instances that are attached to this Data. + + When the strong reference count decreases to zero, the object is deleted + (see below for information on custom deleters). The strong reference + count can also exceptionally be -1, indicating that there are no + QSharedPointers attached to an object, which is tracked too. The only + case where this is possible is that of + \l{QWeakPointer#tracking-qobject}{QWeakPointers tracking a QObject}. + + The weak reference count controls the lifetime of the d-pointer itself. + It can be thought of as an internal/intrusive reference count for + ExternalRefCountData itself. This count is equal to the number of + QSharedPointers and QWeakPointers that are tracking this object. (In case + the object tracked derives from QObject, this number is increased by 1, + since QObjectPrivate tracks it too). + + ExternalRefCountData is a virtual class: it has a virtual destructor and + a virtual destroy() function. The destroy() function is supposed to + delete the object being tracked and return true if it does so. Otherwise, + it returns false to indicate that the caller must simply call delete. + This allows the normal use-case of QSharedPointer without custom deleters + to use only one 12- or 16-byte (depending on whether it's a 32- or 64-bit + architecture) external descriptor structure, without paying the price for + the custom deleter that it isn't using. + + \section3 QtSharedPointer::ExternalRefCountDataWithDestroyFn + + This class is not used directly, per se. It only exists to enable the two + classes that derive from it. It adds one member variable, which is a + pointer to a function (which returns void and takes an + ExternalRefCountData* as a parameter). It also overrides the destroy() + function: it calls that function pointer with \tt this as parameter, and + returns true. + + That means when ExternalRefCountDataWithDestroyFn is used, the \tt + destroyer field must be set to a valid function that \b will delete the + object tracked. + + This class also adds an operator delete function to ensure that simply + calls the global operator delete. That should be the behaviour in all + compilers already, but to be on the safe side, this class ensures that no + funny business happens. + + On a 32-bit architecture, this class is 16 bytes in size, whereas it's 24 + bytes on 64-bit. (On Itanium where function pointers contain the global + pointer, it can be 32 bytes). + + \section3 QtSharedPointer::ExternalRefCountWithCustomDeleter + + This class derives from ExternalRefCountDataWithDestroyFn and is a + template class. As template parameters, it has the type of the pointer + being tracked (\tt T) and a \tt Deleter, which is anything. It adds two + fields to its parent class, matching those template parameters: a member + of type \tt Deleter and a member of type \tt T*. + + The purpose of this class is to store the pointer to be deleted and the + deleter code along with the d-pointer. This allows the last strong + reference to call any arbitrary function that disposes of the object. For + example, this allows calling QObject::deleteLater() on a given object. + The pointer to the object is kept here to avoid the extra cost of keeping + the deleter in the generic case. + + This class is never instantiated directly: the constructors and + destructor are private. Only the create() function may be called to + return an object of this type. See below for construction details. + + The size of this class depends on the size of \tt Deleter. If it's an + empty functor (i.e., no members), ABIs generally assign it the size of 1. + But given that it's followed by a pointer, up to 3 or 7 padding bytes may + be inserted: in that case, the size of this class is 16+4+4 = 24 bytes on + 32-bit architectures, or 24+8+8 = 40 bytes on 64-bit architectures (48 + bytes on Itanium with global pointers stored). If \tt Deleter is a + function pointer, the size should be the same as the empty structure + case, except for Itanium where it may be 56 bytes due to another global + pointer. If \tt Deleter is a pointer to a member function (PMF), the size + will be even bigger and will depend on the ABI. For architectures using + the Itanium C++ ABI, a PMF is twice the size of a normal pointer, or 24 + bytes on Itanium itself. In that case, the size of this structure will be + 16+8+4 = 28 bytes on 32-bit architectures, 24+16+8 = 48 bytes on 64-bit, + and 32+24+8 = 64 bytes on Itanium. + + (Values for Itanium consider an LP64 architecture; for ILP32, pointers + are 32-bit in length, function pointers are 64-bit and PMF are 96-bit, so + the sizes are slightly less) + + \section3 QtSharedPointer::ExternalRefCountWithContiguousData + + This class also derives from ExternalRefCountDataWithDestroyFn and it is + also a template class. The template parameter is the type \tt T of the + class which QSharedPointer tracks. It adds only one member to its parent, + which is of type \tt T (the actual type, not a pointer to it). + + The purpose of this class is to lay the \tt T object out next to the + reference counts, saving one memory allocation per shared pointer. This + is particularly interesting for small \tt T or for the cases when there + are few if any QWeakPointer tracking the object. This class exists to + implement the QSharedPointer::create() call. + + Like ExternalRefCountWithCustomDeleter, this class is never instantiated + directly. This class also provides a create() member that returns the + pointer, and hides its constructors and destructor. (With C++0x, we'd + delete them). + + The size of this class depends on the size of \tt T. + + \section3 Instantiating ExternalRefCountWithCustomDeleter and ExternalRefCountWithContiguousData + + Like explained above, these classes have private constructors. Moreover, + they are not defined anywhere, so trying to call \tt{new ClassType} would + result in a compilation or linker error. Instead, these classes must be + constructed via their create() methods. + + Instead of instantiating the class by the normal way, the create() method + calls \tt{operator new} directly with the size of the class, then calls + the parent class's constructor only (ExternalRefCountDataWithDestroyFn). + This ensures that the inherited members are initialised properly, as well + as the virtual table pointer, which must point to + ExternalRefCountDataWithDestroyFn's virtual table. That way, we also + ensure that the virtual destructor being called is + ExternalRefCountDataWithDestroyFn's. + + After initialising the base class, the + ExternalRefCountWithCustomDeleter::create() function initialises the new + members directly, by using the placement \tt{operator new}. In the case + of the ExternalRefCountWithContiguousData::create() function, the address + to the still-uninitialised \tt T member is saved for the callee to use. + The member is only initialised in QSharedPointer::create(), so that we + avoid having many variants of the internal functions according to the + arguments in use for calling the constructor. + + When initialising the parent class, the create() functions pass the + address of the static deleter() member function. That is, when the + virtual destroy() is called by QSharedPointer, the deleter() functions + are called instead. These functiosn static_cast the ExternalRefCountData* + parameter to their own type and execute their deletion: for the + ExternalRefCountWithCustomDeleter::deleter() case, it runs the user's + custom deleter, then destroys the deleter; for + ExternalRefCountWithContiguousData::deleter, it simply calls the \tt T + destructor directly. + + By not calling the constructor of the derived classes, we avoid + instantiating their virtual tables. Since these classes are + template-based, there would be one virtual table per \tt T and \tt + Deleter type. (This is what Qt 4.5 did) + + Instead, only one non-inline function is required per template, which is + the deleter() static member. All the other functions can be inlined. + What's more, the address of deleter() is calculated only in code, which + can be resolved at link-time if the linker can determine that the + function lies in the current application or library module (since these + classes are not exported, that is the case for Windows or for builds with + \tt{-fvisibility=hidden}). + + In contrast, a virtual table would require at least 3 relocations to be + resolved at module load-time, per module where these classes are used. + (In the Itanium C++ ABI, there would be more relocations, due to the + RTTI) + + \section3 Modifications due to pointer-tracking + + To ensure that pointers created with pointer-tracking enabled get + un-tracked when destroyed, even if destroyed by code compiled without the + feature, QSharedPointer modifies slightly the instructions of the + previous sections. + + When ExternalRefCountWithCustomDeleter or + ExternalRefCountWithContiguousData are used, their create() functions + will set the ExternalRefCountDataWithDestroyFn::destroyer function + pointer to safetyCheckDeleter() instead. These static member functions + simply call internalSafetyCheckRemove2() before passing control to the + normal deleter() function. + + If neither custom deleter nor QSharedPointer::create() are used, then + QSharedPointer uses a custom deleter of its own: the normalDeleter() + function, which simply calls \tt delete. By using a custom deleter, the + safetyCheckDeleter() procedure described above kicks in. + + \endomit + \sa QSharedDataPointer, QWeakPointer */ @@ -182,6 +425,29 @@ QWeakPointers created from QObject should never be passed to code that hasn't been recompiled. + \omit + \secton1 QWeakPointer internals + + QWeakPointer shares most of its internal functionality with + \l{QSharedPointer#qsharedpointer-internals}{QSharedPointer}, so see that + class's internal documentation for more information. + + QWeakPointer requires an external reference counter in order to operate. + Therefore, it is incompatible by design with \l QSharedData-derived + classes. + + It has a special QObject constructor, which works by calling + QtSharedPointer::ExternalRefCountData::getAndRef, which retrieves the + d-pointer from QObjectPrivate. If one isn't set yet, that function + creates the d-pointer and atomically sets it. + + If getAndRef needs to create a d-pointer, it sets the strongref to -1, + indicating that the QObject is not shared: QWeakPointer is used only to + determine whether the QObject has been deleted. In that case, it cannot + be upgraded to QSharedPointer (see the previous section). + + \endomit + \sa QSharedPointer */ diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index ba479f9..cbeb79f 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -115,6 +115,9 @@ namespace QtSharedPointer { template struct RemovePointer > { typedef T Type; }; template struct RemovePointer > { typedef T Type; }; + // This class provides the basic functionality of a pointer wrapper. + // Its existence is mostly legacy, since originally QSharedPointer + // could also be used for internally-refcounted objects. template class Basic { @@ -155,6 +158,12 @@ namespace QtSharedPointer { Type *value; }; + // This class is the d-pointer of QSharedPointer and QWeakPointer. + // + // It is a reference-counted reference counter. "strongref" is the inner + // reference counter, and it tracks the lifetime of the pointer itself. + // "weakref" is the outer reference counter and it tracks the lifetime of + // the ExternalRefCountData object. struct ExternalRefCountData { QBasicAtomicInt weakref; @@ -168,6 +177,9 @@ namespace QtSharedPointer { inline ExternalRefCountData(Qt::Initialization) { } virtual inline ~ExternalRefCountData() { Q_ASSERT(!weakref); Q_ASSERT(strongref <= 0); } + // overridden by derived classes + // returns false to indicate caller should delete the pointer + // returns true in case it has already done so virtual inline bool destroy() { return false; } #ifndef QT_NO_QOBJECT @@ -178,18 +190,8 @@ namespace QtSharedPointer { }; // sizeof(ExternalRefCount) = 12 (32-bit) / 16 (64-bit) - template - struct CustomDeleter - { - Deleter deleter; - T *ptr; - - inline CustomDeleter(T *p, Deleter d) : deleter(d), ptr(p) {} - }; - // sizeof(CustomDeleter) = sizeof(Deleter) + sizeof(void*) - // for Deleter = function pointer: 8 (32-bit) / 16 (64-bit) - // for Deleter = PMF: 12 (32-bit) / 24 (64-bit) (GCC) - + // This class extends ExternalRefCountData with a pointer + // to a function, which is called by the destroy() function. struct ExternalRefCountWithDestroyFn: public ExternalRefCountData { typedef void (*DestroyerFn)(ExternalRefCountData *); @@ -204,13 +206,26 @@ namespace QtSharedPointer { }; // sizeof(ExternalRefCountWithDestroyFn) = 16 (32-bit) / 24 (64-bit) + // This class extends ExternalRefCountWithDestroyFn and implements + // the static function that deletes the object. The pointer and the + // custom deleter are kept in the "extra" member. template struct ExternalRefCountWithCustomDeleter: public ExternalRefCountWithDestroyFn { typedef ExternalRefCountWithCustomDeleter Self; - typedef ExternalRefCountWithDestroyFn Parent; - typedef CustomDeleter Next; - Next extra; + typedef ExternalRefCountWithDestroyFn BaseClass; + + struct CustomDeleter + { + Deleter deleter; + T *ptr; + + inline CustomDeleter(T *p, Deleter d) : deleter(d), ptr(p) {} + }; + CustomDeleter extra; + // sizeof(CustomDeleter) = sizeof(Deleter) + sizeof(void*) + // for Deleter = function pointer: 8 (32-bit) / 16 (64-bit) + // for Deleter = PMF: 12 (32-bit) / 24 (64-bit) (GCC) static inline void deleter(ExternalRefCountData *self) { @@ -218,7 +233,7 @@ namespace QtSharedPointer { executeDeleter(realself->extra.ptr, realself->extra.deleter); // delete the deleter too - realself->extra.~Next(); + realself->extra.~CustomDeleter(); } static void safetyCheckDeleter(ExternalRefCountData *self) { @@ -236,8 +251,8 @@ namespace QtSharedPointer { Self *d = static_cast(::operator new(sizeof(Self))); // initialize the two sub-objects - new (&d->extra) Next(ptr, userDeleter); - new (d) Parent(destroy); // can't throw + new (&d->extra) CustomDeleter(ptr, userDeleter); + new (d) BaseClass(destroy); // can't throw return d; } @@ -247,6 +262,10 @@ namespace QtSharedPointer { ~ExternalRefCountWithCustomDeleter(); }; + // This class extends ExternalRefCountWithDestroyFn and adds a "T" + // member. That way, when the create() function is called, we allocate + // memory for both QSharedPointer's d-pointer and the actual object being + // tracked. template struct ExternalRefCountWithContiguousData: public ExternalRefCountWithDestroyFn { @@ -289,6 +308,8 @@ namespace QtSharedPointer { ~ExternalRefCountWithContiguousData(); }; + // This is the main body of QSharedPointer. It implements the + // external reference counting functionality. template class ExternalRefCount: public Basic { -- cgit v0.12 From 07fcb3b032526e76086d7f75dad01b867233b5d5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 13 Aug 2009 14:59:40 +0200 Subject: Add QIntegerForSize<1> and QIntegerForSize<2>. Undocumented, but maybe they're useful somewhere. It doesn't hurt to add them. --- src/corelib/global/qglobal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 7076a1e..5a2c329 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -848,6 +848,8 @@ typedef quint64 qulonglong; && sizeof(void *) == sizeof(qptrdiff) */ template struct QIntegerForSize; +template <> struct QIntegerForSize<1> { typedef quint8 Unsigned; typedef qint8 Signed; }; +template <> struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; }; template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; }; template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; }; template struct QIntegerForSizeof: QIntegerForSize { }; -- cgit v0.12 From 942abf1a3ba60a60207a213dbeb383904f97e47d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 13 Aug 2009 17:30:02 +0200 Subject: fixing return values _wchmod on Windows CE _wchmod returns 0 on success and -1 on error. Our Windows CE implementation did it wrong. Thanks to Konstantin Ritt for spotting this! Reviewed-by: mauricek --- src/corelib/io/qfsfileengine_win.cpp | 2 +- src/corelib/kernel/qfunctions_wince.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 3394a00..ba93a94 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1706,7 +1706,7 @@ bool QFSFileEngine::setPermissions(uint perms) #if !defined(Q_OS_WINCE) ret = ::_wchmod((wchar_t*)d->filePath.utf16(), mode) == 0; #else - ret = ::_wchmod((wchar_t*)d->longFileName(d->filePath).utf16(), mode); + ret = ::_wchmod((wchar_t*)d->longFileName(d->filePath).utf16(), mode) == 0; #endif return ret; } diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp index 2b5d4fe..77f680a 100644 --- a/src/corelib/kernel/qfunctions_wince.cpp +++ b/src/corelib/kernel/qfunctions_wince.cpp @@ -292,13 +292,14 @@ bool qt_wince__chmod(const char *file, int mode) bool qt_wince__wchmod(const wchar_t *file, int mode) { + BOOL success = FALSE; // ### Does not work properly, what about just adding one property? if(mode&_S_IWRITE) { - return SetFileAttributes(file, FILE_ATTRIBUTE_NORMAL); + success = SetFileAttributes(file, FILE_ATTRIBUTE_NORMAL); } else if((mode&_S_IREAD) && !(mode&_S_IWRITE)) { - return SetFileAttributes(file, FILE_ATTRIBUTE_READONLY); + success = SetFileAttributes(file, FILE_ATTRIBUTE_READONLY); } - return false; + return success ? 0 : -1; } HANDLE qt_wince_CreateFileA(LPCSTR filename, DWORD access, DWORD share, LPSECURITY_ATTRIBUTES attr, DWORD dispo, DWORD flags, HANDLE tempFile) -- cgit v0.12 From f82a226607b079b360c88afbe0423d990071b0ba Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 13 Aug 2009 17:37:05 +0200 Subject: Fix coverity warnings --- src/gui/itemviews/qabstractitemview.cpp | 1 + src/gui/itemviews/qlistview.cpp | 3 ++- src/gui/itemviews/qtreeview.cpp