diff options
author | Lorn Potter <lorn.potter@nokia.com> | 2010-08-03 19:14:44 (GMT) |
---|---|---|
committer | Lorn Potter <lorn.potter@nokia.com> | 2010-08-03 19:14:44 (GMT) |
commit | be83848d31513dfbfffb1e0c43d32b7c27dcefce (patch) | |
tree | c8b965626afcb18cfaca0f26e39596ac4dd6f0a8 /examples | |
parent | 7a2d31989f0f50a34550be846a6f632c2f9e3f59 (diff) | |
parent | 11ad3b195d98b0a2234105da24d1faffd7ef95d6 (diff) | |
download | Qt-be83848d31513dfbfffb1e0c43d32b7c27dcefce.zip Qt-be83848d31513dfbfffb1e0c43d32b7c27dcefce.tar.gz Qt-be83848d31513dfbfffb1e0c43d32b7c27dcefce.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Conflicts:
src/plugins/bearer/connman/qconnmanengine.cpp
Diffstat (limited to 'examples')
19 files changed, 517 insertions, 28 deletions
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/network/bearercloud/cloud.cpp b/examples/network/bearercloud/cloud.cpp index 980efbf..8deaab3 100644 --- a/examples/network/bearercloud/cloud.cpp +++ b/examples/network/bearercloud/cloud.cpp @@ -53,7 +53,7 @@ #include <math.h> -static QMap<QString, QSvgRenderer *> svgCache; +static QMap<QNetworkConfiguration::BearerType, QSvgRenderer *> svgCache; //! [0] Cloud::Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent) @@ -261,9 +261,9 @@ void Cloud::stateChanged(QNetworkSession::State state) tooltip += tr("<br>Id: %1").arg(configuration.identifier()); #endif - const QString bearerName = configuration.bearerName(); - if (!bearerName.isEmpty()) - tooltip += tr("<br>Bearer: %1").arg(bearerName); + const QString bearerTypeName = configuration.bearerTypeName(); + if (!bearerTypeName.isEmpty()) + tooltip += tr("<br>Bearer: %1").arg(bearerTypeName); QString s = tr("<br>State: %1 (%2)"); switch (state) { @@ -313,17 +313,25 @@ void Cloud::stateChanged(QNetworkSession::State state) //! [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"))); + QNetworkConfiguration::BearerType bearerType = configuration.bearerType(); + if (!svgCache.contains(bearerType)) { + QSvgRenderer *renderer = 0; + switch (bearerType) { + case QNetworkConfiguration::BearerWLAN: + renderer = new QSvgRenderer(QLatin1String(":wlan.svg")); + break; + case QNetworkConfiguration::BearerEthernet: + renderer = new QSvgRenderer(QLatin1String(":lan.svg")); + break; + default: + renderer = new QSvgRenderer(QLatin1String(":unknown.svg")); + } + + if (renderer) + svgCache.insert(bearerType, renderer); } - icon->setSharedRenderer(svgCache[bearerName]); + icon->setSharedRenderer(svgCache[bearerType]); if (configuration.name().isEmpty()) { text->setPlainText(tr("HIDDEN NETWORK")); diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp index 8b5693a..ecc2a93 100644 --- a/examples/network/bearermonitor/sessionwidget.cpp +++ b/examples/network/bearermonitor/sessionwidget.cpp @@ -111,11 +111,11 @@ void SessionWidget::updateSession() killTimer(statsTimer); if (session->configuration().type() == QNetworkConfiguration::InternetAccessPoint) - bearer->setText(session->configuration().bearerName()); + bearer->setText(session->configuration().bearerTypeName()); else { QNetworkConfigurationManager mgr; QNetworkConfiguration c = mgr.configurationFromIdentifier(session->sessionProperty("ActiveConfiguration").toString()); - bearer->setText(c.bearerName()); + bearer->setText(c.bearerTypeName()); } #ifndef QT_NO_NETWORKINTERFACE diff --git a/examples/tutorials/addressbook-fr/part2/addressbook.cpp b/examples/tutorials/addressbook-fr/part2/addressbook.cpp index 1fa9d52..8d5b0e1 100644 --- a/examples/tutorials/addressbook-fr/part2/addressbook.cpp +++ b/examples/tutorials/addressbook-fr/part2/addressbook.cpp @@ -111,7 +111,7 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if ( name.isEmpty()|| address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); return; diff --git a/examples/tutorials/addressbook-fr/part3/addressbook.cpp b/examples/tutorials/addressbook-fr/part3/addressbook.cpp index 840f529..2d182c5 100644 --- a/examples/tutorials/addressbook-fr/part3/addressbook.cpp +++ b/examples/tutorials/addressbook-fr/part3/addressbook.cpp @@ -122,9 +122,10 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if (name.isEmpty() || address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); + return; } if (!contacts.contains(name)) { diff --git a/examples/tutorials/addressbook-fr/part4/addressbook.cpp b/examples/tutorials/addressbook-fr/part4/addressbook.cpp index f6390a4..d3bf030 100644 --- a/examples/tutorials/addressbook-fr/part4/addressbook.cpp +++ b/examples/tutorials/addressbook-fr/part4/addressbook.cpp @@ -131,9 +131,10 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if (name.isEmpty() || address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); + return; } //! [submitContact() function part1] if (currentMode == AddingMode) { diff --git a/examples/tutorials/addressbook-fr/part5/addressbook.cpp b/examples/tutorials/addressbook-fr/part5/addressbook.cpp index 80c18c3..d5f5778 100644 --- a/examples/tutorials/addressbook-fr/part5/addressbook.cpp +++ b/examples/tutorials/addressbook-fr/part5/addressbook.cpp @@ -138,10 +138,11 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if (name.isEmpty() || address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); - } + return; + } if (currentMode == AddingMode) { diff --git a/examples/tutorials/addressbook-fr/part6/addressbook.cpp b/examples/tutorials/addressbook-fr/part6/addressbook.cpp index fc41190..7c57db7 100644 --- a/examples/tutorials/addressbook-fr/part6/addressbook.cpp +++ b/examples/tutorials/addressbook-fr/part6/addressbook.cpp @@ -144,9 +144,10 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if (name.isEmpty() || address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); + return; } if (currentMode == AddingMode) { diff --git a/examples/tutorials/addressbook-fr/part7/addressbook.cpp b/examples/tutorials/addressbook-fr/part7/addressbook.cpp index 3ab8702..b0f35a7 100644 --- a/examples/tutorials/addressbook-fr/part7/addressbook.cpp +++ b/examples/tutorials/addressbook-fr/part7/addressbook.cpp @@ -146,9 +146,10 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if (name.isEmpty() || address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); + return; } if (currentMode == AddingMode) { diff --git a/examples/tutorials/addressbook/part2/addressbook.cpp b/examples/tutorials/addressbook/part2/addressbook.cpp index 1fa9d52..f2f0d65 100644 --- a/examples/tutorials/addressbook/part2/addressbook.cpp +++ b/examples/tutorials/addressbook/part2/addressbook.cpp @@ -111,7 +111,7 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if (name.isEmpty() || address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); return; diff --git a/examples/tutorials/addressbook/part3/addressbook.cpp b/examples/tutorials/addressbook/part3/addressbook.cpp index 28a570a..4e58fa1 100644 --- a/examples/tutorials/addressbook/part3/addressbook.cpp +++ b/examples/tutorials/addressbook/part3/addressbook.cpp @@ -122,7 +122,7 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if (name.isEmpty() || address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); return; diff --git a/examples/tutorials/addressbook/part4/addressbook.cpp b/examples/tutorials/addressbook/part4/addressbook.cpp index 55d551f..896a427 100644 --- a/examples/tutorials/addressbook/part4/addressbook.cpp +++ b/examples/tutorials/addressbook/part4/addressbook.cpp @@ -131,7 +131,7 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if (name.isEmpty() || address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); return; diff --git a/examples/tutorials/addressbook/part5/addressbook.cpp b/examples/tutorials/addressbook/part5/addressbook.cpp index 1b3f451..874b151 100644 --- a/examples/tutorials/addressbook/part5/addressbook.cpp +++ b/examples/tutorials/addressbook/part5/addressbook.cpp @@ -138,7 +138,7 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if (name.isEmpty() || address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); return; diff --git a/examples/tutorials/addressbook/part6/addressbook.cpp b/examples/tutorials/addressbook/part6/addressbook.cpp index 724971c..a6bb4a5 100644 --- a/examples/tutorials/addressbook/part6/addressbook.cpp +++ b/examples/tutorials/addressbook/part6/addressbook.cpp @@ -144,7 +144,7 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if (name.isEmpty() || address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); return; diff --git a/examples/tutorials/addressbook/part7/addressbook.cpp b/examples/tutorials/addressbook/part7/addressbook.cpp index bf00298..fb70ba4 100644 --- a/examples/tutorials/addressbook/part7/addressbook.cpp +++ b/examples/tutorials/addressbook/part7/addressbook.cpp @@ -146,7 +146,7 @@ void AddressBook::submitContact() QString name = nameLine->text(); QString address = addressText->toPlainText(); - if (name == "" || address == "") { + if (name.isEmpty() || address.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); return; |