summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2010-03-01 14:06:02 (GMT)
committeraxis <qt-info@nokia.com>2010-03-01 14:06:02 (GMT)
commit88a36e9e7e0e0bc09788c41ab6b968031dbc9154 (patch)
tree947663f695f54a0deb2724116f82d89fde761576 /examples
parent4be1e01c6faebe11bfe205c1b910049747b5c335 (diff)
parentca82ee4ee55e52c75326949148455af1095df014 (diff)
downloadQt-88a36e9e7e0e0bc09788c41ab6b968031dbc9154.zip
Qt-88a36e9e7e0e0bc09788c41ab6b968031dbc9154.tar.gz
Qt-88a36e9e7e0e0bc09788c41ab6b968031dbc9154.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-s60-public
Conflicts: configure mkspecs/common/symbian/symbian.conf qmake/generators/symbian/initprojectdeploy_symbian.cpp qmake/generators/symbian/symmake_abld.cpp qmake/generators/symbian/symmake_sbsv2.cpp src/plugins/plugins.pro
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/animations/easing.qml88
-rw-r--r--examples/declarative/animations/property-animation.qml8
-rw-r--r--examples/declarative/behaviours/test.qml6
-rw-r--r--examples/declarative/border-image/content/MyBorderImage.qml8
-rw-r--r--examples/declarative/connections/connections.qml14
-rw-r--r--examples/declarative/extending/adding/main.cpp10
-rw-r--r--examples/declarative/extending/adding/person.cpp1
-rw-r--r--examples/declarative/extending/adding/person.h2
-rw-r--r--examples/declarative/extending/attached/birthdayparty.cpp7
-rw-r--r--examples/declarative/extending/attached/birthdayparty.h6
-rw-r--r--examples/declarative/extending/attached/main.cpp15
-rw-r--r--examples/declarative/extending/attached/person.cpp4
-rw-r--r--examples/declarative/extending/attached/person.h2
-rw-r--r--examples/declarative/extending/binding/birthdayparty.cpp6
-rw-r--r--examples/declarative/extending/binding/birthdayparty.h6
-rw-r--r--examples/declarative/extending/binding/happybirthday.cpp3
-rw-r--r--examples/declarative/extending/binding/happybirthday.h12
-rw-r--r--examples/declarative/extending/binding/main.cpp17
-rw-r--r--examples/declarative/extending/binding/person.cpp4
-rw-r--r--examples/declarative/extending/binding/person.h2
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.cpp5
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.h6
-rw-r--r--examples/declarative/extending/coercion/main.cpp15
-rw-r--r--examples/declarative/extending/coercion/person.cpp6
-rw-r--r--examples/declarative/extending/coercion/person.h2
-rw-r--r--examples/declarative/extending/default/birthdayparty.cpp5
-rw-r--r--examples/declarative/extending/default/birthdayparty.h6
-rw-r--r--examples/declarative/extending/default/main.cpp13
-rw-r--r--examples/declarative/extending/default/person.cpp3
-rw-r--r--examples/declarative/extending/default/person.h2
-rw-r--r--examples/declarative/extending/extended/lineedit.cpp3
-rw-r--r--examples/declarative/extending/extended/main.cpp11
-rw-r--r--examples/declarative/extending/extending.pro13
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.cpp5
-rw-r--r--examples/declarative/extending/grouped/birthdayparty.h6
-rw-r--r--examples/declarative/extending/grouped/main.cpp14
-rw-r--r--examples/declarative/extending/grouped/person.cpp4
-rw-r--r--examples/declarative/extending/grouped/person.h2
-rw-r--r--examples/declarative/extending/properties/birthdayparty.cpp5
-rw-r--r--examples/declarative/extending/properties/birthdayparty.h6
-rw-r--r--examples/declarative/extending/properties/main.cpp11
-rw-r--r--examples/declarative/extending/properties/person.cpp1
-rw-r--r--examples/declarative/extending/properties/person.h2
-rw-r--r--examples/declarative/extending/signal/birthdayparty.cpp6
-rw-r--r--examples/declarative/extending/signal/birthdayparty.h6
-rw-r--r--examples/declarative/extending/signal/main.cpp15
-rw-r--r--examples/declarative/extending/signal/person.cpp4
-rw-r--r--examples/declarative/extending/signal/person.h2
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.cpp6
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.h6
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.cpp3
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.h11
-rw-r--r--examples/declarative/extending/valuesource/main.cpp17
-rw-r--r--examples/declarative/extending/valuesource/person.cpp4
-rw-r--r--examples/declarative/extending/valuesource/person.h2
-rw-r--r--examples/declarative/fonts/hello.qml2
-rw-r--r--examples/declarative/imageprovider/main.cpp23
-rw-r--r--examples/declarative/layouts/Button.qml2
-rw-r--r--examples/declarative/layouts/positioners.qml16
-rw-r--r--examples/declarative/listview/recipes.qml6
-rw-r--r--examples/declarative/objectlistmodel/main.cpp17
-rw-r--r--examples/declarative/package/Delegate.qml44
-rw-r--r--examples/declarative/package/view.qml35
-rw-r--r--examples/declarative/parallax/qml/ParallaxView.qml4
-rw-r--r--examples/declarative/parallax/qml/Smiley.qml8
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/Clock.qml (renamed from examples/declarative/plugins/files/Clock.qml)0
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/center.png (renamed from examples/declarative/plugins/files/center.png)bin765 -> 765 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/clock.png (renamed from examples/declarative/plugins/files/clock.png)bin20653 -> 20653 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/hour.png (renamed from examples/declarative/plugins/files/hour.png)bin625 -> 625 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/minute.png (renamed from examples/declarative/plugins/files/minute.png)bin625 -> 625 bytes
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/qmldir2
-rw-r--r--examples/declarative/plugins/plugin.cpp15
-rw-r--r--examples/declarative/plugins/plugins.pro22
-rw-r--r--examples/declarative/plugins/plugins.qml1
-rw-r--r--examples/declarative/progressbar/progressbars.qml2
-rw-r--r--examples/declarative/scrollbar/display.qml5
-rw-r--r--examples/declarative/slideswitch/content/Switch.qml2
-rw-r--r--examples/declarative/sql/hello.qml2
-rw-r--r--examples/declarative/states/transitions.qml8
-rw-r--r--examples/declarative/tutorials/helloworld/tutorial3.qml2
-rw-r--r--examples/declarative/velocity/velocity.qml2
-rw-r--r--examples/declarative/webview/qdeclarative-in-html.qml (renamed from examples/declarative/webview/qml-in-html.qml)4
-rw-r--r--examples/declarative/xmldata/yahoonews.qml2
-rw-r--r--examples/network/bearercloud/bearercloud.cpp197
-rw-r--r--examples/network/bearercloud/bearercloud.h81
-rw-r--r--examples/network/bearercloud/bearercloud.pro16
-rw-r--r--examples/network/bearercloud/cloud.cpp361
-rw-r--r--examples/network/bearercloud/cloud.h99
-rw-r--r--examples/network/bearercloud/icons.qrc7
-rw-r--r--examples/network/bearercloud/lan.svg76
-rw-r--r--examples/network/bearercloud/main.cpp89
-rw-r--r--examples/network/bearercloud/unknown.svg76
-rw-r--r--examples/network/bearercloud/wlan.svg151
-rw-r--r--examples/network/bearermonitor/bearermonitor.cpp395
-rw-r--r--examples/network/bearermonitor/bearermonitor.h92
-rw-r--r--examples/network/bearermonitor/bearermonitor.pro26
-rw-r--r--examples/network/bearermonitor/bearermonitor_240_320.ui420
-rw-r--r--examples/network/bearermonitor/bearermonitor_640_480.ui386
-rw-r--r--examples/network/bearermonitor/main.cpp55
-rw-r--r--examples/network/bearermonitor/sessionwidget.cpp177
-rw-r--r--examples/network/bearermonitor/sessionwidget.h78
-rw-r--r--examples/network/bearermonitor/sessionwidget.ui307
-rw-r--r--examples/network/http/httpwindow.cpp129
-rw-r--r--examples/network/http/httpwindow.h23
-rw-r--r--examples/network/http/main.cpp1
-rw-r--r--examples/network/loopback/dialog.cpp10
-rw-r--r--examples/network/network.pro4
107 files changed, 3573 insertions, 358 deletions
diff --git a/examples/declarative/animations/easing.qml b/examples/declarative/animations/easing.qml
index 9b5bcc6..8f2655e 100644
--- a/examples/declarative/animations/easing.qml
+++ b/examples/declarative/animations/easing.qml
@@ -6,47 +6,47 @@ Rectangle {
ListModel {
id: easingTypes
- ListElement { type: "easeLinear"; ballColor: "DarkRed" }
- ListElement { type: "easeInQuad"; ballColor: "IndianRed" }
- ListElement { type: "easeOutQuad"; ballColor: "Salmon" }
- ListElement { type: "easeInOutQuad"; ballColor: "Tomato" }
- ListElement { type: "easeOutInQuad"; ballColor: "DarkOrange" }
- ListElement { type: "easeInCubic"; ballColor: "Gold" }
- ListElement { type: "easeOutCubic"; ballColor: "Yellow" }
- ListElement { type: "easeInOutCubic"; ballColor: "PeachPuff" }
- ListElement { type: "easeOutInCubic"; ballColor: "Thistle" }
- ListElement { type: "easeInQuart"; ballColor: "Orchid" }
- ListElement { type: "easeOutQuart"; ballColor: "Purple" }
- ListElement { type: "easeInOutQuart"; ballColor: "SlateBlue" }
- ListElement { type: "easeOutInQuart"; ballColor: "Chartreuse" }
- ListElement { type: "easeInQuint"; ballColor: "LimeGreen" }
- ListElement { type: "easeOutQuint"; ballColor: "SeaGreen" }
- ListElement { type: "easeInOutQuint"; ballColor: "DarkGreen" }
- ListElement { type: "easeOutInQuint"; ballColor: "Olive" }
- ListElement { type: "easeInSine"; ballColor: "DarkSeaGreen" }
- ListElement { type: "easeOutSine"; ballColor: "Teal" }
- ListElement { type: "easeInOutSine"; ballColor: "Turquoise" }
- ListElement { type: "easeOutInSine"; ballColor: "SteelBlue" }
- ListElement { type: "easeInExpo"; ballColor: "SkyBlue" }
- ListElement { type: "easeOutExpo"; ballColor: "RoyalBlue" }
- ListElement { type: "easeInOutExpo"; ballColor: "MediumBlue" }
- ListElement { type: "easeOutInExpo"; ballColor: "MidnightBlue" }
- ListElement { type: "easeInCirc"; ballColor: "CornSilk" }
- ListElement { type: "easeOutCirc"; ballColor: "Bisque" }
- ListElement { type: "easeInOutCirc"; ballColor: "RosyBrown" }
- ListElement { type: "easeOutInCirc"; ballColor: "SandyBrown" }
- ListElement { type: "easeInElastic"; ballColor: "DarkGoldenRod" }
- ListElement { type: "easeOutElastic"; ballColor: "Chocolate" }
- ListElement { type: "easeInOutElastic"; ballColor: "SaddleBrown" }
- ListElement { type: "easeOutInElastic"; ballColor: "Brown" }
- ListElement { type: "easeInBack"; ballColor: "Maroon" }
- ListElement { type: "easeOutBack"; ballColor: "LavenderBlush" }
- ListElement { type: "easeInOutBack"; ballColor: "MistyRose" }
- ListElement { type: "easeOutInBack"; ballColor: "Gainsboro" }
- ListElement { type: "easeOutBounce"; ballColor: "Silver" }
- ListElement { type: "easeInBounce"; ballColor: "DimGray" }
- ListElement { type: "easeInOutBounce"; ballColor: "SlateGray" }
- ListElement { type: "easeOutInBounce"; ballColor: "DarkSlateGray" }
+ ListElement { type: "Linear"; ballColor: "DarkRed" }
+ ListElement { type: "InQuad"; ballColor: "IndianRed" }
+ ListElement { type: "OutQuad"; ballColor: "Salmon" }
+ ListElement { type: "InOutQuad"; ballColor: "Tomato" }
+ ListElement { type: "OutInQuad"; ballColor: "DarkOrange" }
+ ListElement { type: "InCubic"; ballColor: "Gold" }
+ ListElement { type: "OutCubic"; ballColor: "Yellow" }
+ ListElement { type: "InOutCubic"; ballColor: "PeachPuff" }
+ ListElement { type: "OutInCubic"; ballColor: "Thistle" }
+ ListElement { type: "InQuart"; ballColor: "Orchid" }
+ ListElement { type: "OutQuart"; ballColor: "Purple" }
+ ListElement { type: "InOutQuart"; ballColor: "SlateBlue" }
+ ListElement { type: "OutInQuart"; ballColor: "Chartreuse" }
+ ListElement { type: "InQuint"; ballColor: "LimeGreen" }
+ ListElement { type: "OutQuint"; ballColor: "SeaGreen" }
+ ListElement { type: "InOutQuint"; ballColor: "DarkGreen" }
+ ListElement { type: "OutInQuint"; ballColor: "Olive" }
+ ListElement { type: "InSine"; ballColor: "DarkSeaGreen" }
+ ListElement { type: "OutSine"; ballColor: "Teal" }
+ ListElement { type: "InOutSine"; ballColor: "Turquoise" }
+ ListElement { type: "OutInSine"; ballColor: "SteelBlue" }
+ ListElement { type: "InExpo"; ballColor: "SkyBlue" }
+ ListElement { type: "OutExpo"; ballColor: "RoyalBlue" }
+ ListElement { type: "InOutExpo"; ballColor: "MediumBlue" }
+ ListElement { type: "OutInExpo"; ballColor: "MidnightBlue" }
+ ListElement { type: "InCirc"; ballColor: "CornSilk" }
+ ListElement { type: "OutCirc"; ballColor: "Bisque" }
+ ListElement { type: "InOutCirc"; ballColor: "RosyBrown" }
+ ListElement { type: "OutInCirc"; ballColor: "SandyBrown" }
+ ListElement { type: "InElastic"; ballColor: "DarkGoldenRod" }
+ ListElement { type: "OutElastic"; ballColor: "Chocolate" }
+ ListElement { type: "InOutElastic"; ballColor: "SaddleBrown" }
+ ListElement { type: "OutInElastic"; ballColor: "Brown" }
+ ListElement { type: "InBack"; ballColor: "Maroon" }
+ ListElement { type: "OutBack"; ballColor: "LavenderBlush" }
+ ListElement { type: "InOutBack"; ballColor: "MistyRose" }
+ ListElement { type: "OutInBack"; ballColor: "Gainsboro" }
+ ListElement { type: "OutBounce"; ballColor: "Silver" }
+ ListElement { type: "InBounce"; ballColor: "DimGray" }
+ ListElement { type: "InOutBounce"; ballColor: "SlateGray" }
+ ListElement { type: "OutInBounce"; ballColor: "DarkSlateGray" }
}
Component {
@@ -80,8 +80,8 @@ Rectangle {
transitions: Transition {
ParallelAnimation {
- NumberAnimation { properties: "x"; easing: type; duration: 1000 }
- ColorAnimation { properties: "color"; easing: type; duration: 1000 }
+ NumberAnimation { properties: "x"; easing.type: type; duration: 1000 }
+ ColorAnimation { properties: "color"; easing.type: type; duration: 1000 }
}
}
}
@@ -89,7 +89,7 @@ Rectangle {
}
Flickable {
- anchors.fill: parent; viewportHeight: layout.height
+ anchors.fill: parent; contentHeight: layout.height
Column {
id: layout
anchors.left: parent.left; anchors.right: parent.right
diff --git a/examples/declarative/animations/property-animation.qml b/examples/declarative/animations/property-animation.qml
index 9f76ee5..537ee26 100644
--- a/examples/declarative/animations/property-animation.qml
+++ b/examples/declarative/animations/property-animation.qml
@@ -45,16 +45,16 @@ Item {
y: SequentialAnimation {
repeat: true
- // Move from minHeight to maxHeight in 300ms, using the easeOutExpo easing function
+ // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function
NumberAnimation {
from: smiley.minHeight; to: smiley.maxHeight
- easing: "easeOutExpo"; duration: 300
+ easing.type: "OutExpo"; duration: 300
}
- // Then move back to minHeight in 1 second, using the easeOutBounce easing function
+ // Then move back to minHeight in 1 second, using the OutBounce easing function
NumberAnimation {
from: smiley.maxHeight; to: smiley.minHeight
- easing: "easeOutBounce"; duration: 1000
+ easing.type: "OutBounce"; duration: 1000
}
// Then pause for 500ms
diff --git a/examples/declarative/behaviours/test.qml b/examples/declarative/behaviours/test.qml
index fc3f4bf..8fffd59 100644
--- a/examples/declarative/behaviours/test.qml
+++ b/examples/declarative/behaviours/test.qml
@@ -64,7 +64,8 @@ Rectangle {
property: "y"
from: 0
to: 10
- easing: "easeOutBounce(amplitude:30)"
+ easing.type: "OutBounce"
+ easing.amplitude: 30
duration: 250
}
NumberAnimation {
@@ -72,7 +73,8 @@ Rectangle {
property: "y"
from: 10
to: 0
- easing: "easeOutBounce(amplitude:30)"
+ easing.type: "OutBounce"
+ easing.amplitude: 30
duration: 250
}
}
diff --git a/examples/declarative/border-image/content/MyBorderImage.qml b/examples/declarative/border-image/content/MyBorderImage.qml
index a57acc7..ca886e9 100644
--- a/examples/declarative/border-image/content/MyBorderImage.qml
+++ b/examples/declarative/border-image/content/MyBorderImage.qml
@@ -19,14 +19,14 @@ Item {
width: SequentialAnimation {
repeat: true
- NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing: "easeInOutQuad"}
- NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing: "easeInOutQuad" }
+ NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing.type: "InOutQuad"}
+ NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing.type: "InOutQuad" }
}
height: SequentialAnimation {
repeat: true
- NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing: "easeInOutQuad"}
- NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing: "easeInOutQuad" }
+ NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing.type: "InOutQuad"}
+ NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing.type: "InOutQuad" }
}
border.top: container.margin
diff --git a/examples/declarative/connections/connections.qml b/examples/declarative/connections/connections.qml
index 07f71bb..4692343 100644
--- a/examples/declarative/connections/connections.qml
+++ b/examples/declarative/connections/connections.qml
@@ -5,16 +5,12 @@ Rectangle {
id: window; color: "#646464"
width: 640; height: 480
- function turnLeft() {
- image.rotation -= 90
- }
- function turnRight() {
- image.rotation += 90
- }
+ property int angle: 0
Image {
id: image; source: "content/bg1.jpg"; anchors.centerIn: parent; transformOrigin: Item.Center
- rotation: Behavior { NumberAnimation { easing: "easeOutCubic"; duration: 300 } }
+ rotation: window.angle
+ rotation: Behavior { NumberAnimation { easing.type: "OutCubic"; duration: 300 } }
}
Button {
@@ -26,6 +22,6 @@ Rectangle {
anchors { right: parent.right; bottom: parent.bottom; rightMargin: 10; bottomMargin: 10 }
}
- Connection { sender: leftButton; signal: "clicked()"; script: window.turnLeft() }
- Connection { sender: rightButton; signal: "clicked()"; script: window.turnRight() }
+ Connections { target: leftButton; onClicked: window.angle -= 90 }
+ Connections { target: rightButton; onClicked: window.angle += 90 }
}
diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp
index 74ea35c..76e0736 100644
--- a/examples/declarative/extending/adding/main.cpp
+++ b/examples/declarative/extending/adding/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "person.h"
@@ -48,8 +48,10 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_TYPE(People, 1,0, Person, Person);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
Person *person = qobject_cast<Person *>(component.create());
if (person) {
qWarning() << "The person's name is" << person->name();
diff --git a/examples/declarative/extending/adding/person.cpp b/examples/declarative/extending/adding/person.cpp
index 9efa2b8..cdf08e0 100644
--- a/examples/declarative/extending/adding/person.cpp
+++ b/examples/declarative/extending/adding/person.cpp
@@ -66,5 +66,4 @@ void Person::setShoeSize(int s)
m_shoeSize = s;
}
-QML_DEFINE_TYPE(People, 1,0, Person, Person);
// ![0]
diff --git a/examples/declarative/extending/adding/person.h b/examples/declarative/extending/adding/person.h
index 691766b..fbaf2df 100644
--- a/examples/declarative/extending/adding/person.h
+++ b/examples/declarative/extending/adding/person.h
@@ -43,7 +43,7 @@
#include <QObject>
// ![0]
-#include <qml.h>
+#include <qdeclarative.h>
class Person : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/attached/birthdayparty.cpp b/examples/declarative/extending/attached/birthdayparty.cpp
index ffdda57..d4f2675 100644
--- a/examples/declarative/extending/attached/birthdayparty.cpp
+++ b/examples/declarative/extending/attached/birthdayparty.cpp
@@ -55,8 +55,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d)
m_rsvp = d;
}
-QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
-
BirthdayParty::BirthdayParty(QObject *parent)
: QObject(parent), m_celebrant(0)
{
@@ -72,9 +70,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
@@ -92,4 +90,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
return new BirthdayPartyAttached(object);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/attached/birthdayparty.h b/examples/declarative/extending/attached/birthdayparty.h
index 9ba0f8b..d8ca2e1 100644
--- a/examples/declarative/extending/attached/birthdayparty.h
+++ b/examples/declarative/extending/attached/birthdayparty.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QDate>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -65,7 +65,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -73,7 +73,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/attached/main.cpp b/examples/declarative/extending/attached/main.cpp
index 27a9287..684d8d3 100644
--- a/examples/declarative/extending/attached/main.cpp
+++ b/examples/declarative/extending/attached/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -49,8 +49,15 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached);
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_NOCREATE_TYPE(ShoeDescription);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/attached/person.cpp b/examples/declarative/extending/attached/person.cpp
index 909505a..0a9e508 100644
--- a/examples/declarative/extending/attached/person.cpp
+++ b/examples/declarative/extending/attached/person.cpp
@@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p)
{
m_price = p;
}
-QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
Person::Person(QObject *parent)
: QObject(parent)
@@ -106,18 +105,15 @@ ShoeDescription *Person::shoe()
return &m_shoe;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/attached/person.h b/examples/declarative/extending/attached/person.h
index dd03091..0f86d8b 100644
--- a/examples/declarative/extending/attached/person.h
+++ b/examples/declarative/extending/attached/person.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QColor>
-#include <qml.h>
+#include <qdeclarative.h>
class ShoeDescription : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/binding/birthdayparty.cpp b/examples/declarative/extending/binding/birthdayparty.cpp
index 62b9c7b..e5be2b9 100644
--- a/examples/declarative/extending/binding/birthdayparty.cpp
+++ b/examples/declarative/extending/binding/birthdayparty.cpp
@@ -58,7 +58,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d)
}
}
-QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
BirthdayParty::BirthdayParty(QObject *parent)
: QObject(parent), m_celebrant(0)
@@ -77,9 +76,9 @@ void BirthdayParty::setCelebrant(Person *c)
emit celebrantChanged();
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
@@ -113,4 +112,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
return new BirthdayPartyAttached(object);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/binding/birthdayparty.h b/examples/declarative/extending/binding/birthdayparty.h
index 8bdb76a..8486442 100644
--- a/examples/declarative/extending/binding/birthdayparty.h
+++ b/examples/declarative/extending/binding/birthdayparty.h
@@ -44,7 +44,7 @@
#include <QObject>
#include <QDate>
#include <QDebug>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -71,7 +71,7 @@ Q_OBJECT
// ![0]
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant NOTIFY celebrantChanged)
// ![0]
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker)
Q_CLASSINFO("DefaultProperty", "guests")
public:
@@ -80,7 +80,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/binding/happybirthday.cpp b/examples/declarative/extending/binding/happybirthday.cpp
index 38f3c08..7d4d021 100644
--- a/examples/declarative/extending/binding/happybirthday.cpp
+++ b/examples/declarative/extending/binding/happybirthday.cpp
@@ -50,7 +50,7 @@ HappyBirthday::HappyBirthday(QObject *parent)
timer->start(1000);
}
-void HappyBirthday::setTarget(const QmlMetaProperty &p)
+void HappyBirthday::setTarget(const QDeclarativeMetaProperty &p)
{
m_target = p;
}
@@ -84,4 +84,3 @@ void HappyBirthday::advance()
m_target.write(m_lyrics.at(m_line));
}
-QML_DEFINE_TYPE(People, 1,0, HappyBirthday, HappyBirthday);
diff --git a/examples/declarative/extending/binding/happybirthday.h b/examples/declarative/extending/binding/happybirthday.h
index 852bec7..ee4d1ec 100644
--- a/examples/declarative/extending/binding/happybirthday.h
+++ b/examples/declarative/extending/binding/happybirthday.h
@@ -41,20 +41,20 @@
#ifndef HAPPYBIRTHDAY_H
#define HAPPYBIRTHDAY_H
-#include <QmlPropertyValueSource>
-#include <QmlMetaProperty>
-#include <qml.h>
+#include <QDeclarativePropertyValueSource>
+#include <QDeclarativeMetaProperty>
+#include <qdeclarative.h>
#include <QStringList>
-class HappyBirthday : public QObject, public QmlPropertyValueSource
+class HappyBirthday : public QObject, public QDeclarativePropertyValueSource
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
public:
HappyBirthday(QObject *parent = 0);
- virtual void setTarget(const QmlMetaProperty &);
+ virtual void setTarget(const QDeclarativeMetaProperty &);
QString name() const;
void setName(const QString &);
@@ -67,7 +67,7 @@ signals:
private:
int m_line;
QStringList m_lyrics;
- QmlMetaProperty m_target;
+ QDeclarativeMetaProperty m_target;
QString m_name;
};
QML_DECLARE_TYPE(HappyBirthday);
diff --git a/examples/declarative/extending/binding/main.cpp b/examples/declarative/extending/binding/main.cpp
index ba38e82..873f8c9 100644
--- a/examples/declarative/extending/binding/main.cpp
+++ b/examples/declarative/extending/binding/main.cpp
@@ -39,18 +39,27 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
+#include "happybirthday.h"
#include "person.h"
int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached);
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_TYPE(People, 1,0, HappyBirthday, HappyBirthday);
+ QML_REGISTER_NOCREATE_TYPE(ShoeDescription);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/binding/person.cpp b/examples/declarative/extending/binding/person.cpp
index 50fb754..9a2248f 100644
--- a/examples/declarative/extending/binding/person.cpp
+++ b/examples/declarative/extending/binding/person.cpp
@@ -100,7 +100,6 @@ void ShoeDescription::setPrice(qreal p)
m_price = p;
emit shoeChanged();
}
-QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
Person::Person(QObject *parent)
: QObject(parent)
@@ -126,18 +125,15 @@ ShoeDescription *Person::shoe()
return &m_shoe;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/binding/person.h b/examples/declarative/extending/binding/person.h
index e8aa6a8..1bec71c 100644
--- a/examples/declarative/extending/binding/person.h
+++ b/examples/declarative/extending/binding/person.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QColor>
-#include <qml.h>
+#include <qdeclarative.h>
class ShoeDescription : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/coercion/birthdayparty.cpp b/examples/declarative/extending/coercion/birthdayparty.cpp
index 15a4ca9..523a42d 100644
--- a/examples/declarative/extending/coercion/birthdayparty.cpp
+++ b/examples/declarative/extending/coercion/birthdayparty.cpp
@@ -55,9 +55,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
@@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const
return m_guests.at(index);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/coercion/birthdayparty.h b/examples/declarative/extending/coercion/birthdayparty.h
index 5a9eb08..fffd407 100644
--- a/examples/declarative/extending/coercion/birthdayparty.h
+++ b/examples/declarative/extending/coercion/birthdayparty.h
@@ -42,7 +42,7 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayParty : public QObject
@@ -50,7 +50,7 @@ class BirthdayParty : public QObject
Q_OBJECT
// ![0]
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
// ![0]
public:
BirthdayParty(QObject *parent = 0);
@@ -58,7 +58,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/coercion/main.cpp b/examples/declarative/extending/coercion/main.cpp
index ccbee83..1e2209f 100644
--- a/examples/declarative/extending/coercion/main.cpp
+++ b/examples/declarative/extending/coercion/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -49,8 +49,15 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+// ![0]
+ QML_REGISTER_NOCREATE_TYPE(Person);
+// ![0]
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/coercion/person.cpp b/examples/declarative/extending/coercion/person.cpp
index 9eef8f7..5b5203a 100644
--- a/examples/declarative/extending/coercion/person.cpp
+++ b/examples/declarative/extending/coercion/person.cpp
@@ -65,22 +65,16 @@ void Person::setShoeSize(int s)
m_shoeSize = s;
}
-// ![0]
-QML_DEFINE_NOCREATE_TYPE(Person);
-// ![0]
-
// ![1]
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
// ![1]
diff --git a/examples/declarative/extending/coercion/person.h b/examples/declarative/extending/coercion/person.h
index 9bb9a3d..298ffb1 100644
--- a/examples/declarative/extending/coercion/person.h
+++ b/examples/declarative/extending/coercion/person.h
@@ -42,7 +42,7 @@
#define PERSON_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
class Person : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/default/birthdayparty.cpp b/examples/declarative/extending/default/birthdayparty.cpp
index 15a4ca9..523a42d 100644
--- a/examples/declarative/extending/default/birthdayparty.cpp
+++ b/examples/declarative/extending/default/birthdayparty.cpp
@@ -55,9 +55,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
@@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const
return m_guests.at(index);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/default/birthdayparty.h b/examples/declarative/extending/default/birthdayparty.h
index f25f8c2..49c20bd 100644
--- a/examples/declarative/extending/default/birthdayparty.h
+++ b/examples/declarative/extending/default/birthdayparty.h
@@ -42,7 +42,7 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
// ![0]
@@ -50,7 +50,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -58,7 +58,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/default/main.cpp b/examples/declarative/extending/default/main.cpp
index ccbee83..7d7f8a1 100644
--- a/examples/declarative/extending/default/main.cpp
+++ b/examples/declarative/extending/default/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -49,8 +49,13 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/default/person.cpp b/examples/declarative/extending/default/person.cpp
index a0b4960..69216d3 100644
--- a/examples/declarative/extending/default/person.cpp
+++ b/examples/declarative/extending/default/person.cpp
@@ -65,18 +65,15 @@ void Person::setShoeSize(int s)
m_shoeSize = s;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/default/person.h b/examples/declarative/extending/default/person.h
index 884dda3..b3eceaa 100644
--- a/examples/declarative/extending/default/person.h
+++ b/examples/declarative/extending/default/person.h
@@ -42,7 +42,7 @@
#define PERSON_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
class Person : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/extended/lineedit.cpp b/examples/declarative/extending/extended/lineedit.cpp
index ec86aad..417fbd9 100644
--- a/examples/declarative/extending/extended/lineedit.cpp
+++ b/examples/declarative/extending/extended/lineedit.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
#include "lineedit.h"
-#include <qml.h>
+#include <qdeclarative.h>
LineEditExtension::LineEditExtension(QObject *object)
: QObject(object), m_lineedit(static_cast<QLineEdit *>(object))
@@ -103,4 +103,3 @@ void LineEditExtension::setBottomMargin(int m)
}
QML_DECLARE_TYPE(QLineEdit);
-QML_DEFINE_EXTENDED_TYPE(People, 1,0, QLineEdit, QLineEdit, LineEditExtension);
diff --git a/examples/declarative/extending/extended/main.cpp b/examples/declarative/extending/extended/main.cpp
index 9376af7..5cbeea3 100644
--- a/examples/declarative/extending/extended/main.cpp
+++ b/examples/declarative/extending/extended/main.cpp
@@ -39,17 +39,20 @@
**
****************************************************************************/
#include <QApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include <QLineEdit>
+#include "lineedit.h"
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_EXTENDED_TYPE(People, 1,0, QLineEdit, QLineEdit, LineEditExtension);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
QLineEdit *edit = qobject_cast<QLineEdit *>(component.create());
if (edit) {
diff --git a/examples/declarative/extending/extending.pro b/examples/declarative/extending/extending.pro
new file mode 100644
index 0000000..169c7ab
--- /dev/null
+++ b/examples/declarative/extending/extending.pro
@@ -0,0 +1,13 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ adding \
+ attached \
+ binding \
+ coercion \
+ default \
+ extended \
+ grouped \
+ properties \
+ signal \
+ valuesource
diff --git a/examples/declarative/extending/grouped/birthdayparty.cpp b/examples/declarative/extending/grouped/birthdayparty.cpp
index 15a4ca9..523a42d 100644
--- a/examples/declarative/extending/grouped/birthdayparty.cpp
+++ b/examples/declarative/extending/grouped/birthdayparty.cpp
@@ -55,9 +55,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
@@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const
return m_guests.at(index);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/grouped/birthdayparty.h b/examples/declarative/extending/grouped/birthdayparty.h
index fd0d955..42439c4 100644
--- a/examples/declarative/extending/grouped/birthdayparty.h
+++ b/examples/declarative/extending/grouped/birthdayparty.h
@@ -42,14 +42,14 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -57,7 +57,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/grouped/main.cpp b/examples/declarative/extending/grouped/main.cpp
index 79aaab5..15a0bb5 100644
--- a/examples/declarative/extending/grouped/main.cpp
+++ b/examples/declarative/extending/grouped/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -49,8 +49,14 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_NOCREATE_TYPE(ShoeDescription);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/grouped/person.cpp b/examples/declarative/extending/grouped/person.cpp
index 909505a..0a9e508 100644
--- a/examples/declarative/extending/grouped/person.cpp
+++ b/examples/declarative/extending/grouped/person.cpp
@@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p)
{
m_price = p;
}
-QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
Person::Person(QObject *parent)
: QObject(parent)
@@ -106,18 +105,15 @@ ShoeDescription *Person::shoe()
return &m_shoe;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/grouped/person.h b/examples/declarative/extending/grouped/person.h
index 89ccedc..5dab378 100644
--- a/examples/declarative/extending/grouped/person.h
+++ b/examples/declarative/extending/grouped/person.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QColor>
-#include <qml.h>
+#include <qdeclarative.h>
class ShoeDescription : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/properties/birthdayparty.cpp b/examples/declarative/extending/properties/birthdayparty.cpp
index 23e6e58..14fd6a3 100644
--- a/examples/declarative/extending/properties/birthdayparty.cpp
+++ b/examples/declarative/extending/properties/birthdayparty.cpp
@@ -56,9 +56,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
@@ -72,4 +72,3 @@ Person *BirthdayParty::guest(int index) const
}
// ![0]
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/properties/birthdayparty.h b/examples/declarative/extending/properties/birthdayparty.h
index e5d316c..c4cb536 100644
--- a/examples/declarative/extending/properties/birthdayparty.h
+++ b/examples/declarative/extending/properties/birthdayparty.h
@@ -42,7 +42,7 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
// ![0]
@@ -54,7 +54,7 @@ Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
// ![1]
// ![2]
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
// ![2]
// ![3]
public:
@@ -63,7 +63,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/properties/main.cpp b/examples/declarative/extending/properties/main.cpp
index 97d7905..ce69ad2 100644
--- a/examples/declarative/extending/properties/main.cpp
+++ b/examples/declarative/extending/properties/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -49,8 +49,11 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_TYPE(People, 1,0, Person, Person);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/properties/person.cpp b/examples/declarative/extending/properties/person.cpp
index d1b8bf4..92c54f5 100644
--- a/examples/declarative/extending/properties/person.cpp
+++ b/examples/declarative/extending/properties/person.cpp
@@ -65,4 +65,3 @@ void Person::setShoeSize(int s)
m_shoeSize = s;
}
-QML_DEFINE_TYPE(People, 1,0, Person, Person);
diff --git a/examples/declarative/extending/properties/person.h b/examples/declarative/extending/properties/person.h
index 8d665f0..860a607 100644
--- a/examples/declarative/extending/properties/person.h
+++ b/examples/declarative/extending/properties/person.h
@@ -42,7 +42,7 @@
#define PERSON_H
#include <QObject>
-#include <qml.h>
+#include <qdeclarative.h>
class Person : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/signal/birthdayparty.cpp b/examples/declarative/extending/signal/birthdayparty.cpp
index d8686f0..65ff530 100644
--- a/examples/declarative/extending/signal/birthdayparty.cpp
+++ b/examples/declarative/extending/signal/birthdayparty.cpp
@@ -55,7 +55,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d)
m_rsvp = d;
}
-QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
BirthdayParty::BirthdayParty(QObject *parent)
: QObject(parent), m_celebrant(0)
@@ -72,9 +71,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
@@ -98,4 +97,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
return new BirthdayPartyAttached(object);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/signal/birthdayparty.h b/examples/declarative/extending/signal/birthdayparty.h
index 30ed43b..bcdc513 100644
--- a/examples/declarative/extending/signal/birthdayparty.h
+++ b/examples/declarative/extending/signal/birthdayparty.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QDate>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -65,7 +65,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
@@ -73,7 +73,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/signal/main.cpp b/examples/declarative/extending/signal/main.cpp
index eb3bb4b..afc1a66 100644
--- a/examples/declarative/extending/signal/main.cpp
+++ b/examples/declarative/extending/signal/main.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
#include "person.h"
@@ -49,8 +49,15 @@ int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached);
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_NOCREATE_TYPE(ShoeDescription);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/signal/person.cpp b/examples/declarative/extending/signal/person.cpp
index 909505a..0a9e508 100644
--- a/examples/declarative/extending/signal/person.cpp
+++ b/examples/declarative/extending/signal/person.cpp
@@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p)
{
m_price = p;
}
-QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
Person::Person(QObject *parent)
: QObject(parent)
@@ -106,18 +105,15 @@ ShoeDescription *Person::shoe()
return &m_shoe;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/signal/person.h b/examples/declarative/extending/signal/person.h
index dd03091..0f86d8b 100644
--- a/examples/declarative/extending/signal/person.h
+++ b/examples/declarative/extending/signal/person.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QColor>
-#include <qml.h>
+#include <qdeclarative.h>
class ShoeDescription : public QObject {
Q_OBJECT
diff --git a/examples/declarative/extending/valuesource/birthdayparty.cpp b/examples/declarative/extending/valuesource/birthdayparty.cpp
index a5b3fab..99d98be 100644
--- a/examples/declarative/extending/valuesource/birthdayparty.cpp
+++ b/examples/declarative/extending/valuesource/birthdayparty.cpp
@@ -55,7 +55,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d)
m_rsvp = d;
}
-QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
BirthdayParty::BirthdayParty(QObject *parent)
: QObject(parent), m_celebrant(0)
@@ -72,9 +71,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
@@ -108,4 +107,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
return new BirthdayPartyAttached(object);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/valuesource/birthdayparty.h b/examples/declarative/extending/valuesource/birthdayparty.h
index b5a0522..819a200 100644
--- a/examples/declarative/extending/valuesource/birthdayparty.h
+++ b/examples/declarative/extending/valuesource/birthdayparty.h
@@ -44,7 +44,7 @@
#include <QObject>
#include <QDate>
#include <QDebug>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -66,7 +66,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
// ![0]
Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker)
// ![0]
@@ -77,7 +77,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/valuesource/happybirthday.cpp b/examples/declarative/extending/valuesource/happybirthday.cpp
index fbbc9e9..7b9d05a 100644
--- a/examples/declarative/extending/valuesource/happybirthday.cpp
+++ b/examples/declarative/extending/valuesource/happybirthday.cpp
@@ -50,7 +50,7 @@ HappyBirthday::HappyBirthday(QObject *parent)
timer->start(1000);
}
-void HappyBirthday::setTarget(const QmlMetaProperty &p)
+void HappyBirthday::setTarget(const QDeclarativeMetaProperty &p)
{
m_target = p;
}
@@ -79,4 +79,3 @@ void HappyBirthday::advance()
m_target.write(m_lyrics.at(m_line));
}
-QML_DEFINE_TYPE(People, 1,0, HappyBirthday, HappyBirthday);
diff --git a/examples/declarative/extending/valuesource/happybirthday.h b/examples/declarative/extending/valuesource/happybirthday.h
index c02a7d7..3e68c35 100644
--- a/examples/declarative/extending/valuesource/happybirthday.h
+++ b/examples/declarative/extending/valuesource/happybirthday.h
@@ -41,13 +41,14 @@
#ifndef HAPPYBIRTHDAY_H
#define HAPPYBIRTHDAY_H
-#include <QmlPropertyValueSource>
-#include <qml.h>
+#include <QDeclarativePropertyValueSource>
+#include <QDeclarativeMetaProperty>
+#include <qdeclarative.h>
#include <QStringList>
// ![0]
-class HappyBirthday : public QObject, public QmlPropertyValueSource
+class HappyBirthday : public QObject, public QDeclarativePropertyValueSource
{
Q_OBJECT
// ![0]
@@ -56,7 +57,7 @@ Q_PROPERTY(QString name READ name WRITE setName)
public:
HappyBirthday(QObject *parent = 0);
- virtual void setTarget(const QmlMetaProperty &);
+ virtual void setTarget(const QDeclarativeMetaProperty &);
// ![1]
QString name() const;
@@ -68,7 +69,7 @@ private slots:
private:
int m_line;
QStringList m_lyrics;
- QmlMetaProperty m_target;
+ QDeclarativeMetaProperty m_target;
QString m_name;
// ![2]
};
diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp
index ba38e82..873f8c9 100644
--- a/examples/declarative/extending/valuesource/main.cpp
+++ b/examples/declarative/extending/valuesource/main.cpp
@@ -39,18 +39,27 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
+#include "happybirthday.h"
#include "person.h"
int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached);
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_TYPE(People, 1,0, HappyBirthday, HappyBirthday);
+ QML_REGISTER_NOCREATE_TYPE(ShoeDescription);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/valuesource/person.cpp b/examples/declarative/extending/valuesource/person.cpp
index 909505a..0a9e508 100644
--- a/examples/declarative/extending/valuesource/person.cpp
+++ b/examples/declarative/extending/valuesource/person.cpp
@@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p)
{
m_price = p;
}
-QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
Person::Person(QObject *parent)
: QObject(parent)
@@ -106,18 +105,15 @@ ShoeDescription *Person::shoe()
return &m_shoe;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/valuesource/person.h b/examples/declarative/extending/valuesource/person.h
index dd03091..0f86d8b 100644
--- a/examples/declarative/extending/valuesource/person.h
+++ b/examples/declarative/extending/valuesource/person.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QColor>
-#include <qml.h>
+#include <qdeclarative.h>
class ShoeDescription : public QObject {
Q_OBJECT
diff --git a/examples/declarative/fonts/hello.qml b/examples/declarative/fonts/hello.qml
index c682477..fcc9580 100644
--- a/examples/declarative/fonts/hello.qml
+++ b/examples/declarative/fonts/hello.qml
@@ -11,7 +11,7 @@ Rectangle {
font.letterSpacing: SequentialAnimation {
repeat: true;
- NumberAnimation { from: 100; to: 300; easing: "easeInQuad"; duration: 3000 }
+ NumberAnimation { from: 100; to: 300; easing.type: "InQuad"; duration: 3000 }
ScriptAction { script: {
container.y = (screen.height / 4) + (Math.random() * screen.height / 2)
container.x = (screen.width / 4) + (Math.random() * screen.width / 2)
diff --git a/examples/declarative/imageprovider/main.cpp b/examples/declarative/imageprovider/main.cpp
index 9526105..d9d4c1a 100644
--- a/examples/declarative/imageprovider/main.cpp
+++ b/examples/declarative/imageprovider/main.cpp
@@ -41,22 +41,22 @@
#include <QApplication>
-#include <qmlengine.h>
-#include <qmlcontext.h>
-#include <qml.h>
-#include <qmlgraphicsitem.h>
-#include <qmlimageprovider.h>
-#include <qmlview.h>
+#include <qdeclarativeengine.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarative.h>
+#include <qdeclarativeitem.h>
+#include <qdeclarativeimageprovider.h>
+#include <qdeclarativeview.h>
#include <QImage>
#include <QPainter>
/*
- This example illustrates using a QmlImageProvider to serve
+ This example illustrates using a QDeclarativeImageProvider to serve
images asynchronously.
*/
//![0]
-class ColorImageProvider : public QmlImageProvider
+class ColorImageProvider : public QDeclarativeImageProvider
{
public:
// This is run in a low priority thread.
@@ -74,8 +74,7 @@ int main(int argc, char ** argv)
{
QApplication app(argc, argv);
- QmlView view;
- view.setSource(QUrl("qrc:view.qml"));
+ QDeclarativeView view;
view.engine()->addImageProvider("colors", new ColorImageProvider);
@@ -88,10 +87,10 @@ int main(int argc, char ** argv)
dataList.append("image://colors/purple");
dataList.append("image://colors/yellow");
- QmlContext *ctxt = view.rootContext();
+ QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
- view.execute();
+ view.setSource(QUrl("qrc:view.qml"));
view.show();
return app.exec();
diff --git a/examples/declarative/layouts/Button.qml b/examples/declarative/layouts/Button.qml
index 0bdb9fc..7cbf68a 100644
--- a/examples/declarative/layouts/Button.qml
+++ b/examples/declarative/layouts/Button.qml
@@ -17,6 +17,6 @@ Rectangle { border.color: "black"; color: "steelblue"; radius: 5; width: pix.wid
transitions:
Transition{
- NumberAnimation { properties:"x,left"; easing:"easeInOutQuad"; duration:200 }
+ NumberAnimation { properties:"x,left"; easing.type:"InOutQuad"; duration:200 }
}
}
diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml
index fefd964..7146702 100644
--- a/examples/declarative/layouts/positioners.qml
+++ b/examples/declarative/layouts/positioners.qml
@@ -11,12 +11,12 @@ Rectangle {
y: 0
move: Transition {
NumberAnimation {
- properties: "y"; easing: "easeOutBounce"
+ properties: "y"; easing.type: "OutBounce"
}
}
add: Transition {
NumberAnimation {
- properties: "y"; easing: "easeOutQuad"
+ properties: "y"; easing.type: "OutQuad"
}
}
Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 }
@@ -35,12 +35,12 @@ Rectangle {
y: 300
move: Transition {
NumberAnimation {
- properties: "x"; easing: "easeOutBounce"
+ properties: "x"; easing.type: "OutBounce"
}
}
add: Transition {
NumberAnimation {
- properties: "x"; easing: "easeOutQuad"
+ properties: "x"; easing.type: "OutQuad"
}
}
Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 }
@@ -101,13 +101,13 @@ Rectangle {
move: Transition {
NumberAnimation {
- properties: "x,y"; easing: "easeOutBounce"
+ properties: "x,y"; easing.type: "OutBounce"
}
}
add: Transition {
NumberAnimation {
- properties: "x,y"; easing: "easeOutBounce"
+ properties: "x,y"; easing.type: "OutBounce"
}
}
@@ -136,13 +136,13 @@ Rectangle {
move: Transition {
NumberAnimation {
- properties: "x,y"; easing: "easeOutBounce"
+ properties: "x,y"; easing.type: "OutBounce"
}
}
add: Transition {
NumberAnimation {
- properties: "x,y"; easing: "easeOutBounce"
+ properties: "x,y"; easing.type: "OutBounce"
}
}
Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 }
diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml
index f848be0..b76a9ab 100644
--- a/examples/declarative/listview/recipes.qml
+++ b/examples/declarative/listview/recipes.qml
@@ -81,7 +81,7 @@ Rectangle {
Flickable {
id: flick
anchors.top: methodTitle.bottom; anchors.bottom: parent.bottom
- width: parent.width; viewportHeight: methodText.height; clip: true
+ width: parent.width; contentHeight: methodText.height; clip: true
Text { id: methodText; text: method; wrap: true; width: details.width }
}
Image {
@@ -114,7 +114,7 @@ Rectangle {
// Make the detailed view fill the entire list area
PropertyChanges { target: wrapper; height: list.height }
// Move the list so that this item is at the top.
- PropertyChanges { target: wrapper.ListView.view; explicit: true; viewportY: wrapper.y }
+ PropertyChanges { target: wrapper.ListView.view; explicit: true; contentY: wrapper.y }
// Disallow flicking while we're in detailed view
PropertyChanges { target: wrapper.ListView.view; interactive: false }
}
@@ -124,7 +124,7 @@ Rectangle {
ParallelAnimation {
ColorAnimation { property: "color"; duration: 500 }
NumberAnimation {
- duration: 300; properties: "detailsOpacity,x,viewportY,height,width"
+ duration: 300; properties: "detailsOpacity,x,contentY,height,width"
}
}
}
diff --git a/examples/declarative/objectlistmodel/main.cpp b/examples/declarative/objectlistmodel/main.cpp
index 9e38bea..b210570 100644
--- a/examples/declarative/objectlistmodel/main.cpp
+++ b/examples/declarative/objectlistmodel/main.cpp
@@ -41,11 +41,11 @@
#include <QApplication>
-#include <qmlengine.h>
-#include <qmlcontext.h>
-#include <qml.h>
-#include <qmlgraphicsitem.h>
-#include <qmlview.h>
+#include <qdeclarativeengine.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarative.h>
+#include <qdeclarativeitem.h>
+#include <qdeclarativeview.h>
#include "dataobject.h"
@@ -58,8 +58,7 @@ int main(int argc, char ** argv)
{
QApplication app(argc, argv);
- QmlView view;
- view.setSource(QUrl("qrc:view.qml"));
+ QDeclarativeView view;
QList<QObject*> dataList;
dataList.append(new DataObject("Item 1", "red"));
@@ -67,10 +66,10 @@ int main(int argc, char ** argv)
dataList.append(new DataObject("Item 3", "blue"));
dataList.append(new DataObject("Item 4", "yellow"));
- QmlContext *ctxt = view.rootContext();
+ QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
- view.execute();
+ view.setSource(QUrl("qrc:view.qml"));
view.show();
return app.exec();
diff --git a/examples/declarative/package/Delegate.qml b/examples/declarative/package/Delegate.qml
new file mode 100644
index 0000000..4109633
--- /dev/null
+++ b/examples/declarative/package/Delegate.qml
@@ -0,0 +1,44 @@
+import Qt 4.6
+
+//![0]
+Package {
+ Text { id: listDelegate; width: 200; height: 25; text: "Empty"; Package.name: "list" }
+ Text { id: gridDelegate; width: 100; height: 50; text: "Empty"; Package.name: "grid" }
+
+ Rectangle {
+ id: wrapper
+ width: 200; height: 25
+ color: "lightsteelblue"
+ Text { text: display; anchors.centerIn: parent }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: {
+ if (wrapper.state == "inList")
+ wrapper.state = "inGrid";
+ else
+ wrapper.state = "inList";
+ }
+ }
+ state: "inList"
+ states: [
+ State {
+ name: 'inList'
+ ParentChange { target: wrapper; parent: listDelegate }
+ },
+ State {
+ name: 'inGrid'
+ ParentChange { target: wrapper; parent: gridDelegate }
+ PropertyChanges { target: wrapper; x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height }
+ }
+ ]
+ transitions: [
+ Transition {
+ SequentialAnimation {
+ ParentAction { target: wrapper }
+ NumberAnimation { targets: wrapper; properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/declarative/package/view.qml b/examples/declarative/package/view.qml
new file mode 100644
index 0000000..07bba0c
--- /dev/null
+++ b/examples/declarative/package/view.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+
+Item {
+ width: 400
+ height: 200
+
+ ListModel {
+ id: myModel
+ ListElement { display: "One" }
+ ListElement { display: "Two" }
+ ListElement { display: "Three" }
+ ListElement { display: "Four" }
+ ListElement { display: "Five" }
+ ListElement { display: "Six" }
+ ListElement { display: "Seven" }
+ ListElement { display: "Eight" }
+ }
+ //![0]
+ VisualDataModel {
+ id: visualModel
+ delegate: Delegate {}
+ model: myModel
+ }
+
+ ListView {
+ width: 200; height:200
+ model: visualModel.parts.list
+ }
+ GridView {
+ x: 200; width: 200; height:200
+ cellHeight: 50
+ model: visualModel.parts.grid
+ }
+ //![0]
+}
diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml
index 811891b..5e58100 100644
--- a/examples/declarative/parallax/qml/ParallaxView.qml
+++ b/examples/declarative/parallax/qml/ParallaxView.qml
@@ -10,8 +10,8 @@ Item {
Image {
id: background
fillMode: Image.TileHorizontally
- x: -list.viewportX / 2
- width: Math.max(list.viewportWidth, parent.width)
+ x: -list.contentX / 2
+ width: Math.max(list.contentWidth, parent.width)
}
ListView {
diff --git a/examples/declarative/parallax/qml/Smiley.qml b/examples/declarative/parallax/qml/Smiley.qml
index fc5b4fe..81eadda 100644
--- a/examples/declarative/parallax/qml/Smiley.qml
+++ b/examples/declarative/parallax/qml/Smiley.qml
@@ -27,16 +27,16 @@ Item {
y: SequentialAnimation {
repeat: true
- // Move from minHeight to maxHeight in 300ms, using the easeOutExpo easing function
+ // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function
NumberAnimation {
from: smiley.minHeight; to: smiley.maxHeight
- easing: "easeOutExpo"; duration: 300
+ easing.type: "OutExpo"; duration: 300
}
- // Then move back to minHeight in 1 second, using the easeOutBounce easing function
+ // Then move back to minHeight in 1 second, using the OutBounce easing function
NumberAnimation {
from: smiley.maxHeight; to: smiley.minHeight
- easing: "easeOutBounce"; duration: 1000
+ easing.type: "OutBounce"; duration: 1000
}
// Then pause for 500ms
diff --git a/examples/declarative/plugins/files/Clock.qml b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
index 01ec686..01ec686 100644
--- a/examples/declarative/plugins/files/Clock.qml
+++ b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
diff --git a/examples/declarative/plugins/files/center.png b/examples/declarative/plugins/com/nokia/TimeExample/center.png
index 7fbd802..7fbd802 100644
--- a/examples/declarative/plugins/files/center.png
+++ b/examples/declarative/plugins/com/nokia/TimeExample/center.png
Binary files differ
diff --git a/examples/declarative/plugins/files/clock.png b/examples/declarative/plugins/com/nokia/TimeExample/clock.png
index 462edac..462edac 100644
--- a/examples/declarative/plugins/files/clock.png
+++ b/examples/declarative/plugins/com/nokia/TimeExample/clock.png
Binary files differ
diff --git a/examples/declarative/plugins/files/hour.png b/examples/declarative/plugins/com/nokia/TimeExample/hour.png
index f8061a1..f8061a1 100644
--- a/examples/declarative/plugins/files/hour.png
+++ b/examples/declarative/plugins/com/nokia/TimeExample/hour.png
Binary files differ
diff --git a/examples/declarative/plugins/files/minute.png b/examples/declarative/plugins/com/nokia/TimeExample/minute.png
index 1297ec7..1297ec7 100644
--- a/examples/declarative/plugins/files/minute.png
+++ b/examples/declarative/plugins/com/nokia/TimeExample/minute.png
Binary files differ
diff --git a/examples/declarative/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/plugins/com/nokia/TimeExample/qmldir
new file mode 100644
index 0000000..e9ef115
--- /dev/null
+++ b/examples/declarative/plugins/com/nokia/TimeExample/qmldir
@@ -0,0 +1,2 @@
+Clock 1.0 Clock.qml
+plugin qtimeexampleqmlplugin
diff --git a/examples/declarative/plugins/plugin.cpp b/examples/declarative/plugins/plugin.cpp
index 820d4eb..741f68a 100644
--- a/examples/declarative/plugins/plugin.cpp
+++ b/examples/declarative/plugins/plugin.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include <QtDeclarative/qmlmoduleplugin.h>
-#include <QtDeclarative/qml.h>
+#include <QtDeclarative/QDeclarativeExtensionPlugin>
+#include <QtDeclarative/qdeclarative.h>
#include <qdebug.h>
#include <qdatetime.h>
#include <qbasictimer.h>
@@ -140,19 +140,14 @@ MinuteTimer *Time::timer=0;
QML_DECLARE_TYPE(Time);
-class QExampleQmlPlugin : public QmlModulePlugin
+class QExampleQmlPlugin : public QDeclarativeExtensionPlugin
{
Q_OBJECT
public:
- QStringList keys() const
- {
- return QStringList() << QLatin1String("com.nokia.TimeExample");
- }
-
- void defineModule(const QString& uri)
+ void registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample"));
- qmlRegisterType<Time>("com.nokia.TimeExample", 1, 0, "Time", "Time");
+ qmlRegisterType<Time>(uri, 1, 0, "Time");
}
};
diff --git a/examples/declarative/plugins/plugins.pro b/examples/declarative/plugins/plugins.pro
index 84ab8da..c925cea 100644
--- a/examples/declarative/plugins/plugins.pro
+++ b/examples/declarative/plugins/plugins.pro
@@ -1,15 +1,27 @@
TEMPLATE = lib
+DESTDIR = com/nokia/TimeExample
TARGET = qtimeexampleqmlplugin
CONFIG += qt plugin
QT += declarative
+VERSION = 1.0.0
SOURCES += plugin.cpp
-target.path += $$[QT_INSTALL_PLUGINS]/qmlmodules
-sources.files += files/Clock.qml files/qmldir files/background.png files/center.png files/clock-night.png files/clock.png files/hour.png files/minute.png
-sources.path += $$[QT_INSTALL_DATA]/qml/com/nokia/TimeExample
-INSTALLS += target sources
+qdeclarativesources.files += \
+ com/nokia/TimeExample/qdeclarativedir \
+ com/nokia/TimeExample/center.png \
+ com/nokia/TimeExample/clock.png \
+ com/nokia/TimeExample/Clock.qml \
+ com/nokia/TimeExample/hour.png \
+ com/nokia/TimeExample/minute.png
+qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample
-VERSION=1.0.0
+sources.files += plugins.pro plugin.cpp plugins.qml
+sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins
+target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample
+
+INSTALLS += qdeclarativesources sources target
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/declarative/plugins/plugins.qml b/examples/declarative/plugins/plugins.qml
index dbeb001..44b552b 100644
--- a/examples/declarative/plugins/plugins.qml
+++ b/examples/declarative/plugins/plugins.qml
@@ -1,5 +1,4 @@
import com.nokia.TimeExample 1.0 // import types from the plugin
-import 'files' // import types from the 'files' directory
Clock { // this class is defined in QML (files/Clock.qml)
diff --git a/examples/declarative/progressbar/progressbars.qml b/examples/declarative/progressbar/progressbars.qml
index fdd4ca7..6530c3d 100644
--- a/examples/declarative/progressbar/progressbars.qml
+++ b/examples/declarative/progressbar/progressbars.qml
@@ -6,7 +6,7 @@ Rectangle {
width: 600; height: 405; color: "#edecec"
Flickable {
- anchors.fill: parent; viewportHeight: column.height + 20
+ anchors.fill: parent; contentHeight: column.height + 20
Column {
id: column; x: 10; y: 10; spacing: 10
Repeater {
diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml
index 536a8b7..84763d2 100644
--- a/examples/declarative/scrollbar/display.qml
+++ b/examples/declarative/scrollbar/display.qml
@@ -10,9 +10,10 @@ Rectangle {
Image {
id: picture
source: "pics/niagara_falls.jpg"
+ asynchronous: true
}
- viewportWidth: picture.width
- viewportHeight: picture.height
+ contentWidth: picture.width
+ contentHeight: picture.height
// Only show the scrollbars when the view is moving.
states: [
State {
diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml
index 930f471..758aee6 100644
--- a/examples/declarative/slideswitch/content/Switch.qml
+++ b/examples/declarative/slideswitch/content/Switch.qml
@@ -66,7 +66,7 @@ Item {
//![7]
transitions: Transition {
- NumberAnimation { properties: "x"; easing: "easeInOutQuad"; duration: 200 }
+ NumberAnimation { properties: "x"; easing.type: "InOutQuad"; duration: 200 }
}
//![7]
}
diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml
index 96e0675..277dfeb 100644
--- a/examples/declarative/sql/hello.qml
+++ b/examples/declarative/sql/hello.qml
@@ -3,7 +3,7 @@ import Qt 4.6
Text {
Script {
function findGreetings() {
- var db = openDatabaseSync("QmlExampleDB", "1.0", "The Example QML SQL!", 1000000);
+ var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000);
db.transaction(
function(tx) {
diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml
index 48d5f60..8ad61ad 100644
--- a/examples/declarative/states/transitions.qml
+++ b/examples/declarative/states/transitions.qml
@@ -51,16 +51,16 @@ Rectangle {
// transitions define how the properties change.
transitions: [
// When transitioning to 'Position1' move x,y over a duration of 1 second,
- // with easeOutBounce easing function.
+ // with OutBounce easing function.
Transition {
from: "*"; to: "Position1"
- NumberAnimation { properties: "x,y"; easing: "easeOutBounce"; duration: 1000 }
+ NumberAnimation { properties: "x,y"; easing.type: "OutBounce"; duration: 1000 }
},
// When transitioning to 'Position2' move x,y over a duration of 2 seconds,
- // with easeInOutQuad easing function.
+ // with InOutQuad easing function.
Transition {
from: "*"; to: "Position2"
- NumberAnimation { properties: "x,y"; easing: "easeInOutQuad"; duration: 2000 }
+ NumberAnimation { properties: "x,y"; easing.type: "InOutQuad"; duration: 2000 }
},
// For any other state changes move x,y linearly over duration of 200ms.
Transition {
diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml
index 9eaa009..b8a4f77 100644
--- a/examples/declarative/tutorials/helloworld/tutorial3.qml
+++ b/examples/declarative/tutorials/helloworld/tutorial3.qml
@@ -28,7 +28,7 @@ Rectangle {
transitions: Transition {
from: ""; to: "down"; reversible: true
ParallelAnimation {
- NumberAnimation { properties: "y,rotation"; duration: 500; easing: "easeInOutQuad" }
+ NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: "InOutQuad" }
ColorAnimation { duration: 500 }
}
}
diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml
index 50d69d8..0d1881e 100644
--- a/examples/declarative/velocity/velocity.qml
+++ b/examples/declarative/velocity/velocity.qml
@@ -96,7 +96,7 @@ Rectangle {
}
Flickable {
id: flickable
- anchors.fill: parent; viewportWidth: lay.width
+ anchors.fill: parent; contentWidth: lay.width
Row {
id: lay
Repeater {
diff --git a/examples/declarative/webview/qml-in-html.qml b/examples/declarative/webview/qdeclarative-in-html.qml
index a2f2f2a..77180ec 100644
--- a/examples/declarative/webview/qml-in-html.qml
+++ b/examples/declarative/webview/qdeclarative-in-html.qml
@@ -6,8 +6,8 @@ Rectangle {
Flickable {
width: parent.width
height: parent.height/2
- viewportWidth: web.width*web.scale
- viewportHeight: web.height*web.scale
+ contentWidth: web.width*web.scale
+ contentHeight: web.height*web.scale
WebView {
id: web
width: 250
diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml
index b80e29c..f7c269c 100644
--- a/examples/declarative/xmldata/yahoonews.qml
+++ b/examples/declarative/xmldata/yahoonews.qml
@@ -61,7 +61,7 @@ Rectangle {
transitions: Transition {
from: "*"; to: "Details"; reversible: true
SequentialAnimation {
- NumberAnimation { duration: 200; properties: "height"; easing: "easeOutQuad" }
+ NumberAnimation { duration: 200; properties: "height"; easing.type: "OutQuad" }
NumberAnimation { duration: 200; properties: "opacity" }
}
}
diff --git a/examples/network/bearercloud/bearercloud.cpp b/examples/network/bearercloud/bearercloud.cpp
new file mode 100644
index 0000000..27a296d
--- /dev/null
+++ b/examples/network/bearercloud/bearercloud.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bearercloud.h"
+#include "cloud.h"
+
+#include <QGraphicsTextItem>
+#include <QTimer>
+#include <QDateTime>
+#include <QHostInfo>
+
+#include <QDebug>
+
+#include <math.h>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+//! [0]
+BearerCloud::BearerCloud(QObject *parent)
+: QGraphicsScene(parent), timerId(0)
+{
+ setSceneRect(-300, -300, 600, 600);
+
+ qsrand(QDateTime::currentDateTime().toTime_t());
+
+ offset[QNetworkConfiguration::Active] = 2 * M_PI * qrand() / RAND_MAX;
+ offset[QNetworkConfiguration::Discovered] = offset[QNetworkConfiguration::Active] + M_PI / 6;
+ offset[QNetworkConfiguration::Defined] = offset[QNetworkConfiguration::Discovered] - M_PI / 6;
+ offset[QNetworkConfiguration::Undefined] = offset[QNetworkConfiguration::Undefined] + M_PI / 6;
+
+ thisDevice = new QGraphicsTextItem(QHostInfo::localHostName());
+ thisDevice->setData(0, QLatin1String("This Device"));
+ thisDevice->setPos(thisDevice->boundingRect().width() / -2,
+ thisDevice->boundingRect().height() / -2);
+ addItem(thisDevice);
+
+ qreal radius = Cloud::getRadiusForState(QNetworkConfiguration::Active);
+ QGraphicsEllipseItem *orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::green));
+ addItem(orbit);
+ radius = Cloud::getRadiusForState(QNetworkConfiguration::Discovered);
+ orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::blue));
+ addItem(orbit);
+ radius = Cloud::getRadiusForState(QNetworkConfiguration::Defined);
+ orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::darkGray));
+ addItem(orbit);
+ radius = Cloud::getRadiusForState(QNetworkConfiguration::Undefined);
+ orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius);
+ orbit->setPen(QColor(Qt::lightGray));
+ addItem(orbit);
+
+ connect(&manager, SIGNAL(configurationAdded(QNetworkConfiguration)),
+ this, SLOT(configurationAdded(QNetworkConfiguration)));
+ connect(&manager, SIGNAL(configurationRemoved(QNetworkConfiguration)),
+ this, SLOT(configurationRemoved(QNetworkConfiguration)));
+ connect(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)),
+ this, SLOT(configurationChanged(QNetworkConfiguration)));
+
+ QTimer::singleShot(0, this, SLOT(updateConfigurations()));
+}
+//! [0]
+
+BearerCloud::~BearerCloud()
+{
+}
+
+void BearerCloud::cloudMoved()
+{
+ if (!timerId)
+ timerId = startTimer(1000 / 25);
+}
+
+void BearerCloud::timerEvent(QTimerEvent *)
+{
+ QList<Cloud *> clouds;
+ foreach (QGraphicsItem *item, items()) {
+ if (Cloud *cloud = qgraphicsitem_cast<Cloud *>(item))
+ clouds << cloud;
+ }
+
+ foreach (Cloud *cloud, clouds)
+ cloud->calculateForces();
+
+ bool cloudsMoved = false;
+ foreach (Cloud *cloud, clouds)
+ cloudsMoved |= cloud->advance();
+
+ if (!cloudsMoved) {
+ killTimer(timerId);
+ timerId = 0;
+ }
+}
+
+//! [2]
+void BearerCloud::configurationAdded(const QNetworkConfiguration &config)
+{
+ const QNetworkConfiguration::StateFlags state = config.state();
+
+ configStates.insert(state, config.identifier());
+
+ const qreal radius = Cloud::getRadiusForState(state);
+ const int count = configStates.count(state);
+ const qreal angle = 2 * M_PI / count;
+
+ Cloud *item = new Cloud(config);
+ configurations.insert(config.identifier(), item);
+
+ item->setPos(radius * cos((count-1) * angle + offset[state]),
+ radius * sin((count-1) * angle + offset[state]));
+
+ addItem(item);
+
+ cloudMoved();
+}
+//! [2]
+
+//! [3]
+void BearerCloud::configurationRemoved(const QNetworkConfiguration &config)
+{
+ foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys())
+ configStates.remove(state, config.identifier());
+
+ Cloud *item = configurations.take(config.identifier());
+
+ item->setFinalScale(0.0);
+ item->setDeleteAfterAnimation(true);
+
+ cloudMoved();
+}
+//! [3]
+
+//! [4]
+void BearerCloud::configurationChanged(const QNetworkConfiguration &config)
+{
+ foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys())
+ configStates.remove(state, config.identifier());
+
+ configStates.insert(config.state(), config.identifier());
+
+ cloudMoved();
+}
+//! [4]
+
+//! [1]
+void BearerCloud::updateConfigurations()
+{
+ QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations();
+
+ while (!allConfigurations.isEmpty())
+ configurationAdded(allConfigurations.takeFirst());
+
+ cloudMoved();
+}
+//! [1]
+
diff --git a/examples/network/bearercloud/bearercloud.h b/examples/network/bearercloud/bearercloud.h
new file mode 100644
index 0000000..f09cb53
--- /dev/null
+++ b/examples/network/bearercloud/bearercloud.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qnetworkconfigmanager.h>
+
+#include <QGraphicsScene>
+#include <QMap>
+#include <QHash>
+
+QT_USE_NAMESPACE
+
+class Cloud;
+
+class BearerCloud : public QGraphicsScene
+{
+ Q_OBJECT
+
+public:
+ BearerCloud(QObject *parent = 0);
+ ~BearerCloud();
+
+ void cloudMoved();
+
+ void timerEvent(QTimerEvent *event);
+
+private Q_SLOTS:
+ void configurationAdded(const QNetworkConfiguration &config);
+ void configurationRemoved(const QNetworkConfiguration &config);
+ void configurationChanged(const QNetworkConfiguration &config);
+ void updateConfigurations();
+
+private:
+ QNetworkConfigurationManager manager;
+
+ QGraphicsTextItem *thisDevice;
+ QHash<QString, Cloud *> configurations;
+
+ QMap<QNetworkConfiguration::StateFlags, qreal> offset;
+ QMultiMap<QNetworkConfiguration::StateFlags, QString> configStates;
+
+ int timerId;
+};
+
diff --git a/examples/network/bearercloud/bearercloud.pro b/examples/network/bearercloud/bearercloud.pro
new file mode 100644
index 0000000..c07626a
--- /dev/null
+++ b/examples/network/bearercloud/bearercloud.pro
@@ -0,0 +1,16 @@
+HEADERS = bearercloud.h \
+ cloud.h
+
+SOURCES = main.cpp \
+ bearercloud.cpp \
+ cloud.cpp
+
+RESOURCES = icons.qrc
+
+TARGET = bearercloud
+
+QT = core gui network svg
+
+CONFIG += console
+
+symbian:TARGET.CAPABILITY = NetworkServices ReadUserData
diff --git a/examples/network/bearercloud/cloud.cpp b/examples/network/bearercloud/cloud.cpp
new file mode 100644
index 0000000..81e13a6
--- /dev/null
+++ b/examples/network/bearercloud/cloud.cpp
@@ -0,0 +1,361 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cloud.h"
+#include "bearercloud.h"
+
+#include <qnetworksession.h>
+
+#include <QGraphicsTextItem>
+#include <QGraphicsSvgItem>
+#include <QGraphicsSceneMouseEvent>
+#include <QSvgRenderer>
+#include <QPainter>
+
+#include <QDebug>
+
+#include <math.h>
+
+static QMap<QString, QSvgRenderer *> svgCache;
+
+//! [0]
+Cloud::Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent)
+: QGraphicsItem(parent), configuration(config), deleteAfterAnimation(false)
+{
+ session = new QNetworkSession(configuration, this);
+ connect(session, SIGNAL(newConfigurationActivated()),
+ this, SLOT(newConfigurationActivated()));
+ connect(session, SIGNAL(stateChanged(QNetworkSession::State)),
+ this, SLOT(stateChanged(QNetworkSession::State)));
+
+ setFlag(ItemIsMovable);
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
+ setFlag(ItemSendsGeometryChanges);
+#endif
+ setZValue(1);
+
+ icon = new QGraphicsSvgItem(this);
+ text = new QGraphicsTextItem(this);
+
+ currentScale = 0;
+ finalScale = 1;
+ setTransform(QTransform::fromScale(currentScale, currentScale), false);
+ setOpacity(0);
+
+ newConfigurationActivated();
+}
+//! [0]
+
+Cloud::~Cloud()
+{
+}
+
+void Cloud::setFinalScale(qreal factor)
+{
+ finalScale = factor;
+}
+
+void Cloud::setDeleteAfterAnimation(bool deleteAfter)
+{
+ deleteAfterAnimation = deleteAfter;
+}
+
+void Cloud::calculateForces()
+{
+ if (!scene() || scene()->mouseGrabberItem() == this) {
+ newPos = pos();
+ return;
+ }
+
+ // sum up all the forces push this item away
+ qreal xvel = 0;
+ qreal yvel = 0;
+ QLineF orbitForce;
+ foreach (QGraphicsItem *item, scene()->items()) {
+ // other clouds
+ Cloud *cloud = qgraphicsitem_cast<Cloud *>(item);
+ if (!cloud && item->data(0) != QLatin1String("This Device"))
+ continue;
+
+ qreal factor = 1.0;
+
+ QLineF line(cloud ? item->mapToScene(0, 0) : QPointF(0, 0), mapToScene(0, 0));
+ if (item->data(0) == QLatin1String("This Device"))
+ orbitForce = line;
+
+ if (cloud)
+ factor = cloud->currentScale;
+
+ qreal dx = line.dx();
+ qreal dy = line.dy();
+ double l = 2.0 * (dx * dx + dy * dy);
+ if (l > 0) {
+ xvel += factor * dx * 200.0 / l;
+ yvel += factor * dy * 200.0 / l;
+ }
+ }
+
+ // tendency to stay at a fixed orbit
+ qreal orbit = getRadiusForState(configuration.state());
+ qreal distance = orbitForce.length();
+
+ QLineF unit = orbitForce.unitVector();
+
+ orbitForce.setLength(xvel * unit.dx() + yvel * unit.dy());
+
+ qreal w = 2 - exp(-pow(distance-orbit, 2)/(2 * 50));
+
+ if (distance < orbit) {
+ xvel += orbitForce.dx() * w;
+ yvel += orbitForce.dy() * w;
+ } else {
+ xvel -= orbitForce.dx() * w;
+ yvel -= orbitForce.dy() * w;
+ }
+
+ if (qAbs(xvel) < 0.1 && qAbs(yvel) < 0.1)
+ xvel = yvel = 0;
+
+ QRectF sceneRect = scene()->sceneRect();
+ newPos = pos() + QPointF(xvel, yvel);
+ newPos.setX(qMin(qMax(newPos.x(), sceneRect.left() + 10), sceneRect.right() - 10));
+ newPos.setY(qMin(qMax(newPos.y(), sceneRect.top() + 10), sceneRect.bottom() - 10));
+}
+
+bool Cloud::advance()
+{
+ static const qreal scaleDelta = 0.01;
+
+ bool animated = false;
+
+ if (currentScale < finalScale) {
+ animated = true;
+ currentScale = qMin<qreal>(currentScale + scaleDelta, finalScale);
+ setTransform(QTransform::fromScale(currentScale, currentScale), false);
+ } else if (currentScale > finalScale) {
+ animated = true;
+ currentScale = qMax<qreal>(currentScale - scaleDelta, finalScale);
+ setTransform(QTransform::fromScale(currentScale, currentScale), false);
+ }
+
+ if (newPos != pos()) {
+ setPos(newPos);
+ animated = true;
+ }
+
+ if (opacity() != finalOpacity) {
+ animated = true;
+ if (qAbs(finalScale - currentScale) > 0.0) {
+ // use scale as reference
+ setOpacity(opacity() + scaleDelta * (finalOpacity - opacity()) /
+ qAbs(finalScale - currentScale));
+ } else {
+ setOpacity(finalOpacity);
+ }
+ }
+
+ if (!animated && deleteAfterAnimation)
+ deleteLater();
+
+ return animated;
+}
+
+QRectF Cloud::boundingRect() const
+{
+ return childrenBoundingRect();
+}
+
+void Cloud::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
+{
+}
+
+//! [4]
+QVariant Cloud::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ switch (change) {
+ case ItemPositionHasChanged:
+ if (BearerCloud *bearercloud = qobject_cast<BearerCloud *>(scene()))
+ bearercloud->cloudMoved();
+ default:
+ ;
+ };
+
+ return QGraphicsItem::itemChange(change, value);
+}
+//! [4]
+
+//! [3]
+void Cloud::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+ if (session->isOpen())
+ session->close();
+ else
+ session->open();
+
+ event->accept();
+ }
+}
+//! [3]
+
+//! [2]
+void Cloud::stateChanged(QNetworkSession::State state)
+{
+ if (configuration.name().isEmpty())
+ finalOpacity = qreal(0.1);
+ else if (session->state() == QNetworkSession::NotAvailable)
+ finalOpacity = 0.5;
+ else
+ finalOpacity = 1.0;
+
+ QString tooltip;
+
+ if (configuration.name().isEmpty())
+ tooltip += tr("<b>HIDDEN NETWORK</b><br>");
+ else
+ tooltip += tr("<b>%1</b><br>").arg(configuration.name());
+
+ const QNetworkInterface interface = session->interface();
+ if (interface.isValid())
+ tooltip += tr("<br>Interface: %1").arg(interface.humanReadableName());
+ tooltip += tr("<br>Id: %1").arg(configuration.identifier());
+
+ const QString bearerName = configuration.bearerName();
+ if (!bearerName.isEmpty())
+ tooltip += tr("<br>Bearer: %1").arg(bearerName);
+
+ QString s = tr("<br>State: %1 (%2)");
+ switch (state) {
+ case QNetworkSession::Invalid:
+ s = s.arg(tr("Invalid"));
+ break;
+ case QNetworkSession::NotAvailable:
+ s = s.arg(tr("Not Available"));
+ break;
+ case QNetworkSession::Connecting:
+ s = s.arg(tr("Connecting"));
+ break;
+ case QNetworkSession::Connected:
+ s = s.arg(tr("Connected"));
+ break;
+ case QNetworkSession::Closing:
+ s = s.arg(tr("Closing"));
+ break;
+ case QNetworkSession::Disconnected:
+ s = s.arg(tr("Disconnected"));
+ break;
+ case QNetworkSession::Roaming:
+ s = s.arg(tr("Roaming"));
+ break;
+ default:
+ s = s.arg(tr("Unknown"));
+ }
+
+ if (session->isOpen())
+ s = s.arg(tr("Open"));
+ else
+ s = s.arg(tr("Closed"));
+
+ tooltip += s;
+
+ tooltip += tr("<br><br>Active time: %1 seconds").arg(session->activeTime());
+ tooltip += tr("<br>Received data: %1 bytes").arg(session->bytesReceived());
+ tooltip += tr("<br>Sent data: %1 bytes").arg(session->bytesWritten());
+
+ setToolTip(tooltip);
+}
+//! [2]
+
+//! [1]
+void Cloud::newConfigurationActivated()
+{
+ const QString bearerName = configuration.bearerName();
+ if (!svgCache.contains(bearerName)) {
+ if (bearerName == QLatin1String("WLAN"))
+ svgCache.insert(bearerName, new QSvgRenderer(QLatin1String(":wlan.svg")));
+ else if (bearerName == QLatin1String("Ethernet"))
+ svgCache.insert(bearerName, new QSvgRenderer(QLatin1String(":lan.svg")));
+ else
+ svgCache.insert(bearerName, new QSvgRenderer(QLatin1String(":unknown.svg")));
+ }
+
+ icon->setSharedRenderer(svgCache[bearerName]);
+
+ if (configuration.name().isEmpty()) {
+ text->setPlainText(tr("HIDDEN NETWORK"));
+ } else {
+ if (configuration.type() == QNetworkConfiguration::ServiceNetwork)
+ text->setHtml("<b>" + configuration.name() + "</b>");
+ else
+ text->setPlainText(configuration.name());
+ }
+
+ const qreal height = icon->boundingRect().height() + text->boundingRect().height();
+
+ icon->setPos(icon->boundingRect().width() / -2, height / -2);
+
+ text->setPos(text->boundingRect().width() / -2,
+ height / 2 - text->boundingRect().height());
+
+ stateChanged(session->state());
+}
+//! [1]
+
+qreal Cloud::getRadiusForState(QNetworkConfiguration::StateFlags state)
+{
+ switch (state) {
+ case QNetworkConfiguration::Active:
+ return 100;
+ break;
+ case QNetworkConfiguration::Discovered:
+ return 150;
+ break;
+ case QNetworkConfiguration::Defined:
+ return 200;
+ break;
+ case QNetworkConfiguration::Undefined:
+ return 250;
+ break;
+ default:
+ return 300;
+ }
+}
+
diff --git a/examples/network/bearercloud/cloud.h b/examples/network/bearercloud/cloud.h
new file mode 100644
index 0000000..38f8aff
--- /dev/null
+++ b/examples/network/bearercloud/cloud.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qnetworkconfiguration.h>
+#include <qnetworksession.h>
+
+#include <QGraphicsItem>
+QT_USE_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+class QGraphicsTextItem;
+class QGraphicsSvgItem;
+QT_END_NAMESPACE
+
+class Cloud : public QObject, public QGraphicsItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QGraphicsItem)
+
+public:
+ Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent = 0);
+ ~Cloud();
+
+ enum { Type = UserType + 1 };
+ int type() const { return Type; }
+
+ void setFinalScale(qreal factor);
+ void setDeleteAfterAnimation(bool deleteAfter);
+
+ void calculateForces();
+
+ bool advance();
+ QRectF boundingRect() const;
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+ static qreal getRadiusForState(QNetworkConfiguration::StateFlags state);
+
+protected:
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+
+private Q_SLOTS:
+ void stateChanged(QNetworkSession::State state);
+ void newConfigurationActivated();
+
+private:
+ QNetworkConfiguration configuration;
+ QNetworkSession *session;
+
+ QGraphicsTextItem *text;
+ QGraphicsSvgItem *icon;
+
+ qreal finalOpacity;
+ qreal finalScale;
+ qreal currentScale;
+
+ QPointF newPos;
+
+ bool deleteAfterAnimation;
+};
+
diff --git a/examples/network/bearercloud/icons.qrc b/examples/network/bearercloud/icons.qrc
new file mode 100644
index 0000000..84a8939
--- /dev/null
+++ b/examples/network/bearercloud/icons.qrc
@@ -0,0 +1,7 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>wlan.svg</file>
+ <file>lan.svg</file>
+ <file>unknown.svg</file>
+</qresource>
+</RCC>
diff --git a/examples/network/bearercloud/lan.svg b/examples/network/bearercloud/lan.svg
new file mode 100644
index 0000000..3cce805
--- /dev/null
+++ b/examples/network/bearercloud/lan.svg
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25.000002"
+ height="9.6406126"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="lan.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="19.416667"
+ inkscape:cx="15.244635"
+ inkscape:cy="11.639485"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1459"
+ inkscape:window-height="964"
+ inkscape:window-x="453"
+ inkscape:window-y="166" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-4.0978193e-8,-19.359387)">
+ <text
+ xml:space="preserve"
+ style="font-size:13.99289513px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="-1.1205248"
+ y="29"
+ id="text3239"><tspan
+ sodipodi:role="line"
+ id="tspan3241"
+ x="-1.1205248"
+ y="29">LAN</tspan></text>
+ </g>
+</svg>
diff --git a/examples/network/bearercloud/main.cpp b/examples/network/bearercloud/main.cpp
new file mode 100644
index 0000000..86ef46f
--- /dev/null
+++ b/examples/network/bearercloud/main.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bearercloud.h"
+
+#include <QApplication>
+#include <QGraphicsView>
+
+class CloudView : public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ CloudView(QGraphicsScene *scene);
+ ~CloudView() { }
+
+protected:
+ void resizeEvent(QResizeEvent *) {
+ fitInView(sceneRect(), Qt::KeepAspectRatio);
+ }
+#ifdef Q_OS_WINCE
+ void hideEvent(QHideEvent *) {
+ qApp->quit();
+ }
+#endif
+};
+
+CloudView::CloudView(QGraphicsScene *scene)
+: QGraphicsView(scene)
+{
+ setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing |
+ QPainter::SmoothPixmapTransform);
+#if defined (Q_OS_SYMBIAN) || defined (Q_OS_WINCE)
+ setWindowState(Qt::WindowMaximized);
+#endif
+}
+
+#include "main.moc"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ BearerCloud bearerCloud;
+
+ CloudView view(&bearerCloud);
+ view.show();
+
+ return app.exec();
+}
+
diff --git a/examples/network/bearercloud/unknown.svg b/examples/network/bearercloud/unknown.svg
new file mode 100644
index 0000000..fd10298
--- /dev/null
+++ b/examples/network/bearercloud/unknown.svg
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="25"
+ height="9.0681238"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="unknown.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="19.416667"
+ inkscape:cx="15.244635"
+ inkscape:cy="11.639485"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1459"
+ inkscape:window-height="964"
+ inkscape:window-x="453"
+ inkscape:window-y="166" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-6.891787e-8,-19.931876)">
+ <text
+ xml:space="preserve"
+ style="font-size:13.16195393px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+ x="-1.0539845"
+ y="29"
+ id="text3239"><tspan
+ sodipodi:role="line"
+ id="tspan3241"
+ x="-1.0539845"
+ y="29">NET</tspan></text>
+ </g>
+</svg>
diff --git a/examples/network/bearercloud/wlan.svg b/examples/network/bearercloud/wlan.svg
new file mode 100644
index 0000000..8b86089
--- /dev/null
+++ b/examples/network/bearercloud/wlan.svg
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="27"
+ height="29"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ version="1.0"
+ sodipodi:docname="wlan.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="19.416667"
+ inkscape:cx="23.665236"
+ inkscape:cy="11.639485"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1912"
+ inkscape:window-height="1130"
+ inkscape:window-x="0"
+ inkscape:window-y="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <g
+ id="g6334"
+ transform="translate(1.0000001,0)">
+ <path
+ id="path2393"
+ d="M 12.500248,9.499893 L 12.500248,28.500095"
+ style="fill:none;fill-rule:evenodd;stroke:#3bb3ff;stroke-width:0.99981093;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(1.0216765,0,0,1.0324764,0.4493163,-22.692096)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3171"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.97365081;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(1.6055152,0,0,1.6224868,-7.5798083,-40.80263)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3175"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.61958688;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(2.4812855,0,0,2.5075146,-17.62358,-67.968804)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3177"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.40090355;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(-1.0216765,0,0,1.0324764,24.550388,-22.692096)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3179"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.97365081;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(-1.6055152,0,0,1.6224868,32.580246,-40.80263)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3181"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.61958688;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:open="true"
+ sodipodi:end="4.1887902"
+ sodipodi:start="2.0943951"
+ transform="matrix(-2.4812855,0,0,2.5075146,42.623143,-67.968804)"
+ d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513"
+ sodipodi:ry="3.9141631"
+ sodipodi:rx="3.9141631"
+ sodipodi:cy="30.695278"
+ sodipodi:cx="10.815451"
+ id="path3183"
+ style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.40090355;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc" />
+ </g>
+ </g>
+</svg>
diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp
new file mode 100644
index 0000000..5b2bad1
--- /dev/null
+++ b/examples/network/bearermonitor/bearermonitor.cpp
@@ -0,0 +1,395 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bearermonitor.h"
+#include "sessionwidget.h"
+
+#include <QDebug>
+
+#ifdef Q_OS_WIN
+#include <winsock2.h>
+#undef interface
+
+#ifndef NS_NLA
+#define NS_NLA 15
+#endif
+#endif
+
+BearerMonitor::BearerMonitor(QWidget *parent)
+: QWidget(parent)
+{
+ setupUi(this);
+ delete tabWidget->currentWidget();
+ sessionGroup->hide();
+#if defined (Q_OS_SYMBIAN) || defined(Q_OS_WINCE)
+ setWindowState(Qt::WindowMaximized);
+#endif
+ updateConfigurations();
+
+ onlineStateChanged(!manager.allConfigurations(QNetworkConfiguration::Active).isEmpty());
+
+ QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration();
+ for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
+ QTreeWidgetItem *item = treeWidget->topLevelItem(i);
+
+ if (item->data(0, Qt::UserRole).toString() == defaultConfiguration.identifier()) {
+ treeWidget->setCurrentItem(item);
+ showConfigurationFor(item);
+ break;
+ }
+ }
+
+ connect(&manager, SIGNAL(configurationAdded(const QNetworkConfiguration&)),
+ this, SLOT(configurationAdded(const QNetworkConfiguration&)));
+ connect(&manager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)),
+ this, SLOT(configurationRemoved(const QNetworkConfiguration&)));
+ connect(&manager, SIGNAL(configurationChanged(const QNetworkConfiguration&)),
+ this, SLOT(configurationChanged(const QNetworkConfiguration)));
+ connect(&manager, SIGNAL(updateCompleted()), this, SLOT(updateConfigurations()));
+ connect(&manager, SIGNAL(onlineStateChanged(bool)), this ,SLOT(onlineStateChanged(bool)));
+
+#ifdef Q_OS_WIN
+ connect(registerButton, SIGNAL(clicked()), this, SLOT(registerNetwork()));
+ connect(unregisterButton, SIGNAL(clicked()), this, SLOT(unregisterNetwork()));
+#else
+ nlaGroup->hide();
+#endif
+
+ connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
+ this, SLOT(createSessionFor(QTreeWidgetItem*)));
+
+ connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
+ this, SLOT(showConfigurationFor(QTreeWidgetItem*)));
+
+ connect(newSessionButton, SIGNAL(clicked()),
+ this, SLOT(createNewSession()));
+ connect(deleteSessionButton, SIGNAL(clicked()),
+ this, SLOT(deleteSession()));
+
+ connect(scanButton, SIGNAL(clicked()),
+ this, SLOT(performScan()));
+}
+
+BearerMonitor::~BearerMonitor()
+{
+}
+
+static void updateItem(QTreeWidgetItem *item, const QNetworkConfiguration &config)
+{
+ item->setText(0, config.name());
+ item->setData(0, Qt::UserRole, config.identifier());
+
+ QFont font = item->font(1);
+ font.setBold((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active);
+ item->setFont(0, font);
+}
+
+void BearerMonitor::configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent)
+{
+ QTreeWidgetItem *item = new QTreeWidgetItem;
+ updateItem(item, config);
+
+ if (parent)
+ parent->addChild(item);
+ else
+ treeWidget->addTopLevelItem(item);
+
+ if (config.type() == QNetworkConfiguration::ServiceNetwork) {
+ foreach (const QNetworkConfiguration &child, config.children())
+ configurationAdded(child, item);
+ }
+}
+
+void BearerMonitor::configurationRemoved(const QNetworkConfiguration &config)
+{
+ for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
+ QTreeWidgetItem *item = treeWidget->topLevelItem(i);
+
+ if (item->data(0, Qt::UserRole).toString() == config.identifier()) {
+ delete item;
+ break;
+ }
+ }
+}
+
+void BearerMonitor::configurationChanged(const QNetworkConfiguration &config)
+{
+ for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
+ QTreeWidgetItem *item = treeWidget->topLevelItem(i);
+
+ if (item->data(0, Qt::UserRole).toString() == config.identifier()) {
+ updateItem(item, config);
+
+ if (config.type() == QNetworkConfiguration::ServiceNetwork)
+ updateSnapConfiguration(item, config);
+
+ if (item == treeWidget->currentItem())
+ showConfigurationFor(item);
+
+ break;
+ }
+ }
+}
+
+void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap)
+{
+ QMap<QString, QTreeWidgetItem *> itemMap;
+ for (int i = 0; i < parent->childCount(); ++i) {
+ QTreeWidgetItem *item = parent->child(i);
+ itemMap.insert(item->data(0, Qt::UserRole).toString(), item);
+ }
+
+ QList<QNetworkConfiguration> allConfigurations = snap.children();
+
+ while (!allConfigurations.isEmpty()) {
+ QNetworkConfiguration config = allConfigurations.takeFirst();
+
+ QTreeWidgetItem *item = itemMap.take(config.identifier());
+ if (item) {
+ updateItem(item, config);
+
+ if (config.type() == QNetworkConfiguration::ServiceNetwork)
+ updateSnapConfiguration(item, config);
+ } else {
+ configurationAdded(config, parent);
+ }
+ }
+
+ foreach (const QString &id, itemMap.keys())
+ delete itemMap.value(id);
+
+ itemMap.clear();
+}
+
+void BearerMonitor::updateConfigurations()
+{
+ progressBar->hide();
+ scanButton->show();
+
+ QList<QTreeWidgetItem *> items = treeWidget->findItems(QLatin1String("*"), Qt::MatchWildcard);
+ QMap<QString, QTreeWidgetItem *> itemMap;
+ while (!items.isEmpty()) {
+ QTreeWidgetItem *item = items.takeFirst();
+ itemMap.insert(item->data(0, Qt::UserRole).toString(), item);
+ }
+
+ QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations();
+
+ while (!allConfigurations.isEmpty()) {
+ QNetworkConfiguration config = allConfigurations.takeFirst();
+
+ QTreeWidgetItem *item = itemMap.take(config.identifier());
+ if (item) {
+ updateItem(item, config);
+
+ if (config.type() == QNetworkConfiguration::ServiceNetwork)
+ updateSnapConfiguration(item, config);
+ } else {
+ configurationAdded(config);
+ }
+ }
+
+ foreach (const QString &id, itemMap.keys())
+ delete itemMap.value(id);
+}
+
+void BearerMonitor::onlineStateChanged(bool isOnline)
+{
+ if (isOnline)
+ onlineState->setText(tr("Online"));
+ else
+ onlineState->setText(tr("Offline"));
+}
+
+#ifdef Q_OS_WIN
+void BearerMonitor::registerNetwork()
+{
+ QTreeWidgetItem *item = treeWidget->currentItem();
+
+ QNetworkConfiguration configuration =
+ manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString());
+
+ const QString name = configuration.name();
+
+ qDebug() << "Registering" << name << "with system";
+
+ WSAQUERYSET networkInfo;
+ memset(&networkInfo, 0, sizeof(networkInfo));
+ networkInfo.dwSize = sizeof(networkInfo);
+ networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16();
+ networkInfo.dwNameSpace = NS_NLA;
+
+ if (WSASetService(&networkInfo, RNRSERVICE_REGISTER, 0) == SOCKET_ERROR)
+ qDebug() << "WSASetService(RNRSERVICE_REGISTER) returned" << WSAGetLastError();
+}
+
+void BearerMonitor::unregisterNetwork()
+{
+ QTreeWidgetItem *item = treeWidget->currentItem();
+
+ QNetworkConfiguration configuration =
+ manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString());
+
+ const QString name = configuration.name();
+
+ qDebug() << "Unregistering" << name << "with system";
+
+ WSAQUERYSET networkInfo;
+ memset(&networkInfo, 0, sizeof(networkInfo));
+ networkInfo.dwSize = sizeof(networkInfo);
+ networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16();
+ networkInfo.dwNameSpace = NS_NLA;
+
+ if (WSASetService(&networkInfo, RNRSERVICE_DELETE, 0) == SOCKET_ERROR)
+ qDebug() << "WSASetService(RNRSERVICE_DELETE) returned" << WSAGetLastError();
+}
+#endif
+
+void BearerMonitor::showConfigurationFor(QTreeWidgetItem *item)
+{
+ QString identifier;
+
+ if (item)
+ identifier = item->data(0, Qt::UserRole).toString();
+
+ QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier);
+
+ switch (conf.state()) {
+ case QNetworkConfiguration::Active:
+ configurationState->setText(tr("Active"));
+ break;
+ case QNetworkConfiguration::Discovered:
+ configurationState->setText(tr("Discovered"));
+ break;
+ case QNetworkConfiguration::Defined:
+ configurationState->setText(tr("Defined"));
+ break;
+ case QNetworkConfiguration::Undefined:
+ configurationState->setText(tr("Undefined"));
+ break;
+ default:
+ configurationState->setText(QString());
+ }
+
+ switch (conf.type()) {
+ case QNetworkConfiguration::InternetAccessPoint:
+ configurationType->setText(tr("Internet Access Point"));
+ break;
+ case QNetworkConfiguration::ServiceNetwork:
+ configurationType->setText(tr("Service Network"));
+ break;
+ case QNetworkConfiguration::UserChoice:
+ configurationType->setText(tr("User Choice"));
+ break;
+ case QNetworkConfiguration::Invalid:
+ configurationType->setText(tr("Invalid"));
+ break;
+ default:
+ configurationType->setText(QString());
+ }
+
+ switch (conf.purpose()) {
+ case QNetworkConfiguration::UnknownPurpose:
+ configurationPurpose->setText(tr("Unknown"));
+ break;
+ case QNetworkConfiguration::PublicPurpose:
+ configurationPurpose->setText(tr("Public"));
+ break;
+ case QNetworkConfiguration::PrivatePurpose:
+ configurationPurpose->setText(tr("Private"));
+ break;
+ case QNetworkConfiguration::ServiceSpecificPurpose:
+ configurationPurpose->setText(tr("Service Specific"));
+ break;
+ default:
+ configurationPurpose->setText(QString());
+ }
+
+ configurationIdentifier->setText(conf.identifier());
+
+ configurationRoaming->setText(conf.isRoamingAvailable() ? tr("Available") : tr("Not available"));
+
+ configurationChildren->setText(QString::number(conf.children().count()));
+
+ configurationName->setText(conf.name());
+}
+
+void BearerMonitor::createSessionFor(QTreeWidgetItem *item)
+{
+ const QString identifier = item->data(0, Qt::UserRole).toString();
+
+ QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier);
+
+ SessionWidget *session = new SessionWidget(conf);
+
+ tabWidget->addTab(session, conf.name());
+
+ sessionGroup->show();
+
+ sessionWidgets.append(session);
+}
+
+void BearerMonitor::createNewSession()
+{
+ QTreeWidgetItem *item = treeWidget->currentItem();
+
+ createSessionFor(item);
+}
+
+void BearerMonitor::deleteSession()
+{
+ SessionWidget *session = qobject_cast<SessionWidget *>(tabWidget->currentWidget());
+ if (session) {
+ sessionWidgets.removeAll(session);
+
+ delete session;
+
+ if (tabWidget->count() == 0)
+ sessionGroup->hide();
+ }
+}
+
+void BearerMonitor::performScan()
+{
+ scanButton->hide();
+ progressBar->show();
+ manager.updateConfigurations();
+}
diff --git a/examples/network/bearermonitor/bearermonitor.h b/examples/network/bearermonitor/bearermonitor.h
new file mode 100644
index 0000000..d7025dd
--- /dev/null
+++ b/examples/network/bearermonitor/bearermonitor.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BEARERMONITOR_H
+#define BEARERMONITOR_H
+
+#include <qnetworkconfigmanager.h>
+#include <qnetworksession.h>
+#if defined (Q_OS_SYMBIAN) || defined(Q_OS_WINCE)
+#include "ui_bearermonitor_240_320.h"
+#else
+#include "ui_bearermonitor_640_480.h"
+#endif
+
+QT_USE_NAMESPACE
+
+class SessionWidget;
+
+class BearerMonitor : public QWidget, public Ui_BearerMonitor
+{
+ Q_OBJECT
+
+public:
+ BearerMonitor(QWidget *parent = 0);
+ ~BearerMonitor();
+
+private slots:
+ void configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent = 0);
+ void configurationRemoved(const QNetworkConfiguration &config);
+ void configurationChanged(const QNetworkConfiguration &config);
+ void updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap);
+ void updateConfigurations();
+
+ void onlineStateChanged(bool isOnline);
+
+#ifdef Q_OS_WIN
+ void registerNetwork();
+ void unregisterNetwork();
+#endif
+
+ void showConfigurationFor(QTreeWidgetItem *item);
+
+ void createSessionFor(QTreeWidgetItem *item);
+ void createNewSession();
+ void deleteSession();
+
+ void performScan();
+
+private:
+ QNetworkConfigurationManager manager;
+ QList<SessionWidget *> sessionWidgets;
+};
+
+#endif //BEARERMONITOR_H
diff --git a/examples/network/bearermonitor/bearermonitor.pro b/examples/network/bearermonitor/bearermonitor.pro
new file mode 100644
index 0000000..4b86187
--- /dev/null
+++ b/examples/network/bearermonitor/bearermonitor.pro
@@ -0,0 +1,26 @@
+HEADERS = sessionwidget.h \
+ bearermonitor.h
+
+SOURCES = main.cpp \
+ bearermonitor.cpp \
+ sessionwidget.cpp
+
+FORMS = bearermonitor_240_320.ui \
+ bearermonitor_640_480.ui \
+ sessionwidget.ui
+
+TARGET = bearermonitor
+
+QT = core gui network
+
+win32 {
+ !wince* {
+ LIBS += -lWs2_32
+ } else {
+ LIBS += -lWs2
+ }
+}
+
+CONFIG += console
+
+symbian:TARGET.CAPABILITY = NetworkServices ReadUserData
diff --git a/examples/network/bearermonitor/bearermonitor_240_320.ui b/examples/network/bearermonitor/bearermonitor_240_320.ui
new file mode 100644
index 0000000..ce9c2d1
--- /dev/null
+++ b/examples/network/bearermonitor/bearermonitor_240_320.ui
@@ -0,0 +1,420 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BearerMonitor</class>
+ <widget class="QWidget" name="BearerMonitor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>240</width>
+ <height>320</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="scrollAreaWidgetContents">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>-274</y>
+ <width>206</width>
+ <height>576</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QGroupBox" name="systemState">
+ <property name="title">
+ <string>System State</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="onlineStateLayout">
+ <item>
+ <widget class="QLabel" name="onlineStateLabel">
+ <property name="text">
+ <string>Online State:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="onlineState">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Configurations</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="configurationNameLayout">
+ <item>
+ <widget class="QLabel" name="configurationNameLabel">
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationName">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationStateLayout">
+ <item>
+ <widget class="QLabel" name="configurationStateLabel">
+ <property name="text">
+ <string>State:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationState">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationTypeLayout">
+ <item>
+ <widget class="QLabel" name="configurationTypeLabel">
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationType">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Invalid</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationPurposeLayout">
+ <item>
+ <widget class="QLabel" name="configurationPurposeLabel">
+ <property name="text">
+ <string>Purpose:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationPurpose">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Unknown</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationIdentifierLayout">
+ <item>
+ <widget class="QLabel" name="configurationIdentifierLabel">
+ <property name="text">
+ <string>Identifier:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationIdentifier">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationRoamingLayout">
+ <item>
+ <widget class="QLabel" name="configurationRoamingLabel">
+ <property name="text">
+ <string>Roaming:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationRoaming">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationChildrenLayout">
+ <item>
+ <widget class="QLabel" name="configurationChildrenLabel">
+ <property name="text">
+ <string>Children:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationChildren">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="nlaGroup">
+ <property name="title">
+ <string>Network Location Awareness</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="registerButton">
+ <property name="text">
+ <string>Register</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="unregisterButton">
+ <property name="text">
+ <string>Unregister</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="newSessionButton">
+ <property name="text">
+ <string>New Session</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="deleteSessionButton">
+ <property name="text">
+ <string>Delete Session</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="scanButton">
+ <property name="text">
+ <string>Scan</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>-1</number>
+ </property>
+ <property name="textVisible">
+ <bool>false</bool>
+ </property>
+ <property name="invertedAppearance">
+ <bool>false</bool>
+ </property>
+ <property name="format">
+ <string>%p%</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QTreeWidget" name="treeWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <attribute name="headerVisible">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="sessionGroup">
+ <property name="title">
+ <string>Sessions</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Session 1</string>
+ </attribute>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/network/bearermonitor/bearermonitor_640_480.ui b/examples/network/bearermonitor/bearermonitor_640_480.ui
new file mode 100644
index 0000000..941eaa0
--- /dev/null
+++ b/examples/network/bearermonitor/bearermonitor_640_480.ui
@@ -0,0 +1,386 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BearerMonitor</class>
+ <widget class="QWidget" name="BearerMonitor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>640</width>
+ <height>515</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="systemState">
+ <property name="title">
+ <string>System State</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="onlineStateLayout">
+ <item>
+ <widget class="QLabel" name="onlineStateLabel">
+ <property name="text">
+ <string>Online State:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="onlineState">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Configurations</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTreeWidget" name="treeWidget">
+ <attribute name="headerVisible">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="configurationNameLayout">
+ <item>
+ <widget class="QLabel" name="configurationNameLabel">
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationName">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationStateLayout">
+ <item>
+ <widget class="QLabel" name="configurationStateLabel">
+ <property name="text">
+ <string>State:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationState">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationTypeLayout">
+ <item>
+ <widget class="QLabel" name="configurationTypeLabel">
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationType">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Invalid</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationPurposeLayout">
+ <item>
+ <widget class="QLabel" name="configurationPurposeLabel">
+ <property name="text">
+ <string>Purpose:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationPurpose">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Unknown</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationIdentifierLayout">
+ <item>
+ <widget class="QLabel" name="configurationIdentifierLabel">
+ <property name="text">
+ <string>Identifier:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationIdentifier">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationRoamingLayout">
+ <item>
+ <widget class="QLabel" name="configurationRoamingLabel">
+ <property name="text">
+ <string>Roaming:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationRoaming">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationChildrenLayout">
+ <item>
+ <widget class="QLabel" name="configurationChildrenLabel">
+ <property name="text">
+ <string>Children:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configurationChildren">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="nlaGroup">
+ <property name="title">
+ <string>Network Location Awareness</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="registerButton">
+ <property name="text">
+ <string>Register</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="unregisterButton">
+ <property name="text">
+ <string>Unregister</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="newSessionButton">
+ <property name="text">
+ <string>New Session</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="deleteSessionButton">
+ <property name="text">
+ <string>Delete Session</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="scanButton">
+ <property name="text">
+ <string>Scan</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>-1</number>
+ </property>
+ <property name="textVisible">
+ <bool>false</bool>
+ </property>
+ <property name="invertedAppearance">
+ <bool>false</bool>
+ </property>
+ <property name="format">
+ <string>%p%</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QGroupBox" name="sessionGroup">
+ <property name="title">
+ <string>Sessions</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Session 1</string>
+ </attribute>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/network/bearermonitor/main.cpp b/examples/network/bearermonitor/main.cpp
new file mode 100644
index 0000000..b7ac4fe
--- /dev/null
+++ b/examples/network/bearermonitor/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include "bearermonitor.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ BearerMonitor monitor;
+ monitor.show();
+
+ return app.exec();
+}
+
diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp
new file mode 100644
index 0000000..46ffb20
--- /dev/null
+++ b/examples/network/bearermonitor/sessionwidget.cpp
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "sessionwidget.h"
+#include "qnetworkconfigmanager.h"
+
+SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *parent)
+: QWidget(parent), statsTimer(-1)
+{
+ setupUi(this);
+
+ session = new QNetworkSession(config, this);
+
+ connect(session, SIGNAL(stateChanged(QNetworkSession::State)),
+ this, SLOT(updateSession()));
+ connect(session, SIGNAL(error(QNetworkSession::SessionError)),
+ this, SLOT(updateSession()));
+
+ updateSession();
+
+ sessionId->setText(QString("0x%1").arg(qulonglong(session), 8, 16, QChar('0')));
+
+ configuration->setText(session->configuration().name());
+
+ connect(openSessionButton, SIGNAL(clicked()),
+ this, SLOT(openSession()));
+ connect(openSyncSessionButton, SIGNAL(clicked()),
+ this, SLOT(openSyncSession()));
+ connect(closeSessionButton, SIGNAL(clicked()),
+ this, SLOT(closeSession()));
+ connect(stopSessionButton, SIGNAL(clicked()),
+ this, SLOT(stopSession()));
+}
+
+SessionWidget::~SessionWidget()
+{
+ delete session;
+}
+
+void SessionWidget::timerEvent(QTimerEvent *e)
+{
+ if (e->timerId() == statsTimer) {
+ rxData->setText(QString::number(session->bytesReceived()));
+ txData->setText(QString::number(session->bytesWritten()));
+ activeTime->setText(QString::number(session->activeTime()));
+ }
+}
+
+void SessionWidget::updateSession()
+{
+ updateSessionState(session->state());
+ updateSessionError(session->error());
+
+ if (session->state() == QNetworkSession::Connected)
+ statsTimer = startTimer(1000);
+ else
+ killTimer(statsTimer);
+
+ if (session->configuration().type() == QNetworkConfiguration::InternetAccessPoint)
+ bearer->setText(session->configuration().bearerName());
+ else {
+ QNetworkConfigurationManager mgr;
+ QNetworkConfiguration c = mgr.configurationFromIdentifier(session->sessionProperty("ActiveConfiguration").toString());
+ bearer->setText(c.bearerName());
+ }
+
+ interfaceName->setText(session->interface().humanReadableName());
+ interfaceGuid->setText(session->interface().name());
+}
+
+void SessionWidget::openSession()
+{
+ session->open();
+ updateSession();
+}
+
+void SessionWidget::openSyncSession()
+{
+ session->open();
+ session->waitForOpened();
+ updateSession();
+}
+
+void SessionWidget::closeSession()
+{
+ session->close();
+ updateSession();
+}
+
+void SessionWidget::stopSession()
+{
+ session->stop();
+ updateSession();
+}
+
+void SessionWidget::updateSessionState(QNetworkSession::State state)
+{
+ QString s = tr("%1 (%2)");
+
+ switch (state) {
+ case QNetworkSession::Invalid:
+ s = s.arg(tr("Invalid"));
+ break;
+ case QNetworkSession::NotAvailable:
+ s = s.arg(tr("Not Available"));
+ break;
+ case QNetworkSession::Connecting:
+ s = s.arg(tr("Connecting"));
+ break;
+ case QNetworkSession::Connected:
+ s = s.arg(tr("Connected"));
+ break;
+ case QNetworkSession::Closing:
+ s = s.arg(tr("Closing"));
+ break;
+ case QNetworkSession::Disconnected:
+ s = s.arg(tr("Disconnected"));
+ break;
+ case QNetworkSession::Roaming:
+ s = s.arg(tr("Roaming"));
+ break;
+ default:
+ s = s.arg(tr("Unknown"));
+ }
+
+ if (session->isOpen())
+ s = s.arg(tr("Open"));
+ else
+ s = s.arg(tr("Closed"));
+
+ sessionState->setText(s);
+}
+
+void SessionWidget::updateSessionError(QNetworkSession::SessionError error)
+{
+ lastError->setText(QString::number(error));
+ errorString->setText(session->errorString());
+}
+
diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h
new file mode 100644
index 0000000..cc9c067
--- /dev/null
+++ b/examples/network/bearermonitor/sessionwidget.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SESSIONWIDGET_H
+#define SESSIONWIDGET_H
+
+#include "ui_sessionwidget.h"
+
+#include <qnetworksession.h>
+
+QT_USE_NAMESPACE
+
+class SessionWidget : public QWidget, public Ui_SessionWidget
+{
+ Q_OBJECT
+
+public:
+ SessionWidget(const QNetworkConfiguration &config, QWidget *parent = 0);
+ ~SessionWidget();
+
+ void timerEvent(QTimerEvent *);
+
+private:
+ void updateSessionState(QNetworkSession::State state);
+ void updateSessionError(QNetworkSession::SessionError error);
+
+private Q_SLOTS:
+ void openSession();
+ void openSyncSession();
+ void closeSession();
+ void stopSession();
+ void updateSession();
+
+private:
+ QNetworkSession *session;
+ int statsTimer;
+};
+
+#endif
+
diff --git a/examples/network/bearermonitor/sessionwidget.ui b/examples/network/bearermonitor/sessionwidget.ui
new file mode 100644
index 0000000..45135f5
--- /dev/null
+++ b/examples/network/bearermonitor/sessionwidget.ui
@@ -0,0 +1,307 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SessionWidget</class>
+ <widget class="QWidget" name="SessionWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>340</width>
+ <height>276</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="sessionIdLayout">
+ <item>
+ <widget class="QLabel" name="sessionIdLabel">
+ <property name="text">
+ <string>Session ID:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="sessionId">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="sessionStateLayout">
+ <item>
+ <widget class="QLabel" name="sessionStateLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Session State:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="sessionState">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Invalid</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="configurationLayout">
+ <item>
+ <widget class="QLabel" name="configurationLabel">
+ <property name="text">
+ <string>Configuration:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="configuration">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="bearerLayout">
+ <item>
+ <widget class="QLabel" name="bearerLabel">
+ <property name="text">
+ <string>Bearer:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="bearer">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="interfaceNameLayout">
+ <item>
+ <widget class="QLabel" name="interfaceNameLabel">
+ <property name="text">
+ <string>Interface Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="interfaceName">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="interfaceGuidLayout">
+ <item>
+ <widget class="QLabel" name="interfaceGuidLabel">
+ <property name="text">
+ <string>Interface GUID:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="interfaceGuid">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="lastErrorLayout">
+ <item>
+ <widget class="QLabel" name="lastErrorLabel">
+ <property name="text">
+ <string>Last Error:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="lastError">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="errorStringLayout">
+ <item>
+ <widget class="QLabel" name="errorStringLabel">
+ <property name="text">
+ <string>Error String</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="errorString">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="rxData">
+ <property name="text">
+ <string>0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="txData">
+ <property name="text">
+ <string>0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Active Time:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="activeTime">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>0 seconds</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="openSessionButton">
+ <property name="text">
+ <string>Open</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="openSyncSessionButton">
+ <property name="text">
+ <string>Blocking Open</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QPushButton" name="closeSessionButton">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="stopSessionButton">
+ <property name="text">
+ <string>Stop</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp
index 95fc82f..ec7cd33 100644
--- a/examples/network/http/httpwindow.cpp
+++ b/examples/network/http/httpwindow.cpp
@@ -49,9 +49,9 @@ HttpWindow::HttpWindow(QWidget *parent)
: QDialog(parent)
{
#ifndef QT_NO_OPENSSL
- urlLineEdit = new QLineEdit("https://");
+ urlLineEdit = new QLineEdit("https://qt.nokia.com/");
#else
- urlLineEdit = new QLineEdit("http://");
+ urlLineEdit = new QLineEdit("http://qt.nokia.com/");
#endif
urlLabel = new QLabel(tr("&URL:"));
@@ -70,21 +70,14 @@ HttpWindow::HttpWindow(QWidget *parent)
progressDialog = new QProgressDialog(this);
- http = new QHttp(this);
-
connect(urlLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(enableDownloadButton()));
- connect(http, SIGNAL(requestFinished(int,bool)),
- this, SLOT(httpRequestFinished(int,bool)));
- connect(http, SIGNAL(dataReadProgress(int,int)),
- this, SLOT(updateDataReadProgress(int,int)));
- connect(http, SIGNAL(responseHeaderReceived(QHttpResponseHeader)),
- this, SLOT(readResponseHeader(QHttpResponseHeader)));
- connect(http, SIGNAL(authenticationRequired(QString,quint16,QAuthenticator*)),
- this, SLOT(slotAuthenticationRequired(QString,quint16,QAuthenticator*)));
+
+ connect(&qnam, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
+ this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
#ifndef QT_NO_OPENSSL
- connect(http, SIGNAL(sslErrors(QList<QSslError>)),
- this, SLOT(sslErrors(QList<QSslError>)));
+ connect(&qnam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
+ this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
#endif
connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));
connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile()));
@@ -104,9 +97,21 @@ HttpWindow::HttpWindow(QWidget *parent)
urlLineEdit->setFocus();
}
+void HttpWindow::startRequest(QUrl url)
+{
+ reply = qnam.get(QNetworkRequest(url));
+ connect(reply, SIGNAL(finished()),
+ this, SLOT(httpFinished()));
+ connect(reply, SIGNAL(readyRead()),
+ this, SLOT(httpReadyRead()));
+ connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(updateDataReadProgress(qint64,qint64)));
+}
+
void HttpWindow::downloadFile()
{
- QUrl url(urlLineEdit->text());
+ url = urlLineEdit->text();
+
QFileInfo fileInfo(url.path());
QString fileName = fileInfo.fileName();
if (fileName.isEmpty())
@@ -132,35 +137,26 @@ void HttpWindow::downloadFile()
return;
}
- QHttp::ConnectionMode mode = url.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
- http->setHost(url.host(), mode, url.port() == -1 ? 0 : url.port());
-
- if (!url.userName().isEmpty())
- http->setUser(url.userName(), url.password());
-
- httpRequestAborted = false;
- QByteArray path = QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/");
- if (path.isEmpty())
- path = "/";
- httpGetId = http->get(path, file);
progressDialog->setWindowTitle(tr("HTTP"));
progressDialog->setLabelText(tr("Downloading %1.").arg(fileName));
downloadButton->setEnabled(false);
+
+ // schedule the request
+ httpRequestAborted = false;
+ startRequest(url);
}
void HttpWindow::cancelDownload()
{
statusLabel->setText(tr("Download canceled."));
httpRequestAborted = true;
- http->abort();
+ reply->abort();
downloadButton->setEnabled(true);
}
-void HttpWindow::httpRequestFinished(int requestId, bool error)
+void HttpWindow::httpFinished()
{
- if (requestId != httpGetId)
- return;
if (httpRequestAborted) {
if (file) {
file->close();
@@ -168,54 +164,58 @@ void HttpWindow::httpRequestFinished(int requestId, bool error)
delete file;
file = 0;
}
-
+ reply->deleteLater();
progressDialog->hide();
return;
}
- if (requestId != httpGetId)
- return;
-
progressDialog->hide();
+ file->flush();
file->close();
- if (error) {
+
+ QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (reply->error()) {
file->remove();
QMessageBox::information(this, tr("HTTP"),
tr("Download failed: %1.")
- .arg(http->errorString()));
+ .arg(reply->errorString()));
+ downloadButton->setEnabled(true);
+ } else if (!redirectionTarget.isNull()) {
+ QUrl newUrl = url.resolved(redirectionTarget.toUrl());
+ if (QMessageBox::question(this, tr("HTTP"),
+ tr("Redirect to %1 ?").arg(newUrl.toString()),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ url = newUrl;
+ reply->deleteLater();
+ file->open(QIODevice::WriteOnly);
+ file->resize(0);
+ startRequest(url);
+ return;
+ }
} else {
QString fileName = QFileInfo(QUrl(urlLineEdit->text()).path()).fileName();
statusLabel->setText(tr("Downloaded %1 to current directory.").arg(fileName));
+ downloadButton->setEnabled(true);
}
- downloadButton->setEnabled(true);
+ reply->deleteLater();
+ reply = 0;
delete file;
file = 0;
}
-void HttpWindow::readResponseHeader(const QHttpResponseHeader &responseHeader)
+void HttpWindow::httpReadyRead()
{
- switch (responseHeader.statusCode()) {
- case 200: // Ok
- case 301: // Moved Permanently
- case 302: // Found
- case 303: // See Other
- case 307: // Temporary Redirect
- // these are not error conditions
- break;
-
- default:
- QMessageBox::information(this, tr("HTTP"),
- tr("Download failed: %1.")
- .arg(responseHeader.reasonPhrase()));
- httpRequestAborted = true;
- progressDialog->hide();
- http->abort();
- }
+ // this slot gets called everytime the QNetworkReply has new data.
+ // We read all of its new data and write it into the file.
+ // That way we use less RAM than when reading it at the finished()
+ // signal of the QNetworkReply
+ if (file)
+ file->write(reply->readAll());
}
-void HttpWindow::updateDataReadProgress(int bytesRead, int totalBytes)
+void HttpWindow::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
{
if (httpRequestAborted)
return;
@@ -229,14 +229,19 @@ void HttpWindow::enableDownloadButton()
downloadButton->setEnabled(!urlLineEdit->text().isEmpty());
}
-void HttpWindow::slotAuthenticationRequired(const QString &hostName, quint16, QAuthenticator *authenticator)
+void HttpWindow::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authenticator)
{
QDialog dlg;
Ui::Dialog ui;
ui.setupUi(&dlg);
dlg.adjustSize();
- ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(hostName));
-
+ ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(url.host()));
+
+ // Did the URL have information? Fill the UI
+ // This is only relevant if the URL-supplied credentials were wrong
+ ui.userEdit->setText(url.userName());
+ ui.passwordEdit->setText(url.password());
+
if (dlg.exec() == QDialog::Accepted) {
authenticator->setUser(ui.userEdit->text());
authenticator->setPassword(ui.passwordEdit->text());
@@ -244,7 +249,7 @@ void HttpWindow::slotAuthenticationRequired(const QString &hostName, quint16, QA
}
#ifndef QT_NO_OPENSSL
-void HttpWindow::sslErrors(const QList<QSslError> &errors)
+void HttpWindow::sslErrors(QNetworkReply*,const QList<QSslError> &errors)
{
QString errorString;
foreach (const QSslError &error, errors) {
@@ -253,10 +258,10 @@ void HttpWindow::sslErrors(const QList<QSslError> &errors)
errorString += error.errorString();
}
- if (QMessageBox::warning(this, tr("HTTP Example"),
+ if (QMessageBox::warning(this, tr("HTTP"),
tr("One or more SSL errors has occurred: %1").arg(errorString),
QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) {
- http->ignoreSslErrors();
+ reply->ignoreSslErrors();
}
}
#endif
diff --git a/examples/network/http/httpwindow.h b/examples/network/http/httpwindow.h
index 9dca8a5..83898af 100644
--- a/examples/network/http/httpwindow.h
+++ b/examples/network/http/httpwindow.h
@@ -43,18 +43,21 @@
#define HTTPWINDOW_H
#include <QDialog>
+#include <QNetworkAccessManager>
+#include <QUrl>
QT_BEGIN_NAMESPACE
class QDialogButtonBox;
class QFile;
-class QHttp;
-class QHttpResponseHeader;
class QLabel;
class QLineEdit;
class QProgressDialog;
class QPushButton;
class QSslError;
class QAuthenticator;
+class QNetworkReply;
+
+
QT_END_NAMESPACE
class HttpWindow : public QDialog
@@ -64,16 +67,18 @@ class HttpWindow : public QDialog
public:
HttpWindow(QWidget *parent = 0);
+ void startRequest(QUrl url);
+
private slots:
void downloadFile();
void cancelDownload();
- void httpRequestFinished(int requestId, bool error);
- void readResponseHeader(const QHttpResponseHeader &responseHeader);
- void updateDataReadProgress(int bytesRead, int totalBytes);
+ void httpFinished();
+ void httpReadyRead();
+ void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
void enableDownloadButton();
- void slotAuthenticationRequired(const QString &, quint16, QAuthenticator *);
+ void slotAuthenticationRequired(QNetworkReply*,QAuthenticator *);
#ifndef QT_NO_OPENSSL
- void sslErrors(const QList<QSslError> &errors);
+ void sslErrors(QNetworkReply*,const QList<QSslError> &errors);
#endif
private:
@@ -85,7 +90,9 @@ private:
QPushButton *quitButton;
QDialogButtonBox *buttonBox;
- QHttp *http;
+ QUrl url;
+ QNetworkAccessManager qnam;
+ QNetworkReply *reply;
QFile *file;
int httpGetId;
bool httpRequestAborted;
diff --git a/examples/network/http/main.cpp b/examples/network/http/main.cpp
index ecbe100..817b2be 100644
--- a/examples/network/http/main.cpp
+++ b/examples/network/http/main.cpp
@@ -46,7 +46,6 @@
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- qWarning("The usage of QHttp is not recommended anymore, please use QNetworkAccessManager.");
HttpWindow httpWin;
httpWin.show();
return httpWin.exec();
diff --git a/examples/network/loopback/dialog.cpp b/examples/network/loopback/dialog.cpp
index 27cff31..b504e36 100644
--- a/examples/network/loopback/dialog.cpp
+++ b/examples/network/loopback/dialog.cpp
@@ -44,12 +44,12 @@
#include "dialog.h"
-#if !defined(Q_OS_WINCE)
+#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
static const int TotalBytes = 50 * 1024 * 1024;
#else
static const int TotalBytes = 5 * 1024 * 1024;
#endif
-static const int PayloadSize = 65536;
+static const int PayloadSize = 64 * 1024; // 64 KB
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
@@ -130,6 +130,7 @@ void Dialog::acceptConnection()
void Dialog::startTransfer()
{
+ // called when the TCP client connected to the loopback server
bytesToWrite = TotalBytes - (int)tcpClient.write(QByteArray(PayloadSize, '@'));
clientStatusLabel->setText(tr("Connected"));
}
@@ -155,8 +156,11 @@ void Dialog::updateServerProgress()
void Dialog::updateClientProgress(qint64 numBytes)
{
+ // callen when the TCP client has written some bytes
bytesWritten += (int)numBytes;
- if (bytesToWrite > 0)
+
+ // only write more if not finished and when the Qt write buffer is below a certain size.
+ if (bytesToWrite > 0 && tcpClient.bytesToWrite() <= 4*PayloadSize)
bytesToWrite -= (int)tcpClient.write(QByteArray(qMin(bytesToWrite, PayloadSize), '@'));
clientProgressBar->setMaximum(TotalBytes);
diff --git a/examples/network/network.pro b/examples/network/network.pro
index c5a97fb..bd632b8 100644
--- a/examples/network/network.pro
+++ b/examples/network/network.pro
@@ -11,7 +11,9 @@ SUBDIRS = blockingfortuneclient \
loopback \
threadedfortuneserver \
googlesuggest \
- torrent
+ torrent \
+ bearercloud \
+ bearermonitor
# no QProcess
!vxworks:!qnx:SUBDIRS += network-chat