Commit 345e516c authored by Torsten Rahn's avatar Torsten Rahn
Browse files

In preparation for Qt 6 remove a few deprecation warnings:

- Replace QTime for QElapsedTimer
- Replace QImage::byteCount with QImage::sizeInBytes()
- Replace QList::swap with QList::swapItemsAt().
parent 26ff3d5e
......@@ -12,7 +12,7 @@
#include "MarbleTest.h"
#include <QCoreApplication>
#include <QTime>
#include <QElapsedTimer>
#include <QMessageBox>
#include <MarbleGlobal.h>
......@@ -46,7 +46,7 @@ void MarbleTest::timeDemo()
qDebug() << "Starting Performance Test";
QTime t;
QElapsedTimer t;
t.start();
for ( int j = 0; j < 10; ++j ) {
......
......@@ -12,7 +12,7 @@
#include "FileManager.h"
#include <QFileInfo>
#include <QTime>
#include <QElapsedTimer>
#include <QMessageBox>
#include "FileLoader.h"
......@@ -59,7 +59,7 @@ public:
QList<FileLoader*> m_loaderList;
QHash < QString, GeoDataDocument* > m_fileItemHash;
GeoDataLatLonBox m_latLonBox;
QTime m_timer;
QElapsedTimer m_timer;
};
}
......
......@@ -23,6 +23,7 @@
#include "LayerInterface.h"
#include "RenderState.h"
#include <QElapsedTimer>
#include <QTime>
namespace Marble
......@@ -175,7 +176,7 @@ void LayerManager::renderLayers( GeoPainter *painter, ViewportParams *viewport )
} );
// render the layers of the current renderPosition
QTime timer;
QElapsedTimer timer;
for( auto *layer: layers ) {
timer.start();
layer->render( painter, viewport, renderPosition, nullptr );
......
......@@ -20,7 +20,7 @@
#include <cmath>
// Qt
#include <QTime>
#include <QElapsedTimer>
#include <QRegion>
#include <QtMath>
......@@ -530,7 +530,7 @@ void MarbleMap::downloadRegion( QVector<TileCoordsPyramid> const & pyramid )
{
Q_ASSERT( textureLayer() );
Q_ASSERT( !pyramid.isEmpty() );
QTime t;
QElapsedTimer t;
t.start();
// When downloading a region (the author of these lines thinks) most users probably expect
......@@ -855,7 +855,7 @@ void MarbleMap::paint( GeoPainter &painter, const QRect &dirtyRect )
return;
}
QTime t;
QElapsedTimer t;
t.start();
RenderStatus const oldRenderStatus = d->m_renderState.status();
......
......@@ -15,7 +15,7 @@
#include "MarblePlacemarkModel_P.h"
// Qt
#include <QTime>
#include <QElapsedTimer>
#include <QImage>
// Marble
......@@ -210,7 +210,7 @@ void MarblePlacemarkModel::addPlacemarks( int start,
// MarbleControlBox::m_sortproxy as a sorting customer.
// I leave the balance search as an exercise to the reader...
QTime t;
QElapsedTimer t;
t.start();
// beginInsertRows( QModelIndex(), start, start + length );
d->m_size += length;
......
......@@ -16,7 +16,7 @@
#include <qmath.h>
#include <QHash>
#include <QSettings>
#include <QTime>
#include <QElapsedTimer>
#include <QPaintEvent>
#include <QPaintEngine>
#include <QRegion>
......@@ -699,7 +699,7 @@ QRegion MarbleWidget::mapRegion() const
void MarbleWidget::paintEvent( QPaintEvent *evt )
{
QTime t;
QElapsedTimer t;
t.start();
QPaintDevice *paintDevice = this;
......
......@@ -16,7 +16,7 @@
#include <QProcess>
#include <QMessageBox>
#include <QTimer>
#include <QTime>
#include <QElapsedTimer>
#include <QFile>
namespace Marble
......@@ -177,10 +177,13 @@ void MovieCapture::recordFrame()
d->process.start( d->encoderExec, arguments );
connect(&d->process, SIGNAL(finished(int)), this, SLOT(processWrittenMovie(int)));
}
#if QT_VERSION >= 0x051000
d->process.write( (char*) screenshot.bits(), screenshot.sizeInBytes() );
#else
d->process.write( (char*) screenshot.bits(), screenshot.byteCount() );
#endif
for (int i=0; i<30 && d->process.bytesToWrite()>0; ++i) {
QTime t;
QElapsedTimer t;
int then = d->process.bytesToWrite();
t.start();
d->process.waitForBytesWritten( 100 );
......
......@@ -16,7 +16,7 @@
// Qt
#include <QList>
#include <QPluginLoader>
#include <QTime>
#include <QElapsedTimer>
#include <QMessageBox>
// Local dir
......@@ -213,7 +213,7 @@ void PluginManagerPrivate::loadPlugins()
return;
}
QTime t;
QElapsedTimer t;
t.start();
mDebug() << "Starting to load Plugins.";
......
......@@ -398,7 +398,7 @@ void PopupItem::openUrl(const QUrl &url)
QPixmap PopupItem::pixmap( const QString &imageId ) const
{
QPixmap result;
if ( !QPixmapCache::find( imageId, result ) ) {
if ( !QPixmapCache::find( imageId, &result ) ) {
QImage bottom = QImage(QLatin1String(":/") + imageId + QLatin1String("_shadow.png"));
QImage top = QImage(QLatin1String(":/") + imageId + QLatin1String(".png"));
colorize( top, m_backColor );
......
......@@ -25,6 +25,7 @@
#include <QListView>
#include <QVBoxLayout>
#include <QElapsedTimer>
namespace Marble {
......@@ -66,7 +67,7 @@ void SearchWidgetPrivate::setSearchResult( const QVector<GeoDataPlacemark *>& lo
return;
}
QTime timer;
QElapsedTimer timer;
timer.start();
// fill the local document with results
......
......@@ -214,7 +214,11 @@ uint StackedTile::pixelF( qreal x, qreal y, const QRgb& topLeftValue ) const
int StackedTile::calcByteCount( const QImage &resultImage, const QVector<QSharedPointer<TextureTile> > &tiles )
{
#if QT_VERSION >= 0x051000
int byteCount = resultImage.sizeInBytes();
#else
int byteCount = resultImage.byteCount();
#endif
QVector<QSharedPointer<TextureTile> >::const_iterator pos = tiles.constBegin();
QVector<QSharedPointer<TextureTile> >::const_iterator const end = tiles.constEnd();
......
......@@ -18,7 +18,7 @@
#include <QSharedPointer>
#include <QString>
#include <QVector>
#include <QTime>
#include <QElapsedTimer>
#include <QColor>
#include <QImage>
#include <QPainter>
......@@ -72,7 +72,7 @@ TextureColorizer::TextureColorizer( const QString &seafile,
m_landColor(qRgb( 255, 0, 0 ) ),
m_seaColor( qRgb( 0, 255, 0 ) )
{
QTime t;
QElapsedTimer t;
t.start();
QImage gradientImage ( 256, 1, QImage::Format_RGB32 );
......
......@@ -96,7 +96,11 @@ inline Blending const * TextureTile::blending() const
inline int TextureTile::byteCount() const
{
#if QT_VERSION >= 0x051000
return m_image.sizeInBytes();
#else
return m_image.byteCount();
#endif
}
}
......
......@@ -81,7 +81,12 @@ void GeoDataPlaylist::removePrimitiveAt(int position)
void GeoDataPlaylist::swapPrimitives( int positionA, int positionB )
{
if ( qMin( positionA, positionB ) >= 0 && qMax( positionA, positionB ) < m_primitives.size() ) {
#if QT_VERSION >= 0x051300
m_primitives.swapItemsAt( positionA, positionB );
#else
m_primitives.swap( positionA, positionB );
#endif
}
}
......
......@@ -205,7 +205,7 @@ QPixmap AbstractGeoPolygonGraphicsItem::texture(const QString &texturePath, cons
{
QString const key = QString::number(color.rgba()) + '/' + texturePath;
QPixmap texture;
if (!QPixmapCache::find(key, texture)) {
if (!QPixmapCache::find(key, &texture)) {
QImageReader imageReader(style()->polyStyle().resolvePath(texturePath));
texture = QPixmap::fromImageReader(&imageReader);
......
......@@ -30,7 +30,7 @@
#include "kineticmodel.h"
#include <QTimer>
#include <QTime>
#include <QElapsedTimer>
static const int KineticModelDefaultUpdateInterval = 15; // ms
......@@ -47,7 +47,7 @@ public:
QPointF deacceleration;
qreal deaccelerationHeading;
QTime timestamp;
QElapsedTimer timestamp;
QPointF lastPosition;
qreal lastHeading;
bool changingPosition;
......@@ -208,7 +208,7 @@ void KineticModel::update()
{
Q_D(KineticModel);
int elapsed = qMin( d->timestamp.elapsed(), 100 ); // limit to 100msec to reduce catapult effect (bug 294608)
int elapsed = qMin( static_cast<int>(d->timestamp.elapsed()), 100 ); // limit to 100msec to reduce catapult effect (bug 294608)
qreal delta = static_cast<qreal>(elapsed) / 1000.0;
bool stop = false;
......
......@@ -13,14 +13,14 @@
#include "FpsLayer.h"
#include <QPoint>
#include <QTime>
#include <QElapsedTimer>
#include <QFont>
#include <QPainter>
namespace Marble
{
FpsLayer::FpsLayer( QTime *time )
FpsLayer::FpsLayer( QElapsedTimer *time )
: m_time( time )
{
}
......
......@@ -12,7 +12,7 @@
#define MARBLE_FPSLAYER_H
class QPainter;
class QTime;
class QElapsedTimer;
namespace Marble
{
......@@ -20,12 +20,12 @@ namespace Marble
class FpsLayer
{
public:
explicit FpsLayer( QTime *time );
explicit FpsLayer( QElapsedTimer *time );
void paint( QPainter *painter ) const;
private:
QTime *const m_time;
QElapsedTimer *const m_time;
};
}
......
......@@ -17,6 +17,7 @@
#include "GeoDataLineString.h"
#include "GeoDataPlacemark.h"
#include <QElapsedTimer>
#include <QTimer>
#include <QPainter>
......@@ -92,7 +93,7 @@ public:
QVector<GeoDataDocument*> m_restrainedRoutes;
/** Counts the time between route request and first result */
QTime m_responseTime;
QElapsedTimer m_responseTime;
int m_currentIndex;
};
......
......@@ -77,7 +77,11 @@ bool RoutingProfilesModel::moveUp( int row )
Q_ASSERT( false );
return false;
}
#if QT_VERSION >= 0x051300
m_profiles.swapItemsAt( row, row-1 );
#else
m_profiles.swap( row, row-1 );
#endif
endMoveRows();
return true;
}
......
......@@ -55,7 +55,7 @@ void ArrowDiscWidget::setMarbleWidget( MarbleWidget *marbleWidget )
QPixmap ArrowDiscWidget::pixmap( const QString &id )
{
QPixmap result;
if ( !QPixmapCache::find( id, result ) ) {
if ( !QPixmapCache::find( id, &result ) ) {
result = QPixmap(QLatin1String(":/") + id + QLatin1String(".png"));
QPixmapCache::insert( id, result );
}
......
......@@ -222,7 +222,7 @@ void NavigationFloatItem::updateButtons( int zoomValue )
QPixmap NavigationFloatItem::pixmap( const QString &id )
{
QPixmap result;
if ( !QPixmapCache::find( id, result ) ) {
if ( !QPixmapCache::find( id, &result ) ) {
result = QPixmap(QLatin1String(":/") + id + QLatin1String(".png"));
QPixmapCache::insert( id, result );
}
......
......@@ -39,7 +39,7 @@ NavigationSlider::~NavigationSlider()
QPixmap NavigationSlider::pixmap( const QString &id )
{
QPixmap result;
if ( !QPixmapCache::find( id, result ) ) {
if ( !QPixmapCache::find( id, &result ) ) {
result = QPixmap(QLatin1String(":/") + id + QLatin1String(".png"));
QPixmapCache::insert( id, result );
}
......
......@@ -20,7 +20,7 @@
#include "PositionTracking.h"
#include <QDataStream>
#include <QTime>
#include <QElapsedTimer>
#include <QSqlDatabase>
#include <QSqlQuery>
......@@ -81,7 +81,7 @@ QVector<OsmPlacemark> OsmDatabase::find( const DatabaseQuery &userQuery )
QSqlDatabase database = QSqlDatabase::addDatabase( "QSQLITE", QString( "marble/local-osm-search-%1" ).arg( reinterpret_cast<size_t>( this ) ) );
QVector<OsmPlacemark> result;
QTime timer;
QElapsedTimer timer;
timer.start();
for( const QString &databaseFile: m_databaseFiles ) {
database.setDatabaseName( databaseFile );
......@@ -91,7 +91,7 @@ QVector<OsmPlacemark> OsmDatabase::find( const DatabaseQuery &userQuery )
QString regionRestriction;
if ( !userQuery.region().isEmpty() ) {
QTime regionTimer;
QElapsedTimer regionTimer;
regionTimer.start();
// Nested set model to support region hierarchies, see https://en.wikipedia.org/wiki/Nested_set_model
const QString regionsQueryString = QLatin1String("SELECT lft, rgt FROM regions WHERE name LIKE '%") + userQuery.region() + QLatin1String("%';");
......@@ -165,7 +165,7 @@ QVector<OsmPlacemark> OsmDatabase::find( const DatabaseQuery &userQuery )
QSqlQuery query( database );
query.setForwardOnly( true );
QTime queryTimer;
QElapsedTimer queryTimer;
queryTimer.start();
if ( !query.exec( queryString ) ) {
qWarning() << query.lastError() << "in" << databaseFile << "with query" << query.lastQuery();
......
......@@ -16,7 +16,7 @@
#include <QtGui> //needed because this is a gui test
#include <QtCore>
#include <QTime>
#include <QElapsedTimer>
#include <QTest>
namespace Marble
......@@ -52,7 +52,7 @@ void MarbleWidgetSpeedTest::timeTest()
m_marbleWidget->setZoom( 1500 );
// m_marbleWidget->resize( 800, 600 );
QTime t;
QElapsedTimer t;
//m_marbleWidget->setMapTheme( "plain/plain.dgml" );
//m_marbleWidget->setMapTheme( "bluemarble/bluemarble.dgml" );
......
......@@ -38,7 +38,7 @@ class TestGeoDataPack : public QObject
private:
QString content;
QTime timer;
QElapsedTimer timer;
};
void TestGeoDataPack::initTestCase()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment