diff options
Diffstat (limited to 'examples/embedded')
-rw-r--r-- | examples/embedded/flickable/flickable.cpp | 10 | ||||
-rw-r--r-- | examples/embedded/lightmaps/mapzoom.cpp | 43 | ||||
-rw-r--r-- | examples/embedded/lightmaps/mapzoom.h | 3 | ||||
-rw-r--r-- | examples/embedded/raycasting/raycasting.cpp | 8 |
4 files changed, 9 insertions, 55 deletions
diff --git a/examples/embedded/flickable/flickable.cpp b/examples/embedded/flickable/flickable.cpp index fff4bac0e6..c57ec3d111 100644 --- a/examples/embedded/flickable/flickable.cpp +++ b/examples/embedded/flickable/flickable.cpp @@ -98,7 +98,7 @@ public: QPoint delta; QPoint speed; FlickableTicker *ticker; - QTime timeStamp; + QElapsedTimer timeStamp; QWidget *target; QList<QEvent*> ignoreList; }; @@ -109,7 +109,7 @@ Flickable::Flickable() d->state = FlickablePrivate::Steady; d->threshold = 10; d->ticker = new FlickableTicker(this); - d->timeStamp = QTime::currentTime(); + d->timeStamp.start(); d->target = 0; } @@ -208,7 +208,7 @@ void Flickable::handleMouseRelease(QMouseEvent *event) event->accept(); delta = event->pos() - d->pressPos; if (d->timeStamp.elapsed() > 100) { - d->timeStamp = QTime::currentTime(); + d->timeStamp.start(); d->speed = delta - d->delta; d->delta = delta; } @@ -253,7 +253,7 @@ void Flickable::handleMouseMove(QMouseEvent *event) delta = event->pos() - d->pressPos; if (delta.x() > d->threshold || delta.x() < -d->threshold || delta.y() > d->threshold || delta.y() < -d->threshold) { - d->timeStamp = QTime::currentTime(); + d->timeStamp.start(); d->state = FlickablePrivate::ManualScroll; d->delta = QPoint(0, 0); d->pressPos = event->pos(); @@ -266,7 +266,7 @@ void Flickable::handleMouseMove(QMouseEvent *event) delta = event->pos() - d->pressPos; setScrollOffset(d->offset - delta); if (d->timeStamp.elapsed() > 100) { - d->timeStamp = QTime::currentTime(); + d->timeStamp.start(); d->speed = delta - d->delta; d->delta = delta; } diff --git a/examples/embedded/lightmaps/mapzoom.cpp b/examples/embedded/lightmaps/mapzoom.cpp index d82b9ad473..781d4f27e3 100644 --- a/examples/embedded/lightmaps/mapzoom.cpp +++ b/examples/embedded/lightmaps/mapzoom.cpp @@ -81,52 +81,9 @@ MapZoom::MapZoom() menu->addAction(nightModeAction); menu->addAction(osmAction); - QNetworkConfigurationManager manager; - if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { - // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("QtProject")); - settings.beginGroup(QLatin1String("QtNetwork")); - const QString id = - settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); - settings.endGroup(); - - // If the saved network configuration is not currently discovered use the system - // default - QNetworkConfiguration config = manager.configurationFromIdentifier(id); - if ((config.state() & QNetworkConfiguration::Discovered) != - QNetworkConfiguration::Discovered) { - config = manager.defaultConfiguration(); - } - - networkSession = new QNetworkSession(config, this); - connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); - - networkSession->open(); - } else { - networkSession = 0; - } - setWindowTitle(tr("Light Maps")); } -void MapZoom::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("QtProject")); - settings.beginGroup(QLatin1String("QtNetwork")); - settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); - settings.endGroup(); -} - void MapZoom::chooseOslo() { map->setCenter(59.9138204, 10.7387413); diff --git a/examples/embedded/lightmaps/mapzoom.h b/examples/embedded/lightmaps/mapzoom.h index 30f2e63138..3844eca718 100644 --- a/examples/embedded/lightmaps/mapzoom.h +++ b/examples/embedded/lightmaps/mapzoom.h @@ -53,7 +53,6 @@ #include <QMainWindow> -class QNetworkSession; class LightMaps; class MapZoom : public QMainWindow @@ -64,7 +63,6 @@ public: MapZoom(); private slots: - void sessionOpened(); void chooseOslo(); void chooseBerlin(); void chooseJakarta(); @@ -72,7 +70,6 @@ private slots: private: LightMaps *map; - QNetworkSession *networkSession; }; #endif
\ No newline at end of file diff --git a/examples/embedded/raycasting/raycasting.cpp b/examples/embedded/raycasting/raycasting.cpp index 7213811213..c0a1e48fa6 100644 --- a/examples/embedded/raycasting/raycasting.cpp +++ b/examples/embedded/raycasting/raycasting.cpp @@ -92,7 +92,7 @@ public: } void updatePlayer() { - int interval = qBound(20, watch.elapsed(), 250); + int interval = qBound(20ll, watch.elapsed(), 250ll); watch.start(); angle += angleDelta * interval / 1000; qreal step = moveDelta * interval / 1000; @@ -106,10 +106,10 @@ public: } void showFps() { - static QTime frameTick; + static QElapsedTimer frameTick; static int totalFrame = 0; if (!(totalFrame & 31)) { - int elapsed = frameTick.elapsed(); + const qint64 elapsed = frameTick.elapsed(); frameTick.start(); int fps = 32 * 1000 / (1 + elapsed); setWindowTitle(QString("Raycasting (%1 FPS)").arg(fps)); @@ -355,7 +355,7 @@ protected: } private: - QTime watch; + QElapsedTimer watch; QBasicTimer ticker; QImage buffer; qreal angle; |