Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for Qt6 compatibility #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 93 additions & 8 deletions MapGraphics/MapGraphics.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
QT += network sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat

TARGET = MapGraphics
TEMPLATE = lib

Expand Down Expand Up @@ -69,17 +71,100 @@ symbian {
DEPLOYMENT += addFiles
}

unix:!symbian {
maemo5 {
target.path = /opt/usr/lib
} else {
target.path = /usr/lib
}
INSTALLS += target
}
#unix:!symbian {
# maemo5 {
# target.path = /opt/usr/lib
# } else {
# target.path = /usr/lib
# }
# INSTALLS += target
#}

FORMS += \
guts/CompositeTileSourceConfigurationWidget.ui

RESOURCES += \
resources.qrc

# BUILD OUTPUT DIR outside of parent MapGraphics
# MapGraphics_BUILD at the same dir level of MapGraphics
message( 'Building BUILD_OUT_DIR= $${OUT_PWD} ' )


message( 'Building QMAKESPEC= $${QMAKESPEC} ' )
#-------------------------------------------------
# WIN32
#-------------------------------------------------
win32{
message( 'Building TARGET win32 WINDOWS_TARGET_PLATFORM_VERSION= $${WINDOWS_TARGET_PLATFORM_VERSION}' )
CONFIG(release, debug|release){
message( 'Building TARGET win32 release' )
target.path = $$PWD/../../MapGraphics_BUILD/LIB_BINARY/MSVC2019_64bit-Release
DESTDIR = $${target.path}
}
CONFIG(debug, debug|release){
message( 'Building TARGET win32 debug' )

}
}


#-------------------------------------------------
# ANDROID
#-------------------------------------------------
android {
message('Building android')
message('Building android ANDROID_TARGET_ARCH $${ANDROID_TARGET_ARCH}')

contains(ANDROID_TARGET_ARCH,x86_64) {
message('Building android for x86_64')
#ANDROID_EXTRA_LIBS =
# message('Building ANDROID_TARGET_ARCH x86_64 ANDROID_EXTRA_LIBS=$${ANDROID_EXTRA_LIBS}')
#LIBS += -L$$PWD/ -l
#INCLUDEPATH += $$PWD/.....
#DEPENDPATH += $$PWD/......

#top_builddir=$$shadowed($$PWD)
#DESTDIR = $$top_builddir/plugins/myplugin
#DESTDIR = ../TestApp
target.path = $$PWD/../../MapGraphics_BUILD/LIB_BINARY/Clang_x86_64-Release
DESTDIR = $${target.path}
#INSTALLS += target
message( 'Building android INSTALLS= $${target.path} ' )
}

contains(ANDROID_TARGET_ARCH,arm64-v8a) {
message( 'Building android for arm64-v8a' )
#ANDROID_EXTRA_LIBS =
# message('Building ANDROID_TARGET_ARCH x86_64 ANDROID_EXTRA_LIBS=$${ANDROID_EXTRA_LIBS}')
#LIBS += -L$$PWD/ -l
#INCLUDEPATH += $$PWD/.....
#DEPENDPATH += $$PWD/......
#top_builddir=$$shadowed($$PWD)
#DESTDIR = $$top_builddir/plugins/myplugin
#DESTDIR = ../TestApp
target.path = $$PWD/../../MapGraphics_BUILD/LIB_BINARY/Clang_arm64-v8a-Release
DESTDIR = $${target.path}
#INSTALLS += target
message( 'Building android INSTALLS= $${target.path} ' )
}

android: include(C:/TOOLS/ANDROID/android_openssl/openssl.pri)
}

#-------------------------------------------------
# iOs Configuration
#-------------------------------------------------
ios {
message( 'Building ios : QMAKE_TARGET= $${QMAKE_TARGET} QMAKE_MACOSX_DEPLOYMENT_TARGET= $${QMAKE_MACOSX_DEPLOYMENT_TARGET}' )
# iOs simulator
#target.path = $$PWD/../../MapGraphics_BUILD/LIB_BINARY/iOS_Simulator-Release
#DESTDIR = $${target.path}
#message( 'Building ios simulator' )

# iOs phone
target.path = $$PWD/../../MapGraphics_BUILD/LIB_BINARY/iOS-Release
DESTDIR = $${target.path}
message( 'Building ios phone' )

}
41 changes: 37 additions & 4 deletions MapGraphics/MapGraphicsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,43 @@ void MapGraphicsView::handleChildViewContextMenu(QContextMenuEvent *event)
//protected slot
void MapGraphicsView::handleChildViewScrollWheel(QWheelEvent *event)
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QPoint pixelDelta = event->pixelDelta();
qDebug()<<"MapGraphicsView::handleChildViewScrollWheel: pixelDelta"<<pixelDelta;
QPoint angleDelta = event->angleDelta();
qDebug()<<"MapGraphicsView::handleChildViewScrollWheel: angleDelta"<<angleDelta;

event->setAccepted(true);
this->setDragMode(MapGraphicsView::ScrollHandDrag);


if (!pixelDelta.isNull()) {
//scrollWithPixels(numPixels);
if (pixelDelta.manhattanLength()>0) {
this->zoomIn(MouseZoom);
} else {
this->zoomOut(MouseZoom);
}

} else if (!angleDelta.isNull()) {
QPoint angleDeltaDegree = angleDelta / 120;
//scrollWithDegrees(numSteps);
if (angleDeltaDegree.y()>0) {
this->zoomIn(MouseZoom);
} else {
this->zoomOut(MouseZoom);
}
}
#else
event->setAccepted(true);

this->setDragMode(MapGraphicsView::ScrollHandDrag);
if (event->delta() > 0)
this->zoomIn(MouseZoom);
else
this->zoomOut(MouseZoom);
#endif

}

//private slot
Expand Down Expand Up @@ -399,16 +429,18 @@ void MapGraphicsView::doTileLayout()
//We'll mark tiles that aren't being displayed as free so we can use them
QQueue<MapTileGraphicsObject *> freeTiles;

QSet<QPointF> placesWhereTilesAre;
QSet<QString> placesWhereTilesAre;
foreach(MapTileGraphicsObject * tileObject, _tileObjects)
{
if (!tileObject->isVisible() || !exaggeratedBoundingRect.contains(tileObject->pos()))
{
freeTiles.enqueue(tileObject);
tileObject->setVisible(false);
}
else
placesWhereTilesAre.insert(tileObject->pos());
else{
QString pointKey = QString::number(tileObject->pos().x()) % "," % QString::number(tileObject->pos().y());
placesWhereTilesAre.insert(pointKey);
}
}

const quint16 tileSize = _tileSource->tileSize();
Expand All @@ -435,7 +467,8 @@ void MapGraphicsView::doTileLayout()


bool tileIsThere = false;
if (placesWhereTilesAre.contains(scenePos))
QString pointKey = QString::number(scenePos.x()) % "," % QString::number(scenePos.y());
if (placesWhereTilesAre.contains(pointKey))
tileIsThere = true;

if (tileIsThere)
Expand Down
3 changes: 2 additions & 1 deletion MapGraphics/MapGraphicsView.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ private slots:

DragMode _dragMode;
};

/*
inline uint qHash(const QPointF& key)
{
const QString temp = QString::number(key.x()) % "," % QString::number(key.y());
return qHash(temp);
}
*/

#endif // MAPGRAPHICSVIEW_H
4 changes: 4 additions & 0 deletions MapGraphics/tileSources/CompositeTileSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
CompositeTileSource::CompositeTileSource() :
MapTileSource()
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
_globalMutex = new QRecursiveMutex();
#else
_globalMutex = new QMutex(QMutex::Recursive);
#endif
this->setCacheMode(MapTileSource::NoCaching);
}

Expand Down
4 changes: 4 additions & 0 deletions MapGraphics/tileSources/CompositeTileSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ private slots:

private:
void doChildThreading(QSharedPointer<MapTileSource>);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QRecursiveMutex* _globalMutex;
#else
QMutex * _globalMutex;
#endif
QList<QSharedPointer<MapTileSource> > _childSources;
QList<qreal> _childOpacities;
QList<bool> _childEnabledFlags;
Expand Down
3 changes: 3 additions & 0 deletions MapGraphics/tileSources/OSMTileSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <QStringBuilder>
#include <QtDebug>
#include <QNetworkReply>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QtCore5Compat/QRegExp>
#endif

const qreal PI = 3.14159265358979323846;
const qreal deg2rad = PI / 180.0;
Expand Down
86 changes: 83 additions & 3 deletions TestApp/TestApp.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
QT += core gui network sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat

TARGET = TestApp
TEMPLATE = app

Expand All @@ -19,9 +21,87 @@ HEADERS += MainWindow.h
FORMS += MainWindow.ui

#Linkage for MapGraphics shared library
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../MapGraphics/release/ -lMapGraphics
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../MapGraphics/debug/ -lMapGraphics
else:unix:!symbian: LIBS += -L$$OUT_PWD/../MapGraphics/ -lMapGraphics
#win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../MapGraphics/release/ -lMapGraphics
#else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../MapGraphics/debug/ -lMapGraphics
#else:unix:!symbian: LIBS += -L$$OUT_PWD/../MapGraphics/ -lMapGraphics

