diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-05-17 06:24:00 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-05-17 06:24:00 (GMT) |
commit | 21b388616a0daf06d27d1e1d471e8423fff44f50 (patch) | |
tree | 080641177a6dab05b021bcc4e75e97fc6cc52e3d | |
parent | 58c08b1195add26e2ff96844885ea9d6c124da30 (diff) | |
parent | f60eeb5c165d5b9e5998edae7785cc893a613bca (diff) | |
download | Qt-21b388616a0daf06d27d1e1d471e8423fff44f50.zip Qt-21b388616a0daf06d27d1e1d471e8423fff44f50.tar.gz Qt-21b388616a0daf06d27d1e1d471e8423fff44f50.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
100 files changed, 2482 insertions, 958 deletions
diff --git a/dist/changes-4.7.0 b/dist/changes-4.7.0 index 6bf7ea5..1e3a69c 100644 --- a/dist/changes-4.7.0 +++ b/dist/changes-4.7.0 @@ -33,7 +33,6 @@ New features - QNetworkSession, QNetworkConfiguration, QNetworkConfigurationManager * New bearer management classes added. - Third party components ---------------------- @@ -68,6 +67,9 @@ QtGui functions, and replaced them with setCopyCount(), copyCount() and supportsMultipleCopies(). + - QPrintDialog/QPrinter + * Added support for printing the current page. + - QCommonStyle * Fixed a bug that led to missing text pixels in QTabBar when using small font sizes. (QTBUG-7137) @@ -76,12 +78,30 @@ QtGui * Fixed rendering bugs when scrolling graphics items with drop shadows. + - QGraphicsItem + * [QTBUG-8112] itemChange() is now called when transformation + properties change (setRotation, setScale, setTransformOriginPoint). + + - QGraphicsTextItem + * [QTBUG-7333] Fixed keyboard shortcuts not being triggered when the + the item has focus and something else has the same shortcut sequence. + + - QGraphicsView + * [QTBUG-7438] Fixed viewport cursor getting reset when releasing + the mouse. + - QImage - * [QTBUG-9640] Prevented unneccessary copy in - QImage::setAlphaChannel(). - * Added QImage::bitPlaneCount(). (QTBUG-7982) + * [QTBUG-9640] Prevented unneccessary copy in QImage::setAlphaChannel(). + * [QTBUG-7982] Added QImage::bitPlaneCount(). + + - QPicture + * [QTBUG-4974] Printing QPictures containing text to a high resolution + QPrinter would in many cases cause incorrect character spacing. - QPainter + * Added QPainter::drawPixmapFragments(), which makes it possible to draw + pixmaps, or sub-rectangles of pixmaps, at various positions with + different scale, opacity and rotation. * [QTBUG-10018] Fixed image drawing inconsistencies when drawing 1x1 source rects with rotating / shear / perspective transforms. * Optimized various blending and rendering operations for ARM diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index e5c1d32..e2b8bb6 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -291,28 +291,7 @@ print the name of the current list item. \table \row -\o \code -Rectangle { - color: "lightsteelblue"; width: 240; height: 320 - - ListView { - id: myView; anchors.fill: parent; focus: true - model: ListModel { - ListElement { name: "Bob" } - ListElement { name: "John" } - ListElement { name: "Michael" } - } - delegate: FocusScope { - width: contents.width; height: contents.height - Text { - focus: true - text: name - Keys.onReturnPressed: console.log(name) - } - } - } -} -\endcode +\o \snippet doc/src/snippets/declarative/focusscopes.qml 0 \o \image declarative-qmlfocus4.png \endtable diff --git a/doc/src/development/developing-on-mac.qdoc b/doc/src/development/developing-on-mac.qdoc index 785858f..0c0af79 100644 --- a/doc/src/development/developing-on-mac.qdoc +++ b/doc/src/development/developing-on-mac.qdoc @@ -41,9 +41,8 @@ /*! \page developing-on-mac.html - \title Developing Qt Applications on Mac OS X - \brief A overview of items to be aware of when developing Qt applications - on Mac OS X + \title Developing Qt Applications for Mac OS X + \brief Information for developing Qt applications for Mac OS X \ingroup platform-specific \tableofcontents diff --git a/doc/src/frameworks-technologies/accessible.qdoc b/doc/src/frameworks-technologies/accessible.qdoc index 35f1c75..0aff214 100644 --- a/doc/src/frameworks-technologies/accessible.qdoc +++ b/doc/src/frameworks-technologies/accessible.qdoc @@ -47,7 +47,10 @@ /*! \page accessible.html \title Accessibility + \brief How to make your applications accessible to those with disabilities. + \ingroup technology-apis + \ingroup best-practices \tableofcontents diff --git a/doc/src/frameworks-technologies/dbus-adaptors.qdoc b/doc/src/frameworks-technologies/dbus-adaptors.qdoc index 11c5998..3dd0e4d 100644 --- a/doc/src/frameworks-technologies/dbus-adaptors.qdoc +++ b/doc/src/frameworks-technologies/dbus-adaptors.qdoc @@ -42,8 +42,9 @@ /*! \page usingadaptors.html \title Using QtDBus Adaptors - \ingroup technology-apis + \brief How to create and use DBus adaptors in Qt. + \ingroup technology-apis \ingroup best-practices Adaptors are special classes that are attached to any QObject-derived class diff --git a/doc/src/frameworks-technologies/phonon.qdoc b/doc/src/frameworks-technologies/phonon.qdoc index 61d7926..61b906e 100644 --- a/doc/src/frameworks-technologies/phonon.qdoc +++ b/doc/src/frameworks-technologies/phonon.qdoc @@ -42,7 +42,9 @@ /*! \page phonon-overview.html \title Phonon multimedia framework + \brief Using the Phonon multimedia framework in Qt. \ingroup technology-apis + \ingroup best-practices \tableofcontents diff --git a/doc/src/getting-started/known-issues.qdoc b/doc/src/getting-started/known-issues.qdoc index b73e15d..cedebf9 100644 --- a/doc/src/getting-started/known-issues.qdoc +++ b/doc/src/getting-started/known-issues.qdoc @@ -41,15 +41,15 @@ /*! \page known-issues.html - \title Known Issues in %VERSION% + \title Known Issues in this Qt Version \ingroup platform-specific - \brief A summary of known issues in Qt %VERSION% at the time of release. + \brief A summary of known issues in this Qt version at the time of release. - An up-to-date list of known issues with Qt %VERSION% can be found via the + An up-to-date list of known issues can be found at \l{http://bugreports.qt.nokia.com/}{Qt Bug Tracker}. - For a list list of known bugs in Qt %VERSION%, see the \l{Task Tracker} - on the Qt website. + For a list list of known bugs, see the \l{Task Tracker} at the Qt + website. An overview of known issues may also be found at: \l{http://qt.gitorious.org/qt/pages/QtKnownIssues} diff --git a/doc/src/howtos/HWacceleration.qdoc b/doc/src/howtos/HWacceleration.qdoc index fbc657c..c7b1a72 100644 --- a/doc/src/howtos/HWacceleration.qdoc +++ b/doc/src/howtos/HWacceleration.qdoc @@ -41,17 +41,20 @@ /*! \page HWAcc_rendering.html - \title Using hardware acceleration on embedded platforms. + \title Hardware Acceleration & Embedded Platforms. + \brief How to use hardware acceleration for fast rendering. \ingroup best-practices \section1 Abstract + This document describes how to use hardware acceleration for fast - rendering on embedded platforms supported by Qt. In short, it explains - how the graphics pipeline works. Since there might be differences to - how the APIs are being used on different embedded platforms, a table - links to documentation dedicated to platform specific documentation - for each supported hardware acceleration API. + rendering on embedded platforms supported by Qt. In short, it + explains how the graphics pipeline works. Since there might be + differences to how the APIs are being used on different embedded + platforms, a table links to documentation dedicated to platform + specific documentation for each supported hardware acceleration + API. \input platforms/emb-hardwareacceleration.qdocinc diff --git a/doc/src/howtos/accelerators.qdoc b/doc/src/howtos/accelerators.qdoc index 65f1def..b6ef5c2 100644 --- a/doc/src/howtos/accelerators.qdoc +++ b/doc/src/howtos/accelerators.qdoc @@ -42,6 +42,7 @@ /*! \page accelerators.html \title Standard Accelerator Keys + \brief Recommended accelerator keys. \ingroup best-practices diff --git a/doc/src/howtos/appicon.qdoc b/doc/src/howtos/appicon.qdoc index dd39509..9377961 100644 --- a/doc/src/howtos/appicon.qdoc +++ b/doc/src/howtos/appicon.qdoc @@ -42,6 +42,7 @@ /*! \page appicon.html \title Setting the Application Icon + \brief How to set your application's icon. \ingroup best-practices diff --git a/doc/src/howtos/guibooks.qdoc b/doc/src/howtos/guibooks.qdoc index 1a70670..bccfbe6 100644 --- a/doc/src/howtos/guibooks.qdoc +++ b/doc/src/howtos/guibooks.qdoc @@ -43,6 +43,7 @@ \page guibooks.html \title Books about GUI Design \ingroup best-practices + \brief Some recommended books about GUI design. This is not a comprehensive list -- there are many other books worth buying. Here we mention just a few user interface books that don't diff --git a/doc/src/howtos/qtdesigner.qdoc b/doc/src/howtos/qtdesigner.qdoc index 2dd7fcf..92041f0 100644 --- a/doc/src/howtos/qtdesigner.qdoc +++ b/doc/src/howtos/qtdesigner.qdoc @@ -42,6 +42,7 @@ /*! \page qtdesigner-components.html \title Creating and Using Components for Qt Designer + \brief How to create and use custom widget plugins. \ingroup best-practices \tableofcontents diff --git a/doc/src/howtos/restoring-geometry.qdoc b/doc/src/howtos/restoring-geometry.qdoc index 36c5e4f..e72b993 100644 --- a/doc/src/howtos/restoring-geometry.qdoc +++ b/doc/src/howtos/restoring-geometry.qdoc @@ -42,7 +42,7 @@ /*! \page restoring-geometry.html \title Restoring a Window's Geometry - + \brief How to save & restore window geometry. \ingroup best-practices This document describes how to save and restore a \l{Window diff --git a/doc/src/howtos/session.qdoc b/doc/src/howtos/session.qdoc index e2e87a8..f53af04 100644 --- a/doc/src/howtos/session.qdoc +++ b/doc/src/howtos/session.qdoc @@ -42,7 +42,7 @@ /*! \page session.html \title Session Management - + \brief How to do session management with Qt. \ingroup best-practices A \e session is a group of running applications, each of which has a diff --git a/doc/src/howtos/sharedlibrary.qdoc b/doc/src/howtos/sharedlibrary.qdoc index 70fc4db..ed803ed 100644 --- a/doc/src/howtos/sharedlibrary.qdoc +++ b/doc/src/howtos/sharedlibrary.qdoc @@ -42,7 +42,7 @@ /*! \page sharedlibrary.html \title Creating Shared Libraries - + \brief How to create shared libraries. \ingroup best-practices The following sections list certain things that should be taken into diff --git a/doc/src/howtos/timers.qdoc b/doc/src/howtos/timers.qdoc index cfc2fb4..b001916 100644 --- a/doc/src/howtos/timers.qdoc +++ b/doc/src/howtos/timers.qdoc @@ -42,7 +42,7 @@ /*! \page timers.html \title Timers - \brief How to use timers in your application. + \brief How to use Qt timers in your application. \ingroup best-practices diff --git a/doc/src/overviews.qdoc b/doc/src/overviews.qdoc index 0b82388..c3c59af 100644 --- a/doc/src/overviews.qdoc +++ b/doc/src/overviews.qdoc @@ -117,13 +117,28 @@ */ /*! + \group qt-sql + \title Using SQL in Qt + \brief Qt API's for using SQL. + \ingroup technology-apis + \ingroup best-practices + + These pages document Qt's API's for using SQL database systems + in Qt applications. + + \generatelist{related} +*/ + +/*! \group best-practices \title How-To's and Best Practices \brief How-To Guides and Best Practices - These documents provide guidelines and best practices explaining - how to use Qt to solve specific technical problems. + These documents provide guidelines and best practices for using Qt + to solve specific technical problems. They are listed + alphabetically by the first word in the title, so scan the entire + list to find what you want. \generatelist{related} */ diff --git a/doc/src/platforms/platform-notes.qdoc b/doc/src/platforms/platform-notes.qdoc index 8f5b6a5..16e0c0f 100644 --- a/doc/src/platforms/platform-notes.qdoc +++ b/doc/src/platforms/platform-notes.qdoc @@ -517,7 +517,7 @@ Note that some modules rely on other modules. If your application uses QtXmlPatterns, QtWebkit or QtScript it may still require \c NetworkServices - \o as these modules rely on QtNetwork to go online. + as these modules rely on QtNetwork to go online. For more information see the documentation of the individual Qt classes. If a class does not mention Symbian capabilities, it requires none. diff --git a/doc/src/snippets/declarative/focusscopes.qml b/doc/src/snippets/declarative/focusscopes.qml new file mode 100644 index 0000000..686de29 --- /dev/null +++ b/doc/src/snippets/declarative/focusscopes.qml @@ -0,0 +1,27 @@ +import Qt 4.7 + +//![0] +Rectangle { + color: "lightsteelblue"; width: 240; height: 320 + + ListView { + anchors.fill: parent + focus: true + + model: ListModel { + ListElement { name: "Bob" } + ListElement { name: "John" } + ListElement { name: "Michael" } + } + + delegate: FocusScope { + width: childrenRect.width; height: childrenRect.height + TextInput { + focus: true + text: name + Keys.onReturnPressed: console.log(name) + } + } + } + } +//![0] diff --git a/doc/src/sql-programming/qsqldatatype-table.qdoc b/doc/src/sql-programming/qsqldatatype-table.qdoc index fc961f5..fb5fb49 100644 --- a/doc/src/sql-programming/qsqldatatype-table.qdoc +++ b/doc/src/sql-programming/qsqldatatype-table.qdoc @@ -41,19 +41,20 @@ /*! \page sql-types.html - \title Recommended Use of Data Types in Databases + \title Data Types for Qt-supported Database Systems + \brief Recommended data types for database systems - \ingroup best-practices + \ingroup qt-sql - \section1 Recommended Use of Types in Qt Supported Databases + \section1 Data Types for Qt Supported Database Systems - This table shows the recommended data types used when extracting data - from the databases supported in Qt. It is important to note that the - types used in Qt are not necessarily valid as input to the specific - database. One example could be that a double would work perfectly as - input for floating point records in a database, but not necessarily - as a storage format for output from the database since it would be stored - with 64-bit precision in C++. + This table shows the recommended data types for extracting data from + the databases supported in Qt. Note that types used in Qt are not + necessarily valid as input types to a specific database + system. e.g., A double might work perfectly as input for floating + point records in a particular database, but not necessarily as a + storage format for output from that database, because it would be + stored with 64-bit precision in C++. \tableofcontents diff --git a/doc/src/sql-programming/sql-driver.qdoc b/doc/src/sql-programming/sql-driver.qdoc index 6bccd83..f0e4e52 100644 --- a/doc/src/sql-programming/sql-driver.qdoc +++ b/doc/src/sql-programming/sql-driver.qdoc @@ -44,7 +44,7 @@ \title SQL Database Drivers \brief How to configure and install QtSql drivers for supported databases. - \ingroup best-practices + \ingroup qt-sql The QtSql module uses driver \l{How to Create Qt Plugins}{plugins} to communicate with the different database diff --git a/doc/src/sql-programming/sql-programming.qdoc b/doc/src/sql-programming/sql-programming.qdoc index f1f3e5e..b34810c 100644 --- a/doc/src/sql-programming/sql-programming.qdoc +++ b/doc/src/sql-programming/sql-programming.qdoc @@ -49,6 +49,7 @@ /*! \page sql-programming.html \title SQL Programming + \ingroup qt-sql \nextpage Connecting to Databases \brief Database integration for Qt applications. @@ -118,6 +119,7 @@ /*! \page sql-connecting.html \title Connecting to Databases + \ingroup qt-sql \contentspage SQL Programming \previouspage SQL Programming @@ -187,6 +189,7 @@ /*! \page sql-sqlstatements.html \title Executing SQL Statements + \ingroup qt-sql \previouspage Connecting to Databases \contentspage SQL Programming @@ -337,6 +340,7 @@ /*! \page sql-model.html \title Using the SQL Model Classes + \ingroup qt-sql \previouspage Executing SQL Statements \contentspage SQL Programming @@ -483,6 +487,7 @@ /*! \page sql-presenting.html \title Presenting Data in a Table View + \ingroup qt-sql \previouspage Using the SQL Model Classes \contentspage SQL Programming @@ -587,6 +592,7 @@ /*! \page sql-forms.html \title Creating Data-Aware Forms + \ingroup qt-sql \previouspage Presenting Data in a Table View \contentspage SQL Programming diff --git a/doc/src/widgets-and-layouts/styles.qdoc b/doc/src/widgets-and-layouts/styles.qdoc index b4bec8c..31dfe40 100644 --- a/doc/src/widgets-and-layouts/styles.qdoc +++ b/doc/src/widgets-and-layouts/styles.qdoc @@ -47,15 +47,9 @@ /*! \page style-reference.html - \title Implementing Styles and Style Aware Widgets + \title Styles and Style Aware Widgets \ingroup qt-gui-concepts - \brief An overview of styles and the styling of widgets. - - \ingroup frameworks-technologies - - \previouspage Widget Classes - \contentspage Widgets and Layouts - \nextpage {Qt Style Sheets}{Style sheets} + \brief Styles and the styling of widgets. Styles (classes that inherit QStyle) draw on behalf of widgets and encapsulate the look and feel of a GUI. The QStyle class is @@ -91,8 +85,6 @@ current style. This document shows how widgets draw themselves and which possibilities the style gives them. - \tableofcontents - \section1 Classes for Widget Styling These classes are used to customize an application's appearance and diff --git a/doc/src/widgets-and-layouts/widgets.qdoc b/doc/src/widgets-and-layouts/widgets.qdoc index ac0bf77..9fe2d69 100644 --- a/doc/src/widgets-and-layouts/widgets.qdoc +++ b/doc/src/widgets-and-layouts/widgets.qdoc @@ -40,131 +40,121 @@ ****************************************************************************/ /*! - \page widgets-and-layouts.html - \title Widgets and Layouts - \ingroup qt-gui-concepts - - \ingroup frameworks-technologies - - \nextpage Widget Classes - - The primary elements for designing user interfaces in Qt are widgets and layouts. - - \section1 Widgets - - \l{Widget Classes}{Widgets} can display data and status information, receive - user input, and provide a container for other widgets that should be grouped - together. A widget that is not embedded in a parent widget is called a - \l{Application Windows and Dialogs}{window}. - - \image parent-child-widgets.png A parent widget containing various child widgets. - - The QWidget class provides the basic capability to render to the screen, and to - handle user input events. All UI elements that Qt provides are either subclasses - of QWidget, or are used in connection with a QWidget subclass. Creating custom - widgets is done by subclassing QWidget or a suitable subclass and reimplementing - the virtual event handlers. - - \section1 Layouts - - \l{Layout Management}{Layouts} are an elegant and flexible way to automatically - arrange child widgets within their container. Each widget reports its size requirements - to the layout through the \l{QWidget::}{sizeHint} and \l{QWidget::}{sizePolicy} - properties, and the layout distributes the available space accordingly. - - \table - \row - \o \image qgridlayout-with-5-children.png - \o \image qformlayout-with-6-children.png - \endtable - - \l{Qt Designer Manual}{\QD} is a powerful tool for interactively creating and - arranging widgets in layouts. - - \section1 Widget Styles - - \l{Implementing Styles and Style Aware Widgets}{Styles} draw on behalf of widgets - and encapsulate the look and feel of a GUI. Qt's built-in widgets use the QStyle - class to perform nearly all of their drawing, ensuring that they look exactly like - the equivalent native widgets. + \page widgets-and-layouts.html + \title Widgets and Layouts + \ingroup qt-gui-concepts + \brief The primary elements for designing user interfaces in Qt. + + \section1 Widgets + + Widgets are the primary elements for creating user interfaces in Qt. + \l{Widget Classes}{Widgets} can display data and status information, + receive user input, and provide a container for other widgets that + should be grouped together. A widget that is not embedded in a + parent widget is called a \l{Application Windows and + Dialogs}{window}. + + \image parent-child-widgets.png A parent widget containing various child widgets. + + The QWidget class provides the basic capability to render to the + screen, and to handle user input events. All UI elements that Qt + provides are either subclasses of QWidget, or are used in connection + with a QWidget subclass. Creating custom widgets is done by + subclassing QWidget or a suitable subclass and reimplementing the + virtual event handlers. + + \section1 Layouts + + \l{Layout Management}{Layouts} are an elegant and flexible way to + automatically arrange child widgets within their container. Each + widget reports its size requirements to the layout through the + \l{QWidget::}{sizeHint} and \l{QWidget::}{sizePolicy} properties, + and the layout distributes the available space accordingly. + + \table + \row + \o \image qgridlayout-with-5-children.png + \o \image qformlayout-with-6-children.png + \endtable + + \l{Qt Designer Manual}{\QD} is a powerful tool for interactively creating and + arranging widgets in layouts. + + \section1 Widget Styles + + \l{Implementing Styles and Style Aware Widgets}{Styles} draw on + behalf of widgets and encapsulate the look and feel of a GUI. Qt's + built-in widgets use the QStyle class to perform nearly all of their + drawing, ensuring that they look exactly like the equivalent native + widgets. - \table - \row - \o \image windowsxp-tabwidget.png - \o \image plastique-tabwidget.png - \o \image macintosh-tabwidget.png - \endtable - - \l{Qt Style Sheets} are a powerful mechanism that allows you to customize the - appearance of widgets, in addition to what is already possible by subclassing QStyle. -*/ - -/*! - \page widget-classes.html - \title Widget Classes + \table + \row + \o \image windowsxp-tabwidget.png + \o \image plastique-tabwidget.png + \o \image macintosh-tabwidget.png + \endtable - \contentspage Widgets and Layouts - \nextpage Layout Management + \l{Qt Style Sheets} are a powerful mechanism that allows you to customize the + appearance of widgets, in addition to what is already possible by subclassing QStyle. - Below you find a list of all widget classes in Qt. You can also browse the - widget classes Qt provides in the various supported styles in the - \l{Qt Widget Gallery}. + \section1 The Widget Classes - \tableofcontents + The following sections list the widget classes. See the \l{Qt Widget + Gallery} for some examples. - \section1 Basic Widgets + \section2 Basic Widgets - These basic widgets (controls), such as buttons, comboboxes and scroll bars, are - designed for direct use. + These basic widgets (controls), e.g. buttons, comboboxes and + scroll bars, are designed for direct use. - \table - \row - \o \image windows-label.png - \o \image windowsvista-pushbutton.png - \o \image gtk-progressbar.png - \row - \o \image plastique-combobox.png - \o \image macintosh-radiobutton.png - \o \image cde-lineedit.png - \endtable + \table + \row + \o \image windows-label.png + \o \image windowsvista-pushbutton.png + \o \image gtk-progressbar.png + \row + \o \image plastique-combobox.png + \o \image macintosh-radiobutton.png + \o \image cde-lineedit.png + \endtable - \annotatedlist basicwidgets + \annotatedlist basicwidgets - \section1 Advanced Widgets + \section2 Advanced Widgets - Advanced GUI widgets such as tab widgets and progress bars provide more - complex user interface controls. + Advanced GUI widgets, e.g. tab widgets and progress bars, provide + more complex user interface controls. - \table - \row - \o \image windowsxp-treeview.png - \o \image gtk-calendarwidget.png - \o \image qundoview.png - \endtable + \table + \row + \o \image windowsxp-treeview.png + \o \image gtk-calendarwidget.png + \o \image qundoview.png + \endtable - \annotatedlist advanced + \annotatedlist advanced - \table - \row - \o \image windowsvista-tabwidget.png - \o \image macintosh-groupbox.png - \endtable + \table + \row + \o \image windowsvista-tabwidget.png + \o \image macintosh-groupbox.png + \endtable - \section1 Organizer Widgets + \section2 Organizer Widgets - Classes like splitters, tab bars, button groups, etc are used to - organize and group GUI primitives into more complex applications or - dialogs. + Classes like splitters, tab bars, button groups, etc are used for + organizing and grouping GUI primitives into more complex + applications and dialogs. - \annotatedlist organizers + \annotatedlist organizers - \section1 Abstract Widget Classes + \section2 Abstract Widget Classes - Abstract widget classes usable through subclassing. They are generally - not usable in themselves, but provide functionality that can be used - by inheriting these classes. + The abstract widget classes are base classes. They are not usable as + standalone classes but provide functionality when they are subclassed. - \annotatedlist abstractwidgets + \annotatedlist abstractwidgets */ /*! diff --git a/doc/src/windows-and-dialogs/mainwindow.qdoc b/doc/src/windows-and-dialogs/mainwindow.qdoc index b282dab..c1e66d9 100644 --- a/doc/src/windows-and-dialogs/mainwindow.qdoc +++ b/doc/src/windows-and-dialogs/mainwindow.qdoc @@ -46,12 +46,11 @@ /*! \page application-windows.html - \title Application Windows and Dialogs + \title Window and Dialog Widgets + \brief Windows and Dialogs in Qt. \ingroup qt-gui-concepts \ingroup frameworks-technologies - \nextpage The Application Main Window - A \l{Widgets Tutorial}{widget} that is not embedded in a parent widget is called a window. Usually, windows have a frame and a title bar, although it is also possible to create windows without such decoration using suitable window flags). In Qt, QMainWindow @@ -165,12 +164,9 @@ /*! \page mainwindow.html - \title The Application Main Window - \brief Everything you need for a typical modern main application window, - including menus, toolbars, workspace, etc. - - \contentspage Application Windows and Dialogs - \nextpage Dialog Windows + \title Application Main Window + \ingroup qt-gui-concepts + \brief Creating the application window. \tableofcontents diff --git a/examples/declarative/toys/dial/content/Dial.qml b/examples/declarative/toys/dial/content/Dial.qml index f9ab3e3..6f24801 100644 --- a/examples/declarative/toys/dial/content/Dial.qml +++ b/examples/declarative/toys/dial/content/Dial.qml @@ -8,6 +8,7 @@ Item { Image { source: "background.png" } +//! [needle_shadow] Image { x: 93 y: 35 @@ -17,6 +18,8 @@ Item { angle: needleRotation.angle } } +//! [needle_shadow] +//! [needle] Image { id: needle x: 95; y: 33 @@ -33,5 +36,8 @@ Item { } } } +//! [needle] +//! [overlay] Image { x: 21; y: 18; source: "overlay.png" } +//! [overlay] } diff --git a/examples/declarative/toys/dial/dial-example.qml b/examples/declarative/toys/dial/dial-example.qml index 2e102b0..900954f 100644 --- a/examples/declarative/toys/dial/dial-example.qml +++ b/examples/declarative/toys/dial/dial-example.qml @@ -1,6 +1,7 @@ import Qt 4.7 import "content" +//! [0] Rectangle { color: "#545454" width: 300; height: 300 @@ -14,7 +15,10 @@ Rectangle { Rectangle { id: container - anchors { bottom: parent.bottom; left: parent.left; right: parent.right; leftMargin: 20; rightMargin: 20; bottomMargin: 10 } + anchors { bottom: parent.bottom; left: parent.left + right: parent.right; leftMargin: 20; rightMargin: 20 + bottomMargin: 10 + } height: 16 radius: 8 @@ -37,8 +41,10 @@ Rectangle { MouseArea { anchors.fill: parent - drag.target: parent; drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: container.width - 32 + drag.target: parent; drag.axis: Drag.XAxis + drag.minimumX: 2; drag.maximumX: container.width - 32 } } } } +//! [0]
\ No newline at end of file diff --git a/examples/graphicsview/padnavigator/form.ui b/examples/graphicsview/padnavigator/form.ui new file mode 100644 index 0000000..fc7d123 --- /dev/null +++ b/examples/graphicsview/padnavigator/form.ui @@ -0,0 +1,208 @@ +<ui version="4.0" > + <class>Form</class> + <widget class="QWidget" name="Form" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>378</width> + <height>385</height> + </rect> + </property> + <property name="windowTitle" > + <string>BackSide</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2" > + <item> + <widget class="QGroupBox" name="groupBox" > + <property name="title" > + <string>Settings</string> + </property> + <property name="flat" > + <bool>true</bool> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="label" > + <property name="text" > + <string>Title:</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="hostName" > + <property name="text" > + <string>Pad Navigator Example</string> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Modified:</string> + </property> + </widget> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="label_3" > + <property name="text" > + <string>Extent</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QSlider" name="horizontalSlider" > + <property name="value" > + <number>42</number> + </property> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox" > + <property name="value" > + <number>42</number> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="1" > + <widget class="QDateTimeEdit" name="dateTimeEdit" /> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_2" > + <property name="title" > + <string>Other input</string> + </property> + <property name="flat" > + <bool>true</bool> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2" > + <item> + <widget class="QTreeWidget" name="treeWidget" > + <column> + <property name="text" > + <string>Widgets On Graphics View</string> + </property> + </column> + <item> + <property name="text" > + <string>QGraphicsProxyWidget</string> + </property> + <item> + <property name="text" > + <string>QGraphicsWidget</string> + </property> + <item> + <property name="text" > + <string>QObject</string> + </property> + </item> + <item> + <property name="text" > + <string>QGraphicsItem</string> + </property> + </item> + <item> + <property name="text" > + <string>QGraphicsLayoutItem</string> + </property> + </item> + </item> + </item> + <item> + <property name="text" > + <string>QGraphicsGridLayout</string> + </property> + <item> + <property name="text" > + <string>QGraphicsLayout</string> + </property> + <item> + <property name="text" > + <string>QGraphicsLayoutItem</string> + </property> + </item> + </item> + </item> + <item> + <property name="text" > + <string>QGraphicsLinearLayout</string> + </property> + <item> + <property name="text" > + <string>QGraphicsLayout</string> + </property> + <item> + <property name="text" > + <string>QGraphicsLayoutItem</string> + </property> + </item> + </item> + </item> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>groupBox</tabstop> + <tabstop>hostName</tabstop> + <tabstop>dateTimeEdit</tabstop> + <tabstop>horizontalSlider</tabstop> + <tabstop>spinBox</tabstop> + <tabstop>groupBox_2</tabstop> + <tabstop>treeWidget</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>horizontalSlider</sender> + <signal>valueChanged(int)</signal> + <receiver>spinBox</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel" > + <x>184</x> + <y>125</y> + </hint> + <hint type="destinationlabel" > + <x>275</x> + <y>127</y> + </hint> + </hints> + </connection> + <connection> + <sender>spinBox</sender> + <signal>valueChanged(int)</signal> + <receiver>horizontalSlider</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel" > + <x>272</x> + <y>114</y> + </hint> + <hint type="destinationlabel" > + <x>190</x> + <y>126</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp index 4a6c6ff..0d98eff 100644 --- a/examples/network/bearermonitor/bearermonitor.cpp +++ b/examples/network/bearermonitor/bearermonitor.cpp @@ -255,6 +255,7 @@ void BearerMonitor::onlineStateChanged(bool isOnline) void BearerMonitor::registerNetwork() { QTreeWidgetItem *item = treeWidget->currentItem(); + if (!item) return; QNetworkConfiguration configuration = manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString()); @@ -276,6 +277,7 @@ void BearerMonitor::registerNetwork() void BearerMonitor::unregisterNetwork() { QTreeWidgetItem *item = treeWidget->currentItem(); + if (!item) return; QNetworkConfiguration configuration = manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString()); @@ -384,6 +386,7 @@ void BearerMonitor::createSessionFor(QTreeWidgetItem *item) void BearerMonitor::createNewSession() { QTreeWidgetItem *item = treeWidget->currentItem(); + if (!item) return; createSessionFor(item); } diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp index 443f4b2..3a8e5ea 100644 --- a/examples/network/bearermonitor/sessionwidget.cpp +++ b/examples/network/bearermonitor/sessionwidget.cpp @@ -59,7 +59,7 @@ SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *paren connect(session, SIGNAL(stateChanged(QNetworkSession::State)), this, SLOT(updateSession())); connect(session, SIGNAL(error(QNetworkSession::SessionError)), - this, SLOT(updateSession())); + this, SLOT(updateSessionError(QNetworkSession::SessionError))); updateSession(); @@ -105,7 +105,6 @@ void SessionWidget::deleteSession() void SessionWidget::updateSession() { updateSessionState(session->state()); - updateSessionError(session->error()); if (session->state() == QNetworkSession::Connected) statsTimer = startTimer(1000); @@ -128,12 +127,14 @@ void SessionWidget::updateSession() void SessionWidget::openSession() { + clearError(); session->open(); updateSession(); } void SessionWidget::openSyncSession() { + clearError(); session->open(); session->waitForOpened(); updateSession(); @@ -141,12 +142,14 @@ void SessionWidget::openSyncSession() void SessionWidget::closeSession() { + clearError(); session->close(); updateSession(); } void SessionWidget::stopSession() { + clearError(); session->stop(); updateSession(); } @@ -195,3 +198,8 @@ void SessionWidget::updateSessionError(QNetworkSession::SessionError error) errorString->setText(session->errorString()); } +void SessionWidget::clearError() +{ + lastError->clear(); + errorString->clear(); +} diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h index 5e9d62c..b299b47 100644 --- a/examples/network/bearermonitor/sessionwidget.h +++ b/examples/network/bearermonitor/sessionwidget.h @@ -63,7 +63,7 @@ public: private: void updateSessionState(QNetworkSession::State state); - void updateSessionError(QNetworkSession::SessionError error); + void clearError(); private Q_SLOTS: void openSession(); @@ -71,9 +71,12 @@ private Q_SLOTS: void closeSession(); void stopSession(); void updateSession(); + void updateSessionError(QNetworkSession::SessionError error); #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) void deleteSession(); #endif + + private: QNetworkSession *session; int statsTimer; diff --git a/examples/network/bearermonitor/sessionwidget.ui b/examples/network/bearermonitor/sessionwidget.ui index 45135f5..56a2d0e 100644 --- a/examples/network/bearermonitor/sessionwidget.ui +++ b/examples/network/bearermonitor/sessionwidget.ui @@ -195,7 +195,7 @@ <item> <widget class="QLabel" name="errorStringLabel"> <property name="text"> - <string>Error String</string> + <string>Error String:</string> </property> </widget> </item> diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index d8b4b32..9d754a4 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -57d10d5c05e59bbf7de8189ff47dd18d1be996dc +3d774b9df1f963452b1cfe34f9fafad0d399372a diff --git a/src/3rdparty/webkit/ChangeLog b/src/3rdparty/webkit/ChangeLog index 70eff7d..a0cf2d0 100644 --- a/src/3rdparty/webkit/ChangeLog +++ b/src/3rdparty/webkit/ChangeLog @@ -1,3 +1,12 @@ +2010-05-12 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Detect debug mode consistently + https://bugs.webkit.org/show_bug.cgi?id=38863 + + * WebKit.pri: + 2010-04-09 Simon Hausmann <simon.hausmann@nokia.com> Unreviewed crash fix. diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index 97176ef..a3e6586 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,15 @@ +2010-05-12 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Detect debug mode consistently + https://bugs.webkit.org/show_bug.cgi?id=38863 + + * JavaScriptCore.pri: + * JavaScriptCore.pro: + * jsc.pro: + * qt/api/QtScript.pro: + 2010-05-10 Laszlo Gombos <laszlo.1.gombos@nokia.com> Reviewed by Darin Adler. @@ -21,18 +33,6 @@ * wtf/Platform.h: -2010-05-02 Laszlo Gombos <laszlo.1.gombos@nokia.com> - - Reviewed by Eric Seidel. - - [Qt] Enable JIT for QtWebKit on Symbian - https://bugs.webkit.org/show_bug.cgi?id=38339 - - JIT on Symbian has been stable for quite some time, it - is time to turn it on by default. - - * wtf/Platform.h: - 2010-04-28 Simon Hausmann <simon.hausmann@nokia.com>, Kent Hansen <kent.hansen@nokia.com> Reviewed by Darin Adler. diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri index b7f6665..b3f74a9 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri @@ -1,6 +1,6 @@ # JavaScriptCore - Qt4 build info VPATH += $$PWD -CONFIG(debug, debug|release) { +!CONFIG(release, debug|release) { # Output in JavaScriptCore/<config> JAVASCRIPTCORE_DESTDIR = debug # Use a config-specific target to prevent parallel builds file clashes on Mac diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro index 8e086b3..22fcc91 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro @@ -21,7 +21,7 @@ CONFIG(QTDIR_build) { # This line was extracted from qbase.pri instead of including the whole file win32|mac:!macx-xcode:CONFIG += debug_and_release } else { - CONFIG(debug, debug|release) { + !CONFIG(release, debug|release) { OBJECTS_DIR = obj/debug } else { # Release OBJECTS_DIR = obj/release diff --git a/src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro b/src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro index 88629c7..3c2691e 100644 --- a/src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro +++ b/src/3rdparty/webkit/JavaScriptCore/qt/api/QtScript.pro @@ -7,7 +7,7 @@ INCLUDEPATH += $$PWD CONFIG += building-libs isEmpty(JSC_GENERATED_SOURCES_DIR):JSC_GENERATED_SOURCES_DIR = ../../generated -CONFIG(debug, debug|release) { +!CONFIG(release, debug|release) { OBJECTS_DIR = obj/debug } else { # Release OBJECTS_DIR = obj/release diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h index 8d98765..fac477e 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h @@ -937,8 +937,6 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ #define ENABLE_JIT 1 #elif CPU(ARM_TRADITIONAL) && OS(LINUX) #define ENABLE_JIT 1 -#elif CPU(ARM_TRADITIONAL) && OS(SYMBIAN) && COMPILER(RVCT) - #define ENABLE_JIT 1 #endif #endif /* PLATFORM(QT) */ @@ -1008,7 +1006,6 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ || (CPU(X86) && OS(LINUX) && GCC_VERSION >= 40100) \ || (CPU(X86_64) && OS(LINUX) && GCC_VERSION >= 40100) \ || (CPU(ARM_TRADITIONAL) && OS(LINUX)) \ - || (CPU(ARM_TRADITIONAL) && OS(SYMBIAN) && COMPILER(RVCT)) \ || (CPU(MIPS) && OS(LINUX)) \ || (CPU(X86) && OS(DARWIN)) \ || (CPU(X86_64) && OS(DARWIN)) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index c8c2aa3..a440c03 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - dc5821c3df2ef60456d85263160852f5335cf946 + 5cf023650a8da206a8cf3130e9d4820b95e1bc7c diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 76b4eff..93d00e4 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,46 @@ +2010-05-12 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Detect debug mode consistently + https://bugs.webkit.org/show_bug.cgi?id=38863 + + No new tests as there is no new functionality. + + * WebCore.pro: + +2010-05-14 Andreas Kling <andreas.kling@nokia.com> + + Reviewed by Darin Adler. + + Ignore invalid values for various CanvasRenderingContext2D properties + (lineWidth, miterLimit, shadowOffsetX, shadowOffsetY and shadowBlur) + + https://bugs.webkit.org/show_bug.cgi?id=38841 + + Test: fast/canvas/canvas-invalid-values.html + + * html/canvas/CanvasRenderingContext2D.cpp: + (WebCore::CanvasRenderingContext2D::setLineWidth): + (WebCore::CanvasRenderingContext2D::setMiterLimit): + (WebCore::CanvasRenderingContext2D::setShadowOffsetX): + (WebCore::CanvasRenderingContext2D::setShadowOffsetY): + (WebCore::CanvasRenderingContext2D::setShadowBlur): + +2010-05-12 Noam Rosenthal <noam.rosenthal@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] GraphicsLayer: depth-test causes flicker in certain situations + + This patch removes the simplistic 2D depth test as it leads to flickering side effects. + https://bugs.webkit.org/show_bug.cgi?id=38370 + + Tested by http://webkit.org/blog-files/3d-transforms/morphing-cubes.html + + * platform/graphics/qt/GraphicsLayerQt.cpp: + (WebCore::GraphicsLayerQtImpl::updateTransform): + 2010-04-29 James Robinson <jamesr@chromium.org> Reviewed by Simon Fraser. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 254d17b..689c5ff 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -59,7 +59,7 @@ CONFIG(standalone_package) { isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = generated isEmpty(JSC_GENERATED_SOURCES_DIR):JSC_GENERATED_SOURCES_DIR = ../JavaScriptCore/generated - CONFIG(debug, debug|release) { + !CONFIG(release, debug|release) { OBJECTS_DIR = obj/debug } else { # Release OBJECTS_DIR = obj/release diff --git a/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp index 8add19c..823ab59 100644 --- a/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp +++ b/src/3rdparty/webkit/WebCore/html/canvas/CanvasRenderingContext2D.cpp @@ -209,7 +209,7 @@ float CanvasRenderingContext2D::lineWidth() const void CanvasRenderingContext2D::setLineWidth(float width) { - if (!(width > 0)) + if (!(isfinite(width) && width > 0)) return; state().m_lineWidth = width; GraphicsContext* c = drawingContext(); @@ -259,7 +259,7 @@ float CanvasRenderingContext2D::miterLimit() const void CanvasRenderingContext2D::setMiterLimit(float limit) { - if (!(limit > 0)) + if (!(isfinite(limit) && limit > 0)) return; state().m_miterLimit = limit; GraphicsContext* c = drawingContext(); @@ -275,6 +275,8 @@ float CanvasRenderingContext2D::shadowOffsetX() const void CanvasRenderingContext2D::setShadowOffsetX(float x) { + if (!isfinite(x)) + return; state().m_shadowOffset.setWidth(x); applyShadow(); } @@ -286,6 +288,8 @@ float CanvasRenderingContext2D::shadowOffsetY() const void CanvasRenderingContext2D::setShadowOffsetY(float y) { + if (!isfinite(y)) + return; state().m_shadowOffset.setHeight(y); applyShadow(); } @@ -297,6 +301,8 @@ float CanvasRenderingContext2D::shadowBlur() const void CanvasRenderingContext2D::setShadowBlur(float blur) { + if (!(isfinite(blur) && blur >= 0)) + return; state().m_shadowBlur = blur; applyShadow(); } diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp index 1c4c275..d9394e1 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp @@ -357,14 +357,6 @@ void GraphicsLayerQtImpl::updateTransform() return; } - // Simplistic depth test - we stack the item behind its parent if its computed z is lower than the parent's computed z at the item's center point. - if (parent) { - const QPointF centerPointMappedToRoot = rootLayer()->mapFromItem(this, m_size.width() / 2, m_size.height() / 2); - setFlag(ItemStacksBehindParent, - m_transformRelativeToRootLayer.mapPoint(FloatPoint3D(centerPointMappedToRoot.x(), centerPointMappedToRoot.y(), 0)).z() < - parent->m_transformRelativeToRootLayer.mapPoint(FloatPoint3D(centerPointMappedToRoot.x(), centerPointMappedToRoot.y(), 0)).z()); - } - // The item is front-facing or backface-visibility is on. setVisible(true); diff --git a/src/3rdparty/webkit/WebKit.pri b/src/3rdparty/webkit/WebKit.pri index e737039..a3ccd9d 100644 --- a/src/3rdparty/webkit/WebKit.pri +++ b/src/3rdparty/webkit/WebKit.pri @@ -22,7 +22,7 @@ building-libs { QMAKE_FRAMEWORKPATH = $$OUTPUT_DIR/lib $$QMAKE_FRAMEWORKPATH } else { win32-*|wince* { - CONFIG(debug, debug|release):build_pass: QTWEBKITLIBNAME = $${QTWEBKITLIBNAME}d + !CONFIG(release, debug|release):build_pass: QTWEBKITLIBNAME = $${QTWEBKITLIBNAME}d QTWEBKITLIBNAME = $${QTWEBKITLIBNAME}$${QT_MAJOR_VERSION} win32-g++: LIBS += -l$$QTWEBKITLIBNAME else: LIBS += $${QTWEBKITLIBNAME}.lib diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp index 4e8fd30..ba039c7 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebdatabase.cpp @@ -39,8 +39,10 @@ using namespace WebCore; access on a local computer through JavaScript. QWebDatabase is the C++ interface to these databases. - To get access to all databases defined by a security origin, use QWebSecurityOrigin::databases(). - Each database has an internal name(), as well as a user-friendly name, provided by displayName(). + Databases are grouped together in security origins. To get access to all databases defined by + a security origin, use QWebSecurityOrigin::databases(). Each database has an internal name(), + as well as a user-friendly name, provided by displayName(). These names are specified when + creating the database in the JavaScript code. WebKit uses SQLite to create and access the local SQL databases. The location of the database file in the local file system is returned by fileName(). You can access the database directly @@ -49,7 +51,7 @@ using namespace WebCore; For each database the web site can define an expectedSize(). The current size of the database in bytes is returned by size(). - For more information refer to the \l{http://dev.w3.org/html5/webdatabase/}{HTML 5 Draft Standard}. + For more information refer to the \l{http://dev.w3.org/html5/webdatabase/}{HTML5 Web SQL Database Draft Standard}. \sa QWebSecurityOrigin */ @@ -80,7 +82,7 @@ QString QWebDatabase::name() const } /*! - Returns the name of the database as seen by the user. + Returns the name of the database in a format that is suitable for display to the user. */ QString QWebDatabase::displayName() const { diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp index 955206d..69146a2 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp @@ -84,13 +84,27 @@ public: \snippet webkitsnippets/webelement/main.cpp Traversing with QWebElement + Individual elements can be inspected or changed using methods such as attribute() + or setAttribute(). For examle, to capture the user's input in a text field for later + use (auto-completion), a browser could do something like this: + + \snippet webkitsnippets/webelement/main.cpp autocomplete1 + + When the same page is later revisited, the browser can fill in the text field automatically + by modifying the value attribute of the input element: + + \snippet webkitsnippets/webelement/main.cpp autocomplete2 + + Another use case is to emulate a click event on an element. The following + code snippet demonstrates how to call the JavaScript DOM method click() of + a submit button: + + \snippet webkitsnippets/webelement/main.cpp Calling a DOM element method + 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 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(). diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp index 394ea17..44cc3b5 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp @@ -552,8 +552,10 @@ void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QWebFrame: can connect to the web page's \l{QWebPage::}{frameCreated()} signal to be notified when a new frame is created. - The hitTestContent() function can be used to programmatically examine the - contents of a frame. + There are multiple ways to programmatically examine the contents of a frame. + The hitTestContent() function can be used to find elements by coordinate. + For access to the underlying DOM tree, there is documentElement(), + findAllElements() and findFirstElement(). A QWebFrame can be printed onto a QPrinter using the print() function. This function is marked as a slot and can be conveniently connected to @@ -781,6 +783,10 @@ static inline QUrl ensureAbsoluteUrl(const QUrl &url) \property QWebFrame::url \brief the url of the frame currently viewed + Setting this property clears the view and loads the URL. + + By default, this property contains an empty, invalid URL. + \sa urlChanged() */ diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebhistoryinterface.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebhistoryinterface.cpp index 80567d1..61cf5af 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebhistoryinterface.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebhistoryinterface.cpp @@ -41,7 +41,7 @@ static void gCleanupInterface() /*! Sets a new default interface, \a defaultInterface, that will be used by all of WebKit - for managing history. + to keep track of visited links. If an interface without a parent has already been set, the old interface will be deleted. When the application exists QWebHistoryInterface will automatically delete the @@ -68,8 +68,9 @@ void QWebHistoryInterface::setDefaultInterface(QWebHistoryInterface* defaultInte } /*! - Returns the default interface that will be used by WebKit. If no - default interface has been set, QtWebkit will not track history. + Returns the default interface that will be used by WebKit. If no default interface has been set, + Webkit will not keep track of visited links and a null pointer will be returned. + \sa setDefaultInterface */ QWebHistoryInterface* QWebHistoryInterface::defaultInterface() { @@ -84,11 +85,15 @@ QWebHistoryInterface* QWebHistoryInterface::defaultInterface() \inmodule QtWebKit The QWebHistoryInterface is an interface that can be used to - implement link history. It contains two pure virtual methods that - are called by the WebKit engine. addHistoryEntry() is used to add - pages that have been visited to the interface, while - historyContains() is used to query whether this page has been - visited by the user. + keep track of visited links. It contains two pure virtual methods that + are called by the WebKit engine: addHistoryEntry() is used to add + urls that have been visited to the interface, while + historyContains() is used to query whether the given url has been + visited by the user. By default the QWebHistoryInterface is not set, so WebKit does not keep + track of visited links. + + \note The history tracked by QWebHistoryInterface is not specific to an instance of QWebPage + but applies to all pages. */ /*! @@ -100,7 +105,7 @@ QWebHistoryInterface::QWebHistoryInterface(QObject* parent) } /*! - Destructor. If this is currently the default interface it will be unset. + Destroys the interface. If this is currently the default interface it will be unset. */ QWebHistoryInterface::~QWebHistoryInterface() { diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp index c0e5277..802ea98 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp @@ -31,17 +31,23 @@ /*! \class QWebInspector \since 4.6 + \inmodule QtWebKit \brief The QWebInspector class allows the placement and control of a QWebPage's inspector. - The inspector allows you to see a page current hierarchy and loading - statistics. + The inspector can display a page's hierarchy, its loading statistics and + the current state of its individual elements. It is mostly used by web + developers. - The QWebPage to be inspected is determined with the setPage() method. + The QWebPage to be inspected must be specified using the setPage() method. A typical use of QWebInspector follows: \snippet webkitsnippets/qtwebkit_qwebinspector_snippet.cpp 0 + A QWebInspector can be made visible either programmatically using + setVisible(), or by the user through the attached QWebPage's context + menu. + \note A QWebInspector will display a blank widget if either: \list \o page() is null @@ -61,17 +67,16 @@ \section1 Inspector configuration persistence The inspector allows the user to configure some options through its - interface (e.g. the resource tracking "Always enable" option). - These settings are persisted automatically by QtWebKit using QSettings. - - However since the QSettings object is instantiated using the empty - constructor, QCoreApplication::setOrganizationName() and - QCoreApplication::setApplicationName() must be called within your - application to enable the persistence of these options. + user interface (e.g. the resource tracking "Always enable" option). + These settings will be persisted automatically by QtWebKit only if + your application previously called QCoreApplication::setOrganizationName() + and QCoreApplication::setApplicationName(). + See QSettings's default constructor documentation for an explanation + of why this is necessary. */ /*! - Constructs an empty QWebInspector with parent \a parent. + Constructs an unbound QWebInspector with \a parent as its parent. */ QWebInspector::QWebInspector(QWidget* parent) : QWidget(parent) @@ -89,16 +94,16 @@ QWebInspector::~QWebInspector() } /*! - Sets the QWebPage to be inspected. - - There can only be one QWebInspector associated with a QWebPage - and vices versa. + Bind this inspector to the QWebPage to be inspected. - Calling with \a page as null will break the current association, if any. - - If \a page is already associated to another QWebInspector, the association - will be replaced and the previous QWebInspector will have no page - associated. + \bold {Notes:} + \list + \o There can only be one QWebInspector associated with a QWebPage + and vice versa. + \o Calling this method with a null \a page will break the current association, if any. + \o If \a page is already associated to another QWebInspector, the association + will be replaced and the previous QWebInspector will become unbound + \endlist \sa page() */ diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebkitversion.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebkitversion.cpp index 062839f..181913b 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebkitversion.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebkitversion.cpp @@ -22,11 +22,21 @@ #include <WebKitVersion.h> /*! - + \relates QWebPage + \since 4.6 Returns the version number of WebKit at run-time as a string (for - example, "531.3"). This is the version of WebKit the application - was compiled against. + example, "531.3"). + + This version is commonly used in WebKit based browsers as part + of the user agent string. Web servers and JavaScript might use + it to identify the presence of certain WebKit engine features + and behaviour. + The evolution of this version is bound to the releases of Apple's + Safari browser. For a version specific to the QtWebKit library, + see QTWEBKIT_VERSION + + \sa QWebPage::userAgentForUrl() */ QString qWebKitVersion() { @@ -34,11 +44,13 @@ QString qWebKitVersion() } /*! - + \relates QWebPage + \since 4.6 Returns the 'major' version number of WebKit at run-time as an integer (for example, 531). This is the version of WebKit the application was compiled against. + \sa qWebKitVersion() */ int qWebKitMajorVersion() { @@ -46,13 +58,57 @@ int qWebKitMajorVersion() } /*! - + \relates QWebPage + \since 4.6 Returns the 'minor' version number of WebKit at run-time as an integer (for example, 3). This is the version of WebKit the application was compiled against. + \sa qWebKitVersion() */ int qWebKitMinorVersion() { return WEBKIT_MINOR_VERSION; } + +/*! + \macro QTWEBKIT_VERSION + \relates QWebPage + + This macro expands a numeric value of the form 0xMMNNPP (MM = + major, NN = minor, PP = patch) that specifies QtWebKit's version + number. For example, if you compile your application against QtWebKit + 2.1.2, the QTWEBKIT_VERSION macro will expand to 0x020102. + + You can use QTWEBKIT_VERSION to use the latest QtWebKit API where + available. + + \sa QT_VERSION +*/ + +/*! + \macro QTWEBKIT_VERSION_STR + \relates QWebPage + + This macro expands to a string that specifies QtWebKit's version number + (for example, "2.1.2"). This is the version against which the + application is compiled. + + \sa QTWEBKIT_VERSION +*/ + +/*! + \macro QTWEBKIT_VERSION_CHECK + \relates QWebPage + + Turns the major, minor and patch numbers of a version into an + integer, 0xMMNNPP (MM = major, NN = minor, PP = patch). This can + be compared with another similarly processed version id, for example + in a preprocessor statement: + + \code + #if QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 1, 0) + // code to use API new in QtWebKit 2.1.0 + #endif + \endcode +*/ diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index e9ebce5..c5f508f 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -1627,7 +1627,7 @@ InspectorController* QWebPagePrivate::inspectorController() /*! \enum QWebPage::FindFlag - This enum describes the options available to QWebPage's findText() function. The options + This enum describes the options available to the findText() function. The options can be OR-ed together from the following list: \value FindBackward Searches backwards instead of forwards. @@ -1648,6 +1648,8 @@ InspectorController* QWebPagePrivate::inspectorController() \value DelegateExternalLinks When activating links that point to documents not stored on the local filesystem or an equivalent - such as the Qt resource system - then linkClicked() is emitted. \value DelegateAllLinks Whenever a link is activated the linkClicked() signal is emitted. + + \sa QWebPage::linkDelegationPolicy */ /*! @@ -1662,6 +1664,8 @@ InspectorController* QWebPagePrivate::inspectorController() \value NavigationTypeReload The user activated the reload action. \value NavigationTypeFormResubmitted An HTML form was submitted a second time. \value NavigationTypeOther A navigation to another document using a method not listed above. + + \sa acceptNavigationRequest() */ /*! @@ -1671,7 +1675,7 @@ InspectorController* QWebPagePrivate::inspectorController() Actions only have an effect when they are applicable. The availability of actions can be be determined by checking \l{QAction::}{isEnabled()} on the - action returned by \l{QWebPage::}{action()}. + action returned by action(). One method of enabling the text editing, cursor movement, and text selection actions is by setting \l contentEditable to true. @@ -1753,6 +1757,8 @@ InspectorController* QWebPagePrivate::inspectorController() /*! \enum QWebPage::WebWindowType + This enum describes the types of window that can be created by the createWindow() function. + \value WebBrowserWindow The window is a regular web browser window. \value WebModalDialog The window acts as modal dialog. */ @@ -1769,11 +1775,13 @@ InspectorController* QWebPagePrivate::inspectorController() to provide functionality like QWebView in a widget-less environment. QWebPage's API is very similar to QWebView, as you are still provided with - common functions like action() (known as \l{QWebView::}{pageAction()} in - QWebView), triggerAction(), findText() and settings(). More QWebView-like - functions can be found in the main frame of QWebPage, obtained via - QWebPage::mainFrame(). For example, the load(), setUrl() and setHtml() - unctions for QWebPage can be accessed using QWebFrame. + common functions like action() (known as + \l{QWebView::pageAction()}{pageAction}() in QWebView), triggerAction(), + findText() and settings(). More QWebView-like functions can be found in the + main frame of QWebPage, obtained via the mainFrame() function. For example, + the \l{QWebFrame::load()}{load}(), \l{QWebFrame::setUrl()}{setUrl}() and + \l{QWebFrame::setHtml()}{setHtml}() functions for QWebPage can be accessed + using QWebFrame. The loadStarted() signal is emitted when the page begins to load.The loadProgress() signal, on the other hand, is emitted whenever an element @@ -1877,7 +1885,8 @@ QWebFrame *QWebPage::currentFrame() const /*! \since 4.6 - Returns the frame at the given point \a pos. + Returns the frame at the given point \a pos, or 0 if there is no frame at + that position. \sa mainFrame(), currentFrame() */ @@ -1996,7 +2005,7 @@ bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg) result should be written to \a result and true should be returned. If the prompt was not cancelled by the user, the implementation should return true and the result string must not be null. - The default implementation uses QInputDialog::getText. + The default implementation uses QInputDialog::getText(). */ bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result) { @@ -2210,6 +2219,8 @@ QSize QWebPage::viewportSize() const By default, for a newly-created Web page, this property contains a size with zero width and height. + + \sa QWebFrame::render(), preferredContentsSize */ void QWebPage::setViewportSize(const QSize &size) const { @@ -2238,11 +2249,12 @@ QSize QWebPage::preferredContentsSize() const /*! \property QWebPage::preferredContentsSize \since 4.6 - \brief the size of the fixed layout + \brief the preferred size of the contents - The size affects the layout of the page in the viewport. If set to a fixed size of - 1024x768 for example then webkit will layout the page as if the viewport were that size - rather than something different. + If this property is set to a valid size, it is used to lay out the page. + If it is not set (the default), the viewport size is used instead. + + \sa viewportSize */ void QWebPage::setPreferredContentsSize(const QSize &size) const { @@ -2590,9 +2602,11 @@ QAction *QWebPage::action(WebAction action) const /*! \property QWebPage::modified - \brief whether the page contains unsubmitted form data + \brief whether the page contains unsubmitted form data, or the contents have been changed. By default, this property is false. + + \sa contentsChanged(), contentEditable, undoStack() */ bool QWebPage::isModified() const { @@ -2608,6 +2622,8 @@ bool QWebPage::isModified() const #ifndef QT_NO_UNDOSTACK /*! Returns a pointer to the undo stack used for editable content. + + \sa modified */ QUndoStack *QWebPage::undoStack() const { @@ -2730,7 +2746,7 @@ bool QWebPage::event(QEvent *ev) } /*! - Similar to QWidget::focusNextPrevChild it focuses the next focusable web element + Similar to QWidget::focusNextPrevChild() it focuses the next focusable web element if \a next is true; otherwise the previous element is focused. Returns true if it can find a new focusable element, or false if it can't. @@ -2757,6 +2773,8 @@ bool QWebPage::focusNextPrevChild(bool next) If this property is enabled the contents of the page can be edited by the user through a visible cursor. If disabled (the default) only HTML elements in the web page with their \c{contenteditable} attribute set are editable. + + \sa modified, contentsChanged(), WebAction */ void QWebPage::setContentEditable(bool editable) { @@ -2926,17 +2944,21 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) as a result of the user clicking on a "file upload" button in a HTML form where multiple file selection is allowed. - \omitvalue ErrorPageExtension (introduced in Qt 4.6) + \value ErrorPageExtension Whether the web page can provide an error page when loading fails. + (introduced in Qt 4.6) + + \sa ChooseMultipleFilesExtensionOption, ChooseMultipleFilesExtensionReturn, ErrorPageExtensionOption, ErrorPageExtensionReturn */ /*! \enum QWebPage::ErrorDomain \since 4.6 - \internal - \value QtNetwork - \value Http - \value WebKit + This enum describes the domain of an ErrorPageExtensionOption object (i.e. the layer in which the error occurred). + + \value QtNetwork The error occurred in the QtNetwork layer; the error code is of type QNetworkReply::NetworkError. + \value Http The error occurred in the HTTP layer; the error code is a HTTP status code (see QNetworkRequest::HttpStatusCodeAttribute). + \value WebKit The error is an internal WebKit error. */ /*! @@ -2946,7 +2968,18 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) \inmodule QtWebKit - \sa QWebPage::extension() + \sa QWebPage::extension() QWebPage::ExtensionReturn +*/ + + +/*! + \class QWebPage::ExtensionReturn + \since 4.4 + \brief The ExtensionReturn class provides an output result from a QWebPage's extension. + + \inmodule QtWebKit + + \sa QWebPage::extension() QWebPage::ExtensionOption */ /*! @@ -2957,12 +2990,38 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) \inmodule QtWebKit - The ErrorPageExtensionOption class holds the \a url for which an error occoured as well as + The ErrorPageExtensionOption class holds the \a url for which an error occurred as well as the associated \a frame. The error itself is reported by an error \a domain, the \a error code as well as \a errorString. - \sa QWebPage::ErrorPageExtensionReturn + \sa QWebPage::extension() QWebPage::ErrorPageExtensionReturn +*/ + +/*! + \variable QWebPage::ErrorPageExtensionOption::url + \brief the url for which an error occurred +*/ + +/*! + \variable QWebPage::ErrorPageExtensionOption::frame + \brief the frame associated with the error +*/ + +/*! + \variable QWebPage::ErrorPageExtensionOption::domain + \brief the domain that reported the error +*/ + +/*! + \variable QWebPage::ErrorPageExtensionOption::error + \brief the error code. Interpretation of the value depends on the \a domain + \sa QWebPage::ErrorDomain +*/ + +/*! + \variable QWebPage::ErrorPageExtensionOption::errorString + \brief a string that describes the error */ /*! @@ -2983,7 +3042,7 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) External objects such as stylesheets or images referenced in the HTML are located relative to \a baseUrl. - \sa QWebPage::ErrorPageExtensionOption, QString::toUtf8() + \sa QWebPage::extension() QWebPage::ErrorPageExtensionOption, QString::toUtf8() */ /*! @@ -2992,6 +3051,29 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) Constructs a new error page object. */ + +/*! + \variable QWebPage::ErrorPageExtensionReturn::contentType + \brief the error page's content type +*/ + +/*! + \variable QWebPage::ErrorPageExtensionReturn::encoding + \brief the error page encoding +*/ + +/*! + \variable QWebPage::ErrorPageExtensionReturn::baseUrl + \brief the base url + + External objects such as stylesheets or images referenced in the HTML are located relative to this url. +*/ + +/*! + \variable QWebPage::ErrorPageExtensionReturn::content + \brief the HTML content of the error page +*/ + /*! \class QWebPage::ChooseMultipleFilesExtensionOption \since 4.5 @@ -3003,7 +3085,22 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) The ChooseMultipleFilesExtensionOption class holds the frame originating the request and the suggested filenames which might be provided. - \sa QWebPage::chooseFile(), QWebPage::ChooseMultipleFilesExtensionReturn + \sa QWebPage::extension() QWebPage::chooseFile(), QWebPage::ChooseMultipleFilesExtensionReturn +*/ + +/*! + \variable QWebPage::ChooseMultipleFilesExtensionOption::parentFrame + \brief The frame in which the request originated +*/ + +/*! + \variable QWebPage::ChooseMultipleFilesExtensionOption::suggestedFileNames + \brief The suggested filenames +*/ + +/*! + \variable QWebPage::ChooseMultipleFilesExtensionReturn::fileNames + \brief The selected filenames */ /*! @@ -3017,14 +3114,17 @@ void QWebPage::updatePositionDependentActions(const QPoint &pos) The ChooseMultipleFilesExtensionReturn class holds the filenames selected by the user when the extension is invoked. - \sa QWebPage::ChooseMultipleFilesExtensionOption + \sa QWebPage::extension() QWebPage::ChooseMultipleFilesExtensionOption */ /*! This virtual function can be reimplemented in a QWebPage subclass to provide support for extensions. The \a option argument is provided as input to the extension; the output results can be stored in \a output. - The behavior of this function is determined by \a extension. + The behavior of this function is determined by \a extension. The \a option + and \a output values are typically casted to the corresponding types (for + example, ChooseMultipleFilesExtensionOption and + ChooseMultipleFilesExtensionReturn for ChooseMultipleFilesExtension). You can call supportsExtension() to check if an extension is supported by the page. @@ -3116,6 +3216,8 @@ QWebSettings *QWebPage::settings() const A suggested filename may be provided in \a suggestedFile. The frame originating the request is provided as \a parentFrame. + + \sa ChooseMultipleFilesExtension */ QString QWebPage::chooseFile(QWebFrame *parentFrame, const QString& suggestedFile) { @@ -3369,6 +3471,15 @@ QString QWebPage::userAgentForUrl(const QUrl&) const case QSysInfo::SV_9_4: firstPartTemp += QString::fromLatin1("/9.4"); break; + case QSysInfo::SV_SF_2: + firstPartTemp += QString::fromLatin1("^2"); + break; + case QSysInfo::SV_SF_3: + firstPartTemp += QString::fromLatin1("^3"); + break; + case QSysInfo::SV_SF_4: + firstPartTemp += QString::fromLatin1("^4"); + break; default: firstPartTemp += QString::fromLatin1("/Unknown"); } @@ -3479,7 +3590,7 @@ quint64 QWebPage::totalBytes() const /*! Returns the number of bytes that were received from the network to render the current page. - \sa totalBytes() + \sa totalBytes(), loadProgress() */ quint64 QWebPage::bytesReceived() const { @@ -3511,7 +3622,7 @@ quint64 QWebPage::bytesReceived() const This signal is emitted when a load of the page is finished. \a ok will indicate whether the load was successful or any error occurred. - \sa loadStarted() + \sa loadStarted(), ErrorPageExtension */ /*! @@ -3538,12 +3649,15 @@ quint64 QWebPage::bytesReceived() const \fn void QWebPage::frameCreated(QWebFrame *frame) This signal is emitted whenever the page creates a new \a frame. + + \sa currentFrame() */ /*! \fn void QWebPage::selectionChanged() - This signal is emitted whenever the selection changes. + This signal is emitted whenever the selection changes, either interactively + or programmatically (e.g. by calling triggerAction() with a selection action). \sa selectedText() */ @@ -3555,7 +3669,7 @@ quint64 QWebPage::bytesReceived() const This signal is emitted whenever the text in form elements changes as well as other editable content. - \sa contentEditable, QWebFrame::toHtml(), QWebFrame::toPlainText() + \sa contentEditable, modified, QWebFrame::toHtml(), QWebFrame::toPlainText() */ /*! @@ -3631,9 +3745,9 @@ quint64 QWebPage::bytesReceived() const \fn void QWebPage::microFocusChanged() This signal is emitted when for example the position of the cursor in an editable form - element changes. It is used inform input methods about the new on-screen position where - the user is able to enter text. This signal is usually connected to QWidget's updateMicroFocus() - slot. + element changes. It is used to inform input methods about the new on-screen position where + the user is able to enter text. This signal is usually connected to the + QWidget::updateMicroFocus() slot. */ /*! @@ -3674,6 +3788,8 @@ quint64 QWebPage::bytesReceived() const This signal is emitted whenever the web site shown in \a frame is asking to store data to the database \a databaseName and the quota allocated to that web site is exceeded. + + \sa QWebDatabase */ /*! diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp index 8ff13b1..f715430 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpluginfactory.cpp @@ -23,25 +23,40 @@ /*! \class QWebPluginFactory \since 4.4 - \brief The QWebPluginFactory class creates plugins to be embedded into web - pages. + \brief The QWebPluginFactory class is used to embed custom data types in web pages. \inmodule QtWebKit - QWebPluginFactory is a factory for creating plugins for QWebPage. A plugin - factory can be installed on a QWebPage using QWebPage::setPluginFactory(). + The HTML \c{<object>} tag is used to embed arbitrary content into a web page, + for example: + + \code + <object type="application/x-pdf" data="http://qt.nokia.com/document.pdf" width="500" height="400"></object> + \endcode + + QtWebkit will natively handle the most basic data types like \c{text/html} and + \c{image/jpeg}, but for any advanced or custom data types you will need to + provide a handler yourself. + + QWebPluginFactory is a factory for creating plugins for QWebPage, where each + plugin provides support for one or more data types. A plugin factory can be + installed on a QWebPage using QWebPage::setPluginFactory(). \note The plugin factory is only used if plugins are enabled through QWebSettings. - You can provide a QWebPluginFactory by implementing the plugins() and the - create() method. For plugins() it is necessary to describe the plugins the + You provide a QWebPluginFactory by implementing the plugins() and the + create() methods. For plugins() it is necessary to describe the plugins the factory can create, including a description and the supported MIME types. The MIME types each plugin can handle should match the ones specified in - in the HTML \c{<object>} tag. + in the HTML \c{<object>} tag of your content. The create() method is called if the requested MIME type is supported. The implementation has to return a new instance of the plugin requested for the given MIME type and the specified URL. + + The plugins themselves are subclasses of QObject, but currently only plugins + based on either QWidget or QGraphicsWidget are supported. + */ @@ -183,6 +198,7 @@ void QWebPluginFactory::refreshPlugins() /*! \enum QWebPluginFactory::Extension + \internal This enum describes the types of extensions that the plugin factory can support. Before using these extensions, you should verify that the extension is supported by calling supportsExtension(). @@ -192,6 +208,7 @@ void QWebPluginFactory::refreshPlugins() /*! \class QWebPluginFactory::ExtensionOption + \internal \since 4.4 \brief The ExtensionOption class provides an extended input argument to QWebPluginFactory's extension support. @@ -202,6 +219,7 @@ void QWebPluginFactory::refreshPlugins() /*! \class QWebPluginFactory::ExtensionReturn + \internal \since 4.4 \brief The ExtensionOption class provides an extended output argument to QWebPluginFactory's extension support. @@ -214,6 +232,8 @@ void QWebPluginFactory::refreshPlugins() This virtual function can be reimplemented in a QWebPluginFactory subclass to provide support for extensions. The \a option argument is provided as input to the extension; the output results can be stored in \a output. + \internal + The behaviour of this function is determined by \a extension. You can call supportsExtension() to check if an extension is supported by the factory. @@ -233,6 +253,8 @@ bool QWebPluginFactory::extension(Extension extension, const ExtensionOption *op /*! This virtual function returns true if the plugin factory supports \a extension; otherwise false is returned. + \internal + \sa extension() */ bool QWebPluginFactory::supportsExtension(Extension extension) const diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp index 6c26bd7..7179eaa 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsecurityorigin.cpp @@ -63,6 +63,16 @@ void QWEBKIT_EXPORT qt_drt_setDomainRelaxationForbiddenForURLScheme(bool forbidd \c{http://www.malicious.com/evil.html} from accessing \c{http://www.example.com/}'s resources, because they are of a different security origin. + By default local schemes like \c{file://} and \c{qrc://} are concidered to be in the same + security origin, and can access each other's resources. You can add additional local schemes + by using QWebSecurityOrigin::addLocalScheme(), or override the default same-origin behavior + by setting QWebSettings::LocalContentCanAccessFileUrls to \c{false}. + + \note Local resources are by default restricted from accessing remote content, which + means your \c{file://} will not be able to access \c{http://domain.com/foo.html}. You + can relax this restriction by setting QWebSettings::LocalContentCanAccessRemoteUrls to + \c{true}. + Call QWebFrame::securityOrigin() to get the QWebSecurityOrigin for a frame in a web page, and use host(), scheme() and port() to identify the security origin. @@ -219,7 +229,11 @@ QList<QWebDatabase> QWebSecurityOrigin::databases() const \since 4.6 Adds the given \a scheme to the list of schemes that are considered equivalent - to the \c file: scheme. They are not subject to cross domain restrictions. + to the \c file: scheme. + + Cross domain restrictions depend on the two web settings QWebSettings::LocalContentCanAccessFileUrls + and QWebSettings::LocalContentCanAccessFileUrls. By default all local schemes are concidered to be + in the same security origin, and local schemes can not access remote content. */ void QWebSecurityOrigin::addLocalScheme(const QString& scheme) { @@ -231,6 +245,9 @@ void QWebSecurityOrigin::addLocalScheme(const QString& scheme) Removes the given \a scheme from the list of local schemes. + \note You can not remove the \c{file://} scheme from the list + of local schemes. + \sa addLocalScheme() */ void QWebSecurityOrigin::removeLocalScheme(const QString& scheme) @@ -240,7 +257,10 @@ void QWebSecurityOrigin::removeLocalScheme(const QString& scheme) /*! \since 4.6 - Returns a list of all the schemes that were set by the application as local schemes, + Returns a list of all the schemes concidered to be local. + + By default this is \c{file://} and \c{qrc://}. + \sa addLocalScheme(), removeLocalScheme() */ QStringList QWebSecurityOrigin::localSchemes() diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp index ae7f6a8..115f9fc 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp @@ -289,8 +289,8 @@ QWebSettings* QWebSettings::globalSettings() function. The \l{QWebSettings::WebAttribute}{WebAttribute} enum further describes each attribute. - QWebSettings also configures global properties such as the Web page memory - cache and the Web page icon database, local database storage and offline + QWebSettings also configures global properties such as the web page memory + cache, icon database, local database storage and offline applications storage. \section1 Enabling Plugins @@ -299,8 +299,8 @@ QWebSettings* QWebSettings::globalSettings() \l{QWebSettings::PluginsEnabled}{PluginsEnabled} attribute. For many applications, this attribute is enabled for all pages by setting it on the \l{globalSettings()}{global settings object}. QtWebKit will always ignore this setting - \when processing Qt plugins. The decision to allow a Qt plugin is made by the client - \in its reimplementation of QWebPage::createPlugin. + when processing Qt plugins. The decision to allow a Qt plugin is made by the client + in its reimplementation of QWebPage::createPlugin(). \section1 Web Application Support @@ -339,7 +339,7 @@ QWebSettings* QWebSettings::globalSettings() \value MinimumFontSize The hard minimum font size. \value MinimumLogicalFontSize The minimum logical font size that is applied - after zooming with QWebFrame's textSizeMultiplier(). + when zooming out with QWebFrame::setTextSizeMultiplier(). \value DefaultFontSize The default font size for regular text. \value DefaultFixedFontSize The default font size for fixed-pitch text. */ @@ -361,66 +361,74 @@ QWebSettings* QWebSettings::globalSettings() This enum describes various attributes that are configurable through QWebSettings. \value AutoLoadImages Specifies whether images are automatically loaded in - web pages. + web pages. This is enabled by default. \value DnsPrefetchEnabled Specifies whether QtWebkit will try to pre-fetch DNS entries to - speed up browsing. This only works as a global attribute. Only for Qt 4.6 and later. + speed up browsing. This only works as a global attribute. Only for Qt 4.6 and later. This is disabled by default. \value JavascriptEnabled Enables or disables the running of JavaScript - programs. + programs. This is enabled by default \value JavaEnabled Enables or disables Java applets. Currently Java applets are not supported. - \value PluginsEnabled Enables or disables plugins in Web pages. Qt plugins - with a mimetype such as "application/x-qt-plugin" are not affected by this setting. + \value PluginsEnabled Enables or disables plugins in Web pages (e.g. using NPAPI). Qt plugins + with a mimetype such as "application/x-qt-plugin" are not affected by this setting. This is disabled by default. \value PrivateBrowsingEnabled Private browsing prevents WebKit from - recording visited pages in the history and storing web page icons. + recording visited pages in the history and storing web page icons. This is disabled by default. \value JavascriptCanOpenWindows Specifies whether JavaScript programs - can open new windows. + can open new windows. This is disabled by default. \value JavascriptCanAccessClipboard Specifies whether JavaScript programs - can read or write to the clipboard. + can read or write to the clipboard. This is disabled by default. \value DeveloperExtrasEnabled Enables extra tools for Web developers. Currently this enables the "Inspect" element in the context menu as - well as the use of QWebInspector which controls the WebKit WebInspector - for web site debugging. + well as the use of QWebInspector which controls the web inspector + for web site debugging. This is disabled by default. \value SpatialNavigationEnabled Enables or disables the Spatial Navigation feature, which consists in the ability to navigate between focusable elements in a Web page, such as hyperlinks and form controls, by using - Left, Right, Up and Down arrow keys. For example, if an user presses the + Left, Right, Up and Down arrow keys. For example, if a user presses the Right key, heuristics determine whether there is an element he might be - trying to reach towards the right, and if there are multiple elements, - which element he probably wants. + trying to reach towards the right and which element he probably wants. + This is disabled by default. \value LinksIncludedInFocusChain Specifies whether hyperlinks should be - included in the keyboard focus chain. - \value ZoomTextOnly Specifies whether the zoom factor on a frame applies to - only the text or all content. + included in the keyboard focus chain. This is enabled by default. + \value ZoomTextOnly Specifies whether the zoom factor on a frame applies + only to the text or to all content. This is disabled by default. \value PrintElementBackgrounds Specifies whether the background color and images - are also drawn when the page is printed. + are also drawn when the page is printed. This is enabled by default. \value OfflineStorageDatabaseEnabled Specifies whether support for the HTML 5 - offline storage feature is enabled or not. Disabled by default. + offline storage feature is enabled or not. This is disabled by default. \value OfflineWebApplicationCacheEnabled Specifies whether support for the HTML 5 - web application cache feature is enabled or not. Disabled by default. + web application cache feature is enabled or not. This is disabled by default. \value LocalStorageEnabled Specifies whether support for the HTML 5 - local storage feature is enabled or not. Disabled by default. + local storage feature is enabled or not. This is disabled by default. \value LocalStorageDatabaseEnabled \e{This enum value is deprecated.} Use QWebSettings::LocalStorageEnabled instead. - \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are allowed to access remote urls. - \value LocalContentCanAccessFileUrls Specifies whether locally loaded documents are allowed to access other local urls. - \value XSSAuditorEnabled Specifies whether load requests should be monitored for cross-site scripting attempts. + \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are + allowed to access remote urls. This is disabled by default. For more information + about security origins and local vs. remote content see QWebSecurityOrigin. + \value LocalContentCanAccessFileUrls Specifies whether locally loaded documents are + allowed to access other local urls. This is enabled by default. For more information + about security origins and local vs. remote content see QWebSecurityOrigin. + \value XSSAuditingEnabled Specifies whether load requests should be monitored for cross-site + scripting attempts. Suspicious scripts will be blocked and reported in the inspector's + JavaScript console. Enabling this feature might have an impact on performance + and it is disabled by default. \value AcceleratedCompositingEnabled This feature, when used in conjunction with QGraphicsWebView, accelerates animations of web content. CSS animations of the transform and opacity properties will be rendered by composing the cached content of the animated elements. - This feature is enabled by default + This is enabled by default. \value TiledBackingStoreEnabled This setting enables the tiled backing store feature for a QGraphicsWebView. With the tiled backing store enabled, the web page contents in and around the current visible area is speculatively cached to bitmap tiles. The tiles are automatically kept in sync with the web page as it changes. Enabling tiling can significantly speed up painting heavy operations like scrolling. Enabling the feature increases memory consumption. It does not work well with contents using CSS fixed positioning (see also \l{QGraphicsWebView::}{resizesToContents} property). - \l{QGraphicsWebView::}{tiledBackingStoreFrozen} property allows application to temporarily freeze the contents of the backing store. + \l{QGraphicsWebView::}{tiledBackingStoreFrozen} property allows application to temporarily + freeze the contents of the backing store. This is disabled by default. \value FrameFlatteningEnabled With this setting each subframe is expanded to its contents. On touch devices, it is desired to not have any scrollable sub parts of the page as it results in a confusing user experience, with scrolling sometimes scrolling sub parts and at other times scrolling the page itself. For this reason iframes and framesets are barely usable on touch devices. This will flatten all the frames to become one scrollable page. - Disabled by default. + This is disabled by default. */ /*! @@ -525,7 +533,8 @@ void QWebSettings::resetFontSize(FontSize type) with UTF-8 and Base64 encoded data, such as: "data:text/css;charset=utf-8;base64,cCB7IGJhY2tncm91bmQtY29sb3I6IHJlZCB9Ow==" - NOTE: In case the base 64 data is not valid the style will not be applied. + + \note If the base64 data is not valid, the style will not be applied. \sa userStyleSheetUrl() */ @@ -576,9 +585,11 @@ QString QWebSettings::defaultTextEncoding() const Sets the path of the icon database to \a path. The icon database is used to store "favicons" associated with web sites. - \a path must point to an existing directory where the icons are stored. + \a path must point to an existing directory. Setting an empty path disables the icon database. + + \sa iconDatabasePath(), clearIconDatabase() */ void QWebSettings::setIconDatabasePath(const QString& path) { @@ -621,7 +632,7 @@ void QWebSettings::clearIconDatabase() /*! Returns the web site's icon for \a url. - If the web site does not specify an icon, or the icon is not in the + If the web site does not specify an icon \bold OR if the icon is not in the database, a null QIcon is returned. \note The returned icon's size is arbitrary. @@ -658,7 +669,7 @@ QWebPluginDatabase *QWebSettings::pluginDatabase() Sets \a graphic to be drawn when QtWebKit needs to draw an image of the given \a type. - For example, when an image cannot be loaded the pixmap specified by + For example, when an image cannot be loaded, the pixmap specified by \l{QWebSettings::WebGraphic}{MissingImageGraphic} is drawn instead. \sa webGraphic() @@ -676,9 +687,6 @@ void QWebSettings::setWebGraphic(WebGraphic type, const QPixmap& graphic) Returns a previously set pixmap used to draw replacement graphics of the specified \a type. - For example, when an image cannot be loaded the pixmap specified by - \l{QWebSettings::WebGraphic}{MissingImageGraphic} is drawn instead. - \sa setWebGraphic() */ QPixmap QWebSettings::webGraphic(WebGraphic type) @@ -719,8 +727,7 @@ void QWebSettings::clearMemoryCaches() Sets the maximum number of pages to hold in the memory page cache to \a pages. The Page Cache allows for a nicer user experience when navigating forth or back - to pages in the forward/back history, by pausing and resuming up to \a pages - per page group. + to pages in the forward/back history, by pausing and resuming up to \a pages. For more information about the feature, please refer to: @@ -792,8 +799,8 @@ QString QWebSettings::fontFamily(FontFamily which) const } /*! - Resets the actual font family to the default font family, specified by - \a which. + Resets the actual font family specified by \a which to the one set + in the global QWebSettings instance. This function has no effect on the global QWebSettings instance. */ @@ -835,7 +842,9 @@ bool QWebSettings::testAttribute(WebAttribute attr) const /*! \fn void QWebSettings::resetAttribute(WebAttribute attribute) - Resets the setting of \a attribute. + Resets the setting of \a attribute to the value specified in the + global QWebSettings instance. + This function has no effect on the global QWebSettings instance. \sa globalSettings() @@ -851,12 +860,15 @@ void QWebSettings::resetAttribute(WebAttribute attr) /*! \since 4.5 - Sets the path for HTML5 offline storage to \a path. + Sets \a path as the save location for HTML5 client-side database storage data. - \a path must point to an existing directory where the databases are stored. + \a path must point to an existing directory. Setting an empty path disables the feature. + Support for client-side databases can enabled by setting the + \l{QWebSettings::OfflineStorageDatabaseEnabled}{OfflineStorageDatabaseEnabled} attribute. + \sa offlineStoragePath() */ void QWebSettings::setOfflineStoragePath(const QString& path) @@ -869,7 +881,7 @@ void QWebSettings::setOfflineStoragePath(const QString& path) /*! \since 4.5 - Returns the path of the HTML5 offline storage or an empty string if the + Returns the path of the HTML5 client-side database storage or an empty string if the feature is disabled. \sa setOfflineStoragePath() @@ -906,22 +918,24 @@ qint64 QWebSettings::offlineStorageDefaultQuota() /*! \since 4.6 - \relates QWebSettings Sets the path for HTML5 offline web application cache storage to \a path. An application cache acts like an HTTP cache in some sense. For documents - that use the application cache via JavaScript, the loader mechinery will + that use the application cache via JavaScript, the loader engine will first ask the application cache for the contents, before hitting the network. The feature is described in details at: http://dev.w3.org/html5/spec/Overview.html#appcache - \a path must point to an existing directory where the cache is stored. + \a path must point to an existing directory. Setting an empty path disables the feature. + Support for offline web application cache storage can enabled by setting the + \l{QWebSettings::OfflineWebApplicationCacheEnabled}{OfflineWebApplicationCacheEnabled} attribute. + \sa offlineWebApplicationCachePath() */ void QWebSettings::setOfflineWebApplicationCachePath(const QString& path) @@ -933,7 +947,6 @@ void QWebSettings::setOfflineWebApplicationCachePath(const QString& path) /*! \since 4.6 - \relates QWebSettings Returns the path of the HTML5 offline web application cache storage or an empty string if the feature is disabled. @@ -980,7 +993,6 @@ qint64 QWebSettings::offlineWebApplicationCacheQuota() /*! \since 4.6 - \relates QWebSettings Sets the path for HTML5 local storage to \a path. @@ -1025,7 +1037,6 @@ QUrl QWebSettings::inspectorUrl() const /*! \since 4.6 - \relates QWebSettings Returns the path for HTML5 local storage. @@ -1038,13 +1049,14 @@ QString QWebSettings::localStoragePath() const /*! \since 4.6 - \relates QWebSettings - Enables WebKit persistent data and sets the path to \a path. - If the \a path is empty the path for persistent data is set to the - user-specific data location specified by - \l{QDesktopServices::DataLocation}{DataLocation}. - + Enables WebKit data persistence and sets the path to \a path. + If \a path is empty, the user-specific data location specified by + \l{QDesktopServices::DataLocation}{DataLocation} will be used instead. + + This method will simultaneously set and enable the iconDatabasePath(), + localStoragePath(), offlineStoragePath() and offlineWebApplicationCachePath(). + \sa localStoragePath() */ void QWebSettings::enablePersistentStorage(const QString& path) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h index d2e536e..3592e2c 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h @@ -63,7 +63,7 @@ public: OfflineStorageDatabaseEnabled, OfflineWebApplicationCacheEnabled, LocalStorageEnabled, -#ifdef QT_DEPRECATED +#if defined(QT_DEPRECATED) || defined(qdoc) LocalStorageDatabaseEnabled = LocalStorageEnabled, #endif LocalContentCanAccessRemoteUrls, diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 6ddaa2b..efc8f27 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,102 @@ +2010-05-14 Kent Hansen <kent.hansen@nokia.com>, Jocelyn Turcotte <jocelyn.turcotte@nokia.com>, Tor Arne Vestbø <tor.arne.vestbo@nokia.com>, Henry Haverinen <henry.haverinen@nokia.com>, Jedrzej Nowacki <jedrzej.nowacki@nokia.com>, Andreas Kling <andreas.kling@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Merge overhaul of the QtWebKit API documentation + + Numerous improvements in wording, qdoc warning fixes and + clarifications, done in a team work effort. + + No functional changes. + + * Api/qwebdatabase.cpp: + * Api/qwebelement.cpp: + * Api/qwebframe.cpp: + * Api/qwebhistoryinterface.cpp: + * Api/qwebinspector.cpp: + * Api/qwebkitversion.cpp: + * Api/qwebpage.cpp: + * Api/qwebpluginfactory.cpp: + * Api/qwebsecurityorigin.cpp: + * Api/qwebsettings.cpp: + * Api/qwebsettings.h: + * docs/qtwebkit.qdoc: + * docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp: + (wrapInFunction): + * docs/webkitsnippets/webelement/main.cpp: + (findButtonAndClick): + (autocomplete1): + (autocomplete2): + (main): + +2010-05-14 Martin Smith <msmith@trolltech.com> + + Reviewed by Simon Hausmann. + + Documentation: Fix overview grouping. + + * docs/qtwebkit.qdoc: + +2010-05-14 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Laszlo Gombos. + + [QT] Update the Symbian version for the user agent + https://bugs.webkit.org/show_bug.cgi?id=38389 + + Update the user agent for Symbian^2 to Symbian^4 + + * Api/qwebpage.cpp: + (QWebPage::userAgentForUrl): + +2010-05-11 Antonio Gomes <tonikitoo@webkit.org> + + Reviewed by Kenneth Christiansen. + + [Qt] emit initialLayoutCompleted signal from FrameLoaderClientQt::dispatchDidFirstVisuallyNonEmptyLayout + https://bugs.webkit.org/show_bug.cgi?id=38921 + + Emit initialLayoutCompleted signal from FrameLoaderClientQt::dispatchDidFirstVisuallyNonEmptyLayout + instead of FrameLoaderClientQt::dispatchDidFirstLayout , because the former ensures that a + visual content layed out on the frame. + + It matches to QWebFrame::initialLayoutCompleted signal documentation at: + + "... This is the first time you will see contents displayed on the frame ..." + + * WebCoreSupport/FrameLoaderClientQt.cpp: + (WebCore::FrameLoaderClientQt::dispatchDidFirstLayout): + (WebCore::FrameLoaderClientQt::dispatchDidFirstVisuallyNonEmptyLayout): + +2010-05-11 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Laszlo Gombos. + + [Qt] REGRESSION(r58497) tst_QGraphicsWebView::crashOnViewlessWebPages() is failing + https://bugs.webkit.org/show_bug.cgi?id=38655 + + Fix double free by moving the connect till after the resize. + + The bug is causes by the fact that a resize of an empty page causes a + layout, thus deleting the qgraphicswebview before setHtml is called, + which then deletes it again, causing a double free. + + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView::crashOnViewlessWebPages): + +2010-05-11 Diego Gonzalez <diegohcg@webkit.org> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] tst_QWebPage::inputMethods failing on Maemo5 + https://bugs.webkit.org/show_bug.cgi?id=38685 + + Check if the SIP (Software Input Panel) is triggered, which normally + happens on mobile platforms, when a user input form receives a mouse click. + + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::inputMethods): + 2010-05-09 Noam Rosenthal <noam.rosenthal@nokia.com> Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index 4ad008b..686bfcc 100644 --- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -414,13 +414,13 @@ void FrameLoaderClientQt::dispatchDidFinishLoad() void FrameLoaderClientQt::dispatchDidFirstLayout() { - if (m_webFrame) - emit m_webFrame->initialLayoutCompleted(); + notImplemented(); } void FrameLoaderClientQt::dispatchDidFirstVisuallyNonEmptyLayout() { - notImplemented(); + if (m_webFrame) + emit m_webFrame->initialLayoutCompleted(); } void FrameLoaderClientQt::dispatchShow() diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc index 96eb16e..c6dd550 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc +++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc @@ -7,63 +7,9 @@ \ingroup modules \ingroup technology-apis - \brief The QtWebKit module provides a web browser engine and + \brief The QtWebKit module provides a web browser engine as well as classes to render and interact with web content. - To include the definitions of the module's classes, use the - following directive: - - \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 1 - - To link against the module, add this line to your \l qmake \c - .pro file: - - \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 0 - - \section1 License Information - - This is a snapshot of the Qt port of WebKit. The exact version information - can be found in the \c{src/3rdparty/webkit/VERSION} file supplied with Qt. - - Qt Commercial Edition licensees that wish to distribute applications that - use the QtWebKit module need to be aware of their obligations under the - GNU Library General Public License (LGPL). - - Developers using the Open Source Edition can choose to redistribute - the module under the appropriate version of the GNU LGPL. - - \legalese - WebKit is licensed under the GNU Library General Public License. - Individual contributor names and copyright dates can be found - inline in the code. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - \endlegalese -*/ - -/*! - \page webintegration.html - \title Integrating Web Content with QtWebKit - \since 4.4 - - \ingroup frameworks-technologies - - \keyword Browser - \keyword Web Browser - QtWebKit provides a Web browser engine that makes it easy to embed content from the World Wide Web into your Qt application. At the same time Web content can be enhanced with native controls. @@ -85,6 +31,20 @@ QtWebKit is based on the Open Source WebKit engine. More information about WebKit itself can be found on the \l{WebKit Open Source Project} Web site. + \section1 Including In Your Project + + To include the definitions of the module's classes, use the + following directive: + + \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 1 + + To link against the module, add this line to your \l qmake \c + .pro file: + + \snippet webkitsnippets/qtwebkit_build_snippet.qdoc 0 + + \section1 Notes + \note Building the QtWebKit module with debugging symbols is problematic on many platforms due to the size of the WebKit engine. We recommend building the module only in release mode for embedded platforms. @@ -99,10 +59,6 @@ Embedded Linux systems. See the \l{Qt for Embedded Linux Requirements} document for more information. - Topics: - - \tableofcontents - \section1 Architecture The easiest way to render content is through the QWebView class. As a @@ -195,4 +151,39 @@ \o The system \c{/Library/Internet Plug-Ins} directory \endlist \endtable + + + \section1 License Information + + This is a snapshot of the Qt port of WebKit. The exact version information + can be found in the \c{src/3rdparty/webkit/VERSION} file supplied with Qt. + + Qt Commercial Edition licensees that wish to distribute applications that + use the QtWebKit module need to be aware of their obligations under the + GNU Library General Public License (LGPL). + + Developers using the Open Source Edition can choose to redistribute + the module under the appropriate version of the GNU LGPL. + + \legalese + WebKit is licensed under the GNU Library General Public License. + Individual contributor names and copyright dates can be found + inline in the code. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + \endlegalese */ + diff --git a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp index a6b6620..07f1d45 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp +++ b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp @@ -9,8 +9,6 @@ void wrapInFunction() QWebInspector *inspector = new QWebInspector; inspector->setPage(page); - - connect(page, SIGNAL(webInspectorTriggered(QWebElement)), inspector, SLOT(show())); //! [0] } diff --git a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webelement/main.cpp b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webelement/main.cpp index 822b61c..b1781a6 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webelement/main.cpp +++ b/src/3rdparty/webkit/WebKit/qt/docs/webkitsnippets/webelement/main.cpp @@ -36,6 +36,59 @@ static void traverse() //! [Traversing with QWebElement] } +static void findButtonAndClick() +{ + + frame->setHtml("<form name=\"myform\" action=\"submit_form.asp\" method=\"get\">" + "<input type=\"text\" name=\"myfield\">" + "<input type=\"submit\" value=\"Submit\">" + "</form>"); + +//! [Calling a DOM element method] + + QWebElement document = frame->documentElement(); + /* Assume that the document has the following structure: + + <form name="myform" action="submit_form.asp" method="get"> + <input type="text" name="myfield"> + <input type="submit" value="Submit"> + </form> + + */ + + QWebElement button = document.findFirst("input[type=submit]"); + button.evaluateJavaScript("click()"); + +//! [Calling a DOM element method] + + } + +static void autocomplete1() +{ + QWebElement document = frame->documentElement(); + +//! [autocomplete1] + QWebElement firstTextInput = document.findFirst("input[type=text]"); + QString storedText = firstTextInput.attribute("value"); +//! [autocomplete1] + +} + + +static void autocomplete2() +{ + + QWebElement document = frame->documentElement(); + QString storedText = "text"; + +//! [autocomplete2] + QWebElement firstTextInput = document.findFirst("input[type=text]"); + textInput.setAttribute("value", storedText); +//! [autocomplete2] + +} + + static void findAll() { //! [FindAll] @@ -65,5 +118,8 @@ int main(int argc, char *argv[]) frame = view->page()->mainFrame(); traverse(); findAll(); + findButtonAndClick(); + autocomplete1(); + autocomplete2(); return 0; } diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp index 14f5820..ebe847d 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp @@ -84,16 +84,19 @@ void tst_QGraphicsWebView::crashOnViewlessWebPages() WebPage* page = new WebPage; webView->setPage(page); page->webView = webView; - connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), page, SLOT(aborting())); - scene.addItem(webView); view.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); view.resize(600, 480); webView->resize(view.geometry().size()); + QCoreApplication::processEvents(); view.show(); + // Resizing the page will resize and layout the empty "about:blank" + // page, so we first connect the signal afterward. + connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), page, SLOT(aborting())); + page->mainFrame()->setHtml(QString("data:text/html," "<frameset cols=\"25%,75%\">" "<frame src=\"data:text/html,foo \">" @@ -101,6 +104,7 @@ void tst_QGraphicsWebView::crashOnViewlessWebPages() "</frameset>")); QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); + delete page; } void tst_QGraphicsWebView::microFocusCoordinates() diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 834a394..12fb9b3 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -26,6 +26,7 @@ #include <QLocale> #include <QMenu> #include <QPushButton> +#include <QStyle> #include <QtTest/QtTest> #include <QTextCharFormat> #include <qgraphicsscene.h> @@ -1367,7 +1368,27 @@ void tst_QWebPage::inputMethods() page->event(&evrel); #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) - QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); + // This part of the test checks if the SIP (Software Input Panel) is triggered, + // which normally happens on mobile platforms, when a user input form receives + // a mouse click. + int inputPanel = 0; + if (viewType == "QWebView") { + if (QWebView* wv = qobject_cast<QWebView*>(view)) + inputPanel = wv->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel); + } else if (viewType == "QGraphicsWebView") { + if (QGraphicsWebView* wv = qobject_cast<QGraphicsWebView*>(view)) + inputPanel = wv->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel); + } + + // For non-mobile platforms RequestSoftwareInputPanel event is not called + // because there is no SIP (Software Input Panel) triggered. In the case of a + // mobile platform, an input panel, e.g. virtual keyboard, is usually invoked + // and the RequestSoftwareInputPanel event is called. For these two situations + // this part of the test can verified as the checks below. + if (inputPanel) + QVERIFY(viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); + else + QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel)); #endif viewEventSpy.clear(); diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index fe78c84..e1874b8 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1651,6 +1651,9 @@ qreal QDeclarativeGridView::maxXExtent() const void QDeclarativeGridView::keyPressEvent(QKeyEvent *event) { Q_D(QDeclarativeGridView); + keyPressPreHandler(event); + if (event->isAccepted()) + return; if (d->model && d->model->count() && d->interactive) { d->moveReason = QDeclarativeGridViewPrivate::SetIndex; int oldCurrent = currentIndex(); @@ -1676,10 +1679,8 @@ void QDeclarativeGridView::keyPressEvent(QKeyEvent *event) } } d->moveReason = QDeclarativeGridViewPrivate::Other; - QDeclarativeFlickable::keyPressEvent(event); - if (event->isAccepted()) - return; event->ignore(); + QDeclarativeFlickable::keyPressEvent(event); } /*! diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index f251ba1..9547884 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -375,7 +375,7 @@ void QDeclarativeContents::childAdded(QDeclarativeItem *item) } QDeclarativeItemKeyFilter::QDeclarativeItemKeyFilter(QDeclarativeItem *item) -: m_next(0) +: m_processPost(false), m_next(0) { QDeclarativeItemPrivate *p = item?static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(item)):0; @@ -389,19 +389,19 @@ QDeclarativeItemKeyFilter::~QDeclarativeItemKeyFilter() { } -void QDeclarativeItemKeyFilter::keyPressed(QKeyEvent *event) +void QDeclarativeItemKeyFilter::keyPressed(QKeyEvent *event, bool post) { - if (m_next) m_next->keyPressed(event); + if (m_next) m_next->keyPressed(event, post); } -void QDeclarativeItemKeyFilter::keyReleased(QKeyEvent *event) +void QDeclarativeItemKeyFilter::keyReleased(QKeyEvent *event, bool post) { - if (m_next) m_next->keyReleased(event); + if (m_next) m_next->keyReleased(event, post); } -void QDeclarativeItemKeyFilter::inputMethodEvent(QInputMethodEvent *event) +void QDeclarativeItemKeyFilter::inputMethodEvent(QInputMethodEvent *event, bool post) { - if (m_next) m_next->inputMethodEvent(event); + if (m_next) m_next->inputMethodEvent(event, post); } QVariant QDeclarativeItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const @@ -463,9 +463,11 @@ void QDeclarativeItemKeyFilter::componentComplete() } \endcode - KeyNavigation receives key events after the item it is attached to. + By default KeyNavigation receives key events after the item it is attached to. If the item accepts an arrow key event, the KeyNavigation - attached property will not receive an event for that key. + attached property will not receive an event for that key. Setting the + \l priority property to KeyNavigation.BeforeItem allows handling + of the key events before normal item processing. If an item has been set for a direction and the KeyNavigation attached property receives the corresponding @@ -490,6 +492,7 @@ QDeclarativeKeyNavigationAttached::QDeclarativeKeyNavigationAttached(QObject *pa : QObject(*(new QDeclarativeKeyNavigationAttachedPrivate), parent), QDeclarativeItemKeyFilter(qobject_cast<QDeclarativeItem*>(parent)) { + m_processPost = true; } QDeclarativeKeyNavigationAttached * @@ -576,12 +579,45 @@ void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i) emit changed(); } -void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event) +/*! + \qmlproperty enumeration KeyNavigation::priority + + This property determines whether the keys are processed before + or after the attached item's own key handling. + + \list + \o KeyNavigation.BeforeItem - process the key events before normal + item key processing. If the event is accepted it will not + be passed on to the item. + \o KeyNavigation.AfterItem (default) - process the key events after normal item key + handling. If the item accepts the key event it will not be + handled by the KeyNavigation attached property handler. + \endlist +*/ +QDeclarativeKeyNavigationAttached::Priority QDeclarativeKeyNavigationAttached::priority() const { - Q_D(QDeclarativeKeyNavigationAttached); + return m_processPost ? AfterItem : BeforeItem; +} + +void QDeclarativeKeyNavigationAttached::setPriority(Priority order) +{ + bool processPost = order == AfterItem; + if (processPost != m_processPost) { + m_processPost = processPost; + emit priorityChanged(); + } +} +void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event, bool post) +{ + Q_D(QDeclarativeKeyNavigationAttached); event->ignore(); + if (post != m_processPost) { + QDeclarativeItemKeyFilter::keyPressed(event, post); + return; + } + switch(event->key()) { case Qt::Key_Left: if (d->left) { @@ -623,15 +659,19 @@ void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event) break; } - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event); + if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event, post); } -void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event) +void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) { Q_D(QDeclarativeKeyNavigationAttached); - event->ignore(); + if (post != m_processPost) { + QDeclarativeItemKeyFilter::keyReleased(event, post); + return; + } + switch(event->key()) { case Qt::Key_Left: if (d->left) { @@ -667,7 +707,7 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event) break; } - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event); + if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post); } /*! @@ -709,6 +749,28 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event) See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. + If priority is Keys.BeforeItem (default) the order of key event processing is: + + \list 1 + \o Items specified in \c forwardTo + \o specific key handlers, e.g. onReturnPressed + \o onKeyPress, onKeyRelease handlers + \o Item specific key handling, e.g. TextInput key handling + \o parent item + \endlist + + If priority is Keys.AfterItem the order of key event processing is: + \list 1 + \o Item specific key handling, e.g. TextInput key handling + \o Items specified in \c forwardTo + \o specific key handlers, e.g. onReturnPressed + \o onKeyPress, onKeyRelease handlers + \o parent item + \endlist + + If the event is accepted during any of the above steps, key + propagation stops. + \sa KeyEvent, {KeyNavigation}{KeyNavigation attached property} */ @@ -720,6 +782,22 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event) */ /*! + \qmlproperty enumeration Keys::priority + + This property determines whether the keys are processed before + or after the attached item's own key handling. + + \list + \o Keys.BeforeItem (default) - process the key events before normal + item key processing. If the event is accepted it will not + be passed on to the item. + \o Keys.AfterItem - process the key events after normal item key + handling. If the item accepts the key event it will not be + handled by the Keys attached property handler. + \endlist +*/ + +/*! \qmlproperty list<Object> Keys::forwardTo This property provides a way to forward key presses, key releases, and keyboard input @@ -1039,6 +1117,7 @@ QDeclarativeKeysAttached::QDeclarativeKeysAttached(QObject *parent) QDeclarativeItemKeyFilter(qobject_cast<QDeclarativeItem*>(parent)) { Q_D(QDeclarativeKeysAttached); + m_processPost = false; d->item = qobject_cast<QDeclarativeItem*>(parent); } @@ -1046,6 +1125,20 @@ QDeclarativeKeysAttached::~QDeclarativeKeysAttached() { } +QDeclarativeKeysAttached::Priority QDeclarativeKeysAttached::priority() const +{ + return m_processPost ? AfterItem : BeforeItem; +} + +void QDeclarativeKeysAttached::setPriority(Priority order) +{ + bool processPost = order == AfterItem; + if (processPost != m_processPost) { + m_processPost = processPost; + emit priorityChanged(); + } +} + void QDeclarativeKeysAttached::componentComplete() { Q_D(QDeclarativeKeysAttached); @@ -1060,11 +1153,12 @@ void QDeclarativeKeysAttached::componentComplete() } } -void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event) +void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event, bool post) { Q_D(QDeclarativeKeysAttached); - if (!d->enabled || d->inPress) { + if (post != m_processPost || !d->enabled || d->inPress) { event->ignore(); + QDeclarativeItemKeyFilter::keyPressed(event, post); return; } @@ -1099,14 +1193,15 @@ void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event) emit pressed(&ke); event->setAccepted(ke.isAccepted()); - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event); + if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event, post); } -void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event) +void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event, bool post) { Q_D(QDeclarativeKeysAttached); - if (!d->enabled || d->inRelease) { + if (post != m_processPost || !d->enabled || d->inRelease) { event->ignore(); + QDeclarativeItemKeyFilter::keyReleased(event, post); return; } @@ -1129,13 +1224,13 @@ void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event) emit released(&ke); event->setAccepted(ke.isAccepted()); - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event); + if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post); } -void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event) +void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post) { Q_D(QDeclarativeKeysAttached); - if (d->item && !d->inIM && d->item->scene()) { + if (post == m_processPost && d->item && !d->inIM && d->item->scene()) { d->inIM = true; for (int ii = 0; ii < d->targets.count(); ++ii) { QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); @@ -1150,7 +1245,7 @@ void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event) } d->inIM = false; } - if (!event->isAccepted()) QDeclarativeItemKeyFilter::inputMethodEvent(event); + if (!event->isAccepted()) QDeclarativeItemKeyFilter::inputMethodEvent(event, post); } class QDeclarativeItemAccessor : public QGraphicsItem @@ -1822,8 +1917,11 @@ void QDeclarativeItemPrivate::removeItemChangeListener(QDeclarativeItemChangeLis void QDeclarativeItem::keyPressEvent(QKeyEvent *event) { Q_D(QDeclarativeItem); + keyPressPreHandler(event); + if (event->isAccepted()) + return; if (d->keyHandler) - d->keyHandler->keyPressed(event); + d->keyHandler->keyPressed(event, true); else event->ignore(); } @@ -1832,8 +1930,11 @@ void QDeclarativeItem::keyPressEvent(QKeyEvent *event) void QDeclarativeItem::keyReleaseEvent(QKeyEvent *event) { Q_D(QDeclarativeItem); + keyReleasePreHandler(event); + if (event->isAccepted()) + return; if (d->keyHandler) - d->keyHandler->keyReleased(event); + d->keyHandler->keyReleased(event, true); else event->ignore(); } @@ -1842,8 +1943,11 @@ void QDeclarativeItem::keyReleaseEvent(QKeyEvent *event) void QDeclarativeItem::inputMethodEvent(QInputMethodEvent *event) { Q_D(QDeclarativeItem); + inputMethodPreHandler(event); + if (event->isAccepted()) + return; if (d->keyHandler) - d->keyHandler->inputMethodEvent(event); + d->keyHandler->inputMethodEvent(event, true); else event->ignore(); } @@ -1862,6 +1966,37 @@ QVariant QDeclarativeItem::inputMethodQuery(Qt::InputMethodQuery query) const return v; } +void QDeclarativeItem::keyPressPreHandler(QKeyEvent *event) +{ + Q_D(QDeclarativeItem); + if (d->keyHandler && !d->doneEventPreHandler) + d->keyHandler->keyPressed(event, false); + else + event->ignore(); + d->doneEventPreHandler = true; +} + +void QDeclarativeItem::keyReleasePreHandler(QKeyEvent *event) +{ + Q_D(QDeclarativeItem); + if (d->keyHandler && !d->doneEventPreHandler) + d->keyHandler->keyReleased(event, false); + else + event->ignore(); + d->doneEventPreHandler = true; +} + +void QDeclarativeItem::inputMethodPreHandler(QInputMethodEvent *event) +{ + Q_D(QDeclarativeItem); + if (d->keyHandler && !d->doneEventPreHandler) + d->keyHandler->inputMethodEvent(event, false); + else + event->ignore(); + d->doneEventPreHandler = true; +} + + /*! \internal */ @@ -2976,6 +3111,17 @@ void QDeclarativeItem::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidg */ bool QDeclarativeItem::event(QEvent *ev) { + Q_D(QDeclarativeItem); + switch (ev->type()) { + case QEvent::KeyPress: + case QEvent::KeyRelease: + case QEvent::InputMethod: + d->doneEventPreHandler = false; + break; + default: + break; + } + return QGraphicsObject::event(ev); } diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h index 3b05b09..29fd241 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.h +++ b/src/declarative/graphicsitems/qdeclarativeitem.h @@ -178,6 +178,10 @@ protected: virtual void keyReleaseEvent(QKeyEvent *event); virtual void inputMethodEvent(QInputMethodEvent *); virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; + void keyPressPreHandler(QKeyEvent *); + void keyReleasePreHandler(QKeyEvent *); + void inputMethodPreHandler(QInputMethodEvent *); + virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 516d6d0..15b34f0 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -124,7 +124,7 @@ public: _stateGroup(0), origin(QDeclarativeItem::Center), widthValid(false), heightValid(false), _componentComplete(true), _keepMouse(false), - smooth(false), transformOriginDirty(true), keyHandler(0), + smooth(false), transformOriginDirty(true), doneEventPreHandler(false), keyHandler(0), mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0) { QGraphicsItemPrivate::acceptedMouseButtons = 0; @@ -263,6 +263,7 @@ public: bool _keepMouse:1; bool smooth:1; bool transformOriginDirty : 1; + bool doneEventPreHandler : 1; QDeclarativeItemKeyFilter *keyHandler; @@ -324,12 +325,14 @@ public: QDeclarativeItemKeyFilter(QDeclarativeItem * = 0); virtual ~QDeclarativeItemKeyFilter(); - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); - virtual void inputMethodEvent(QInputMethodEvent *event); + virtual void keyPressed(QKeyEvent *event, bool post); + virtual void keyReleased(QKeyEvent *event, bool post); + virtual void inputMethodEvent(QInputMethodEvent *event, bool post); virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; virtual void componentComplete(); + bool m_processPost; + private: QDeclarativeItemKeyFilter *m_next; }; @@ -359,6 +362,9 @@ class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeIte Q_PROPERTY(QDeclarativeItem *down READ down WRITE setDown NOTIFY changed) Q_PROPERTY(QDeclarativeItem *tab READ tab WRITE setTab NOTIFY changed) Q_PROPERTY(QDeclarativeItem *backtab READ backtab WRITE setBacktab NOTIFY changed) + Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged) + + Q_ENUMS(Priority) public: QDeclarativeKeyNavigationAttached(QObject * = 0); @@ -376,14 +382,19 @@ public: QDeclarativeItem *backtab() const; void setBacktab(QDeclarativeItem *); + enum Priority { BeforeItem, AfterItem }; + Priority priority() const; + void setPriority(Priority); + static QDeclarativeKeyNavigationAttached *qmlAttachedProperties(QObject *); Q_SIGNALS: void changed(); + void priorityChanged(); private: - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); + virtual void keyPressed(QKeyEvent *event, bool post); + virtual void keyReleased(QKeyEvent *event, bool post); }; class QDeclarativeKeysAttachedPrivate : public QObjectPrivate @@ -423,6 +434,9 @@ class QDeclarativeKeysAttached : public QObject, public QDeclarativeItemKeyFilte Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> forwardTo READ forwardTo) + Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged) + + Q_ENUMS(Priority) public: QDeclarativeKeysAttached(QObject *parent=0); @@ -437,6 +451,10 @@ public: } } + enum Priority { BeforeItem, AfterItem}; + Priority priority() const; + void setPriority(Priority); + QDeclarativeListProperty<QDeclarativeItem> forwardTo() { Q_D(QDeclarativeKeysAttached); return QDeclarativeListProperty<QDeclarativeItem>(this, d->targets); @@ -448,6 +466,7 @@ public: Q_SIGNALS: void enabledChanged(); + void priorityChanged(); void pressed(QDeclarativeKeyEvent *event); void released(QDeclarativeKeyEvent *event); void digit0Pressed(QDeclarativeKeyEvent *event); @@ -492,9 +511,9 @@ Q_SIGNALS: void volumeDownPressed(QDeclarativeKeyEvent *event); private: - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); - virtual void inputMethodEvent(QInputMethodEvent *); + virtual void keyPressed(QKeyEvent *event, bool post); + virtual void keyReleased(QKeyEvent *event, bool post); + virtual void inputMethodEvent(QInputMethodEvent *, bool post); virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; const QByteArray keyToSignal(int key) { diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index b71bb7e..936f9b0 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -2263,6 +2263,9 @@ qreal QDeclarativeListView::maxXExtent() const void QDeclarativeListView::keyPressEvent(QKeyEvent *event) { Q_D(QDeclarativeListView); + keyPressPreHandler(event); + if (event->isAccepted()) + return; if (d->model && d->model->count() && d->interactive) { if ((d->orient == QDeclarativeListView::Horizontal && event->key() == Qt::Key_Left) @@ -2287,10 +2290,8 @@ void QDeclarativeListView::keyPressEvent(QKeyEvent *event) } } } - QDeclarativeFlickable::keyPressEvent(event); - if (event->isAccepted()) - return; event->ignore(); + QDeclarativeFlickable::keyPressEvent(event); } /*! diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 7edd53c..cbdfd87 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -321,6 +321,7 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() emit q->statusChanged(); emit q->progressChanged(); emit q->itemChanged(); + emit q->loaded(); } } @@ -341,10 +342,13 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() of the following ways: \list \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: loader.status = Loader.Ready;} - \o Do something inside the onStatusChanged signal handler, e.g. Loader{id: loader; onStatusChanged: if(loader.status == Loader.Ready) console.log('Loaded');} + \o Do something inside the onLoaded signal handler, e.g. Loader{id: loader; onLoaded: console.log('Loaded');} \o Bind to the status variable somewhere, e.g. Text{text: if(loader.status!=Loader.Ready){'Not Loaded';}else{'Loaded';}} \endlist \sa progress + + Note that if the source is a local file, the status will initially be Ready (or Error). While + there will be no onStatusChanged signal in that case, the onLoaded will still be invoked. */ QDeclarativeLoader::Status QDeclarativeLoader::status() const @@ -360,6 +364,21 @@ QDeclarativeLoader::Status QDeclarativeLoader::status() const return d->source.isEmpty() ? Null : Error; } +void QDeclarativeLoader::componentComplete() +{ + if (status() == Ready) + emit loaded(); +} + + +/*! + \qmlsignal Loader::onLoaded() + + This handler is called when the \l status becomes Loader.Ready, or on successful + initial load. +*/ + + /*! \qmlproperty real Loader::progress @@ -382,7 +401,6 @@ qreal QDeclarativeLoader::progress() const return 0.0; } - void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged) { Q_Q(QDeclarativeLoader); diff --git a/src/declarative/graphicsitems/qdeclarativeloader_p.h b/src/declarative/graphicsitems/qdeclarativeloader_p.h index 49dfa11..ec7ffe9 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader_p.h +++ b/src/declarative/graphicsitems/qdeclarativeloader_p.h @@ -84,11 +84,14 @@ Q_SIGNALS: void sourceChanged(); void statusChanged(); void progressChanged(); + void loaded(); protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); QVariant itemChange(GraphicsItemChange change, const QVariant &value); bool eventFilter(QObject *watched, QEvent *e); + void componentComplete(); + private: Q_DISABLE_COPY(QDeclarativeLoader) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeLoader) diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 93bff3e..8796e63 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -204,7 +204,11 @@ void QDeclarativeBasePositioner::prePositioning() if (!isComponentComplete()) return; + if (d->doingPositioning) + return; + d->queuedPositioning = false; + d->doingPositioning = true; //Need to order children by creation order modified by stacking order QList<QGraphicsItem *> children = d->QGraphicsItemPrivate::children; qSort(children.begin(), children.end(), d->insertionOrder); @@ -242,6 +246,7 @@ void QDeclarativeBasePositioner::prePositioning() doPositioning(&contentSize); if(d->addTransition || d->moveTransition) finishApplyTransitions(); + d->doingPositioning = false; //Set implicit size to the size of its children setImplicitHeight(contentSize.height()); setImplicitWidth(contentSize.width()); @@ -339,7 +344,8 @@ Column { Note that the positioner assumes that the x and y positions of its children will not change. If you manually change the x or y properties in script, bind - the x or y properties, or use anchors on a child of a positioner, then the + the x or y properties, use anchors on a child of a positioner, or have the + height of a child depend on the position of a child, then the positioner may exhibit strange behaviour. */ @@ -437,7 +443,7 @@ void QDeclarativeColumn::doPositioning(QSizeF *contentSize) void QDeclarativeColumn::reportConflictingAnchors() { - bool childsWithConflictingAnchors(false); + QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item) { @@ -446,15 +452,16 @@ void QDeclarativeColumn::reportConflictingAnchors() QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors(); if (usedAnchors & QDeclarativeAnchors::TopAnchor || usedAnchors & QDeclarativeAnchors::BottomAnchor || - usedAnchors & QDeclarativeAnchors::VCenterAnchor) { - childsWithConflictingAnchors = true; + usedAnchors & QDeclarativeAnchors::VCenterAnchor || + anchors->fill() || anchors->centerIn()) { + d->anchorConflict = true; break; } } } } - if (childsWithConflictingAnchors) { - qmlInfo(this) << "Cannot specify top, bottom or verticalCenter anchors for items inside Column"; + if (d->anchorConflict) { + qmlInfo(this) << "Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column"; } } @@ -486,7 +493,8 @@ Row { Note that the positioner assumes that the x and y positions of its children will not change. If you manually change the x or y properties in script, bind - the x or y properties, or use anchors on a child of a positioner, then the + the x or y properties, use anchors on a child of a positioner, or have the + width of a child depend on the position of a child, then the positioner may exhibit strange behaviour. */ @@ -574,7 +582,7 @@ void QDeclarativeRow::doPositioning(QSizeF *contentSize) void QDeclarativeRow::reportConflictingAnchors() { - bool childsWithConflictingAnchors(false); + QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item) { @@ -583,16 +591,16 @@ void QDeclarativeRow::reportConflictingAnchors() QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors(); if (usedAnchors & QDeclarativeAnchors::LeftAnchor || usedAnchors & QDeclarativeAnchors::RightAnchor || - usedAnchors & QDeclarativeAnchors::HCenterAnchor) { - childsWithConflictingAnchors = true; + usedAnchors & QDeclarativeAnchors::HCenterAnchor || + anchors->fill() || anchors->centerIn()) { + d->anchorConflict = true; break; } } } } - if (childsWithConflictingAnchors) { - qmlInfo(this) << "Cannot specify left, right or horizontalCenter anchors for items inside Row"; - } + if (d->anchorConflict) + qmlInfo(this) << "Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row"; } /*! @@ -638,7 +646,8 @@ Grid { Note that the positioner assumes that the x and y positions of its children will not change. If you manually change the x or y properties in script, bind - the x or y properties, or use anchors on a child of a positioner, then the + the x or y properties, use anchors on a child of a positioner, or have the + width or height of a child depend on the position of a child, then the positioner may exhibit strange behaviour. */ /*! @@ -866,20 +875,19 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize) void QDeclarativeGrid::reportConflictingAnchors() { - bool childsWithConflictingAnchors(false); + QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item) { QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors; - if (anchors && anchors->usedAnchors()) { - childsWithConflictingAnchors = true; + if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) { + d->anchorConflict = true; break; } } } - if (childsWithConflictingAnchors) { + if (d->anchorConflict) qmlInfo(this) << "Cannot specify anchors for items inside Grid"; - } } /*! @@ -888,6 +896,11 @@ void QDeclarativeGrid::reportConflictingAnchors() \brief The Flow item lines up its children side by side, wrapping as necessary. \inherits Item + Note that the positioner assumes that the x and y positions of its children + will not change. If you manually change the x or y properties in script, bind + the x or y properties, use anchors on a child of a positioner, or have the + width or height of a child depend on the position of a child, then the + positioner may exhibit strange behaviour. */ /*! @@ -1026,20 +1039,19 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize) void QDeclarativeFlow::reportConflictingAnchors() { - bool childsWithConflictingAnchors(false); + Q_D(QDeclarativeFlow); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item) { QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors; - if (anchors && anchors->usedAnchors()) { - childsWithConflictingAnchors = true; + if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) { + d->anchorConflict = true; break; } } } - if (childsWithConflictingAnchors) { + if (d->anchorConflict) qmlInfo(this) << "Cannot specify anchors for items inside Flow"; - } } QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h index 576f35b..04f0181 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h @@ -75,6 +75,7 @@ public: QDeclarativeBasePositionerPrivate() : spacing(0), type(QDeclarativeBasePositioner::None) , moveTransition(0), addTransition(0), queuedPositioning(false) + , doingPositioning(false), anchorConflict(false) { } @@ -95,7 +96,9 @@ public: void watchChanges(QDeclarativeItem *other); void unwatchChanges(QDeclarativeItem* other); - bool queuedPositioning; + bool queuedPositioning : 1; + bool doingPositioning : 1; + bool anchorConflict : 1; virtual void itemSiblingOrderChanged(QDeclarativeItem* other) { diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index db20da8..45b79a7 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -858,8 +858,9 @@ Handles the given key \a event. void QDeclarativeTextEdit::keyPressEvent(QKeyEvent *event) { Q_D(QDeclarativeTextEdit); - d->control->processEvent(event, QPointF(0, 0)); - + keyPressPreHandler(event); + if (!event->isAccepted()) + d->control->processEvent(event, QPointF(0, 0)); if (!event->isAccepted()) QDeclarativePaintedItem::keyPressEvent(event); } @@ -871,7 +872,9 @@ Handles the given key \a event. void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event) { Q_D(QDeclarativeTextEdit); - d->control->processEvent(event, QPointF(0, 0)); + keyReleasePreHandler(event); + if (!event->isAccepted()) + d->control->processEvent(event, QPointF(0, 0)); if (!event->isAccepted()) QDeclarativePaintedItem::keyReleaseEvent(event); } @@ -903,10 +906,8 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) if (d->focusOnPress){ QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope? while(p) { - if(p->flags() & QGraphicsItem::ItemIsFocusScope){ + if (p->flags() & QGraphicsItem::ItemIsFocusScope) p->setFocus(); - break; - } p = p->parentItem(); } setFocus(true); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index b00f724..8aa7e99 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -863,6 +863,9 @@ void QDeclarativeTextInputPrivate::focusChanged(bool hasFocus) void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev) { Q_D(QDeclarativeTextInput); + keyPressPreHandler(ev); + if (ev->isAccepted()) + return; if (((ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down) && ev->modifiers() == Qt::NoModifier) // Don't allow MacOSX up/down support, and we don't allow a completer. || (((d->control->cursor() == 0 && ev->key() == Qt::Key_Left) || (d->control->cursor() == d->control->text().length() @@ -886,10 +889,8 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) if(d->focusOnPress){ QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope? while(p) { - if(p->flags() & QGraphicsItem::ItemIsFocusScope){ + if (p->flags() & QGraphicsItem::ItemIsFocusScope) p->setFocus(); - break; - } p = p->parentItem(); } setFocus(true); diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm index 24498f8..2b9cf85 100644 --- a/src/gui/kernel/qcocoawindowdelegate_mac.mm +++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm @@ -202,6 +202,11 @@ static void cleanupCocoaWindowDelegate() QWindowStateChangeEvent e(Qt::WindowStates(widgetData->window_state & ~Qt::WindowMaximized)); qt_sendSpontaneousEvent(qwidget, &e); + } else { + widgetData->window_state = widgetData->window_state & ~Qt::WindowMaximized; + QWindowStateChangeEvent e(Qt::WindowStates(widgetData->window_state + | Qt::WindowMaximized)); + qt_sendSpontaneousEvent(qwidget, &e); } NSRect rect = [[window contentView] frame]; const QSize newSize(rect.size.width, rect.size.height); @@ -305,9 +310,19 @@ static void cleanupCocoaWindowDelegate() Q_UNUSED(newFrame); // saving the current window geometry before the window is maximized QWidget *qwidget = m_windowHash->value(window); - if (qwidget->isWindow() && !(qwidget->windowState() & Qt::WindowMaximized)) { - QWidgetPrivate *widgetPrivate = qt_widget_private(qwidget); - widgetPrivate->topData()->normalGeometry = qwidget->geometry(); + QWidgetPrivate *widgetPrivate = qt_widget_private(qwidget); + if (qwidget->isWindow()) { + if(qwidget->windowState() & Qt::WindowMaximized) { + // Restoring + widgetPrivate->topData()->wasMaximized = false; + } else { + // Maximizing + widgetPrivate->topData()->normalGeometry = qwidget->geometry(); + // If the window was maximized we need to update the coordinates since now it will start at 0,0. + // We do this in a special field that is only used when not restoring but manually resizing the window. + // Since the coordinates are fixed we just set a boolean flag. + widgetPrivate->topData()->wasMaximized = true; + } } return YES; } diff --git a/src/gui/kernel/qt_mac_p.h b/src/gui/kernel/qt_mac_p.h index 3341ce1..ca9541a 100644 --- a/src/gui/kernel/qt_mac_p.h +++ b/src/gui/kernel/qt_mac_p.h @@ -57,7 +57,9 @@ #ifdef __OBJC__ #include <Cocoa/Cocoa.h> +#ifdef QT_MAC_USE_COCOA #include <objc/runtime.h> +#endif // QT_MAC_USE_COCOA #endif #include <CoreServices/CoreServices.h> diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 4a9fa94..1f2cd8c 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1581,6 +1581,11 @@ void QWidgetPrivate::createTLExtra() x->inTopLevelResize = false; x->inRepaint = false; x->embedded = 0; +#ifdef Q_WS_MAC +#ifdef QT_MAC_USE_COCOA + x->wasMaximized = false; +#endif // QT_MAC_USE_COCOA +#endif // Q_WS_MAC createTLSysExtra(); #ifdef QWIDGET_EXTRA_DEBUG static int count = 0; @@ -6720,6 +6725,18 @@ void QWidget::setGeometry(const QRect &r) */ QByteArray QWidget::saveGeometry() const { +#ifdef QT_MAC_USE_COCOA + // We check if the window was maximized during this invocation. If so, we need to record the + // starting position as 0,0. + Q_D(const QWidget); + QRect newFramePosition = frameGeometry(); + QRect newNormalPosition = normalGeometry(); + if(d->topData()->wasMaximized && !(windowState() & Qt::WindowMaximized)) { + // Change the starting position + newFramePosition.moveTo(0, 0); + newNormalPosition.moveTo(0, 0); + } +#endif // QT_MAC_USE_COCOA QByteArray array; QDataStream stream(&array, QIODevice::WriteOnly); stream.setVersion(QDataStream::Qt_4_0); @@ -6729,8 +6746,13 @@ QByteArray QWidget::saveGeometry() const stream << magicNumber << majorVersion << minorVersion +#ifdef QT_MAC_USE_COCOA + << newFramePosition + << newNormalPosition +#else << frameGeometry() << normalGeometry() +#endif // QT_MAC_USE_COCOA << qint32(QApplication::desktop()->screenNumber(this)) << quint8(windowState() & Qt::WindowMaximized) << quint8(windowState() & Qt::WindowFullScreen); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index cad60b5..3f494d8 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -170,6 +170,14 @@ struct QTLWExtra { WindowGroupRef group; IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys. quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys() +#ifdef QT_MAC_USE_COCOA + // This value is just to make sure we maximize and restore to the right location, yet we allow apps to be maximized and + // manually resized. + // The name is misleading, since this is set when maximizing the window. It is a hint to saveGeometry(..) to record the + // starting position as 0,0 instead of the normal starting position. + bool wasMaximized; +#endif // QT_MAC_USE_COCOA + #elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS #ifndef QT_NO_QWS_MANAGER QWSManager *qwsManager; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index afba678..c7a9756 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1947,7 +1947,7 @@ QVariant QTextDocument::loadResource(int type, const QUrl &name) #endif // handle data: URLs - if (r.isNull() && name.scheme() == QLatin1String("data")) + if (r.isNull() && name.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) r = qDecodeDataUrl(name).second; // if resource was not loaded try to load it here diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 452d37d..410cf21 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -57,21 +57,13 @@ QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyph , ctx(context) , m_width(0) , m_height(0) - , m_broken_fbo_readback(false) { // broken FBO readback is a bug in the SGX 1.3 and 1.4 drivers for the N900 where // copying between FBO's is broken if the texture is either GL_ALPHA or POT. The // workaround is to use a system-memory copy of the glyph cache for this device. // Switching to NPOT and GL_RGBA would both cost a lot more graphics memory and // be slower, so that is not desireable. -#if defined QT_OPENGL_ES_2 && !defined(QT_NO_EGL) - if (QByteArray((char*) glGetString(GL_RENDERER)).contains("SGX")) { - QGLContextPrivate *ctxd = context->d_func(); - m_broken_fbo_readback = QByteArray((char *) eglQueryString(ctxd->eglContext->display(), EGL_VERSION)).contains("1.3"); - } -#endif - - if (!m_broken_fbo_readback) + if (!ctx->d_ptr->workaround_brokenFBOReadBack) glGenFramebuffers(1, &m_fbo); connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), @@ -83,7 +75,7 @@ QGLTextureGlyphCache::~QGLTextureGlyphCache() if (ctx) { QGLShareContextScope scope(ctx); - if (!m_broken_fbo_readback) + if (!ctx->d_ptr->workaround_brokenFBOReadBack) glDeleteFramebuffers(1, &m_fbo); if (m_width || m_height) @@ -96,9 +88,15 @@ void QGLTextureGlyphCache::createTextureData(int width, int height) // create in QImageTextureGlyphCache baseclass is meant to be called // only to create the initial image and does not preserve the content, // so we don't call when this function is called from resize. - if (m_broken_fbo_readback && image().isNull()) + if (ctx->d_ptr->workaround_brokenFBOReadBack && image().isNull()) QImageTextureGlyphCache::createTextureData(width, height); + // Make the lower glyph texture size 16 x 16. + if (width < 16) + width = 16; + if (height < 16) + height = 16; + glGenTextures(1, &m_texture); glBindTexture(GL_TEXTURE_2D, m_texture); @@ -123,10 +121,16 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) int oldWidth = m_width; int oldHeight = m_height; + // Make the lower glyph texture size 16 x 16. + if (width < 16) + width = 16; + if (height < 16) + height = 16; + GLuint oldTexture = m_texture; createTextureData(width, height); - if (m_broken_fbo_readback) { + if (ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::resizeTextureData(width, height); Q_ASSERT(image().depth() == 8); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, image().constBits()); @@ -209,7 +213,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) { - if (m_broken_fbo_readback) { + if (ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::fillTexture(c, glyph); glBindTexture(GL_TEXTURE_2D, m_texture); diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index efb7435..6bcd655 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -115,8 +115,6 @@ private: int m_height; QGLShaderProgram *m_program; - - bool m_broken_fbo_readback; }; QT_END_NAMESPACE diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 7c457de..922a96c 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1612,6 +1612,9 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) current_fbo = 0; default_fbo = 0; active_engine = 0; + workaround_needsFullClearOnEveryFrame = false; + workaround_brokenFBOReadBack = false; + workaroundsCached = false; for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) vertexAttributeArraysEnabledState[i] = false; } diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 92a064f..f297009 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -431,6 +431,7 @@ private: friend class QGLFramebufferObjectPrivate; friend class QGLFBOGLPaintDevice; friend class QGLPaintDevice; + friend class QGLWidgetGLPaintDevice; friend class QX11GLPixmapData; friend class QX11GLSharedContexts; private: diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 0fbbbf9..44e8ae9 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -185,8 +185,26 @@ void QGLContext::makeCurrent() return; } - if (d->eglContext->makeCurrent(d->eglSurfaceForDevice())) + if (d->eglContext->makeCurrent(d->eglSurfaceForDevice())) { QGLContextPrivate::setCurrentContext(this); + if (!d->workaroundsCached) { + d->workaroundsCached = true; + const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER)); + if (strstr(renderer, "SGX") || strstr(renderer, "MBX")) { + // PowerVR MBX/SGX chips needs to clear all buffers when starting to render + // a new frame, otherwise there will be a performance penalty to pay for + // each frame. + d->workaround_needsFullClearOnEveryFrame = true; + + // Older PowerVR SGX drivers (like the one in the N900) have a + // bug which prevents glCopyTexSubImage2D() to work with a POT + // or GL_ALPHA texture bound to an FBO. The only way to + // identify that driver is to check the EGL version number for it. + if (strstr(eglQueryString(d->eglContext->display(), EGL_VERSION), "1.3")) + d->workaround_brokenFBOReadBack = true; + } + } + } } void QGLContext::doneCurrent() diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index f19e394..d92f963 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -345,7 +345,7 @@ public: HDC hbitmap_hdc; #endif #ifndef QT_NO_EGL - bool ownsEglContext; + uint ownsEglContext : 1; QEglContext *eglContext; EGLSurface eglSurface; void destroyEglSurfaceForDevice(); @@ -382,6 +382,12 @@ public: uint internal_context : 1; uint version_flags_cached : 1; uint extension_flags_cached : 1; + + // workarounds for driver/hw bugs on different platforms + uint workaround_needsFullClearOnEveryFrame : 1; + uint workaround_brokenFBOReadBack : 1; + uint workaroundsCached : 1; + QPaintDevice *paintDevice; QColor transpColor; QGLContext *q_ptr; diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index e874e85..e1dcbfd 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -175,7 +175,10 @@ void QGLWidgetGLPaintDevice::beginPaint() float alpha = c.alphaF(); glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); } - glClear(GL_COLOR_BUFFER_BIT); + if (context()->d_func()->workaround_needsFullClearOnEveryFrame) + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + else + glClear(GL_COLOR_BUFFER_BIT); } } diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 5fc0edb..3cd18fb 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -53,15 +53,17 @@ QT_BEGIN_NAMESPACE QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) - : CActive(CActive::EPriorityStandard), engine(engine), ipConnectionNotifier(0), - iError(QNetworkSession::UnknownSessionError), - iALREnabled(0), iConnectInBackground(false) + : CActive(CActive::EPriorityUserInput), engine(engine), + ipConnectionNotifier(0), iHandleStateNotificationsFromManager(false), + iFirstSync(true), iStoppedByUser(false), iClosedByUser(false), iDeprecatedConnectionId(0), + iError(QNetworkSession::UnknownSessionError), iALREnabled(0), iConnectInBackground(false) { CActiveScheduler::Add(this); #ifdef SNAP_FUNCTIONALITY_AVAILABLE iMobility = NULL; #endif + TRAP_IGNORE(iConnectionMonitor.ConnectL()); } @@ -90,18 +92,72 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() // Close global 'Open C' RConnection setdefaultif(0); - - iConnectionMonitor.CancelNotifications(); + iConnectionMonitor.Close(); } +void QNetworkSessionPrivateImpl::configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState) +{ + if (iHandleStateNotificationsFromManager) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "configurationStateChanged from manager for IAP : " << QString::number(accessPointId) + << "configurationStateChanged connMon ID : " << QString::number(connMonId) + << " : to a state: " << newState + << " whereas my current state is: " << state; +#endif + if (connMonId == iDeprecatedConnectionId) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "however status update from manager ignored because it related to already closed connection."; +#endif + return; + } + this->newState(newState, accessPointId); + } +} + +void QNetworkSessionPrivateImpl::configurationRemoved(QNetworkConfigurationPrivatePointer config) +{ + if (!publicConfig.isValid()) + return; + + SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(config); + + symbianConfig->mutex.lock(); + TUint32 configNumericId = symbianConfig->numericId; + symbianConfig->mutex.unlock(); + + symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); + + symbianConfig->mutex.lock(); + TUint32 publicNumericId = symbianConfig->numericId; + symbianConfig->mutex.unlock(); + + if (configNumericId == publicNumericId) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "configurationRemoved IAP: " << QString::number(publicNumericId) << " : going to State: Invalid"; +#endif + this->newState(QNetworkSession::Invalid, publicNumericId); + } +} + void QNetworkSessionPrivateImpl::syncStateWithInterface() { if (!publicConfig.isValid()) return; - // Start monitoring changes in IAP states - TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); + if (iFirstSync && publicConfig.isValid()) { + QObject::connect(engine, SIGNAL(configurationStateChanged(TUint32, TUint32, QNetworkSession::State)), + this, SLOT(configurationStateChanged(TUint32, TUint32, QNetworkSession::State))); + // Listen to configuration removals, so that in case the configuration + // this session is based on is removed, session knows to enter Invalid -state. + QObject::connect(engine, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); + } + // Start listening IAP state changes from QNetworkConfigurationManagerPrivate + iHandleStateNotificationsFromManager = true; // Check open connections to see if there is already // an open connection to selected IAP or SNAP @@ -137,11 +193,8 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface() } if (state != QNetworkSession::Connected) { - // There were no open connections to used IAP or SNAP - if (iError == QNetworkSession::InvalidConfigurationError) { - newState(QNetworkSession::Invalid); - } else if ((publicConfig.state() & QNetworkConfiguration::Discovered) == - QNetworkConfiguration::Discovered) { + if ((publicConfig.state() & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { newState(QNetworkSession::Disconnected); } else { newState(QNetworkSession::NotAvailable); @@ -245,13 +298,18 @@ QNetworkSession::SessionError QNetworkSessionPrivateImpl::error() const void QNetworkSessionPrivateImpl::open() { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "open() called, session state is: " << state << " and isOpen is: " + << isOpen; +#endif if (isOpen || (state == QNetworkSession::Connecting)) { return; } - - // Cancel notifications from RConnectionMonitor + + // Stop handling IAP state change signals from QNetworkConfigurationManagerPrivate // => RConnection::ProgressNotification will be used for IAP/SNAP monitoring - iConnectionMonitor.CancelNotifications(); + iHandleStateNotificationsFromManager = false; // Configuration may have been invalidated after session creation by platform // (e.g. configuration has been deleted). @@ -259,19 +317,25 @@ void QNetworkSessionPrivateImpl::open() newState(QNetworkSession::Invalid); iError = QNetworkSession::InvalidConfigurationError; emit QNetworkSessionPrivate::error(iError); - syncStateWithInterface(); return; } - // If opening a (un)defined configuration, session emits error and enters - // NotAvailable -state. - if (publicConfig.state() == QNetworkConfiguration::Undefined || - publicConfig.state() == QNetworkConfiguration::Defined) { + // If opening a undefined configuration, session emits error and enters + // NotAvailable -state. Note that we will try ones in 'defined' state to avoid excessive + // need for WLAN scans (via updateConfigurations()), because user may have walked + // into a WLAN range, but periodic background scan has not occurred yet --> + // we don't want to force application to make frequent updateConfigurations() calls + // to be able to try if e.g. home WLAN is available. + if (publicConfig.state() == QNetworkConfiguration::Undefined) { newState(QNetworkSession::NotAvailable); iError = QNetworkSession::InvalidConfigurationError; emit QNetworkSessionPrivate::error(iError); return; } - + // Clear possible previous states + iStoppedByUser = false; + iClosedByUser = false; + iDeprecatedConnectionId = 0; + TInt error = iSocketServ.Connect(); if (error != KErrNone) { // Could not open RSocketServ @@ -446,16 +510,18 @@ TUint QNetworkSessionPrivateImpl::iapClientCount(TUint aIAPId) const void QNetworkSessionPrivateImpl::close(bool allowSignals) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "close() called, session state is: " << state << " and isOpen is : " + << isOpen; +#endif if (!isOpen) { return; } - - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(activeConfig)); - - symbianConfig->mutex.lock(); - TUint activeIap = symbianConfig->numericId; - symbianConfig->mutex.unlock(); + // Mark this session as closed-by-user so that we are able to report + // distinguish between stop() and close() state transitions + // when reporting. + iClosedByUser = true; isOpen = false; activeConfig = QNetworkConfiguration(); @@ -469,8 +535,10 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) } #endif - if (ipConnectionNotifier) { + if (ipConnectionNotifier && !iHandleStateNotificationsFromManager) { ipConnectionNotifier->StopNotifications(); + // Start handling IAP state change signals from QNetworkConfigurationManagerPrivate + iHandleStateNotificationsFromManager = true; } iConnection.Close(); @@ -479,29 +547,31 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) // Close global 'Open C' RConnection setdefaultif(0); -#ifdef Q_CC_NOKIAX86 - if ((allowSignals && iapClientCount(activeIap) <= 0) || -#else - if ((allowSignals && iapClientCount(activeIap) <= 1) || -#endif - (publicConfig.type() == QNetworkConfiguration::UserChoice)) { + if (publicConfig.type() == QNetworkConfiguration::UserChoice) { newState(QNetworkSession::Closing); + newState(QNetworkSession::Disconnected); } - syncStateWithInterface(); if (allowSignals) { - if (publicConfig.type() == QNetworkConfiguration::UserChoice) { - newState(QNetworkSession::Disconnected); - } emit closed(); } } void QNetworkSessionPrivateImpl::stop() { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "stop() called, session state is: " << state << " and isOpen is : " + << isOpen; +#endif if (!isOpen && publicConfig.isValid() && publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "since session is not open, using RConnectionMonitor to stop() the interface"; +#endif + iStoppedByUser = true; // If the publicConfig is type of IAP, enumerate through connections at // connection monitor. If publicConfig is active in that list, stop it. // Otherwise there is nothing to stop. Note: because this QNetworkSession is not open, @@ -515,7 +585,7 @@ void QNetworkSessionPrivateImpl::stop() } TUint numSubConnections; // Not used but needed by GetConnectionInfo i/f TUint connectionId; - for (TInt i = 1; i <= count; ++i) { + for (TUint i = 1; i <= count; ++i) { // Get (connection monitor's assigned) connection ID TInt ret = iConnectionMonitor.GetConnectionInfo(i, connectionId, numSubConnections); if (ret == KErrNone) { @@ -532,11 +602,25 @@ void QNetworkSessionPrivateImpl::stop() ETrue); } } + // Enter disconnected state right away since the session is not even open. + // Symbian^3 connection monitor does not emit KLinkLayerClosed when + // connection is stopped via connection monitor. + newState(QNetworkSession::Disconnected); } } else if (isOpen) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "since session is open, using RConnection to stop() the interface"; +#endif // Since we are open, use RConnection to stop the interface isOpen = false; + iStoppedByUser = true; newState(QNetworkSession::Closing); + if (ipConnectionNotifier) { + ipConnectionNotifier->StopNotifications(); + // Start handling IAP state change signals from QNetworkConfigurationManagerPrivate + iHandleStateNotificationsFromManager = true; + } iConnection.Stop(RConnection::EStopAuthoritative); isOpen = true; close(false); @@ -654,6 +738,10 @@ void QNetworkSessionPrivateImpl::NewCarrierActive(TAccessPointInfo /*aNewAPInfo* void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "roaming Error() occured"; +#endif if (isOpen) { isOpen = false; activeConfig = QNetworkConfiguration(); @@ -671,6 +759,11 @@ void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) // changes immediately to Disconnected. newState(QNetworkSession::Disconnected); emit closed(); + } else if (iStoppedByUser) { + // If the user of this session has called the stop() and + // configuration is based on internet SNAP, this needs to be + // done here because platform might roam. + newState(QNetworkSession::Disconnected); } } #endif @@ -975,7 +1068,12 @@ void QNetworkSessionPrivateImpl::RunL() isOpen = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); - iError = QNetworkSession::UnknownSessionError; + if (publicConfig.state() == QNetworkConfiguration::Undefined || + publicConfig.state() == QNetworkConfiguration::Defined) { + iError = QNetworkSession::InvalidConfigurationError; + } else { + iError = QNetworkSession::UnknownSessionError; + } emit QNetworkSessionPrivate::error(iError); Cancel(); if (ipConnectionNotifier) { @@ -991,8 +1089,16 @@ void QNetworkSessionPrivateImpl::DoCancel() iConnection.Close(); } +// Enters newState if feasible according to current state. +// AccessPointId may be given as parameter. If it is zero, state-change is assumed to +// concern this session's configuration. If non-zero, the configuration is looked up +// and checked if it matches the configuration this session is based on. bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint accessPointId) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "NEW STATE, IAP ID : " << QString::number(accessPointId) << " , newState : " << QString::number(newState); +#endif // Make sure that activeConfig is always updated when SNAP is signaled to be // connected. if (isOpen && publicConfig.type() == QNetworkConfiguration::ServiceNetwork && @@ -1027,9 +1133,29 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint if (state == QNetworkSession::Roaming && newState == QNetworkSession::Connecting) { return false; } + + // Make sure that Connected state is not reported when Connection is + // already Closing. + // Note: Stopping connection results sometimes KLinkLayerOpen + // to be reported first (just before KLinkLayerClosed). + if (state == QNetworkSession::Closing && newState == QNetworkSession::Connected) { + return false; + } + + // Make sure that some lagging 'closing' state-changes do not overwrite + // if we are already disconnected or closed. + if (state == QNetworkSession::Disconnected && newState == QNetworkSession::Closing) { + return false; + } bool emitSessionClosed = false; - if (isOpen && state == QNetworkSession::Connected && newState == QNetworkSession::Disconnected) { + + // If we abruptly go down and user hasn't closed the session, we've been aborted. + // Note that session may be in 'closing' state and not in 'connected' state, because + // depending on platform the platform may report KConfigDaemonStartingDeregistration + // event before KLinkLayerClosed + if ((isOpen && state == QNetworkSession::Connected && newState == QNetworkSession::Disconnected) || + (isOpen && !iClosedByUser && newState == QNetworkSession::Disconnected)) { // Active & Connected state should change directly to Disconnected state // only when something forces connection to close (eg. when another // application or session stops connection or when network drops @@ -1043,14 +1169,17 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); } - // Start monitoring changes in IAP states - TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); + // Start handling IAP state change signals from QNetworkConfigurationManagerPrivate + iHandleStateNotificationsFromManager = true; emitSessionClosed = true; // Emit SessionClosed after state change has been reported } bool retVal = false; if (accessPointId == 0) { state = newState; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed A to: " << state; +#endif emit stateChanged(state); retVal = true; } else { @@ -1063,6 +1192,9 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint configLocker.unlock(); state = newState; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed B to: " << state; +#endif emit stateChanged(state); retVal = true; } @@ -1075,6 +1207,9 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint configLocker.unlock(); state = newState; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed C to: " << state; +#endif emit stateChanged(state); retVal = true; } @@ -1087,21 +1222,14 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint QMutexLocker configLocker(&symbianConfig->mutex); if (symbianConfig->numericId == accessPointId) { - if (newState == QNetworkSession::Connected) { - // Make sure that when AccessPoint is reported to be Connected - // also state of the related configuration changes to Active. - symbianConfig->state = QNetworkConfiguration::Active; - configLocker.unlock(); - + if (newState != QNetworkSession::Disconnected) { state = newState; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed D to: " << state; +#endif emit stateChanged(state); retVal = true; } else { - if (newState == QNetworkSession::Disconnected) { - // Make sure that when AccessPoint is reported to be disconnected - // also state of the related configuration changes from Active to Defined. - symbianConfig->state = QNetworkConfiguration::Defined; - } QNetworkConfiguration config = bestConfigFromSNAP(publicConfig); if ((config.state() == QNetworkConfiguration::Defined) || (config.state() == QNetworkConfiguration::Discovered)) { @@ -1109,8 +1237,21 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint configLocker.unlock(); state = newState; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed E to: " << state; +#endif emit stateChanged(state); retVal = true; + } else if (config.state() == QNetworkConfiguration::Active) { + // Connection to used IAP was closed, but there is another + // IAP that's active in used SNAP + // => Change state back to Connected + state = QNetworkSession::Connected; + emit stateChanged(state); + retVal = true; +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed F to: " << state; +#endif } } } @@ -1121,6 +1262,19 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint if (emitSessionClosed) { emit closed(); } + if (state == QNetworkSession::Disconnected) { + // The connection has gone down, and processing of status updates must be + // stopped. Depending on platform, there may come 'connecting/connected' states + // considerably later (almost a second). Connection id is an increasing + // number, so this does not affect next _real_ 'conneting/connected' states. + + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + + symbianConfig->mutex.lock(); + iDeprecatedConnectionId = symbianConfig->connectionId; + symbianConfig->mutex.unlock(); + } return retVal; } @@ -1129,6 +1283,9 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne TInt aError, TUint accessPointId) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << QString::number(accessPointId) << " , status : " << QString::number(aConnectionStatus); +#endif switch (aConnectionStatus) { // Connection unitialised @@ -1167,6 +1324,7 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne case KCsdGotLoginInfo: break; + case KConfigDaemonStartingRegistration: // Creating connection (e.g. GPRS activation) case KCsdStartingConnect: case KCsdFinishedConnect: @@ -1193,6 +1351,7 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne case KDataTransferTemporarilyBlocked: break; + case KConfigDaemonStartingDeregistration: // Hangup or GRPS deactivation case KConnectionStartingClose: newState(QNetworkSession::Closing,accessPointId); @@ -1200,137 +1359,27 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne // Connection closed case KConnectionClosed: - break; - case KLinkLayerClosed: newState(QNetworkSession::Disconnected,accessPointId); + // Report manager about this to make sure this event + // is received by all interseted parties (mediated by + // manager because it does always receive all events from + // connection monitor). +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "reporting disconnection to manager."; +#endif + if (publicConfig.isValid()) { + engine->configurationStateChangeReport(toSymbianConfig(privateConfiguration(publicConfig))->numericId, QNetworkSession::Disconnected); + } break; - // Unhandled state default: break; } } -void QNetworkSessionPrivateImpl::EventL(const CConnMonEventBase& aEvent) -{ - switch (aEvent.EventType()) - { - case EConnMonConnectionStatusChange: - { - CConnMonConnectionStatusChange* realEvent; - realEvent = (CConnMonConnectionStatusChange*) &aEvent; - - TUint connectionId = realEvent->ConnectionId(); - TInt connectionStatus = realEvent->ConnectionStatus(); - - // Try to Find IAP Id using connection Id - TUint apId = 0; - if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { - QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); - for (int i = 0; i < subConfigurations.count(); i++ ) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(subConfigurations[i])); - - QMutexLocker configLocker(&symbianConfig->mutex); - - if (symbianConfig->connectionId == connectionId) { - apId = symbianConfig->numericId; - break; - } - } - } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - - symbianConfig->mutex.lock(); - if (symbianConfig->connectionId == connectionId) - apId = symbianConfig->numericId; - symbianConfig->mutex.unlock(); - } - - if (apId > 0) { - handleSymbianConnectionStatusChange(connectionStatus, KErrNone, apId); - } - } - break; - - case EConnMonCreateConnection: - { - CConnMonCreateConnection* realEvent; - realEvent = (CConnMonCreateConnection*) &aEvent; - TUint apId; - TUint connectionId = realEvent->ConnectionId(); - TRequestStatus status; - iConnectionMonitor.GetUintAttribute(connectionId, 0, KIAPId, apId, status); - User::WaitForRequest(status); - if (status.Int() == KErrNone) { - // Store connection id to related AccessPoint Configuration - if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { - QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); - for (int i = 0; i < subConfigurations.count(); i++ ) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(subConfigurations[i])); - - QMutexLocker configLocker(&symbianConfig->mutex); - - if (symbianConfig->numericId == apId) { - symbianConfig->connectionId = connectionId; - break; - } - } - } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - - symbianConfig->mutex.lock(); - if (symbianConfig->numericId == apId) - symbianConfig->connectionId = connectionId; - symbianConfig->mutex.unlock(); - } - } - } - break; - - case EConnMonDeleteConnection: - { - CConnMonDeleteConnection* realEvent; - realEvent = (CConnMonDeleteConnection*) &aEvent; - TUint connectionId = realEvent->ConnectionId(); - // Remove connection id from related AccessPoint Configuration - if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { - QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); - for (int i = 0; i < subConfigurations.count(); i++ ) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(subConfigurations[i])); - - QMutexLocker configLocker(&symbianConfig->mutex); - - if (symbianConfig->connectionId == connectionId) { - symbianConfig->connectionId = 0; - break; - } - } - } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - - symbianConfig->mutex.lock(); - if (symbianConfig->connectionId == connectionId) - symbianConfig->connectionId = 0; - symbianConfig->mutex.unlock(); - } - } - break; - - default: - // For unrecognized events - break; - } -} - -ConnectionProgressNotifier::ConnectionProgressNotifier(QNetworkSessionPrivateImpl &owner, RConnection &connection) - : CActive(CActive::EPriorityStandard), iOwner(owner), iConnection(connection) +ConnectionProgressNotifier::ConnectionProgressNotifier(QNetworkSessionPrivateImpl& owner, RConnection& connection) + : CActive(CActive::EPriorityUserInput), iOwner(owner), iConnection(connection) { CActiveScheduler::Add(this); } diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index 7116519..9767293 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -75,9 +75,8 @@ class SymbianEngine; class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive, #ifdef SNAP_FUNCTIONALITY_AVAILABLE - public MMobilityProtocolResp, + public MMobilityProtocolResp #endif - public MConnectionMonitorObserver { Q_OBJECT public: @@ -130,8 +129,9 @@ protected: // From CActive void RunL(); void DoCancel(); -private: // MConnectionMonitorObserver - void EventL(const CConnMonEventBase& aEvent); +private Q_SLOTS: + void configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState); + void configurationRemoved(QNetworkConfigurationPrivatePointer config); private: TUint iapClientCount(TUint aIAPId) const; @@ -157,6 +157,13 @@ private: // data mutable RConnection iConnection; mutable RConnectionMonitor iConnectionMonitor; ConnectionProgressNotifier* ipConnectionNotifier; + + bool iHandleStateNotificationsFromManager; + bool iFirstSync; + bool iStoppedByUser; + bool iClosedByUser; + TUint32 iDeprecatedConnectionId; + #ifdef SNAP_FUNCTIONALITY_AVAILABLE CActiveCommsMobilityApiExt* iMobility; #endif diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 8e9675e..cea8b67 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -45,14 +45,14 @@ #include <commdb.h> #include <cdbcols.h> #include <d32dbms.h> +#include <nifvar.h> #include <QEventLoop> #include <QTimer> #include <QTime> // For randgen seeding #include <QtCore> // For randgen seeding -// #define QT_BEARERMGMT_CONFIGMGR_DEBUG -#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG #include <QDebug> #endif @@ -73,7 +73,9 @@ QT_BEGIN_NAMESPACE -static const int KValueThatWillBeAddedToSNAPId = 1000; +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + static const int KValueThatWillBeAddedToSNAPId = 1000; +#endif static const int KUserChoiceIAPId = 0; SymbianNetworkConfigurationPrivate::SymbianNetworkConfigurationPrivate() @@ -657,26 +659,34 @@ void SymbianEngine::updateActiveAccessPoints() iConnectionMonitor.GetConnectionCount(connectionCount, status); User::WaitForRequest(status); - // Go through all connections and set state of related IAPs to Active + // Go through all connections and set state of related IAPs to Active. + // Status needs to be checked carefully, because ConnMon lists also e.g. + // WLAN connections that are being currently tried --> we don't want to + // state these as active. TUint connectionId; TUint subConnectionCount; TUint apId; + TInt connectionStatus; if (status.Int() == KErrNone) { for (TUint i = 1; i <= connectionCount; i++) { iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount); iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); QString ident = QString::number(qHash(apId)); - QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { - online = true; - inactiveConfigs.removeOne(ident); + iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); + User::WaitForRequest(status); + if (connectionStatus == KLinkLayerOpen) { + online = true; + inactiveConfigs.removeOne(ident); - toSymbianConfig(ptr)->connectionId = connectionId; + QMutexLocker configLocker(&ptr->mutex); + toSymbianConfig(ptr)->connectionId = connectionId; - // Configuration is Active - changeConfigurationStateTo(ptr, QNetworkConfiguration::Active); + // Configuration is Active + changeConfigurationStateTo(ptr, QNetworkConfiguration::Active); + } } } } @@ -733,12 +743,12 @@ void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapIn } } - // Make sure that state of rest of the IAPs won't be Discovered or Active + // Make sure that state of rest of the IAPs won't be Active foreach (const QString &iface, unavailableConfigs) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); if (ptr) { // Configuration is Defined - changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Defined); + changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered); } } } @@ -894,21 +904,22 @@ void SymbianEngine::RunL() QMutexLocker locker(&mutex); if (iIgnoringUpdates) { -#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG - qDebug("CommsDB event handling postponed (postpone-timer running because IAPs/SNAPs were updated very recently)."); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug("QNCM CommsDB event handling postponed (postpone-timer running because IAPs/SNAPs were updated very recently)."); #endif return; } if (iStatus != KErrCancel) { RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int()); + switch (event) { case RDbNotifier::EUnlock: /** All read locks have been removed. */ case RDbNotifier::ECommit: /** A transaction has been committed. */ case RDbNotifier::ERollback: /** A transaction has been rolled back */ case RDbNotifier::ERecover: /** The database has been recovered */ -#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG - qDebug("CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug("QNCM CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); #endif iIgnoringUpdates = true; // Other events than ECommit get lower priority. In practice with those events, @@ -957,73 +968,95 @@ void SymbianEngine::DoCancel() ipCommsDB->CancelRequestNotification(); } - void SymbianEngine::EventL(const CConnMonEventBase& aEvent) { QMutexLocker locker(&mutex); switch (aEvent.EventType()) { - case EConnMonCreateConnection: + case EConnMonConnectionStatusChange: { - CConnMonCreateConnection* realEvent; - realEvent = (CConnMonCreateConnection*) &aEvent; - TUint subConnectionCount = 0; - TUint apId; - TUint connectionId = realEvent->ConnectionId(); - TRequestStatus status; - iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); - User::WaitForRequest(status); - QString ident = QString::number(qHash(apId)); - - QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); - if (ptr) { - toSymbianConfig(ptr)->connectionId = connectionId; - // Configuration is Active - if (changeConfigurationStateTo(ptr, QNetworkConfiguration::Active)) - updateStatesToSnaps(); - - if (!iOnline) { - iOnline = true; - - locker.unlock(); - emit this->onlineStateChanged(iOnline); - locker.relock(); + CConnMonConnectionStatusChange* realEvent; + realEvent = (CConnMonConnectionStatusChange*) &aEvent; + TInt connectionStatus = realEvent->ConnectionStatus(); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNCM Connection status : " << QString::number(connectionStatus) << " , connection monitor Id : " << realEvent->ConnectionId(); +#endif + if (connectionStatus == KConfigDaemonStartingRegistration) { + TUint connectionId = realEvent->ConnectionId(); + TUint subConnectionCount = 0; + TUint apId; + TRequestStatus status; + iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); + User::WaitForRequest(status); + QString ident = QString::number(qHash(apId)); + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); + if (ptr) { + QMutexLocker configLocker(&ptr->mutex); + toSymbianConfig(ptr)->connectionId = connectionId; + emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Connecting); } - } - } - break; - - case EConnMonDeleteConnection: - { - CConnMonDeleteConnection* realEvent; - realEvent = (CConnMonDeleteConnection*) &aEvent; - TUint connectionId = realEvent->ConnectionId(); - - QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); - if (ptr) { - toSymbianConfig(ptr)->connectionId = 0; - // Configuration is either Defined or Discovered - if (changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered)) - updateStatesToSnaps(); - } - - bool online = false; - foreach (const QString &iface, accessPointConfigurations.keys()) { - QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); - if (ptr->state == QNetworkConfiguration::Active) { - online = true; - break; + } else if (connectionStatus == KLinkLayerOpen) { + // Connection has been successfully opened + TUint connectionId = realEvent->ConnectionId(); + TUint subConnectionCount = 0; + TUint apId; + TRequestStatus status; + iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); + User::WaitForRequest(status); + QString ident = QString::number(qHash(apId)); + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); + if (ptr) { + QMutexLocker configLocker(&ptr->mutex); + toSymbianConfig(ptr)->connectionId = connectionId; + // Configuration is Active + if (changeConfigurationStateTo(ptr, QNetworkConfiguration::Active)) { + updateStatesToSnaps(); + } + emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Connected); + if (!iOnline) { + iOnline = true; + emit this->onlineStateChanged(iOnline); + } } - } - if (iOnline != online) { - iOnline = online; + } else if (connectionStatus == KConfigDaemonStartingDeregistration) { + TUint connectionId = realEvent->ConnectionId(); + QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); + if (ptr) { + QMutexLocker configLocker(&ptr->mutex); + emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Closing); + } + } else if (connectionStatus == KLinkLayerClosed || + connectionStatus == KConnectionClosed) { + // Connection has been closed. Which of the above events is reported, depends on the Symbian + // platform. + TUint connectionId = realEvent->ConnectionId(); + QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); + if (ptr) { + // Configuration is either Defined or Discovered + if (changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered)) { + updateStatesToSnaps(); + } - locker.unlock(); - emit this->onlineStateChanged(iOnline); - locker.relock(); + QMutexLocker configLocker(&ptr->mutex); + emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Disconnected); + } + + bool online = false; + foreach (const QString &iface, accessPointConfigurations.keys()) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); + QMutexLocker configLocker(&ptr->mutex); + if (ptr->state == QNetworkConfiguration::Active) { + online = true; + break; + } + } + if (iOnline != online) { + iOnline = online; + emit this->onlineStateChanged(iOnline); + } } } - break; + break; case EConnMonIapAvailabilityChange: { @@ -1051,21 +1084,78 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) } break; + case EConnMonCreateConnection: + { + // This event is caught to keep connection monitor IDs up-to-date. + CConnMonCreateConnection* realEvent; + realEvent = (CConnMonCreateConnection*) &aEvent; + TUint subConnectionCount = 0; + TUint apId; + TUint connectionId = realEvent->ConnectionId(); + TRequestStatus status; + iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); + User::WaitForRequest(status); + QString ident = QString::number(qHash(apId)); + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); + if (ptr) { + QMutexLocker configLocker(&ptr->mutex); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNCM updating connection monitor ID : from, to, whose: " << toSymbianConfig(ptr)->connectionId << connectionId << ptr->name; +#endif + toSymbianConfig(ptr)->connectionId = connectionId; + } + } + break; default: // For unrecognized events break; } } -// Waits for 1..4 seconds. +// Sessions may use this function to report configuration state changes, +// because on some Symbian platforms (especially Symbian^3) all state changes are not +// reported by the RConnectionMonitor, in particular in relation to stop() call, +// whereas they _are_ reported on RConnection progress notifier used by sessions --> centralize +// this data here so that other sessions may benefit from it too (not all sessions necessarily have +// RConnection progress notifiers available but they relay on having e.g. disconnected information from +// manager). Currently only 'Disconnected' state is of interest because it has proven to be troublesome. +void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetworkSession::State newState) +{ +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNCM A session reported state change for IAP ID: " << accessPointId << " whose new state is: " << newState; +#endif + switch (newState) { + case QNetworkSession::Disconnected: + { + QString ident = QString::number(qHash(accessPointId)); + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); + if (ptr) { + // Configuration is either Defined or Discovered + if (changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered)) { + updateStatesToSnaps(); + } + + QMutexLocker configLocker(&ptr->mutex); + emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, + toSymbianConfig(ptr)->connectionId, + QNetworkSession::Disconnected); + } + } + break; + default: + break; + } +} + +// Waits for 2..6 seconds. void SymbianEngine::waitRandomTime() { - iTimeToWait = (qAbs(qrand()) % 5) * 1000; - if (iTimeToWait < 1000) { - iTimeToWait = 1000; + iTimeToWait = (qAbs(qrand()) % 7) * 1000; + if (iTimeToWait < 2000) { + iTimeToWait = 2000; } -#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG - qDebug("QNetworkConfigurationManager waiting random time: %d ms", iTimeToWait); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug("QNCM waiting random time: %d ms", iTimeToWait); #endif QTimer::singleShot(iTimeToWait, iIgnoreEventLoop, SLOT(quit())); iIgnoreEventLoop->exec(); @@ -1076,11 +1166,11 @@ QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aCon QMutexLocker locker(&mutex); QNetworkConfiguration item; - QHash<QString, QNetworkConfigurationPrivatePointer>::const_iterator i = accessPointConfigurations.constBegin(); while (i != accessPointConfigurations.constEnd()) { QNetworkConfigurationPrivatePointer ptr = i.value(); + QMutexLocker configLocker(&ptr->mutex); if (toSymbianConfig(ptr)->connectionId == aConnectionId) return ptr; diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index afb37de..7d565db 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -52,6 +52,9 @@ #include <cmmanager.h> #endif +// Uncomment and compile QtBearer to gain detailed state tracing +// #define QT_BEARERMGMT_SYMBIAN_DEBUG + class CCommsDatabase; class QEventLoop; @@ -90,7 +93,18 @@ public: Bearer bearer; + // So called IAP id from the platform. Remains constant as long as the + // platform is aware of the configuration ie. it is stored in the databases + // --> does not depend on whether connections are currently open or not. + // In practice is the same for the lifetime of the QNetworkConfiguration. TUint32 numericId; + // So called connection id, or connection monitor ID. A dynamic ID assigned + // by RConnectionMonitor whenever a new connection is opened. ConnectionID and + // numericId/IAP id have 1-to-1 mapping during the lifetime of the connection at + // connection monitor. Notably however it changes whenever a new connection to + // a given IAP is created. In a sense it is constant during the time the + // configuration remains between states Discovered..Active..Discovered, do not + // however relay on this. TUint connectionId; }; @@ -124,6 +138,9 @@ public: Q_SIGNALS: void onlineStateChanged(bool isOnline); + void configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, + QNetworkSession::State newState); + public Q_SLOTS: void updateConfigurations(); @@ -157,12 +174,17 @@ private: void startMonitoringIAPData(TUint32 aIapId); QNetworkConfigurationPrivatePointer dataByConnectionId(TUint aConnectionId); -protected: // From CActive +protected: + // From CActive void RunL(); void DoCancel(); -private: // MConnectionMonitorObserver +private: + // MConnectionMonitorObserver void EventL(const CConnMonEventBase& aEvent); + // For QNetworkSessionPrivate to indicate about state changes + void configurationStateChangeReport(TUint32 accessPointId, + QNetworkSession::State newState); private: // Data bool iFirstUpdate; @@ -181,6 +203,7 @@ private: // Data friend class QNetworkSessionPrivate; friend class AccessPointsAvailabilityScanner; + friend class QNetworkSessionPrivateImpl; #ifdef SNAP_FUNCTIONALITY_AVAILABLE RCmManager iCmManager; diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index 010965c..400fcc1 100644 --- a/tests/auto/bic/tst_bic.cpp +++ b/tests/auto/bic/tst_bic.cpp @@ -191,7 +191,7 @@ void tst_Bic::sizesAndVTables_data() #elif defined Q_OS_MAC && defined(__i386__) # define FILESUFFIX "macx-gcc-ia32" #elif defined Q_OS_MAC && defined(__amd64__) -# define FILESUFFIX "macx-gcc-amd64"; +# define FILESUFFIX "macx-gcc-amd64" #elif defined Q_OS_WIN && defined Q_CC_GNU # define FILESUFFIX "win32-gcc-ia32" #else diff --git a/tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml b/tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml new file mode 100644 index 0000000..171536b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml @@ -0,0 +1,9 @@ +import Qt 4.7 +import Test 1.0 + +KeyTestItem { + focus: true + Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) + Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } + Keys.priority: keysTestObject.processLast ? Keys.AfterItem : Keys.BeforeItem +} diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index f4edeb2..ecc813e 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -55,7 +55,9 @@ public: tst_QDeclarativeItem(); private slots: + void initTestCase(); void keys(); + void keysProcessingOrder(); void keyNavigation(); void smooth(); void clip(); @@ -79,8 +81,11 @@ private: class KeysTestObject : public QObject { Q_OBJECT + + Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged) + public: - KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0) {} + KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {} void reset() { mKey = 0; @@ -89,6 +94,14 @@ public: mForwardedKey = 0; } + bool processLast() const { return mLast; } + void setProcessLast(bool b) { + if (b != mLast) { + mLast = b; + emit processLastChanged(); + } + } + public slots: void keyPress(int key, QString text, int modifiers) { mKey = key; @@ -104,20 +117,73 @@ public slots: mForwardedKey = key; } +signals: + void processLastChanged(); + public: int mKey; QString mText; int mModifiers; int mForwardedKey; + bool mLast; private: }; +class KeyTestItem : public QDeclarativeItem +{ + Q_OBJECT +public: + KeyTestItem(QDeclarativeItem *parent=0) : QDeclarativeItem(parent), mKey(0) {} + +protected: + void keyPressEvent(QKeyEvent *e) { + keyPressPreHandler(e); + if (e->isAccepted()) + return; + + mKey = e->key(); + + if (e->key() == Qt::Key_A) + e->accept(); + else + e->ignore(); + + if (!e->isAccepted()) + QDeclarativeItem::keyPressEvent(e); + } + + void keyReleaseEvent(QKeyEvent *e) { + keyReleasePreHandler(e); + + if (e->isAccepted()) + return; + + if (e->key() == Qt::Key_B) + e->accept(); + else + e->ignore(); + + if (!e->isAccepted()) + QDeclarativeItem::keyReleaseEvent(e); + } + +public: + int mKey; +}; + +QML_DECLARE_TYPE(KeyTestItem); + tst_QDeclarativeItem::tst_QDeclarativeItem() { } +void tst_QDeclarativeItem::initTestCase() +{ + qmlRegisterType<KeyTestItem>("Test",1,0,"KeyTestItem"); +} + void tst_QDeclarativeItem::keys() { QDeclarativeView *canvas = new QDeclarativeView(0); @@ -214,6 +280,69 @@ void tst_QDeclarativeItem::keys() QCOMPARE(testObject->mKey, 0); QVERIFY(!key.isAccepted()); + canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_Return)); + QVERIFY(key.isAccepted()); + + delete canvas; + delete testObject; +} + +void tst_QDeclarativeItem::keysProcessingOrder() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setFixedSize(240,320); + + KeysTestObject *testObject = new KeysTestObject; + canvas->rootContext()->setContextProperty("keysTestObject", testObject); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keyspriority.qml")); + canvas->show(); + qApp->processEvents(); + + KeyTestItem *testItem = qobject_cast<KeyTestItem*>(canvas->rootObject()); + QVERIFY(testItem); + + QEvent wa(QEvent::WindowActivate); + QApplication::sendEvent(canvas, &wa); + QFocusEvent fe(QEvent::FocusIn); + QApplication::sendEvent(canvas, &fe); + + QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_A)); + QCOMPARE(testObject->mText, QLatin1String("A")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + testObject->setProcessLast(true); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, 0); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_B)); + QCOMPARE(testObject->mText, QLatin1String("B")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(!key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, 0); + QVERIFY(key.isAccepted()); + delete canvas; delete testObject; } diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index b56ff13..59580ea 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -104,13 +104,14 @@ tst_QDeclarativeLoader::tst_QDeclarativeLoader() void tst_QDeclarativeLoader::url() { QDeclarativeComponent component(&engine); - component.setData(QByteArray("import Qt 4.7\nLoader { source: \"Rect120x60.qml\" }"), TEST_FILE("")); + component.setData(QByteArray("import Qt 4.7\nLoader { property int did_load: 0; onLoaded: did_load=123; source: \"Rect120x60.qml\" }"), TEST_FILE("")); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); QVERIFY(loader != 0); QVERIFY(loader->item()); QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml")); QCOMPARE(loader->progress(), 1.0); QCOMPARE(loader->status(), QDeclarativeLoader::Ready); + QCOMPARE(loader->property("did_load").toInt(), 123); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); delete loader; @@ -427,7 +428,7 @@ void tst_QDeclarativeLoader::networkRequestUrl() server.serveDirectory(SRCDIR "/data"); QDeclarativeComponent component(&engine); - component.setData(QByteArray("import Qt 4.7\nLoader { source: \"http://127.0.0.1:14450/Rect120x60.qml\" }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml")); + component.setData(QByteArray("import Qt 4.7\nLoader { property int did_load : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: did_load=123 }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml")); if (component.isError()) qDebug() << component.errors(); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); @@ -437,6 +438,7 @@ void tst_QDeclarativeLoader::networkRequestUrl() QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->property("did_load").toInt(), 123); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); delete loader; @@ -483,7 +485,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Network error for URL http://127.0.0.1:14450/IDontExist.qml"); QDeclarativeComponent component(&engine); - component.setData(QByteArray("import Qt 4.7\nLoader { source: \"http://127.0.0.1:14450/IDontExist.qml\" }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml")); + component.setData(QByteArray("import Qt 4.7\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml")); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); QVERIFY(loader != 0); @@ -491,6 +493,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() QVERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); + QCOMPARE(loader->property("did_load").toInt(), 123); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0); delete loader; diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 7a23773..e639014 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -687,7 +687,13 @@ void tst_QDeclarativePositioners::test_conflictinganchors() component.setData("import Qt 4.7\nColumn { Item { anchors.top: parent.top } }", QUrl::fromLocalFile("")); item = qobject_cast<QDeclarativeItem*>(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom or verticalCenter anchors for items inside Column")); + QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nColumn { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column")); warningMessage.clear(); component.setData("import Qt 4.7\nColumn { Item { anchors.left: parent.left } }", QUrl::fromLocalFile("")); @@ -699,7 +705,13 @@ void tst_QDeclarativePositioners::test_conflictinganchors() component.setData("import Qt 4.7\nRow { Item { anchors.left: parent.left } }", QUrl::fromLocalFile("")); item = qobject_cast<QDeclarativeItem*>(component.create()); QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right or horizontalCenter anchors for items inside Row")); + QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nRow { Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row")); warningMessage.clear(); component.setData("import Qt 4.7\nRow { Item { anchors.top: parent.top } }", QUrl::fromLocalFile("")); @@ -714,10 +726,21 @@ void tst_QDeclarativePositioners::test_conflictinganchors() QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid")); warningMessage.clear(); + component.setData("import Qt 4.7\nGrid { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid")); + warningMessage.clear(); + component.setData("import Qt 4.7\nFlow { Item { anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile("")); item = qobject_cast<QDeclarativeItem*>(component.create()); QVERIFY(item); QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow")); + + component.setData("import Qt 4.7\nFlow { Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow")); } QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename) diff --git a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp index ce3acb7..a3cccb2 100644 --- a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp +++ b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp @@ -45,6 +45,13 @@ #include <QtNetwork/qnetworkconfiguration.h> #include <QtNetwork/qnetworkconfigmanager.h> +/* + Although this unit test doesn't use QNetworkAccessManager + this include is used to ensure that bearer continues to compile against + Qt 4.7+ which has a QNetworkConfiguration enabled QNetworkAccessManager +*/ +#include <QNetworkAccessManager> + #if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) #include <stdio.h> #include <iapconf.h> diff --git a/tests/auto/qnetworksession/lackey/main.cpp b/tests/auto/qnetworksession/lackey/main.cpp index 8759b52..ec2fad9 100644 --- a/tests/auto/qnetworksession/lackey/main.cpp +++ b/tests/auto/qnetworksession/lackey/main.cpp @@ -47,6 +47,8 @@ #include <QtNetwork/qnetworkconfigmanager.h> #include <QtNetwork/qnetworksession.h> +#include <QEventLoop> +#include <QTimer> #include <QDebug> QT_USE_NAMESPACE @@ -60,15 +62,14 @@ int main(int argc, char** argv) { QCoreApplication app(argc, argv); - // Cannot read/write to processes on WinCE or Symbian. - // Easiest alternative is to use sockets for IPC. - - QLocalSocket oopSocket; - - oopSocket.connectToServer("tst_qnetworksession"); - oopSocket.waitForConnected(-1); - + // Update configurations so that everything is up to date for this process too. + // Event loop is used to wait for awhile. QNetworkConfigurationManager manager; + manager.updateConfigurations(); + QEventLoop iIgnoreEventLoop; + QTimer::singleShot(3000, &iIgnoreEventLoop, SLOT(quit())); + iIgnoreEventLoop.exec(); + QList<QNetworkConfiguration> discovered = manager.allConfigurations(QNetworkConfiguration::Discovered); @@ -82,6 +83,13 @@ int main(int argc, char** argv) return NO_DISCOVERED_CONFIGURATIONS_ERROR; } + // Cannot read/write to processes on WinCE or Symbian. + // Easiest alternative is to use sockets for IPC. + QLocalSocket oopSocket; + + oopSocket.connectToServer("tst_qnetworksession"); + oopSocket.waitForConnected(-1); + qDebug() << "Lackey started"; QNetworkSession *session = 0; diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index 23cdc6a..934a50e 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -100,6 +100,7 @@ private slots: private: QNetworkConfigurationManager manager; + QMap<QString, bool> testsToRun; int inProcessSessionManagementCount; @@ -117,6 +118,7 @@ private: bool openSession(QNetworkSession *session); bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration = true); void updateConfigurations(); +void printConfigurations(); QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfiguration::Type configType); void tst_QNetworkSession::initTestCase() @@ -125,7 +127,19 @@ void tst_QNetworkSession::initTestCase() qRegisterMetaType<QNetworkSession::SessionError>("QNetworkSession::SessionError"); qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration"); qRegisterMetaType<QNetworkConfiguration::Type>("QNetworkConfiguration::Type"); - + + // If you wish to skip tests, set value as false. This is often very convinient because tests are so lengthy. + // Better way still would be to make this readable from a file. + testsToRun["robustnessBombing"] = true; + testsToRun["outOfProcessSession"] = true; + testsToRun["invalidSession"] = true; + testsToRun["repeatedOpenClose"] = true; + testsToRun["roamingErrorCodes"] = true; + testsToRun["sessionStop"] = true; + testsToRun["sessionProperties"] = true; + testsToRun["userChoiceSession"] = true; + testsToRun["sessionOpenCloseStop"] = true; + #if defined(Q_WS_MAEMO_6) || defined(Q_WS_MAEMO_5) iapconf = new Maemo::IAPConf("007"); iapconf->setValue("ipv4_type", "AUTO"); @@ -238,6 +252,10 @@ void tst_QNetworkSession::cleanupTestCase() // Robustness test for calling interfaces in nonsense order / with nonsense parameters void tst_QNetworkSession::robustnessBombing() { + if (!testsToRun["robustnessBombing"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } + QNetworkConfigurationManager mgr; QNetworkSession testSession(mgr.defaultConfiguration()); // Should not reset even session is not opened @@ -245,15 +263,14 @@ void tst_QNetworkSession::robustnessBombing() testSession.accept(); testSession.ignore(); testSession.reject(); - quint64 temp; - temp = testSession.bytesWritten(); - temp = testSession.bytesReceived(); - temp = testSession.activeTime(); } void tst_QNetworkSession::invalidSession() -{ +{ + if (!testsToRun["invalidSession"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } // 1. Verify that session created with invalid configuration remains in invalid state QNetworkSession session(QNetworkConfiguration(), 0); QVERIFY(!session.isOpen()); @@ -270,11 +287,24 @@ void tst_QNetworkSession::invalidSession() QVERIFY(error == QNetworkSession::InvalidConfigurationError); QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError); QVERIFY(session.state() == QNetworkSession::Invalid); - + #ifdef QNETWORKSESSION_MANUAL_TESTS + + QNetworkConfiguration invalidatedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint); + if (invalidatedConfig.isValid()) { + // 3. Verify that invalidating a session after its successfully configured works + QNetworkSession invalidatedSession(invalidatedConfig); + qDebug() << "Delete the WLAN IAP from phone now (waiting 60 seconds): " << invalidatedConfig.name(); + QTest::qWait(60000); + QVERIFY(!invalidatedConfig.isValid()); + QVERIFY(invalidatedSession.state() == QNetworkSession::Invalid); + qDebug() << "Add the WLAN IAP back (waiting 60 seconds): " << invalidatedConfig.name(); + QTest::qWait(60000); + } + QNetworkConfiguration definedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint); if (definedConfig.isValid()) { - // 3. Verify that opening a session with defined configuration emits error and enters notavailable-state + // 4. Verify that opening a session with defined configuration emits error and enters notavailable-state // TODO these timer waits should be changed to waiting appropriate signals, now these wait excessively qDebug() << "Shutdown WLAN IAP (waiting 60 seconds): " << definedConfig.name(); QTest::qWait(60000); @@ -283,43 +313,27 @@ void tst_QNetworkSession::invalidSession() QNetworkSession definedSession(definedConfig); QSignalSpy errorSpy(&definedSession, SIGNAL(error(QNetworkSession::SessionError))); QNetworkSession::SessionError sessionError; + updateConfigurations(); definedSession.open(); +#ifdef Q_OS_SYMBIAN + // On symbian, the connection opening is tried even with defined state. + qDebug("Waiting for 10 seconds to all signals to propagate."); + QTest::qWait(10000); +#endif + updateConfigurations(); QVERIFY(definedConfig.isValid()); // Session remains valid QVERIFY(definedSession.state() == QNetworkSession::NotAvailable); // State is not available because WLAN is not in coverage QVERIFY(!errorSpy.isEmpty()); // Session tells with error about invalidated configuration sessionError = qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0)); - qDebug() << "Error code is: " << sessionError; QVERIFY(sessionError == QNetworkSession::InvalidConfigurationError); - qDebug() << "Turn the WLAN IAP back on (waiting 60 seconds): " << definedConfig.name(); QTest::qWait(60000); - updateConfigurations(); - + updateConfigurations(); QVERIFY(definedConfig.state() == QNetworkConfiguration::Discovered); } - - QNetworkConfiguration invalidatedConfig = suitableConfiguration("WLAN",QNetworkConfiguration::InternetAccessPoint); - if (invalidatedConfig.isValid()) { - // 4. Verify that invalidating a session after its successfully configured works - QNetworkSession invalidatedSession(invalidatedConfig); - QSignalSpy errorSpy(&invalidatedSession, SIGNAL(error(QNetworkSession::SessionError))); - QNetworkSession::SessionError sessionError; - - qDebug() << "Delete the WLAN IAP from phone now (waiting 60 seconds): " << invalidatedConfig.name(); - QTest::qWait(60000); - - invalidatedSession.open(); - QVERIFY(!invalidatedConfig.isValid()); - QVERIFY(invalidatedSession.state() == QNetworkSession::Invalid); - QVERIFY(!errorSpy.isEmpty()); - - sessionError = qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0)); - QVERIFY(sessionError == QNetworkSession::InvalidConfigurationError); - qDebug() << "Add the WLAN IAP back (waiting 60 seconds): " << invalidatedConfig.name(); - QTest::qWait(60000); - } + #endif } @@ -337,12 +351,12 @@ void tst_QNetworkSession::sessionProperties_data() void tst_QNetworkSession::sessionProperties() { + if (!testsToRun["sessionProperties"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } QFETCH(QNetworkConfiguration, configuration); - QNetworkSession session(configuration); - QVERIFY(session.configuration() == configuration); - QStringList validBearerNames = QStringList() << QLatin1String("Unknown") << QLatin1String("Ethernet") << QLatin1String("WLAN") @@ -356,9 +370,6 @@ void tst_QNetworkSession::sessionProperties() if (!configuration.isValid()) { QVERIFY(configuration.bearerName().isEmpty()); } else { - qDebug() << "Type:" << configuration.type() - << "Bearer:" << configuration.bearerName(); - switch (configuration.type()) { case QNetworkConfiguration::ServiceNetwork: @@ -374,9 +385,7 @@ void tst_QNetworkSession::sessionProperties() // QNetworkSession::interface() should return an invalid interface unless // session is in the connected state. - qDebug() << "Session state:" << session.state(); #ifndef QT_NO_NETWORKINTERFACE - qDebug() << "Session iface:" << session.interface().isValid() << session.interface().name(); #if !(defined(Q_OS_SYMBIAN) && defined(__WINS__)) // On Symbian emulator, the support for data bearers is limited QCOMPARE(session.state() == QNetworkSession::Connected, session.interface().isValid()); @@ -420,7 +429,12 @@ void tst_QNetworkSession::repeatedOpenClose_data() { } // Tests repeated-open close. -void tst_QNetworkSession::repeatedOpenClose() { +void tst_QNetworkSession::repeatedOpenClose() +{ + if (!testsToRun["repeatedOpenClose"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } + QFETCH(QString, bearerType); QFETCH(QNetworkConfiguration::Type, configurationType); QFETCH(int, repeatTimes); @@ -436,13 +450,20 @@ void tst_QNetworkSession::repeatedOpenClose() { !closeSession(&permanentSession)) { QSKIP("Unable to open/close session, skipping this round of repeated open-close test.", SkipSingle); } - for (int i = repeatTimes; i > 0; i--) { + for (int i = 0; i < repeatTimes; i++) { + qDebug() << "Opening, loop number " << i; QVERIFY(openSession(&permanentSession)); + qDebug() << "Closing, loop number, then waiting 5 seconds: " << i; QVERIFY(closeSession(&permanentSession)); + QTest::qWait(5000); } } -void tst_QNetworkSession::roamingErrorCodes() { +void tst_QNetworkSession::roamingErrorCodes() +{ + if (!testsToRun["roamingErrorCodes"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } #ifndef Q_OS_SYMBIAN QSKIP("Roaming supported on Symbian.", SkipAll); #else @@ -466,41 +487,11 @@ void tst_QNetworkSession::roamingErrorCodes() { adminIapSession.stop(); // requires NetworkControl capabilities QTRY_VERIFY(!errorSpy.isEmpty()); // wait for error signals QNetworkSession::SessionError error = qvariant_cast<QNetworkSession::SessionError>(errorSpy.first().at(0)); + QTest::qWait(2000); // Wait for a moment to all platform signals to propagate QVERIFY(error == QNetworkSession::SessionAbortedError); QVERIFY(iapSession.state() == QNetworkSession::Disconnected); QVERIFY(adminIapSession.state() == QNetworkSession::Disconnected); #endif // Q_OS_SYMBIAN - -#ifdef QNETWORKSESSION_MANUAL_TESTS - // Check for roaming error. - // Case requires that you have controllable WLAN in Internet SNAP (only). - QNetworkConfiguration snapConfig = suitableConfiguration("bearer_not_relevant_with_snaps", QNetworkConfiguration::ServiceNetwork); - if (!snapConfig.isValid()) { - QSKIP("No SNAP accessible, skipping test.", SkipAll); - } - QNetworkSession snapSession(snapConfig); - QVERIFY(openSession(&snapSession)); - QSignalSpy errorSpySnap(&snapSession, SIGNAL(error(QNetworkSession::SessionError))); - qDebug("Disconnect the WLAN now"); - QTRY_VERIFY(!errorSpySnap.isEmpty()); // wait for error signals - QVERIFY(errorSpySnap.count() == 1); - error = qvariant_cast<QNetworkSession::SessionError>(errorSpySnap.first().at(0)); - qDebug() << "Error received when turning off wlan on SNAP: " << error; - QVERIFY(error == QNetworkSession::RoamingError); - - qDebug("Connect the WLAN now"); - QTest::qWait(60000); // Wait for WLAN to get up - QNetworkConfiguration wlanIapConfig2 = suitableConfiguration("WLAN", QNetworkConfiguration::InternetAccessPoint); - QNetworkSession iapSession2(wlanIapConfig2); - QVERIFY(openSession(&iapSession2)); - QSignalSpy errorSpy2(&iapSession2, SIGNAL(error(QNetworkSession::SessionError))); - qDebug("Disconnect the WLAN now"); - QTRY_VERIFY(!errorSpy2.isEmpty()); // wait for error signals - QVERIFY(errorSpy2.count() == 1); - error = qvariant_cast<QNetworkSession::SessionError>(errorSpy2.first().at(0)); - QVERIFY(error == QNetworkSession::SessionAbortedError); - QVERIFY(iapSession2.state() == QNetworkSession::Disconnected); -#endif } @@ -515,6 +506,9 @@ void tst_QNetworkSession::sessionStop_data() { void tst_QNetworkSession::sessionStop() { + if (!testsToRun["sessionStop"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } #ifndef Q_OS_SYMBIAN QSKIP("Testcase contains mainly Symbian specific checks, because it is only platform to really support interface (IAP-level) Stop.", SkipAll); #endif @@ -522,6 +516,9 @@ void tst_QNetworkSession::sessionStop() QFETCH(QNetworkConfiguration::Type, configurationType); int configWaitdelayInMs = 2000; + + updateConfigurations(); + printConfigurations(); QNetworkConfiguration config = suitableConfiguration(bearerType, configurationType); if (!config.isValid()) { @@ -539,6 +536,9 @@ void tst_QNetworkSession::sessionStop() QSignalSpy closedSessionStateChangedSpy(&closedSession, SIGNAL(stateChanged(QNetworkSession::State))); QSignalSpy closedErrorSpy(&closedSession, SIGNAL(error(QNetworkSession::SessionError))); + QSignalSpy openedSessionClosedSpy(&openedSession, SIGNAL(closed())); + QSignalSpy openedSessionStateChangedSpy(&openedSession, SIGNAL(stateChanged(QNetworkSession::State))); + QSignalSpy innocentSessionClosedSpy(&innocentSession, SIGNAL(closed())); QSignalSpy innocentSessionStateChangedSpy(&innocentSession, SIGNAL(stateChanged(QNetworkSession::State))); QSignalSpy innocentErrorSpy(&innocentSession, SIGNAL(error(QNetworkSession::SessionError))); @@ -554,10 +554,18 @@ void tst_QNetworkSession::sessionStop() closedSessionClosedSpy.clear(); closedSessionStateChangedSpy.clear(); closedErrorSpy.clear(); + openedSessionStateChangedSpy.clear(); + openedSessionClosedSpy.clear(); + openedSession.stop(); - QVERIFY(openedSession.state() == QNetworkSession::Disconnected); + qDebug("Waiting for %d ms to get all configurationChange signals from platform.", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals + + // First to closing, then to disconnected + QVERIFY(openedSessionStateChangedSpy.count() == 2); + QVERIFY(!openedSessionClosedSpy.isEmpty()); + QVERIFY(openedSession.state() == QNetworkSession::Disconnected); QVERIFY(config.state() != QNetworkConfiguration::Active); // 2. Verify that stopping a session based on non-connected configuration does nothing @@ -583,18 +591,20 @@ void tst_QNetworkSession::sessionStop() // 3. Check that stopping a opened session affects also other opened session based on the same configuration. if (config.type() == QNetworkConfiguration::InternetAccessPoint) { qDebug("----------3. Check that stopping a opened session affects also other opened session based on the same configuration."); + QVERIFY(openSession(&openedSession)); QVERIFY(openSession(&innocentSession)); - + configChangeSpy.clear(); innocentSessionClosedSpy.clear(); innocentSessionStateChangedSpy.clear(); innocentErrorSpy.clear(); - + openedSession.stop(); qDebug("Waiting for %d ms to get all configurationChange signals from platform.", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals - + QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals + QVERIFY(!innocentSessionClosedSpy.isEmpty()); QVERIFY(!innocentSessionStateChangedSpy.isEmpty()); QVERIFY(!innocentErrorSpy.isEmpty()); @@ -614,14 +624,19 @@ void tst_QNetworkSession::sessionStop() if (config.type() == QNetworkConfiguration::ServiceNetwork) { qDebug("----------4. Skip for SNAP configuration."); } else if (config.type() == QNetworkConfiguration::InternetAccessPoint) { - qDebug("----------4. Check that stopping a non-opened session stops the other session based on the same configuration"); - QVERIFY(openSession(&innocentSession)); + qDebug("----------4. Check that stopping a non-opened session stops the other session based on the same configuration"); + qDebug("----------4.1 Opening innocent session"); + QVERIFY(openSession(&innocentSession)); qDebug("Waiting for %d ms after open to make sure all platform indications are propagated", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); + qDebug("----------4.2 Calling closedSession.stop()"); closedSession.stop(); qDebug("Waiting for %d ms to get all configurationChange signals from platform..", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals + QTest::qWait(configWaitdelayInMs); + QTest::qWait(configWaitdelayInMs); + QVERIFY(!innocentSessionClosedSpy.isEmpty()); QVERIFY(!innocentSessionStateChangedSpy.isEmpty()); QVERIFY(!innocentErrorSpy.isEmpty()); @@ -653,6 +668,9 @@ void tst_QNetworkSession::userChoiceSession_data() void tst_QNetworkSession::userChoiceSession() { + if (!testsToRun["userChoiceSession"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } QFETCH(QNetworkConfiguration, configuration); QVERIFY(configuration.type() == QNetworkConfiguration::UserChoice); @@ -682,7 +700,20 @@ void tst_QNetworkSession::userChoiceSession() session.open(); +#if defined(Q_OS_SYMBIAN) + // Opening & closing multiple connections in a row sometimes + // results hanging of connection opening on Symbian devices + // => If first open fails, wait a moment and try again. + if (!session.waitForOpened()) { + qDebug("**** Session open Timeout - Wait 5 seconds and try once again ****"); + session.close(); + QTest::qWait(5000); // Wait a while before trying to open session again + session.open(); + session.waitForOpened(); + } +#else session.waitForOpened(); +#endif if (session.isOpen()) QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty()); @@ -786,6 +817,9 @@ void tst_QNetworkSession::sessionOpenCloseStop_data() void tst_QNetworkSession::sessionOpenCloseStop() { + if (!testsToRun["sessionOpenCloseStop"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } QFETCH(QNetworkConfiguration, configuration); QFETCH(bool, forceSessionStop); @@ -818,7 +852,20 @@ void tst_QNetworkSession::sessionOpenCloseStop() session.open(); +#if defined(Q_OS_SYMBIAN) + // Opening & closing multiple connections in a row sometimes + // results hanging of connection opening on Symbian devices + // => If first open fails, wait a moment and try again. + if (!session.waitForOpened()) { + qDebug("**** Session open Timeout - Wait 5 seconds and try once again ****"); + session.close(); + QTest::qWait(5000); // Wait a while before trying to open session again + session.open(); + session.waitForOpened(); + } +#else session.waitForOpened(); +#endif if (session.isOpen()) QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty()); @@ -894,26 +941,30 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(session.error() == QNetworkSession::UnknownSessionError); session2.open(); - + QTRY_VERIFY(!sessionOpenedSpy2.isEmpty() || !errorSpy2.isEmpty()); + if (errorSpy2.isEmpty()) { + QVERIFY(session2.isOpen()); + QVERIFY(session2.state() == QNetworkSession::Connected); + } QVERIFY(session.isOpen()); - QVERIFY(session2.isOpen()); QVERIFY(session.state() == QNetworkSession::Connected); - QVERIFY(session2.state() == QNetworkSession::Connected); #ifndef QT_NO_NETWORKINTERFACE #if !(defined(Q_OS_SYMBIAN) && defined(__WINS__)) // On Symbian emulator, the support for data bearers is limited QVERIFY(session.interface().isValid()); #endif - QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress()); - QCOMPARE(session.interface().index(), session2.interface().index()); + if (errorSpy2.isEmpty()) { + QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress()); + QCOMPARE(session.interface().index(), session2.interface().index()); + } #endif } sessionOpenedSpy2.clear(); - if (forceSessionStop) { + if (forceSessionStop && session2.isOpen()) { // Test forcing the second session to stop the interface. QNetworkSession::State previousState = session.state(); #ifdef Q_CC_NOKIAX86 @@ -922,15 +973,17 @@ void tst_QNetworkSession::sessionOpenCloseStop() #else bool expectStateChange = previousState != QNetworkSession::Disconnected; #endif - session2.stop(); + // QNetworkSession::stop() must result either closed() signal + // or error() signal QTRY_VERIFY(!sessionClosedSpy2.isEmpty() || !errorSpy2.isEmpty()); - QVERIFY(!session2.isOpen()); if (!errorSpy2.isEmpty()) { - QVERIFY(!errorSpy.isEmpty()); + // QNetworkSession::stop() resulted error() signal for session2 + // => also session should emit error() signal + QTRY_VERIFY(!errorSpy.isEmpty()); // check for SessionAbortedError QNetworkSession::SessionError error = @@ -950,9 +1003,12 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(errorSpy.isEmpty()); QVERIFY(errorSpy2.isEmpty()); - + + // Wait for Disconnected state + QTRY_NOOP(session2.state() == QNetworkSession::Disconnected); + if (expectStateChange) - QTRY_VERIFY(stateChangedSpy2.count() >= 2 || !errorSpy2.isEmpty()); + QTRY_VERIFY(stateChangedSpy2.count() >= 1 || !errorSpy2.isEmpty()); if (!errorSpy2.isEmpty()) { QVERIFY(session2.state() == previousState); @@ -996,16 +1052,29 @@ void tst_QNetworkSession::sessionOpenCloseStop() state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(3).at(0)); QVERIFY(state == QNetworkSession::Disconnected); + + QTRY_VERIFY(session.state() == QNetworkSession::Roaming || + session.state() == QNetworkSession::Connected || + session.state() == QNetworkSession::Disconnected); + QTRY_VERIFY(stateChangedSpy.count() > 0); - state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(0).at(0)); + state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(stateChangedSpy.count() - 1).at(0)); + if (state == QNetworkSession::Roaming) { - QTRY_VERIFY(!errorSpy.isEmpty() || stateChangedSpy.count() > 1); - if (stateChangedSpy.count() > 1 && - qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(1).at(0)) == - QNetworkSession::Connected) { - roamedSuccessfully = true; + QTRY_VERIFY(session.state() == QNetworkSession::Connected); + QTRY_VERIFY(session2.state() == QNetworkSession::Connected); + roamedSuccessfully = true; + } else if (state == QNetworkSession::Disconnected) { + QTRY_VERIFY(!errorSpy.isEmpty()); + QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); + } else if (state == QNetworkSession::Connected) { + QTRY_VERIFY(errorSpy.isEmpty()); + if (stateChangedSpy.count() > 1) { + state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(stateChangedSpy.count() - 2).at(0)); + QVERIFY(state == QNetworkSession::Roaming); } - } + roamedSuccessfully = true; + } if (roamedSuccessfully) { QString configId = session.sessionProperty("ActiveConfiguration").toString(); @@ -1013,37 +1082,36 @@ void tst_QNetworkSession::sessionOpenCloseStop() QNetworkSession session3(config); QSignalSpy errorSpy3(&session3, SIGNAL(error(QNetworkSession::SessionError))); QSignalSpy sessionOpenedSpy3(&session3, SIGNAL(opened())); - session3.open(); - session3.waitForOpened(); - + session3.waitForOpened(); if (session.isOpen()) QVERIFY(!sessionOpenedSpy3.isEmpty() || !errorSpy3.isEmpty()); - session.stop(); - QTRY_VERIFY(session.state() == QNetworkSession::Disconnected); - QTRY_VERIFY(session3.state() == QNetworkSession::Disconnected); } #ifndef Q_CC_NOKIAX86 if (!roamedSuccessfully) QVERIFY(!errorSpy.isEmpty()); #endif } else { - QCOMPARE(stateChangedSpy2.count(), 2); - - QNetworkSession::State state = - qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); - QVERIFY(state == QNetworkSession::Closing); - - state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0)); - QVERIFY(state == QNetworkSession::Disconnected); + QTest::qWait(2000); // Wait awhile to get all signals from platform + + if (stateChangedSpy2.count() == 2) { + QNetworkSession::State state = + qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); + QVERIFY(state == QNetworkSession::Closing); + state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0)); + QVERIFY(state == QNetworkSession::Disconnected); + } else { // Assume .count() == 1 + QCOMPARE(stateChangedSpy2.count(), 1); + QNetworkSession::State state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); + // Symbian version dependant. + QVERIFY(state == QNetworkSession::Disconnected); + } } QTRY_VERIFY(!sessionClosedSpy.isEmpty()); - QTRY_VERIFY(session.state() == QNetworkSession::Disconnected); - QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); } QVERIFY(errorSpy2.isEmpty()); @@ -1062,7 +1130,7 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(!session.isOpen()); #endif QVERIFY(!session2.isOpen()); - } else { + } else if (session2.isOpen()) { // Test closing the second session. { int stateChangedCountBeforeClose = stateChangedSpy2.count(); @@ -1161,11 +1229,15 @@ QDebug operator<<(QDebug debug, const QList<QNetworkConfiguration> &list) // at Discovered -state. void tst_QNetworkSession::outOfProcessSession() { - qDebug() << "START"; - + if (!testsToRun["outOfProcessSession"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } #if defined(Q_OS_SYMBIAN) && defined(__WINS__) QSKIP("Symbian emulator does not support two [QR]PRocesses linking a dll (QtBearer.dll) with global writeable static data.", SkipAll); #endif + updateConfigurations(); + QTest::qWait(2000); + QNetworkConfigurationManager manager; // Create a QNetworkConfigurationManager to detect configuration changes made in Lackey. This // is actually the essence of this testcase - to check that platform mediates/reflects changes @@ -1182,16 +1254,15 @@ void tst_QNetworkSession::outOfProcessSession() QLocalServer::removeServer("tst_qnetworksession"); oopServer.listen("tst_qnetworksession"); - qDebug() << "starting lackey"; QProcess lackey; lackey.start("lackey/lackey"); qDebug() << lackey.error() << lackey.errorString(); QVERIFY(lackey.waitForStarted()); - qDebug() << "waiting for connection"; + QVERIFY(oopServer.waitForNewConnection(-1)); QLocalSocket *oopSocket = oopServer.nextPendingConnection(); - qDebug() << "got connection"; + do { QByteArray output; @@ -1258,7 +1329,6 @@ void tst_QNetworkSession::outOfProcessSession() default: QSKIP("Lackey failed", SkipAll); } - qDebug("STOP"); } // A convinience / helper function for testcases. Return the first matching configuration. @@ -1269,6 +1339,7 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur // Refresh configurations and derive configurations matching given parameters. QNetworkConfigurationManager mgr; QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted())); + mgr.updateConfigurations(); QTRY_NOOP(updateSpy.count() == 1); if (updateSpy.count() != 1) { @@ -1277,8 +1348,7 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur } QList<QNetworkConfiguration> discoveredConfigs = mgr.allConfigurations(QNetworkConfiguration::Discovered); foreach(QNetworkConfiguration config, discoveredConfigs) { - if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { - // qDebug() << "Dumping config because is active: " << config.name(); + if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { discoveredConfigs.removeOne(config); } else if (config.type() != configType) { // qDebug() << "Dumping config because type (IAP/SNAP) mismatches: " << config.name(); @@ -1315,9 +1385,23 @@ void updateConfigurations() QTRY_NOOP(updateSpy.count() == 1); } +// A convinience-function: updates and prints all available confiurations and their states +void printConfigurations() +{ + QNetworkConfigurationManager manager; + QList<QNetworkConfiguration> allConfigs = + manager.allConfigurations(); + qDebug("tst_QNetworkSession::printConfigurations QNetworkConfigurationManager gives following configurations: "); + foreach(QNetworkConfiguration config, allConfigs) { + qDebug() << "Name of the configuration: " << config.name(); + qDebug() << "State of the configuration: " << config.state(); + } +} + // A convinience function for test-cases: opens the given configuration and return // true if it was done gracefully. bool openSession(QNetworkSession *session) { + bool result = true; QNetworkConfigurationManager mgr; QSignalSpy openedSpy(session, SIGNAL(opened())); QSignalSpy stateChangeSpy(session, SIGNAL(stateChanged(QNetworkSession::State))); @@ -1327,43 +1411,57 @@ bool openSession(QNetworkSession *session) { // active by some other session QNetworkConfiguration::StateFlags configInitState = session->configuration().state(); QNetworkSession::State sessionInitState = session->state(); + qDebug() << "tst_QNetworkSession::openSession() name of the configuration to be opened: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::openSession() state of the configuration to be opened: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::openSession() state of the session to be opened: " << session->state(); if (session->isOpen() || !session->sessionProperty("ActiveConfiguration").toString().isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: session was already open / active."); - return false; + result = false; } else { session->open(); session->waitForOpened(120000); // Bringing interfaces up and down may take time at platform } + QTest::qWait(5000); // Wait a moment to ensure all signals are propagated // Check that connection opening went by the book. Add checks here if more strictness needed. if (!session->isOpen()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::open() failed."); - return false; + result = false; } if (openedSpy.count() != 1) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::opened() - signal not received."); - return false; + result = false; } if (!errorSpy.isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::error() - signal was detected."); - return false; + result = false; } if (sessionInitState != QNetworkSession::Connected && stateChangeSpy.isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkSession::stateChanged() - signals not detected."); - return false; + result = false; } if (configInitState != QNetworkConfiguration::Active && configChangeSpy.isEmpty()) { qDebug("tst_QNetworkSession::openSession() failure: QNetworkConfigurationManager::configurationChanged() - signals not detected."); - return false; + result = false; } if (session->configuration().state() != QNetworkConfiguration::Active) { qDebug("tst_QNetworkSession::openSession() failure: session's configuration is not in 'Active' -state."); - return false; + qDebug() << "tst_QNetworkSession::openSession() state is: " << session->configuration().state(); + result = false; + } + if (result == false) { + qDebug() << "tst_QNetworkSession::openSession() opening session failed."; + } else { + qDebug() << "tst_QNetworkSession::openSession() opening session succeeded."; } - return true; + qDebug() << "tst_QNetworkSession::openSession() name of the configuration is: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::openSession() configuration state is: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::openSession() session state is: " << session->state(); + + return result; } // Helper function for closing opened session. Performs checks that @@ -1376,6 +1474,11 @@ bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) { qDebug("tst_QNetworkSession::closeSession() failure: NULL session given"); return false; } + + qDebug() << "tst_QNetworkSession::closeSession() name of the configuration to be closed: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::closeSession() state of the configuration to be closed: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::closeSession() state of the session to be closed: " << session->state(); + if (session->state() != QNetworkSession::Connected || !session->isOpen()) { qDebug("tst_QNetworkSession::closeSession() failure: session is not opened."); @@ -1387,38 +1490,48 @@ bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) { QSignalSpy sessionErrorSpy(session, SIGNAL(error(QNetworkSession::SessionError))); QSignalSpy configChangeSpy(&mgr, SIGNAL(configurationChanged(QNetworkConfiguration))); + bool result = true; session->close(); + QTest::qWait(5000); // Wait a moment so that all signals are propagated if (!sessionErrorSpy.isEmpty()) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::error() received."); - return false; + result = false; } if (sessionClosedSpy.count() != 1) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::closed() signal not received."); - return false; + result = false; } if (lastSessionOnConfiguration && sessionStateChangedSpy.isEmpty()) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession::stateChanged() signals not received."); - return false; + result = false; } if (lastSessionOnConfiguration && session->state() != QNetworkSession::Disconnected) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkSession is not in Disconnected -state"); - return false; + result = false; } QTRY_NOOP(!configChangeSpy.isEmpty()); if (lastSessionOnConfiguration && configChangeSpy.isEmpty()) { qDebug("tst_QNetworkSession::closeSession() failure: QNetworkConfigurationManager::configurationChanged() - signal not detected."); - return false; + result = false; } if (lastSessionOnConfiguration && session->configuration().state() == QNetworkConfiguration::Active) { qDebug("tst_QNetworkSession::closeSession() failure: session's configuration is still in active state."); - return false; + result = false; } - return true; + if (result == false) { + qDebug() << "tst_QNetworkSession::closeSession() closing session failed."; + } else { + qDebug() << "tst_QNetworkSession::closeSession() closing session succeeded."; + } + qDebug() << "tst_QNetworkSession::closeSession() name of the configuration is: " << session->configuration().name(); + qDebug() << "tst_QNetworkSession::closeSession() configuration state is: " << session->configuration().state(); + qDebug() << "tst_QNetworkSession::closeSession() session state is: " << session->state(); + return result; } void tst_QNetworkSession::sessionAutoClose_data() diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index cd512a1..31cae40 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -144,6 +144,7 @@ private slots: void blockingIMAP(); void nonBlockingIMAP(); void hostNotFound(); + void timeoutConnect_data(); void timeoutConnect(); void delayedClose(); void partialRead(); @@ -544,19 +545,36 @@ void tst_QTcpSocket::hostNotFound() } //---------------------------------------------------------------------------------- +void tst_QTcpSocket::timeoutConnect_data() +{ + QTest::addColumn<QString>("address"); + QTest::newRow("host") << QtNetworkSettings::serverName(); + QTest::newRow("ip") << QtNetworkSettings::serverIP().toString(); +} void tst_QTcpSocket::timeoutConnect() { + QFETCH(QString, address); QTcpSocket *socket = newSocket(); - // Outgoing port 53 is firewalled in the Oslo office. - socket->connectToHost("cisco.com", 53); + QElapsedTimer timer; + timer.start(); + + // Port 1357 is configured to drop packets on the test server + socket->connectToHost(address, 1357); + QVERIFY(timer.elapsed() < 50); QVERIFY(!socket->waitForConnected(200)); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); QCOMPARE(int(socket->error()), int(QTcpSocket::SocketTimeoutError)); - socket->connectToHost("cisco.com", 53); - QTest::qSleep(50); + timer.start(); + socket->connectToHost(address, 1357); + QVERIFY(timer.elapsed() < 50); + QTimer::singleShot(50, &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(socket->state() == QTcpSocket::ConnectingState + || socket->state() == QTcpSocket::HostLookupState); socket->abort(); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); QCOMPARE(socket->openMode(), QIODevice::NotOpen); diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index 19246a2..bf60dd1 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -300,8 +300,12 @@ SessionTab::SessionTab(QNetworkConfiguration* apNetworkConfiguration, SessionTab::~SessionTab() { + // Need to be nulled, because modal dialogs may return after destruction of this object and + // use already released resources. delete m_NetworkSession; + m_NetworkSession = NULL; delete m_http; + m_http = NULL; } void SessionTab::on_createQHttpButton_clicked() @@ -551,10 +555,16 @@ void SessionTab::done(bool error) msgBox.setText(QString("HTTP request finished successfully.\nReceived ")+QString::number(result.length())+QString(" bytes.")); } msgBox.exec(); - - sentRecDataLineEdit->setText(QString::number(m_NetworkSession->bytesWritten())+ - QString(" / ")+ - QString::number(m_NetworkSession->bytesReceived())); + // Check if the networksession still exists - it may have gone after returning from + // the modal dialog (in the case that app has been closed, and deleting QHttp will + // trigger the done() invokation). + if (m_NetworkSession) { + sentRecDataLineEdit->setText(QString::number(m_NetworkSession->bytesWritten())+ + QString(" / ")+ + QString::number(m_NetworkSession->bytesReceived())); + } else { + sentRecDataLineEdit->setText("Data amounts not available."); + } } // End of file |