diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-05 09:58:55 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-05 09:58:55 (GMT) |
commit | 2144aece152bc34faff5b25632e808e96d523f48 (patch) | |
tree | 7a3762788646792cd131f13ce4115111d16790fe /examples | |
parent | babf1ff43584b454ac24728fbf93bf291b9f36d1 (diff) | |
parent | 1be2e830da7aa09f92d8cdca906f8a588cd10381 (diff) | |
download | Qt-2144aece152bc34faff5b25632e808e96d523f48.zip Qt-2144aece152bc34faff5b25632e808e96d523f48.tar.gz Qt-2144aece152bc34faff5b25632e808e96d523f48.tar.bz2 |
Merge remote branch 'lighthouse/4.7' into lighthouse-master
Diffstat (limited to 'examples')
26 files changed, 520 insertions, 41 deletions
diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp index 8778046..02cdb71 100644 --- a/examples/animation/stickman/lifecycle.cpp +++ b/examples/animation/stickman/lifecycle.cpp @@ -103,7 +103,7 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver) m_animationGroup->addAnimation(pa); } - // Set up intial state graph + // Set up initial state graph //! [3] m_machine = new QStateMachine(); m_machine->addDefaultAnimation(m_animationGroup); diff --git a/examples/declarative/cppextensions/referenceexamples/adding/main.cpp b/examples/declarative/cppextensions/referenceexamples/adding/main.cpp index f429b6e..391113c 100644 --- a/examples/declarative/cppextensions/referenceexamples/adding/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/adding/main.cpp @@ -57,7 +57,7 @@ int main(int argc, char ** argv) qWarning() << "The person's name is" << person->name(); qWarning() << "They wear a" << person->shoeSize() << "sized shoe"; } else { - qWarning() << "An error occured"; + qWarning() << "An error occurred"; } return 0; diff --git a/examples/declarative/cppextensions/referenceexamples/attached/main.cpp b/examples/declarative/cppextensions/referenceexamples/attached/main.cpp index 22e844f..5a39a98 100644 --- a/examples/declarative/cppextensions/referenceexamples/attached/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/attached/main.cpp @@ -83,7 +83,7 @@ int main(int argc, char ** argv) } } else { - qWarning() << "An error occured"; + qWarning() << "An error occurred"; } return 0; diff --git a/examples/declarative/cppextensions/referenceexamples/binding/main.cpp b/examples/declarative/cppextensions/referenceexamples/binding/main.cpp index 29da994..fe1bbc8 100644 --- a/examples/declarative/cppextensions/referenceexamples/binding/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/binding/main.cpp @@ -85,7 +85,7 @@ int main(int argc, char ** argv) party->startParty(); } else { - qWarning() << "An error occured"; + qWarning() << "An error occurred"; } return app.exec(); diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp index 9b32c8b..5c53368 100644 --- a/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp @@ -70,7 +70,7 @@ int main(int argc, char ** argv) for (int ii = 0; ii < party->guestCount(); ++ii) qWarning() << " " << party->guest(ii)->name(); } else { - qWarning() << "An error occured"; + qWarning() << "An error occurred"; } return 0; diff --git a/examples/declarative/cppextensions/referenceexamples/default/main.cpp b/examples/declarative/cppextensions/referenceexamples/default/main.cpp index f3a7068..f611bc4 100644 --- a/examples/declarative/cppextensions/referenceexamples/default/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/default/main.cpp @@ -68,7 +68,7 @@ int main(int argc, char ** argv) for (int ii = 0; ii < party->guestCount(); ++ii) qWarning() << " " << party->guest(ii)->name(); } else { - qWarning() << "An error occured"; + qWarning() << "An error occurred"; } return 0; diff --git a/examples/declarative/cppextensions/referenceexamples/extended/main.cpp b/examples/declarative/cppextensions/referenceexamples/extended/main.cpp index fb7ce1a..65527c3 100644 --- a/examples/declarative/cppextensions/referenceexamples/extended/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/extended/main.cpp @@ -58,7 +58,7 @@ int main(int argc, char ** argv) edit->show(); return app.exec(); } else { - qWarning() << "An error occured"; + qWarning() << "An error occurred"; return 0; } } diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp index f2e0f55..e56a14d 100644 --- a/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp @@ -78,7 +78,7 @@ int main(int argc, char ** argv) qWarning() << bestShoe->name() << "is wearing the best shoes!"; } else { - qWarning() << "An error occured"; + qWarning() << "An error occurred"; } return 0; diff --git a/examples/declarative/cppextensions/referenceexamples/properties/main.cpp b/examples/declarative/cppextensions/referenceexamples/properties/main.cpp index b5dafe2..80237ef 100644 --- a/examples/declarative/cppextensions/referenceexamples/properties/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/properties/main.cpp @@ -61,7 +61,7 @@ int main(int argc, char ** argv) for (int ii = 0; ii < party->guestCount(); ++ii) qWarning() << " " << party->guest(ii)->name(); } else { - qWarning() << "An error occured"; + qWarning() << "An error occurred"; } return 0; diff --git a/examples/declarative/cppextensions/referenceexamples/signal/main.cpp b/examples/declarative/cppextensions/referenceexamples/signal/main.cpp index 6add975..56c0809 100644 --- a/examples/declarative/cppextensions/referenceexamples/signal/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/signal/main.cpp @@ -84,7 +84,7 @@ int main(int argc, char ** argv) party->startParty(); } else { - qWarning() << "An error occured"; + qWarning() << "An error occurred"; } return 0; diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp index 5752af7..40dc3cb 100644 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp @@ -86,7 +86,7 @@ int main(int argc, char ** argv) party->startParty(); } else { - qWarning() << "An error occured"; + qWarning() << "An error occurred"; } return app.exec(); diff --git a/examples/declarative/screenorientation/Core/Bubble.qml b/examples/declarative/screenorientation/Core/Bubble.qml new file mode 100644 index 0000000..2474f30 --- /dev/null +++ b/examples/declarative/screenorientation/Core/Bubble.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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 QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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$ +** +****************************************************************************/ + +import Qt 4.7 + +Rectangle { + property bool rising: false + property bool verticalRise: true + property real xAttractor: 0 + property real yAttractor: 0 + + width: 5 + 10*Math.random() + height: width + radius: Math.floor(width/2)-1 + property real amountOfGray: Math.random() + color: Qt.rgba(amountOfGray,amountOfGray,amountOfGray,1) + + y: (rising && verticalRise) ? yAttractor : Math.random()*(main.inPortrait ? main.baseHeight : main.baseWidth) + x: (rising && !verticalRise) ? xAttractor : Math.random()*(main.inPortrait ? main.baseWidth : main.baseHeight) + Behavior on x { + id: xBehavior + SmoothedAnimation { + velocity: 100+Math.random()*100 + } + } + Behavior on y { + id: yBehavior + SmoothedAnimation { + velocity: 100+Math.random()*100 + } + } + Timer { + interval: 80+Math.random()*40 + repeat: true + running: true + onTriggered: { + if (rising) { + if (x > main.width || x < 0) { + xBehavior.enabled = false; + rising = false; + xBehavior.enabled = true; + rising = true; + } + if (y > main.height || y < 0) { + yBehavior.enabled = false; + rising = false; + yBehavior.enabled = true; + rising = true; + } + } + } + } +}
\ No newline at end of file diff --git a/examples/declarative/screenorientation/Core/Button.qml b/examples/declarative/screenorientation/Core/Button.qml new file mode 100644 index 0000000..60083d8 --- /dev/null +++ b/examples/declarative/screenorientation/Core/Button.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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 QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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$ +** +****************************************************************************/ + +import Qt 4.7 +Item { + id: button + signal clicked + property string text + property bool toggled: false + width: 100 + height: 60 + Rectangle { + anchors.fill: button + anchors.margins: mouseArea.pressed ? 3 : 2 + color: toggled ? (mouseArea.pressed ? "#442222" : "darkred") : (mouseArea.pressed ? "#333333": "black") + radius: mouseArea.pressed ? 8 : 6 + Text { + id: text + anchors.centerIn: parent + text: button.text + font.pixelSize: mouseArea.pressed ? 12 : 14 + color: "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + button.clicked() + } + } + } +} diff --git a/examples/declarative/screenorientation/Core/screenorientation.js b/examples/declarative/screenorientation/Core/screenorientation.js new file mode 100644 index 0000000..f0a5574 --- /dev/null +++ b/examples/declarative/screenorientation/Core/screenorientation.js @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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$ +** +****************************************************************************/ + +function printOrientation(orientation) { + var orientationString; + if (orientation == Orientation.Portrait) { + orientationString = "Portrait"; + } else if (orientation == Orientation.Landscape) { + orientationString = "Landscape"; + } else if (orientation == Orientation.PortraitInverted) { + orientationString = "Portrait inverted"; + } else if (orientation == Orientation.LandscapeInverted) { + orientationString = "Landscape inverted"; + } else { + orientationString = "UnknownOrientation"; + } + return orientationString; +} + +function getAngle(orientation) { + var angle; + if (orientation == Orientation.Portrait) { + angle = 0; + } else if (orientation == Orientation.Landscape) { + angle = 90; + } else if (orientation == Orientation.PortraitInverted) { + angle = 180; + } else if (orientation == Orientation.LandscapeInverted) { + angle = 270; + } else { + angle = 0; + } + return angle; +} + +function parallel(firstOrientation, secondOrientation) { + var difference = getAngle(firstOrientation) - getAngle(secondOrientation) + return difference % 180 == 0; +} + +function calculateGravityPoint(firstOrientation, secondOrientation) { + var position = Qt.point(0, 0); + var difference = getAngle(firstOrientation) - getAngle(secondOrientation) + if (difference < 0) { + difference = 360 + difference; + } + if (difference == 0) { + position = Qt.point(0, -10); + } else if (difference == 90) { + position = Qt.point(-10, 0); + } else if (difference == 180) { + position = Qt.point(0, 1000); + } else if (difference == 270) { + position = Qt.point(1000, 0); + } + return position; +} diff --git a/examples/declarative/screenorientation/screenorientation.qml b/examples/declarative/screenorientation/screenorientation.qml new file mode 100644 index 0000000..6af38bb --- /dev/null +++ b/examples/declarative/screenorientation/screenorientation.qml @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** 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 QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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$ +** +****************************************************************************/ + +import Qt 4.7 +import "Core" +import "Core/screenorientation.js" as ScreenOrientation + +Rectangle { + id: window + width: 360 + height: 640 + color: "white" + + Rectangle { + id: main + clip: true + property variant selectedOrientation: Orientation.UnknownOrientation + property variant activeOrientation: selectedOrientation == Orientation.UnknownOrientation ? runtime.orientation : selectedOrientation + state: "orientation " + activeOrientation + property bool inPortrait: (activeOrientation == Orientation.Portrait || activeOrientation == Orientation.PortraitInverted); + + // rotation correction for landscape devices like N900 + property bool landscapeWindow: window.width > window.height + property variant rotationDelta: landscapeWindow ? -90 : 0 + rotation: rotationDelta + + // initial state is portrait + property real baseWidth: landscapeWindow ? window.height-10 : window.width-10 + property real baseHeight: landscapeWindow ? window.width-10 : window.height-10 + + width: baseWidth + height: baseHeight + anchors.centerIn: parent + + color: "black" + gradient: Gradient { + GradientStop { position: 0.0; color: Qt.rgba(0.5,0.5,0.5,0.5) } + GradientStop { position: 0.8; color: "black" } + GradientStop { position: 1.0; color: "black" } + } + Item { + id: bubbles + property bool rising: false + anchors.fill: parent + property variant gravityPoint: ScreenOrientation.calculateGravityPoint(main.activeOrientation, runtime.orientation) + Repeater { + model: 24 + Bubble { + rising: bubbles.rising + verticalRise: ScreenOrientation.parallel(main.activeOrientation, runtime.orientation) + xAttractor: parent.gravityPoint.x + yAttractor: parent.gravityPoint.y + } + } + Component.onCompleted: bubbles.rising = true; + } + + Column { + width: centeredText.width + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenterOffset: 30 + Text { + text: "Orientation" + color: "white" + font.pixelSize: 22 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + id: centeredText + text: ScreenOrientation.printOrientation(main.activeOrientation) + color: "white" + font.pixelSize: 40 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "sensor: " + ScreenOrientation.printOrientation(runtime.orientation) + color: "white" + font.pixelSize: 14 + anchors.horizontalCenter: parent.horizontalCenter + } + } + Flow { + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: 10 + spacing: 4 + Button { + width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3 + text: "Portrait" + onClicked: main.selectedOrientation = Orientation.Portrait + toggled: main.selectedOrientation == Orientation.Portrait + } + Button { + width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3 + text: "Portrait inverted" + onClicked: main.selectedOrientation = Orientation.PortraitInverted + toggled: main.selectedOrientation == Orientation.PortraitInverted + } + Button { + width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3 + text: "Landscape" + onClicked: main.selectedOrientation = Orientation.Landscape + toggled: main.selectedOrientation == Orientation.Landscape + } + Button { + width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3 + text: "Landscape inverted" + onClicked: main.selectedOrientation = Orientation.LandscapeInverted + toggled: main.selectedOrientation == Orientation.LandscapeInverted + } + Button { + width: main.inPortrait ? parent.width : 2*(parent.width-2)/3 + text: "From runtime.orientation" + onClicked: main.selectedOrientation = Orientation.UnknownOrientation + toggled: main.selectedOrientation == Orientation.UnknownOrientation + } + } + states: [ + State { + name: "orientation " + Orientation.Landscape + PropertyChanges { + target: main + rotation: ScreenOrientation.getAngle(Orientation.Landscape)+rotationDelta + width: baseHeight + height: baseWidth + } + }, + State { + name: "orientation " + Orientation.PortraitInverted + PropertyChanges { + target: main + rotation: ScreenOrientation.getAngle(Orientation.PortraitInverted)+rotationDelta + width: baseWidth + height: baseHeight + } + }, + State { + name: "orientation " + Orientation.LandscapeInverted + PropertyChanges { + target: main + rotation: ScreenOrientation.getAngle(Orientation.LandscapeInverted)+rotationDelta + width: baseHeight + height: baseWidth + } + } + ] + transitions: Transition { + ParallelAnimation { + RotationAnimation { + direction: RotationAnimation.Shortest + duration: 300 + easing.type: Easing.InOutQuint + } + NumberAnimation { + properties: "x,y,width,height" + duration: 300 + easing.type: Easing.InOutQuint + } + } + } + } +} diff --git a/examples/declarative/screenorientation/screenorientation.qmlproject b/examples/declarative/screenorientation/screenorientation.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/screenorientation/screenorientation.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/dynamicscene/dynamicscene.qml b/examples/declarative/toys/dynamicscene/dynamicscene.qml index 2a22a5f..d1055cd 100644 --- a/examples/declarative/toys/dynamicscene/dynamicscene.qml +++ b/examples/declarative/toys/dynamicscene/dynamicscene.qml @@ -136,10 +136,11 @@ Item { Text { text: "Drag an item into the scene." } Rectangle { - width: childrenRect.width + 10; height: childrenRect.height + 10 + width: palette.width + 10; height: palette.height + 10 border.color: "black" Row { + id: palette anchors.centerIn: parent spacing: 8 diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml index 80567ef..68f8712 100644 --- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml @@ -55,7 +55,7 @@ Rectangle { Image { id: background anchors.fill: parent - source: "../shared/pics/background.png" + source: "../shared/pics/background.jpg" fillMode: Image.PreserveAspectCrop } } diff --git a/examples/network/download/main.cpp b/examples/network/download/main.cpp index c322a44..0fb9137 100644 --- a/examples/network/download/main.cpp +++ b/examples/network/download/main.cpp @@ -150,7 +150,7 @@ void DownloadManager::downloadFinished(QNetworkReply *reply) } else { QString filename = saveFileName(url); if (saveToDisk(filename, reply)) - printf("Download of %s succeded (saved to %s)\n", + printf("Download of %s succeeded (saved to %s)\n", url.toEncoded().constData(), qPrintable(filename)); } diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp index b931b96..4dca38c 100644 --- a/examples/network/fortuneserver/server.cpp +++ b/examples/network/fortuneserver/server.cpp @@ -107,17 +107,19 @@ Server::Server(QWidget *parent) void Server::sessionOpened() { // Save the used configuration - QNetworkConfiguration config = networkSession->configuration(); - QString id; - if (config.type() == QNetworkConfiguration::UserChoice) - id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); - else - id = config.identifier(); - - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); - settings.beginGroup(QLatin1String("QtNetwork")); - settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); - settings.endGroup(); + if (networkSession) { + QNetworkConfiguration config = networkSession->configuration(); + QString id; + if (config.type() == QNetworkConfiguration::UserChoice) + id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); + else + id = config.identifier(); + + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); + } //! [0] //! [1] tcpServer = new QTcpServer(this); diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp index b1ea98c..ea48546 100644 --- a/examples/network/http/httpwindow.cpp +++ b/examples/network/http/httpwindow.cpp @@ -206,7 +206,7 @@ void HttpWindow::httpFinished() void HttpWindow::httpReadyRead() { - // this slot gets called everytime the QNetworkReply has new data. + // this slot gets called every time 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 diff --git a/examples/network/torrent/torrent.pro b/examples/network/torrent/torrent.pro index 7665455..44716fd 100644 --- a/examples/network/torrent/torrent.pro +++ b/examples/network/torrent/torrent.pro @@ -5,7 +5,7 @@ HEADERS += addtorrentdialog.h \ metainfo.h \ peerwireclient.h \ ratecontroller.h \ - filemanager.h \ + filemanager.h \ torrentclient.h \ torrentserver.h \ trackerclient.h diff --git a/examples/network/torrent/torrentclient.cpp b/examples/network/torrent/torrentclient.cpp index 5e25b9a..b7607a6 100644 --- a/examples/network/torrent/torrentclient.cpp +++ b/examples/network/torrent/torrentclient.cpp @@ -1243,8 +1243,8 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client) // depending on the state we're in. int pieceIndex = 0; if (d->state == WarmingUp || (qrand() & 4) == 0) { - int *occurrances = new int[d->pieceCount]; - memset(occurrances, 0, d->pieceCount * sizeof(int)); + int *occurrences = new int[d->pieceCount]; + memset(occurrences, 0, d->pieceCount * sizeof(int)); // Count how many of each piece are available. foreach (PeerWireClient *peer, d->connections) { @@ -1252,38 +1252,38 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client) int peerPiecesSize = peerPieces.size(); for (int i = 0; i < peerPiecesSize; ++i) { if (peerPieces.testBit(i)) - ++occurrances[i]; + ++occurrences[i]; } } // Find the rarest or most common pieces. - int numOccurrances = d->state == WarmingUp ? 0 : 99999; + int numOccurrences = d->state == WarmingUp ? 0 : 99999; QList<int> piecesReadyForDownload; for (int i = 0; i < d->pieceCount; ++i) { if (d->state == WarmingUp) { // Add common pieces - if (occurrances[i] >= numOccurrances + if (occurrences[i] >= numOccurrences && incompletePiecesAvailableToClient.testBit(i)) { - if (occurrances[i] > numOccurrances) + if (occurrences[i] > numOccurrences) piecesReadyForDownload.clear(); piecesReadyForDownload.append(i); - numOccurrances = occurrances[i]; + numOccurrences = occurrences[i]; } } else { // Add rare pieces - if (occurrances[i] <= numOccurrances + if (occurrences[i] <= numOccurrences && incompletePiecesAvailableToClient.testBit(i)) { - if (occurrances[i] < numOccurrances) + if (occurrences[i] < numOccurrences) piecesReadyForDownload.clear(); piecesReadyForDownload.append(i); - numOccurrances = occurrances[i]; + numOccurrences = occurrences[i]; } } } // Select one piece randomly pieceIndex = piecesReadyForDownload.at(qrand() % piecesReadyForDownload.size()); - delete [] occurrances; + delete [] occurrences; } else { // Make up a list of available piece indices, and pick // a random one. diff --git a/examples/opengl/shared/qtlogo.cpp b/examples/opengl/shared/qtlogo.cpp index 0352d29..0165032 100644 --- a/examples/opengl/shared/qtlogo.cpp +++ b/examples/opengl/shared/qtlogo.cpp @@ -327,7 +327,7 @@ RectTorus::RectTorus(Geometry *g, qreal iRad, qreal oRad, qreal depth, int k) QVector<QVector3D> in_back = extrude(inside, depth); QVector<QVector3D> out_back = extrude(outside, depth); - // Create front, back and sides as seperate patches so that smooth normals + // Create front, back and sides as separate patches so that smooth normals // are generated for the curving sides, but a faceted edge is created between // sides and front/back Patch *front = new Patch(g); diff --git a/examples/tools/customcompleter/textedit.cpp b/examples/tools/customcompleter/textedit.cpp index 5467e53..77699e0 100644 --- a/examples/tools/customcompleter/textedit.cpp +++ b/examples/tools/customcompleter/textedit.cpp @@ -141,7 +141,7 @@ void TextEdit::keyPressEvent(QKeyEvent *e) } bool isShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_E); // CTRL+E - if (!c || !isShortcut) // dont process the shortcut when we have a completer + if (!c || !isShortcut) // do not process the shortcut when we have a completer QTextEdit::keyPressEvent(e); //! [7] diff --git a/examples/xml/htmlinfo/main.cpp b/examples/xml/htmlinfo/main.cpp index 066edb6..06fc33d 100644 --- a/examples/xml/htmlinfo/main.cpp +++ b/examples/xml/htmlinfo/main.cpp @@ -94,7 +94,7 @@ void parseHtmlFile(QTextStream &out, const QString &fileName) { int main(int argc, char **argv) { - // intialize QtCore application + // initialize QtCore application QCoreApplication app(argc, argv); // get a list of all html files in the current directory |