INCLUDEPATH += $$PWD/../MapGraphics
DEPENDPATH += $$PWD/../MapGraphics

# BUILD OUTPUT DIR outside of parent MapGraphics
# MapGraphics_BUILD at the same dir level of MapGraphics
message( 'Building BUILD_OUT_DIR= $${OUT_PWD} ' )

message( 'Building QMAKESPEC= $${QMAKESPEC} ' )

#-------------------------------------------------
# WIN32 MSVC
#-------------------------------------------------
win32{
message( 'Building TARGET win32' )
CONFIG(release, debug|release){
message( 'Building TARGET win32 release' )
LIBS += -L$$PWD/../../MapGraphics_BUILD/LIB_BINARY/MSVC2019_64bit-Release/ -lMapGraphics
INCLUDEPATH += $$PWD/../../MapGraphics_BUILD/LIB_BINARY/MSVC2019_64bit-Release
DEPENDPATH += $$PWD/../../MapGraphics_BUILD/LIB_BINARY/MSVC2019_64bit-Release
}
CONFIG(debug, debug|release){
message( 'Building TARGET win32 debug' )

}
}

#-------------------------------------------------
# ANDROID
#-------------------------------------------------
android {
message('Building android')
message('Building TARGET ANDROID_TARGET_ARCH $${ANDROID_TARGET_ARCH}')

contains(ANDROID_TARGET_ARCH,x86_64) {
message('Building android for x86_64')
ANDROID_EXTRA_LIBS = $$PWD/../../MapGraphics_BUILD/LIB_BINARY/Clang_x86_64-Release/libMapGraphics_x86_64.so
LIBS += -L$$PWD/../../MapGraphics_BUILD/LIB_BINARY/Clang_x86_64-Release/ -lMapGraphics_x86_64
INCLUDEPATH += $$PWD/../../MapGraphics_BUILD/LIB_BINARY/Clang_x86_64-Release
DEPENDPATH += $$PWD/../../MapGraphics_BUILD/LIB_BINARY/Clang_x86_64-Release
message('Building android for x86_64 ANDROID_EXTRA_LIBS=$${ANDROID_EXTRA_LIBS}')
}

contains(ANDROID_TARGET_ARCH,arm64-v8a) {
message( 'Building android for arm64-v8a' )
ANDROID_EXTRA_LIBS = $$PWD/../../MapGraphics_BUILD/LIB_BINARY/Clang_arm64-v8a-Release/libMapGraphics_arm64-v8a.so
LIBS += -L$$PWD/../../MapGraphics_BUILD/LIB_BINARY/Clang_arm64-v8a-Release/ -lMapGraphics_arm64-v8a
INCLUDEPATH += $$PWD/../../MapGraphics_BUILD/LIB_BINARY/Clang_arm64-v8a-Release
DEPENDPATH += $$PWD/../../MapGraphics_BUILD/LIB_BINARY/Clang_arm64-v8a-Release
message('Building android for x86_64 ANDROID_EXTRA_LIBS=$${ANDROID_EXTRA_LIBS}')
}
android: include(C:/TOOLS/ANDROID/android_openssl/openssl.pri)

}

#-------------------------------------------------
# iOs Configuration
#-------------------------------------------------
ios{
# message( 'Building ios : QMAKE_MACOSX_DEPLOYMENT_TARGET= $${QMAKE_MACOSX_DEPLOYMENT_TARGET}' )
# iOs simulator
#LIBS += -L$$PWD/../../MapGraphics_BUILD/LIB_BINARY/iOS_Simulator-Release/ -lMapGraphics
#INCLUDEPATH += $$PWD/../../MapGraphics_BUILD/LIB_BINARY/iOS_Simulator-Release
#DEPENDPATH += $$PWD/../../MapGraphics_BUILD/LIB_BINARY/iOS_Simulator-Release
#message('Building ios simulator')

# iOs phone
LIBS += -L$$PWD/../../MapGraphics_BUILD/LIB_BINARY/iOS-Release/ -lMapGraphics
INCLUDEPATH += $$PWD/../../MapGraphics_BUILD/LIB_BINARY/iOS-Release
DEPENDPATH += $$PWD/../../MapGraphics_BUILD/LIB_BINARY/iOS-Release
message('Building ios')

}


#unix:!symbian
#{
#LIBS += -L$$OUT_PWD/../MapGraphics/ -lMapGraphics
#}

message('Building using LIBS= $${LIBS} ')