Commit 8ba3eee2 authored by Torsten Rahn's avatar Torsten Rahn Committed by Torsten Rahn

- Use QT_VERSION_CHECK and remove checks for versions < 5.6.

- Remove deprecated API (e.g. qVariantFromValue).
parent 00131cf8
......@@ -74,7 +74,7 @@ void MarbleMaps::setKeepScreenOn(bool screenOn)
m_keepScreenOn = screenOn;
char const * const action = m_keepScreenOn ? "addFlags" : "clearFlags";
#ifdef Q_OS_ANDROID
#if QT_VERSION >= 0x050700
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
QtAndroid::runOnAndroidThread([action](){
QAndroidJniObject activity = QtAndroid::androidActivity();
if (activity.isValid()) {
......
......@@ -99,7 +99,7 @@ int main(int argc, char ** argv)
app.setApplicationName( "Marble Maps" );
app.setOrganizationName( "KDE" );
app.setOrganizationDomain( "kde.org" );
#if QT_VERSION >= 0x050700
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
app.setDesktopFileName(QStringLiteral("org.kde.marble.maps"));
#endif
......
......@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
app.setApplicationName( "Marble Virtual Globe" );
app.setOrganizationName( "KDE" );
app.setOrganizationDomain( "kde.org" );
#if QT_VERSION >= 0x050700
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
app.setDesktopFileName(QStringLiteral("org.kde.marble-qt"));
#endif
......
......@@ -121,9 +121,9 @@ QVariant MarblePlacemarkModel::data( const QModelIndex &index, int role ) const
if ( role == Qt::DisplayRole ) {
return d->m_placemarkContainer->at( index.row() )->name();
} else if ( role == Qt::DecorationRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->style()->iconStyle().icon() );
return QVariant::fromValue( d->m_placemarkContainer->at( index.row() )->style()->iconStyle().icon() );
} else if ( role == IconPathRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->style()->iconStyle().iconPath() );
return QVariant::fromValue( d->m_placemarkContainer->at( index.row() )->style()->iconStyle().iconPath() );
} else if ( role == PopularityIndexRole ) {
return d->m_placemarkContainer->at( index.row() )->zoomLevel();
} else if ( role == VisualCategoryRole ) {
......@@ -145,21 +145,21 @@ QVariant MarblePlacemarkModel::data( const QModelIndex &index, int role ) const
} else if ( role == GeoTypeRole ) {
return d->m_placemarkContainer->at( index.row() )->role();
} else if ( role == CoordinateRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->coordinate() );
return QVariant::fromValue( d->m_placemarkContainer->at( index.row() )->coordinate() );
} else if ( role == StyleRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->style().data() );
return QVariant::fromValue( d->m_placemarkContainer->at( index.row() )->style().data() );
} else if ( role == GmtRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->extendedData().value(QStringLiteral("gmt")).value() );
return QVariant::fromValue( d->m_placemarkContainer->at( index.row() )->extendedData().value(QStringLiteral("gmt")).value() );
} else if ( role == DstRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->extendedData().value(QStringLiteral("dst")).value() );
return QVariant::fromValue( d->m_placemarkContainer->at( index.row() )->extendedData().value(QStringLiteral("dst")).value() );
} else if ( role == GeometryRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->geometry() );
return QVariant::fromValue( d->m_placemarkContainer->at( index.row() )->geometry() );
} else if ( role == ObjectPointerRole ) {
return qVariantFromValue( dynamic_cast<GeoDataObject*>( d->m_placemarkContainer->at( index.row() ) ) );
return QVariant::fromValue( dynamic_cast<GeoDataObject*>( d->m_placemarkContainer->at( index.row() ) ) );
} else if ( role == LongitudeRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->coordinate().longitude( GeoDataCoordinates::Degree ) );
return QVariant::fromValue( d->m_placemarkContainer->at( index.row() )->coordinate().longitude( GeoDataCoordinates::Degree ) );
} else if ( role == LatitudeRole ) {
return qVariantFromValue( d->m_placemarkContainer->at( index.row() )->coordinate().latitude( GeoDataCoordinates::Degree ) );
return QVariant::fromValue( d->m_placemarkContainer->at( index.row() )->coordinate().latitude( GeoDataCoordinates::Degree ) );
} else
return QVariant();
}
......
......@@ -177,7 +177,7 @@ void MovieCapture::recordFrame()
d->process.start( d->encoderExec, arguments );
connect(&d->process, SIGNAL(finished(int)), this, SLOT(processWrittenMovie(int)));
}
#if QT_VERSION >= 0x051000
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
d->process.write( (char*) screenshot.bits(), screenshot.sizeInBytes() );
#else
d->process.write( (char*) screenshot.bits(), screenshot.byteCount() );
......
......@@ -121,20 +121,8 @@ void ReverseGeocodingRunnerManager::reverseGeocoding( const GeoDataCoordinates &
{
d->m_reverseTasks.clear();
d->m_reverseGeocodingResult.clear();
#if QT_VERSION >= 0x050400
d->m_reverseGeocodingResults.removeAll( coordinates );
#else
QVector<GeoDataCoordinates> &vector = d->m_reverseGeocodingResults;
QVector<GeoDataCoordinates>::iterator it = vector.begin();
while (it != vector.end()) {
if (*it == coordinates) {
it = vector.erase(it);
} else {
++it;
}
}
#endif
QList<const ReverseGeocodingRunnerPlugin*> plugins = d->plugins( d->m_pluginManager->reverseGeocodingRunnerPlugins() );
for( const ReverseGeocodingRunnerPlugin* plugin: plugins ) {
ReverseGeocodingTask* task = new ReverseGeocodingTask( plugin->newRunner(), this, d->m_marbleModel, coordinates );
......
......@@ -214,7 +214,7 @@ 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
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
int byteCount = resultImage.sizeInBytes();
#else
int byteCount = resultImage.byteCount();
......
......@@ -141,7 +141,7 @@ StyleBuilder::Private::Private() :
QLocale::WallisAndFutunaIslands, QLocale::NorfolkIsland
})
{
#if QT_VERSION >= 0x050700
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
m_oceanianCountries << QLocale::TuvaluCountry << QLocale::OutlyingOceania;
#else
m_oceanianCountries << QLocale::Tuvalu;
......
......@@ -96,7 +96,7 @@ inline Blending const * TextureTile::blending() const
inline int TextureTile::byteCount() const
{
#if QT_VERSION >= 0x051000
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
return m_image.sizeInBytes();
#else
return m_image.byteCount();
......
......@@ -231,25 +231,7 @@ void GeoDataContainer::remove(int index, int count)
int GeoDataContainer::removeAll(GeoDataFeature *feature)
{
Q_D(GeoDataContainer);
#if QT_VERSION >= 0x050400
return d->m_vector.removeAll(feature);
#else
int count = 0;
QVector<GeoDataFeature*> &vector = d->m_vector;
QVector<GeoDataFeature*>::iterator it = vector.begin();
while(it != vector.end()) {
if (*it == feature) {
it = vector.erase(it);
++count;
} else {
++it;
}
}
return count;
#endif
}
void GeoDataContainer::removeAt(int index)
......@@ -273,20 +255,7 @@ void GeoDataContainer::removeLast()
bool GeoDataContainer::removeOne( GeoDataFeature *feature )
{
Q_D(GeoDataContainer);
#if QT_VERSION >= 0x050400
return d->m_vector.removeOne( feature );
#else
QVector<GeoDataFeature*> &vector = d->m_vector;
const int i = vector.indexOf(feature);
if (i < 0) {
return false;
}
vector.remove(i);
return true;
#endif
}
int GeoDataContainer::size() const
......
......@@ -421,14 +421,7 @@ void GeoDataLineString::append(const QVector<GeoDataCoordinates>& values)
d->m_dirtyRange = true;
d->m_dirtyBox = true;
#if QT_VERSION >= 0x050500
d->m_vector.append(values);
#else
d->m_vector.reserve(d->m_vector.size() + values.size());
for (const GeoDataCoordinates &coordinates: values) {
d->m_vector.append(coordinates);
}
#endif
}
GeoDataLineString& GeoDataLineString::operator << ( const GeoDataCoordinates& value )
......
......@@ -82,7 +82,7 @@ void GeoDataPlaylist::swapPrimitives( int positionA, int positionB )
{
if ( qMin( positionA, positionB ) >= 0 && qMax( positionA, positionB ) < m_primitives.size() ) {
#if QT_VERSION >= 0x051300
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
m_primitives.swapItemsAt( positionA, positionB );
#else
m_primitives.swap( positionA, positionB );
......
......@@ -170,7 +170,7 @@ QSet<qint64> GeoDataRelation::memberIds() const
bool GeoDataRelation::containsAnyOf(const QSet<qint64> &memberIds) const
{
Q_D(const GeoDataRelation);
#if QT_VERSION >= 0x050600 // intersects was introduced in Qt 5.6.
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
return d->m_memberIds.intersects(memberIds);
#else
for (auto memberId: memberIds) {
......
......@@ -65,10 +65,17 @@ void LonLatParser::initAll()
// use a set to remove duplicates
QSet<QString> dirs = QSet<QString>()
<< m_north << m_east << m_south << m_west;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
dirs += QSet<QString>( m_northLocale.begin(), m_northLocale.end() );
dirs += QSet<QString>( m_eastLocale.begin(), m_eastLocale.end() );
dirs += QSet<QString>( m_southLocale.begin(), m_southLocale.end() );
dirs += QSet<QString>( m_westLocale.begin(), m_westLocale.end() );
#else
dirs += m_northLocale.toSet();
dirs += m_eastLocale.toSet();
dirs += m_southLocale.toSet();
dirs += m_westLocale.toSet();
#endif
QString fullNamesExp;
QString simpleLetters;
......
......@@ -61,11 +61,7 @@ class KBiAssociativeContainer
{
/* implicit */ _iterator_impl_ctor(const typename QHash<T, U>::iterator it)
// Using internals here because I was too lazy to write my own iterator.
#if QT_VERSION < 0x050000
: QHash<T, U>::iterator(reinterpret_cast<void *>(static_cast<QHashNode<T, U> *>(it)))
#else
: QHash<T, U>::iterator(it)
#endif
{
}
......@@ -76,11 +72,7 @@ class KBiAssociativeContainer
{
/* implicit */ _iterator_impl_ctor(const typename QMap<T, U>::iterator it)
// Using internals here because I was too lazy to write my own iterator.
#if QT_VERSION < 0x050000
: QMap<T, U>::iterator(static_cast<QMapData::Node*>(it))
#else
: QMap<T, U>::iterator(it)
#endif
{
}
......
......@@ -77,7 +77,7 @@ bool RoutingProfilesModel::moveUp( int row )
Q_ASSERT( false );
return false;
}
#if QT_VERSION >= 0x051300
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
m_profiles.swapItemsAt( row, row-1 );
#else
m_profiles.swap( row, row-1 );
......
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