From 39eca8b35f50410c62ab449ce8af26f803b365e0 Mon Sep 17 00:00:00 2001 From: Olgerik Albers Date: Tue, 3 Sep 2024 20:32:53 +0200 Subject: [PATCH] qt6 --- CMakeLists.txt | 36 ++++---- src/BoardPanel.cpp | 92 +++++++++++---------- src/CMakeLists.txt | 4 +- src/DialogLoadGRIB.cpp | 3 +- src/DialogLoadGRIB.h | 2 +- src/DialogSelectMetar.cpp | 21 ++--- src/DialogSelectMetar.h | 2 +- src/DialogServerStatus.h | 2 +- src/DialogUnits.cpp | 4 +- src/FileLoaderGRIB.cpp | 2 +- src/GUI/CMakeLists.txt | 4 +- src/Grib2Record.cpp | 6 +- src/GriddedPlotter.cpp | 34 ++++---- src/GriddedReader.cpp | 2 +- src/ImageWriter.cpp | 5 +- src/IsoLine.cpp | 2 +- src/LonLatGrid.cpp | 2 +- src/MainWindow.cpp | 17 ++-- src/MapDrawer.cpp | 8 +- src/MenuBar.cpp | 2 +- src/MeteoTableWidget.cpp | 17 ++-- src/MeteotableOptionsDialog.cpp | 6 +- src/SkewT.cpp | 31 ++++--- src/SkewTWindow.cpp | 24 ++++-- src/Terrain.cpp | 29 +++---- src/Therm.cpp | 2 +- src/main.cpp | 61 +++++++------- src/map/CMakeLists.txt | 2 +- src/map/POI.cpp | 10 +-- src/util/CMakeLists.txt | 2 +- src/util/Font.cpp | 1 + src/util/Settings.cpp | 10 +-- src/util/Util.cpp | 142 +++++++++++++++++--------------- 33 files changed, 309 insertions(+), 278 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 358a87a2..5f1269c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,11 @@ cmake_minimum_required (VERSION 3.1.0) project (XyGrib) -set(VERSION_MAJOR 1) -set(VERSION_MINOR 2) -set(VERSION_PATCH 7) - +set(VERSION_MAJOR 2) +set(VERSION_MINOR 0) +set(VERSION_PATCH 0) +string(TIMESTAMP TODAY "%Y-%m-%d") set(XYGRIB_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") -set(XYGRIB_VERSION_DATE "2019-07-19") +set(XYGRIB_VERSION_DATE "${TODAY}") option(GNU_PACKAGE "Install into GNU standard directories" OFF) option(GEN_TRANSLATIONS "Generate translations" ON) @@ -25,14 +25,14 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) #set(CMAKE_AUTOUIC ON) #set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/src/GUI") -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") if(UNIX AND NOT APPLE) add_compile_options(-Wall -fPIC) endif() - +add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) # Add support for address etc sanitizers, part 1/2 (other half after ADD_EXECUTABLE) -if ( CMAKE_VERSION VERSION_GREATER 3.4 ) +if ( CMAKE_VERSION VERSION_GREATER 3.4 ) set(ENABLE_SANITIZER "none" CACHE STRING "Add clang sanitizer to the build") set_property(CACHE ENABLE_SANITIZER PROPERTY STRINGS none address memory thread undefined) if (NOT "${ENABLE_SANITIZER}" MATCHES "none") @@ -45,16 +45,16 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_PREFIX}/cmake") set(CMAKE_FIND_FRAMEWORK LAST) # Find the QtWidgets library -find_package(Qt5Widgets CONFIG REQUIRED) -include_directories(${Qt5Widgets_INCLUDE_DIRS}) -find_package(Qt5Core CONFIG REQUIRED) -find_package(Qt5Gui CONFIG REQUIRED) -find_package(Qt5Network CONFIG REQUIRED) -include_directories(${Qt5Network_INCLUDE_DIRS}) -find_package(Qt5PrintSupport CONFIG REQUIRED) -include_directories(${Qt5PrintSupport_INCLUDE_DIRS}) -find_package(Qt5Xml CONFIG REQUIRED) -include_directories(${Qt5Xml_INCLUDE_DIRS}) +find_package(Qt6Widgets CONFIG REQUIRED) +include_directories(${Qt6Widgets_INCLUDE_DIRS}) +find_package(Qt6Core CONFIG REQUIRED) +find_package(Qt6Gui CONFIG REQUIRED) +find_package(Qt6Network CONFIG REQUIRED) +include_directories(${Qt6Network_INCLUDE_DIRS}) +find_package(Qt6PrintSupport CONFIG REQUIRED) +include_directories(${Qt6PrintSupport_INCLUDE_DIRS}) +find_package(Qt6Xml CONFIG REQUIRED) +include_directories(${Qt6Xml_INCLUDE_DIRS}) find_library(LIBNOVA_LIBRARY NAMES "libnova.a" "libnova.so" diff --git a/src/BoardPanel.cpp b/src/BoardPanel.cpp index 64f563d8..7e86f4a8 100644 --- a/src/BoardPanel.cpp +++ b/src/BoardPanel.cpp @@ -25,6 +25,7 @@ along with this program. If not, see . //===================================================================== void BoardPanel::showPosition (double x, double y) { + if (cellPosition->isVisible()) { lbLon.setText (Util::formatLongitude(x)); lbLat.setText (Util::formatLatitude (y)); @@ -58,9 +59,11 @@ void BoardPanel::showDataPointInfo ( lbWindSpeed.setText(""); lbWindBf.setText(""); float v, dir; - if (pf.getWindValues (windAlt, &v, &dir)) { - lbWindDir.setText (s.sprintf("%.0f ", dir)+tr("°")); - lbWindBf.setText (s.sprintf("%2d ", Util::msToBeaufort(v))+tr("Bf")); + if (pf.getWindValues (windAlt, &v, &dir)) { + s = QString("%1 ").arg(dir,0,'f',0)+tr("°"); + lbWindDir.setText (s); + s = QString("%1 ").arg(Util::msToBeaufort(v),2,10)+tr("Bf"); + lbWindBf.setText (s); lbWindSpeed.setText (Util::formatSpeed_Wind(v) ); } else { @@ -72,8 +75,9 @@ void BoardPanel::showDataPointInfo ( //------------------------------------------------------------ if (cellCurrent->isVisible()) { float v, dir; - if (pf.getCurrentValues (&v, &dir)) { - lbCurrentDir.setText (s.sprintf("%.0f ", dir)+tr("°")); + if (pf.getCurrentValues (&v, &dir)) { + s = QString("%1 ").arg(dir,0,'f',0)+tr("°"); + lbCurrentDir.setText (s); lbCurrentSpeed.setText (Util::formatSpeed_Current(v) ); } else { @@ -190,7 +194,8 @@ void BoardPanel::showDataPointInfo ( for (int i=0; i0 && GribDataIsDef(pf.hThetae[i]) && GribDataIsDef(pf.hThetae[i-1])) { QString delta; - delta.sprintf(" (%+.1f)", pf.hThetae[i]-pf.hThetae[i-1]); + //delta.asprintf(" (%+.1f)", pf.hThetae[i]-pf.hThetae[i-1]); + delta = QString("%1").arg(pf.hThetae[i]-pf.hThetae[i-1], 5, 'f', 1); sv[i] += delta; } } @@ -278,20 +284,20 @@ QString BoardPanel::formatWave (const QString &title, float ht, float dir, float QString r = title; QString s; - if (GribDataIsDef(ht)) - s.sprintf(" %5.2fm", ht); + if (GribDataIsDef(ht)) + s = QString("%1m").arg(ht, 5, 'f', 2); //s.asprintf(" %5.2fm", ht); else - s.sprintf(" "); + s.asprintf(" "); r += s; - if (GribDataIsDef(dir)) - s.sprintf(" %+4.0f°", dir); + if (GribDataIsDef(dir)) + s = QString("%1°").arg(dir, 4, 'f', 0); //s.asprintf(" %+4.0f°", dir); else - s.sprintf(" "); + s.asprintf(" "); r += s; - if (GribDataIsDef(per)) - s.sprintf(" %3.0fs", per); + if (GribDataIsDef(per)) + s = QString("%1s").arg(per, 3, 'f', 0); //s.asprintf(" %3.0fs", per); else - s.sprintf(" "); + s.asprintf(" "); r += s; return r; @@ -384,68 +390,68 @@ void BoardPanel::updateLabelsSizes() QFontMetrics fmt(qApp->font()); int style = QFrame::Panel | QFrame::Sunken; - lbLon.setMinimumWidth( fmt.width("X888X88X00XX-") ); + lbLon.setMinimumWidth( fmt.horizontalAdvance("X888X88X00XX-") ); lbLon.setFrameStyle(style); - lbLat.setMinimumWidth( fmt.width("X888X88X00XX-") ); + lbLat.setMinimumWidth( fmt.horizontalAdvance("X888X88X00XX-") ); lbLat.setFrameStyle(style); - lbWindDir.setMinimumWidth( fmt.width("888XX-.") ); + lbWindDir.setMinimumWidth( fmt.horizontalAdvance("888XX-.") ); lbWindDir.setFrameStyle(style); - lbWindBf.setMinimumWidth( fmt.width("8888Bf-") ); + lbWindBf.setMinimumWidth( fmt.horizontalAdvance("8888Bf-") ); lbWindBf.setFrameStyle(style); - lbWindSpeed.setMinimumWidth( fmt.width("888XXXXXkm/h-") ); + lbWindSpeed.setMinimumWidth( fmt.horizontalAdvance("888XXXXXkm/h-") ); lbWindSpeed.setFrameStyle(style); lbGUSTsfc.setFrameStyle(style); - lbGUSTsfc.setMinimumWidth( fmt.width("888XXXXXkm/h-") ); + lbGUSTsfc.setMinimumWidth( fmt.horizontalAdvance("888XXXXXkm/h-") ); - lbCurrentDir.setMinimumWidth( fmt.width("888XX-.") ); + lbCurrentDir.setMinimumWidth( fmt.horizontalAdvance("888XX-.") ); lbCurrentDir.setFrameStyle(style); - lbCurrentSpeed.setMinimumWidth( fmt.width("888XXXXXX-.") ); + lbCurrentSpeed.setMinimumWidth( fmt.horizontalAdvance("888XXXXXX-.") ); lbCurrentSpeed.setFrameStyle(style); QString strlong = "888888888888"; - lbPres.setMinimumWidth( fmt.width(strlong) ); + lbPres.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbPres.setFrameStyle(style); - lbRain.setMinimumWidth( fmt.width(strlong) ); + lbRain.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbRain.setFrameStyle(style); - lbTemp.setMinimumWidth( fmt.width(strlong) ); + lbTemp.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbTemp.setFrameStyle(style); - lbTempMin.setMinimumWidth( fmt.width(strlong) ); + lbTempMin.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbTempMin.setFrameStyle(style); - lbTempMax.setMinimumWidth( fmt.width(strlong) ); + lbTempMax.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbTempMax.setFrameStyle(style); - lbCloud.setMinimumWidth( fmt.width(strlong) ); + lbCloud.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbCloud.setFrameStyle(style); - lbHumid.setMinimumWidth( fmt.width(strlong) ); + lbHumid.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbHumid.setFrameStyle(style); - lbDewPoint.setMinimumWidth( fmt.width(strlong) ); + lbDewPoint.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbDewPoint.setFrameStyle(style); - lbWaterTemp.setMinimumWidth( fmt.width(strlong) ); + lbWaterTemp.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbWaterTemp.setFrameStyle(style); - lbIsotherm0HGT.setMinimumWidth( fmt.width(strlong) ); + lbIsotherm0HGT.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbIsotherm0HGT.setFrameStyle(style); lbSnowDepth.setFrameStyle(style); - lbSnowDepth.setMinimumWidth( fmt.width(strlong) ); + lbSnowDepth.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbSnowCateg.setFrameStyle(style); - lbSnowCateg.setMinimumWidth( fmt.width(strlong) ); + lbSnowCateg.setMinimumWidth( fmt.horizontalAdvance(strlong) ); //added by david lbReflect.setFrameStyle(style); - lbReflect.setMinimumWidth( fmt.width(strlong) ); + lbReflect.setMinimumWidth( fmt.horizontalAdvance(strlong) ); strlong = "888888"; lbCAPEsfc.setFrameStyle(style); - lbCAPEsfc.setMinimumWidth( fmt.width(strlong) ); + lbCAPEsfc.setMinimumWidth( fmt.horizontalAdvance(strlong) ); lbCINsfc.setFrameStyle(style); - lbCINsfc.setMinimumWidth( fmt.width(strlong) ); + lbCINsfc.setMinimumWidth( fmt.horizontalAdvance(strlong) ); // Altitude : hPa Geopot Temp Theta-e // strlong = " 850 hPa "; -// lbWindTitle.setMinimumWidth( fmt.width(strlong) ); +// lbWindTitle.setMinimumWidth( fmt.horizontalAdvance(strlong) ); QFont fontAlt = Font::getFont(FONT_AltitudeLabel); QFont fontAltTitle = Font::getFont(FONT_AltitudeLabelTitle); @@ -470,10 +476,10 @@ void BoardPanel::updateLabelsSizes() QFontMetrics fmtAltTitle (fontAltTitle); strlong = "hPa altitude temp θe"; - lbAltTitle.setMinimumWidth (fmtAltTitle.width(strlong)); + lbAltTitle.setMinimumWidth (fmtAltTitle.horizontalAdvance(strlong)); strlong = "999 99999 gpft -99.9°C 100% 99.9°C (-99.9)"; - int wmin = fmtAlt.width(strlong); + int wmin = fmtAlt.horizontalAdvance(strlong); lb925.setMinimumWidth (wmin); lb850.setMinimumWidth (wmin); lb700.setMinimumWidth (wmin); @@ -540,7 +546,7 @@ void BoardPanel::mouseReleaseEvent (QMouseEvent *e) menuPopup->exec(QCursor::pos()); break; case Qt::LeftButton : - case Qt::MidButton : + case Qt::MiddleButton : break; default : break; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d1c42f95..b92cbed1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,7 +106,7 @@ IF(WIN32) SET(XYGRIB_SRCS ${XYGRIB_SRCS} ../data/img/resource.rc) ENDIF() -qt5_wrap_cpp(xygrib_mocs ${XYGRIB_SRCS} ${XYGRIB_HDRS}) +qt6_wrap_cpp(xygrib_mocs ${XYGRIB_SRCS} ${XYGRIB_HDRS}) add_executable(${CMAKE_PROJECT_NAME} WIN32 MACOSX_BUNDLE ${XYGRIB_SRCS} ${xygrib_mocs}) @@ -118,7 +118,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/map ${MAP_GENERATED_HEADERS}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/GUI ${GUI_GENERATED_HEADERS}) -target_link_libraries(${CMAKE_PROJECT_NAME} g2clib gui util map ${LIBNOVA_LIBRARY} ${OPENJPEG_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARIES} ${PROJ_LIBRARIES} ${PNG_LIBRARIES}) +target_link_libraries(${CMAKE_PROJECT_NAME} g2clib gui util map ${LIBNOVA_LIBRARY} ${OPENJPEG_LIBRARIES} ${Q65Core_LIBRARIES} ${Qt6Gui_LIBRARIES} ${Qt6Widgets_LIBRARIES} ${Qt6Network_LIBRARIES} ${Q6Xml_LIBRARIES} ${Qt6PrintSupport_LIBRARIES} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARIES} ${PROJ_LIBRARIES} ${PNG_LIBRARIES}) # Sanitizers, part 2/2 if ( CMAKE_VERSION VERSION_GREATER 3.4 ) diff --git a/src/DialogLoadGRIB.cpp b/src/DialogLoadGRIB.cpp index 2addaa32..1e4f2b7f 100644 --- a/src/DialogLoadGRIB.cpp +++ b/src/DialogLoadGRIB.cpp @@ -279,8 +279,7 @@ void DialogLoadGRIB::slotGribLoadError (const QString& error) //---------------------------------------------------- void DialogLoadGRIB::slotGribStartLoadData() -{ - timeLoad.start(); +{ timeLoad.start(); } //---------------------------------------------------- diff --git a/src/DialogLoadGRIB.h b/src/DialogLoadGRIB.h index b3dc187b..13ba0da8 100644 --- a/src/DialogLoadGRIB.h +++ b/src/DialogLoadGRIB.h @@ -71,7 +71,7 @@ class DialogLoadGRIB : public DialogBoxBase QString savedFileName; bool loadInProgress; - QTime timeLoad; + QElapsedTimer timeLoad; QCursor oldcursor; QDoubleSpinBox *sbNorth; diff --git a/src/DialogSelectMetar.cpp b/src/DialogSelectMetar.cpp index a4a45527..2c626a43 100644 --- a/src/DialogSelectMetar.cpp +++ b/src/DialogSelectMetar.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . #include #include #include +#include #include "DialogSelectMetar.h" #include "Util.h" @@ -62,7 +63,7 @@ DialogSelectMetar::DialogSelectMetar (QWidget *parent) : DialogBoxBase (parent) //---------------------------------------------------------- int treeoffset = Util::getSetting ("metar_tree_offset", 0).toInt(); treeWidget->verticalScrollBar()->setSliderPosition (treeoffset); - QDesktopWidget *wscr = QApplication::desktop (); + QScreen *wscr = QGuiApplication::primaryScreen(); QRect r = wscr->availableGeometry(); this->setMinimumWidth (qMin(400,r.width())); this->setMinimumHeight (qMin(800,r.height())); @@ -110,15 +111,15 @@ void DialogSelectMetar::make_metar_tree () { MetarWidgetFactory factory; - QSet allExpanded = - QSet ::fromList - (Util::getSetting("metar_country_expanded", QStringList()).toStringList() ); - QSet allSelected = - QSet ::fromList - (Util::getSetting("metar_selected", QStringList()).toStringList() ); + // need to fix for qt6 + QStringList metarCountryExpanded = Util::getSetting("metar_country_expanded", QStringList()).toStringList(); + QStringList metarSelected = Util::getSetting("metar_selected", QStringList()).toStringList(); + QSet allExpanded = QSet (metarCountryExpanded.begin(), metarCountryExpanded.end()); + QSet allSelected = QSet (metarSelected.begin(), metarSelected.end()); + //QSet allSelected = QSet(Util::getSetting("metar_selected", QStringList()).toStringList() ); allAirports = factory.mapAirports.values (); - qSort (allAirports); // sort by country/state/name + std::sort (allAirports.begin(),allAirports.end()); // sort by country/state/name treeWidget = new QTreeWidget (); treeWidget->setColumnCount (2); @@ -141,7 +142,7 @@ void DialogSelectMetar::make_metar_tree () assert (itemCountry); itemRoot = itemCountry; curState = ""; - treeWidget->setFirstItemColumnSpanned (itemCountry, true); + itemCountry->setFirstColumnSpanned (true); name = factory.mapCountries [curCountry]; if (name == "") DBGQS ("Country name not found : "+curCountry); @@ -156,7 +157,7 @@ void DialogSelectMetar::make_metar_tree () itemState = new QTreeWidgetItem (itemCountry); assert (itemState); itemRoot = itemState; - treeWidget->setFirstItemColumnSpanned (itemState, true); + itemState->setFirstColumnSpanned (true); name = factory.mapStates [QPair(curCountry,curState)]; if (name == "") DBGQS ("State name not found : "+curState); diff --git a/src/DialogSelectMetar.h b/src/DialogSelectMetar.h index 80b2f66e..c88895e3 100644 --- a/src/DialogSelectMetar.h +++ b/src/DialogSelectMetar.h @@ -30,7 +30,7 @@ along with this program. If not, see . #include #include #include -#include +//#include qt5 #include "DialogBoxBase.h" #include "Metar.h" diff --git a/src/DialogServerStatus.h b/src/DialogServerStatus.h index 40288604..4171d558 100644 --- a/src/DialogServerStatus.h +++ b/src/DialogServerStatus.h @@ -59,7 +59,7 @@ class DialogServerStatus : public DialogBoxBase QNetworkReply *reply_step1; bool downloadError; - QTime timeLoad; + QElapsedTimer timeLoad; QLabel *lbResponseStatus; std::vector ar_lbRunDate; diff --git a/src/DialogUnits.cpp b/src/DialogUnits.cpp index cdb3acca..f2d81ab4 100644 --- a/src/DialogUnits.cpp +++ b/src/DialogUnits.cpp @@ -243,7 +243,7 @@ QFrame *DialogUnits::createFrameGui(QWidget *parent) { // UTC-12 UTC-11 ... UTC+1 UTC+2 UTC+3 ... UTC+14 QString stz; if (i != 0) - stz.sprintf("UTC%+d", i); + stz.asprintf("UTC%+d", i); else stz = "UTC"; cbTimeZone->addItem( tr("Fixed time ")+stz, stz); @@ -282,7 +282,7 @@ void DialogUnits::slotTimeZoneChanged(int index) QString val = cbTimeZone->itemData(index).toString(); if (val == "LOC") { - time_t locnow = QDateTime::currentDateTime().toTime_t(); + time_t locnow = QDateTime::currentDateTime().toSecsSinceEpoch(); QString saveTimeZone = Util::getSetting("timeZone", "UTC").toString(); Util::setSetting("timeZone", "UTC", false); diff --git a/src/FileLoaderGRIB.cpp b/src/FileLoaderGRIB.cpp index f6738153..1b0cad3f 100644 --- a/src/FileLoaderGRIB.cpp +++ b/src/FileLoaderGRIB.cpp @@ -271,7 +271,7 @@ void FileLoaderGRIB::getGribFile( reply_step1 = networkManager->get (request); connect (reply_step1, SIGNAL(downloadProgress (qint64,qint64)), this, SLOT(downloadProgress (qint64,qint64))); - connect (reply_step1, SIGNAL(error(QNetworkReply::NetworkError)), + connect (reply_step1, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(slotNetworkError (QNetworkReply::NetworkError))); connect (reply_step1, SIGNAL(finished()), this, SLOT(slotFinished_step1 ())); diff --git a/src/GUI/CMakeLists.txt b/src/GUI/CMakeLists.txt index 9311842f..1453e736 100644 --- a/src/GUI/CMakeLists.txt +++ b/src/GUI/CMakeLists.txt @@ -29,8 +29,8 @@ PositionEditorWidget.cpp TextStyleEditorWidget.cpp ) -qt5_wrap_ui(gui_gen_srcs ${GUI_UI}) -qt5_wrap_cpp(gui_mocs ${GUI_SRCS} ${GUI_HDRS} ${gui_gen_srcs}) +qt6_wrap_ui(gui_gen_srcs ${GUI_UI}) +qt6_wrap_cpp(gui_mocs ${GUI_SRCS} ${GUI_HDRS} ${gui_gen_srcs}) add_library(gui STATIC ${GUI_SRCS} ${gui_gen_srcs} ${gui_mocs}) diff --git a/src/Grib2Record.cpp b/src/Grib2Record.cpp index 5a60cd5e..388a8b25 100644 --- a/src/Grib2Record.cpp +++ b/src/Grib2Record.cpp @@ -15,7 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ***********************************************************************/ - +//qt6 fix.. 112 and 432 different from qt5 #include "Grib2Record.h" //---------------------------------------- @@ -109,7 +109,7 @@ Grib2Record::Grib2Record (gribfield *gfld, int id, int idCenter, time_t refDate this->idCenter = idCenter; this->refDate = refDate; this->idGrid = gfld->griddef; - sprintf(strRefDate, "%s", qPrintable(QDateTime::fromTime_t(refDate,Qt::UTC).toString("yyyy-MM-dd HH:mm"))); + sprintf(strRefDate, "%s", QString::fromStdString(std::to_string(refDate)).toUtf8().constData()); ok = true; waveData = false; // TODO verticalOrientationIsAmbiguous = false; @@ -429,7 +429,7 @@ void Grib2Record::analyseProductDefinitionTemplate (gribfield *gfld) return; } } - sprintf(strCurDate, "%s", qPrintable(QDateTime::fromTime_t(curDate,Qt::UTC).toString("yyyy-MM-dd HH:mm"))); + sprintf(strCurDate, "%s", qPrintable(QDateTime::fromSecsSinceEpoch(curDate, Qt::UTC).toString("yyyy-MM-dd HH:mm"))); //------------------------- // Altitude //------------------------- diff --git a/src/GriddedPlotter.cpp b/src/GriddedPlotter.cpp index 8ab5d4e9..5d402462 100644 --- a/src/GriddedPlotter.cpp +++ b/src/GriddedPlotter.cpp @@ -748,7 +748,7 @@ void GriddedPlotter::draw_DATA_Labels ( v = rec->getInterpolatedValue (lon, lat, mustInterpolateValues); if (GribDataIsDef(v)) { QString strtemp = formatLabelFunction (v,false); - pnt.drawText(i-fmet.width("XXX")/2, j+fmet.ascent()/2, strtemp); + pnt.drawText(i-fmet.horizontalAdvance("XXX")/2, j+fmet.ascent()/2, strtemp); } } } @@ -891,54 +891,54 @@ void GriddedPlotter::draw_DATA_MinMax ( // now display the maxima and minima for each quarter if (q1savLv < 9999999.9) { proj->map2screen(q1savLx, q1savLy, &pi, &pj); - pnt.drawText(pi-fmet.width('L')/2, pj+fmet.ascent()/2, minSymbol);; + pnt.drawText(pi-fmet.horizontalAdvance('L')/2, pj+fmet.ascent()/2, minSymbol);; proj->map2screen(q1savLx-360.0,q1savLy, &pi, &pj); - pnt.drawText(pi-fmet.width('L')/2, pj+fmet.ascent()/2, minSymbol);; + pnt.drawText(pi-fmet.horizontalAdvance('L')/2, pj+fmet.ascent()/2, minSymbol);; } if (q1savHv > 0.0) { proj->map2screen(q1savHx, q1savHy, &pi, &pj); - pnt.drawText(pi-fmet.width('H')/2, pj+fmet.ascent()/2, maxSymbol); + pnt.drawText(pi-fmet.horizontalAdvance('H')/2, pj+fmet.ascent()/2, maxSymbol); proj->map2screen(q1savHx-360.0,q1savHy, &pi, &pj); - pnt.drawText(pi-fmet.width('H')/2, pj+fmet.ascent()/2, maxSymbol); + pnt.drawText(pi-fmet.horizontalAdvance('H')/2, pj+fmet.ascent()/2, maxSymbol); } // next quarter if (q2savLv < 9999999.9) { proj->map2screen(q2savLx, q2savLy, &pi, &pj); - pnt.drawText(pi-fmet.width('L')/2, pj+fmet.ascent()/2, minSymbol);; + pnt.drawText(pi-fmet.horizontalAdvance('L')/2, pj+fmet.ascent()/2, minSymbol);; proj->map2screen(q2savLx-360.0,q2savLy, &pi, &pj); - pnt.drawText(pi-fmet.width('L')/2, pj+fmet.ascent()/2, minSymbol);; + pnt.drawText(pi-fmet.horizontalAdvance('L')/2, pj+fmet.ascent()/2, minSymbol);; } if (q2savHv > 0.0) { proj->map2screen(q2savHx, q2savHy, &pi, &pj); - pnt.drawText(pi-fmet.width('H')/2, pj+fmet.ascent()/2, maxSymbol); + pnt.drawText(pi-fmet.horizontalAdvance('H')/2, pj+fmet.ascent()/2, maxSymbol); proj->map2screen(q2savHx-360.0,q2savHy, &pi, &pj); - pnt.drawText(pi-fmet.width('H')/2, pj+fmet.ascent()/2, maxSymbol); + pnt.drawText(pi-fmet.horizontalAdvance('H')/2, pj+fmet.ascent()/2, maxSymbol); } // next quarter if (q3savLv < 9999999.9) { proj->map2screen(q3savLx, q3savLy, &pi, &pj); - pnt.drawText(pi-fmet.width('L')/2, pj+fmet.ascent()/2, minSymbol);; + pnt.drawText(pi-fmet.horizontalAdvance('L')/2, pj+fmet.ascent()/2, minSymbol);; proj->map2screen(q3savLx-360.0,q3savLy, &pi, &pj); - pnt.drawText(pi-fmet.width('L')/2, pj+fmet.ascent()/2, minSymbol);; + pnt.drawText(pi-fmet.horizontalAdvance('L')/2, pj+fmet.ascent()/2, minSymbol);; } if (q3savHv > 0.0) { proj->map2screen(q3savHx, q3savHy, &pi, &pj); - pnt.drawText(pi-fmet.width('H')/2, pj+fmet.ascent()/2, maxSymbol); + pnt.drawText(pi-fmet.horizontalAdvance('H')/2, pj+fmet.ascent()/2, maxSymbol); proj->map2screen(q3savHx-360.0,q3savHy, &pi, &pj); - pnt.drawText(pi-fmet.width('H')/2, pj+fmet.ascent()/2, maxSymbol); + pnt.drawText(pi-fmet.horizontalAdvance('H')/2, pj+fmet.ascent()/2, maxSymbol); } // last quarter if (q4savLv < 9999999.9) { proj->map2screen(q4savLx, q4savLy, &pi, &pj); - pnt.drawText(pi-fmet.width('L')/2, pj+fmet.ascent()/2, minSymbol);; + pnt.drawText(pi-fmet.horizontalAdvance('L')/2, pj+fmet.ascent()/2, minSymbol);; proj->map2screen(q4savLx-360.0,q4savLy, &pi, &pj); - pnt.drawText(pi-fmet.width('L')/2, pj+fmet.ascent()/2, minSymbol);; + pnt.drawText(pi-fmet.horizontalAdvance('L')/2, pj+fmet.ascent()/2, minSymbol);; } if (q4savHv > 0.0) { proj->map2screen(q4savHx, q4savHy, &pi, &pj); - pnt.drawText(pi-fmet.width('H')/2, pj+fmet.ascent()/2, maxSymbol); + pnt.drawText(pi-fmet.horizontalAdvance('H')/2, pj+fmet.ascent()/2, maxSymbol); proj->map2screen(q4savHx-360.0,q4savHy, &pi, &pj); - pnt.drawText(pi-fmet.width('H')/2, pj+fmet.ascent()/2, maxSymbol); + pnt.drawText(pi-fmet.horizontalAdvance('H')/2, pj+fmet.ascent()/2, maxSymbol); } } diff --git a/src/GriddedReader.cpp b/src/GriddedReader.cpp index 227c6ad8..89a4d492 100644 --- a/src/GriddedReader.cpp +++ b/src/GriddedReader.cpp @@ -87,7 +87,7 @@ time_t GriddedReader::getClosestDateFromNow () // pstm = gmtime(&now); // now = mktime(pstm); - time_t utcnow = QDateTime::currentDateTime().toUTC().toTime_t(); + time_t utcnow = QDateTime::currentDateTimeUtc().toSecsSinceEpoch(); return getClosestDateFromDate (utcnow); } //------------------------------------------------------------ diff --git a/src/ImageWriter.cpp b/src/ImageWriter.cpp index 42c6e3dd..f564d707 100644 --- a/src/ImageWriter.cpp +++ b/src/ImageWriter.cpp @@ -20,6 +20,7 @@ along with this program. If not, see . #include #include #include +#include #include "ImageWriter.h" #include "Util.h" @@ -249,8 +250,8 @@ void ImageWriter::saveAllImages () tr("Images (*.jpg *.jpeg)") ); if (filename != "") { - QRegExp reg ("(.jpeg$|.jpg$)"); - reg.setCaseSensitivity(Qt::CaseInsensitive); + QRegularExpression reg ("(.jpeg$|.jpg$)", QRegularExpression::CaseInsensitiveOption); + //reg.setCaseSensitivity(Qt::CaseInsensitive); qt6 QString prefix = filename.replace(reg, ""); reg.setPattern ("(_$|_\\d\\d\\d$)"); prefix = filename.replace(reg, ""); diff --git a/src/IsoLine.cpp b/src/IsoLine.cpp index 3ccd5651..ba5b8601 100644 --- a/src/IsoLine.cpp +++ b/src/IsoLine.cpp @@ -84,7 +84,7 @@ void IsoLine::drawIsoLineLabels(QPainter &pnt, std::vector &overlap, int nb = first; QString label; - label = label.sprintf("%d", qRound(value*coef+offset)); + label = label.asprintf("%d", qRound(value*coef+offset)); QPen penText(couleur); QFont fontText = Font::getFont(FONT_IsolineLabel); diff --git a/src/LonLatGrid.cpp b/src/LonLatGrid.cpp index beb45431..112a93ba 100644 --- a/src/LonLatGrid.cpp +++ b/src/LonLatGrid.cpp @@ -144,7 +144,7 @@ void LonLatGrid::drawLabel(QPainter &pnt, QString label; QColor couleur(10,10,10); - label = label.sprintf("%g", value); + label = label.asprintf("%g", value); QPen penText(couleur); QFont fontText = Font::getFont(FONT_LonLatGridLabel); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 6fb8ed18..e62b5ca2 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -30,6 +30,7 @@ along with this program. If not, see . #include #include #include +#include #include "MainWindow.h" #include "MeteoTable.h" @@ -260,8 +261,12 @@ void MainWindow::connectSignals() connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotFile_Quit())); //------------------------------------------------------- + // old way from qt5 still working..only needed to add header connect(mb->acMap_GroupQuality, SIGNAL(triggered(QAction *)), this, SLOT(slotMap_Quality())); + //connect(mb->acMap_GroupQuality, &QActionGroup::triggered, this, &MainWindow::slotMap_Quality); + + connect(mb->acMap_GroupProjection, SIGNAL(triggered(QAction *)), this, SLOT(slotMap_Projection(QAction *))); @@ -1938,9 +1943,9 @@ void MainWindow::statusBar_showSelectedZone() void MainWindow::slotMouseClicked(QMouseEvent * e) { statusBar_showSelectedZone(); - - mouseClicX = e->x(); - mouseClicY = e->y(); + + mouseClicX = e->position().x(); + mouseClicY = e->position().y(); switch (e->button()) { case Qt::LeftButton : { // added by Tim Holtschneider, 05.2010 @@ -1951,8 +1956,8 @@ void MainWindow::slotMouseClicked(QMouseEvent * e) } break; } - case Qt::MidButton : // Centre la carte sur le point - proj->setCentralPixel(e->x(), e->y()); + case Qt::MiddleButton : // Centre la carte sur le point + proj->setCentralPixel(e->position().x(), e->position().y()); terre->setProjection(proj); break; @@ -2569,7 +2574,7 @@ void MainWindow::slotCheckForUpdates() QString page = "/getversion.php"; QNetworkRequest request = Util::makeNetworkRequest("http://"+Util::getServerName()+page); reply = networkManager->get(request); - connect (reply, SIGNAL(error(QNetworkReply::NetworkError)), + connect (reply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(slotNetworkError (QNetworkReply::NetworkError))); connect (reply, SIGNAL(finished()), this, SLOT(slotFinished ())); diff --git a/src/MapDrawer.cpp b/src/MapDrawer.cpp index cb1f22fd..a644f701 100644 --- a/src/MapDrawer.cpp +++ b/src/MapDrawer.cpp @@ -737,11 +737,11 @@ void MapDrawer::draw_Cartouche_Gridded //--------------------------------------------------------- QString tval2 = Util::formatDateTimeLong(plotter->getCurrentDate()); n += datalist.size(); - w1 = fmbig.width(tval2)+5; + w1 = fmbig.horizontalAdvance(tval2)+5; w2 = 0; // get largest string data for (int i = 0; i < datalist.size(); i++) { - int t = fmsmall.width (datalist.at(i))+5; + int t = fmsmall.horizontalAdvance (datalist.at(i))+5; if (t>w2) w2 = t; } @@ -781,7 +781,7 @@ void MapDrawer::draw_Cartouche_Gridded pnt.setFont (fontdate); w = 0; // get largest string data for (int i = 0; i < datalist.size(); i++) { - int t = fmdate.width (datalist.at(i))+5; + int t = fmdate.horizontalAdvance (datalist.at(i))+5; if (t>w) w = t; } @@ -803,7 +803,7 @@ void MapDrawer::draw_Cartouche_Gridded //-------------------------------------------------- QString sign = tr("XyGrib"); pnt.setFont(fontsign); - w = fmsign.width(sign)+5; + w = fmsign.horizontalAdvance(sign)+5; dy = fontsign.pointSize()+1; h = dy+2; x = QApplication::isRightToLeft() ? 0 : proj->getW() - w; diff --git a/src/MenuBar.cpp b/src/MenuBar.cpp index f9fc85a0..2c018022 100644 --- a/src/MenuBar.cpp +++ b/src/MenuBar.cpp @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ***********************************************************************/ #include - +#include #include "MenuBar.h" #include "Font.h" #include "Util.h" diff --git a/src/MeteoTableWidget.cpp b/src/MeteoTableWidget.cpp index 93936786..4d627db6 100644 --- a/src/MeteoTableWidget.cpp +++ b/src/MeteoTableWidget.cpp @@ -17,7 +17,7 @@ along with this program. If not, see . ***********************************************************************/ #include - +#include #include "Astro.h" #include "Settings.h" #include "DataQString.h" @@ -464,7 +464,8 @@ void MeteoTableWidget::createListVisibleGribData () DataCode(GRB_PRESSURE_MSL,LV_MSL,0).toInt32(), pos++) ); } // Sort visible data by position - qSort (listVisibleData.begin(), listVisibleData.end(), lessThanMTGribData); + std::sort (listVisibleData.begin(), listVisibleData.end(),lessThanMTGribData); + //qSort (listVisibleData.begin(), listVisibleData.end(), lessThanMTGribData); } //----------------------------------------------------------------- void MeteoTableWidget::addLine_Isotherm0Height(int lig) @@ -551,11 +552,13 @@ void MeteoTableWidget::addLine_Wind (const Altitude &alt, int lig) if (pf->getWindValues (alt, &v, &dir)) { if (GribDataIsDef(dir)) { QString tmp; - tmp.sprintf("%.0f", dir); + //tmp.asprintf("%.0f", dir); + tmp = QString("%1").arg(dir,0,'f',0); txt += tmp + tr(" °") + "\n"; txt += Util::formatSpeed_Wind(v); if ( Util::getSetting("MTABLE_showWindBeauforts", true).toBool() ) { - tmp.sprintf("%2d", Util::msToBeaufort(v)); + //tmp.asprintf("%2d", Util::msToBeaufort(v)); + tmp = QString("%1").arg(Util::msToBeaufort(v),0,10,QChar('0')); txt += "\n"; txt += tmp + tr(" Bf"); } @@ -585,7 +588,8 @@ void MeteoTableWidget::addLine_Current (const Altitude &alt, int lig) if (pf->getCurrentValues (&v, &dir)) { if (GribDataIsDef(dir)) { QString tmp; - tmp.sprintf("%.0f", dir); + //tmp.asprintf("%.0f", dir); + tmp = QString("%1").arg(dir,0,'f',0); txt += tmp + tr(" °") + "\n"; txt += Util::formatSpeed_Current(v); bgColor = QColor(plotter->getCurrentColor(v, true)); @@ -836,7 +840,8 @@ void MeteoTableWidget::addLine_Rain(int lig) txt = ""; if (pinfo->hasRain()) { double v = pinfo->rain; - txt.sprintf("%.2f ", v); + //txt.asprintf("%.2f ", v); + txt = QString::number(v, 'f', 2); txt += tr("mm/h"); bgColor = QColor(plotter->getRainColor(v, true)); } diff --git a/src/MeteotableOptionsDialog.cpp b/src/MeteotableOptionsDialog.cpp index 3c0c7fe3..080e0b04 100644 --- a/src/MeteotableOptionsDialog.cpp +++ b/src/MeteotableOptionsDialog.cpp @@ -150,7 +150,7 @@ void DialogMeteotableOptions::slotChangeVisibleItems() } } // update positions after movings (numerate from 0) - qSort (listAllOptionItems.begin(), listAllOptionItems.end(), + std::sort (listAllOptionItems.begin(), listAllOptionItems.end(), MeteotableOptionItem::lessThan_byPos); int posVis = 0; int posNotVis = 0; @@ -218,10 +218,10 @@ void DialogMeteotableOptions::updateListWidgetsItems () } // sort visible data by position - qSort (listVisibleItems.begin(), listVisibleItems.end(), + std::sort (listVisibleItems.begin(), listVisibleItems.end(), MeteotableOptionItem::lessThan_byPos); // sort hidden data by name - qSort (listHiddenItems.begin(), listHiddenItems.end(), + std::sort (listHiddenItems.begin(), listHiddenItems.end(), MeteotableOptionItem::lessThan_byName); // add ordered items in widget lists listVisibleData->clear(); diff --git a/src/SkewT.cpp b/src/SkewT.cpp index 24cd2dbb..197267c0 100644 --- a/src/SkewT.cpp +++ b/src/SkewT.cpp @@ -1,6 +1,6 @@ #include "SkewT.h" - +#include //------------------------------------------------------ SkewT::SkewT (int W, int H, QWidget *parent) : QWidget (parent) { @@ -115,9 +115,9 @@ void SkewT::setConvectiveBase (const QString& cbase) } else if (cbase.startsWith ("surface-")) { // format "surface-50" - QRegExp reg ("surface-(\\d+)"); - if (reg.indexIn (cbase) != -1) { - p2 = reg.cap(1); + QRegularExpression reg ("surface-(\\d+)"); + if (reg.match(cbase).hasMatch()) { + p2 = reg.match(cbase).captured(1); hmax = surfaceHpa; hmin = surfaceHpa - p2.toDouble (&ok); if (ok) { @@ -128,10 +128,10 @@ void SkewT::setConvectiveBase (const QString& cbase) } } else { // format "1000-950" - QRegExp reg ("(\\d+)-(\\d+)"); - if (reg.indexIn (cbase) != -1) { - p1 = reg.cap(1); - p2 = reg.cap(2); + QRegularExpression reg ("(\\d+)-(\\d+)"); + if (reg.match (cbase).hasMatch()) { + p1 = reg.match(cbase).captured(1); + p2 = reg.match(cbase).captured(2); hmax = p1.toDouble (&ok); if (ok) { hmin = p2.toDouble (&ok); @@ -442,28 +442,27 @@ void SkewT::draw_temperatureScale (QPainter &pnt, bool withLabels) pnt.drawLine (i0, j0, i0, j0+4); if (withLabels) { QString txt = QString("%1").arg(temp); - pnt.drawText (i0-fmet.width(txt)/2, j0+fh, txt); + pnt.drawText (i0-fmet.horizontalAdvance(txt)/2, j0+fh, txt); } } else { // line starts outside of X axis QLineF lineTemp (i0, j0, i1, j1); QPointF interleft; - if (lineTemp.intersect (lineLeft, &interleft) == QLineF::BoundedIntersection - ) { + if (lineTemp.intersects (lineLeft, &interleft)) { QPoint pl = interleft.toPoint (); int i = pl.x(); int j = pl.y(); pnt.drawLine (i, j, i-4, j); if (withLabels) { QString txt = QString("%1").arg(temp); - pnt.drawText (DX1-fmet.width(txt)-5, j+fh/3, txt); + pnt.drawText (DX1-fmet.horizontalAdvance(txt)-5, j+fh/3, txt); } } } } if (withLabels) { QString txt = "°C"; - pnt.drawText (DX1-fmet.width(txt)-5, H-DY2+fh, txt); + pnt.drawText (DX1-fmet.horizontalAdvance(txt)-5, H-DY2+fh, txt); } } //------------------------------------------------------ @@ -499,7 +498,7 @@ void SkewT::draw_pressureScale (QPainter &pnt, bool withLabels) } } if (withLabels) - pnt.drawText (i1-fmet.width("hPa")-6, DY1-6, "hPa"); + pnt.drawText (i1-fmet.horizontalAdvance("hPa")-6, DY1-6, "hPa"); // intermediate lines pen.setWidthF (0.4); pnt.setPen (pen); @@ -851,7 +850,7 @@ void SkewT::draw_linesCAPE (QPainter &pnt) void SkewT::draw_comments (QPainter &pnt) { QFontMetrics fmet (pnt.font()); - double fw = fmet.width ("W"); + double fw = fmet.horizontalAdvance ("W"); double fh = fmet.lineSpacing (); pnt.save (); QColor commentsColor = QColor (70,70,70); @@ -960,7 +959,7 @@ void SkewT::draw_comments (QPainter &pnt) QString dat = tr("Date: ")+curdate; pnt.drawText (W/2, 2*fh, dat); //------------------------------------------------------- - pnt.drawText (W-fmet.width("XyGrib")-5, H-5, "XyGrib"); + pnt.drawText (W-fmet.horizontalAdvance("XyGrib")-5, H-5, "XyGrib"); //------------------------------------------------------- QFont font = pnt.font(); font.setFamily ("times"); diff --git a/src/SkewTWindow.cpp b/src/SkewTWindow.cpp index 62ddd81d..20197a33 100644 --- a/src/SkewTWindow.cpp +++ b/src/SkewTWindow.cpp @@ -209,13 +209,25 @@ void SkewTWindow::actionsCommonSlot () { QPainter painter; painter.begin(&printer); - double xscale = printer.pageRect().width()/double(skewt->width()); - double yscale = printer.pageRect().height()/double(skewt->height()); + + const auto pageLayout = printer.pageLayout(); + const auto pageRect = pageLayout.paintRectPixels(printer.resolution()); + const auto paperRect = pageLayout.fullRectPixels(printer.resolution()); + double xscale = pageRect.width() / double(skewt->width()); + double yscale = pageRect.height() / double(skewt->height()); double scale = qMin(xscale, yscale); - painter.translate(printer.paperRect().x() + printer.pageRect().width()/2, - printer.paperRect().y() + printer.pageRect().height()/2); + painter.translate(pageRect.x() + paperRect.width() / 2., + pageRect.y() + paperRect.height() / 2.); painter.scale(scale, scale); - painter.translate(-skewt->width()/2, -skewt->height()/2); + painter.translate(-skewt->width() / 2., -skewt->height() / 2.); + + // double xscale = printer.pageRect().width()/double(skewt->width()); + // double yscale = printer.pageRect().height()/double(skewt->height()); + // double scale = qMin(xscale, yscale); + // painter.translate(printer.paperRect().x() + printer.pageRect().width()/2, + // printer.paperRect().y() + printer.pageRect().height()/2); + // painter.scale(scale, scale); + // painter.translate(-skewt->width()/2, -skewt->height()/2); skewt->setPrinterRendering (true); skewt->render (&painter); skewt->setPrinterRendering (false); @@ -340,7 +352,7 @@ void SkewTWindow::saveFileSYLK (SylkFile &slk) if (allwind.ok() && !allAlts.contains(allwind.hpa)) allAlts << allwind.hpa; } - qSort (allAlts); + std::sort (allAlts.begin(), allAlts.end()); //qt6 is this correcT? col = 1; slk.addCell (lig, col++, "Altitude (hPa)"); diff --git a/src/Terrain.cpp b/src/Terrain.cpp index 304e2289..9e2e50d3 100644 --- a/src/Terrain.cpp +++ b/src/Terrain.cpp @@ -911,10 +911,11 @@ void Terrain::keyReleaseEvent (QKeyEvent *e) //--------------------------------------------------------- void Terrain::wheelEvent(QWheelEvent * e) { -//printf("wheelEvent\n"); - double k = 1 + .002 * e->delta(); + QPoint numDegrees = e->angleDelta(); // qt6 / 8; + + double k = 1 + .002 * numDegrees.y(); - if (e->delta() != 0) + if (numDegrees.y() != 0) deltaZoomWheel *= k; else { e->ignore(); @@ -966,13 +967,13 @@ void Terrain::mousePressEvent (QMouseEvent * e) { isDraggingMapEnCours = true; } } - proj->screen2map(e->x(),e->y(), &selX1, &selY1); + proj->screen2map(e->position().x(),e->position().y(), &selX1, &selY1); selX0 = selX1; selY0 = selY1; - globalX0 = e->globalX(); - globalY0 = e->globalY(); - lastMouseX = e->x(); - lastMouseY = e->y(); + globalX0 = e->globalPosition().x(); + globalY0 = e->globalPosition().y(); + lastMouseX = e->position().x(); + lastMouseY = e->position().y(); update(); } } @@ -1000,7 +1001,7 @@ void Terrain::mouseReleaseEvent (QMouseEvent * e) { if (isSelectionZoneEnCours) { isSelectionZoneEnCours = false; - proj->screen2map(e->x(),e->y(), &selX1, &selY1); + proj->screen2map(e->position().x(),e->position().y(), &selX1, &selY1); if (getSelectedRectangle(&x0,&y0, &x1,&y1)) { emit selectionOK(x0, y0, x1, y1); @@ -1025,8 +1026,8 @@ void Terrain::mouseMoveEvent (QMouseEvent * e) { // TODO use tiles to drag map double x0, y0, x1, y1; - int mx = lastMouseX-e->x(); - int my = lastMouseY-e->y(); + int mx = lastMouseX-e->position().x(); + int my = lastMouseY-e->position().y(); proj->screen2map (mx, my, &x0, &y0); proj->screen2map (mx+width(), my+height(), &x1, &y1); proj->setVisibleArea (x0,y0, x1,y1); @@ -1034,12 +1035,12 @@ void Terrain::mouseMoveEvent (QMouseEvent * e) } else if (isSelectionZoneEnCours) { - proj->screen2map (e->x(),e->y(), &selX1, &selY1); + proj->screen2map (e->position().x(),e->position().y(), &selX1, &selY1); update(); // draw selection rectangle } - lastMouseX = e->x(); - lastMouseY = e->y(); + lastMouseX = e->position().x(); + lastMouseY = e->position().y(); emit mouseMoved(e); } //--------------------------------------------------------- diff --git a/src/Therm.cpp b/src/Therm.cpp index 1644bbc1..458dbdbb 100644 --- a/src/Therm.cpp +++ b/src/Therm.cpp @@ -239,7 +239,7 @@ Sounding::Sounding () void Sounding::addSoundingPointC (double hpa, double tempC, double dewpC) { allSounds << SoundingPoint (hpa, tempC, dewpC); - qSort (allSounds); + std::sort (allSounds.begin(), allSounds.end()); levelsAreValid = false; } //------------------------------------------------------ diff --git a/src/main.cpp b/src/main.cpp index e3d538c5..45c78e73 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,7 +17,6 @@ along with this program. If not, see . ***********************************************************************/ #include -#include #include #include #include @@ -59,7 +58,7 @@ int main (int argc, char *argv[]) // Remove warning: // qt.network.ssl: QSslSocket: cannot resolve SSLv2_client_method - QLoggingCategory::setFilterRules("qt.network.ssl.warning=false"); + //QLoggingCategory::setFilterRules("qt.network.ssl.warning=false"); //---------------------------------------------------------- // Find/initialize application settings files @@ -137,100 +136,100 @@ int main (int argc, char *argv[]) //----------------------------------------------- if (lang == "fr") { QLocale::setDefault(QLocale("fr_FR")); - trSystem.load( QString("qt_fr"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_fr"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "fi") { QLocale::setDefault(QLocale("fi_FI")); - trSystem.load( QString("qt_fi"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_fi"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "de") { QLocale::setDefault(QLocale("de_DE")); - trSystem.load( QString("qt_de"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_de"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "ru") { QLocale::setDefault(QLocale("ru_RU")); - trSystem.load( QString("qt_ru"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_ru"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "pl") { QLocale::setDefault(QLocale("pl_PL")); - trSystem.load( QString("qt_pl"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_pl"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "pt") { QLocale::setDefault(QLocale("pt_PT")); - trSystem.load( QString("qt_pt"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_pt"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "es") { QLocale::setDefault(QLocale("es_ES")); - trSystem.load( QString("qt_es"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_es"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "it") { QLocale::setDefault(QLocale("it_IT")); - trSystem.load( QString("qt_it"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_it"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "nl") { QLocale::setDefault(QLocale("nl_NL")); - trSystem.load( QString("qt_nl"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_nl"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "cz") { QLocale::setDefault(QLocale("cz_CZ")); - trSystem.load( QString("qt_cz"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_cz"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } // A. Degwerth [Cassidian] added Arabic language support else if (lang == "ar") { QLocale::setDefault(QLocale("ar_AR")); - trSystem.load( QString("qt_ar"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_ar"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "gr") { QLocale::setDefault(QLocale("gr_GR")); - trSystem.load( QString("qt_gr"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_gr"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED( trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "he") { QLocale::setDefault(QLocale("he_IL")); - trSystem.load( QString("qt_he"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_he"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } else if (lang == "cn") { QLocale::setDefault(QLocale("zh_CN")); - trSystem.load( QString("qt_cn"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - trXygrib.load( Util::pathTr(lang)); + Q_UNUSED(trSystem.load( QString("qt_cn"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))); + Q_UNUSED(trXygrib.load( Util::pathTr(lang))); QApplication::installTranslator(&trXygrib); QApplication::installTranslator(&trSystem); } @@ -256,7 +255,7 @@ int main (int argc, char *argv[]) assert (win); //----------------------------------------------------- if (shiftsWindow) { - QRect rsz = QApplication::desktop()->screenGeometry (); + QRect rsz = QGuiApplication::primaryScreen()->geometry(); int ws = rsz.width (); int hs = rsz.height (); int x = win->x (); diff --git a/src/map/CMakeLists.txt b/src/map/CMakeLists.txt index 6219882c..44dd5e70 100644 --- a/src/map/CMakeLists.txt +++ b/src/map/CMakeLists.txt @@ -19,7 +19,7 @@ Projection.cpp Projection_libproj.cpp ) -qt5_wrap_cpp(map_mocs ${MAP_SRCS} ${MAP_HDRS}) +qt6_wrap_cpp(map_mocs ${MAP_SRCS} ${MAP_HDRS}) add_library(map STATIC ${MAP_SRCS} ${map_mocs}) diff --git a/src/map/POI.cpp b/src/map/POI.cpp index 85a27ed1..7baf845b 100644 --- a/src/map/POI.cpp +++ b/src/map/POI.cpp @@ -329,8 +329,8 @@ void POI::mouseMoveEvent (QMouseEvent * e) { if (moveInCourse) { int i,j; // position on screen - i = x() + e->x() - xMouse + hpx; - j = y() + e->y() - yMouse + hpy; + i = x() + e->position().x() - xMouse + hpx; + j = y() + e->position().y() - yMouse + hpy; if (i>0 && j>0 && i+hpxgetW() && j+hpygetH()) { proj->screen2map(i, j, &lon, &lat); @@ -345,8 +345,8 @@ void POI::mousePressEvent(QMouseEvent *e) { if (isMovable && e->modifiers()==Qt::ControlModifier) { moveInCourse = true; // Ctrl+Clic : move POI - xMouse = e->x(); - yMouse = e->y(); + xMouse = e->position().x(); + yMouse = e->position().y(); } else if (e->modifiers()==Qt::ShiftModifier) { // add POI to global list, TH20100514 GLOB_listSelectedPOI.append( this ); @@ -360,7 +360,7 @@ void POI::mousePressEvent(QMouseEvent *e) //------------------------------------------------------------------------------- void POI::mouseReleaseEvent(QMouseEvent *e) { - if (e->x()<0 ||e->x()>width() ||e->y()<0 ||e->y()>height()) + if (e->position().x()<0 ||e->position().x()>width() ||e->position().y()<0 ||e->position().y()>height()) return; if (! moveInCourse && e->modifiers()==Qt::NoModifier) { diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index bac2c40d..9577054f 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -15,7 +15,7 @@ Util.cpp zuFile.cpp ) -qt5_wrap_cpp(util_mocs ${UTIL_SRCS} ${UTIL_HDRS}) +qt6_wrap_cpp(util_mocs ${UTIL_SRCS} ${UTIL_HDRS}) add_library(util STATIC ${UTIL_SRCS} ${util_mocs}) diff --git a/src/util/Font.cpp b/src/util/Font.cpp index ea1124c3..0447c51c 100644 --- a/src/util/Font.cpp +++ b/src/util/Font.cpp @@ -27,6 +27,7 @@ QFont GLOB_Font [FONT_MaxValue]; //------------------------------------------------------------------- QString Font::getFontCodeString (FontCode code) { + QString res = "test"; switch (code) { case FONT_Default : return "FONT_Default"; case FONT_ComboBox : return "FONT_ComboBox"; diff --git a/src/util/Settings.cpp b/src/util/Settings.cpp index bbac4e55..159d3353 100644 --- a/src/util/Settings.cpp +++ b/src/util/Settings.cpp @@ -529,13 +529,9 @@ bool Settings::findAppDataDir () if (path == "") { // first search option is to locate setting files in user application data area // this should be OK for all systems -#ifdef Q_OS_WIN - // "AppDataLocation" is new and does not appear in earlier QT5 versions and may crash linux builds - // in windows binaries it does exist for sure. This will put app data in c:/user/AppData/Roaming... + dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); -#else - dir = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); -#endif + QDir maps = QDir(dir.absolutePath() + "/data/maps"); QDir gis = QDir(dir.absolutePath() + "/data/gis"); @@ -550,7 +546,7 @@ bool Settings::findAppDataDir () if (path == "") { // second option is to locate app data files in shared area - slist = QStandardPaths::standardLocations(QStandardPaths::DataLocation); + slist = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation); foreach (QString str, slist) { DBGQS("Searching in: " + str); diff --git a/src/util/Util.cpp b/src/util/Util.cpp index 918b7a53..e1faf59e 100644 --- a/src/util/Util.cpp +++ b/src/util/Util.cpp @@ -195,15 +195,15 @@ QString Util::formatTemperature (float tempKelvin, bool withUnit) { QString unit = Util::getSetting("unitsTemp", QVariant(tr("°C"))).toString(); QString r; - if (unit == tr("°K")) { - r.sprintf("%.1f", tempKelvin); + if (unit == tr("°K")) { + r = QString::number(tempKelvin, 'f', 1); } - else if (unit == tr("°F")) { - r.sprintf("%.1f", 1.8f*(tempKelvin-273.15f)+32.0f); + else if (unit == tr("°F")) { + r = QString::number(1.8f*(tempKelvin-273.15f)+32.0f, 'f', 1); } else { // if (unit == tr("°K")) - unit = tr("°C"); - r.sprintf("%.1f", tempKelvin-273.15f); + unit = tr("°C"); + r = QString::number(tempKelvin-273.15f, 'f', 1); } return (withUnit) ? r+""+unit : r; } @@ -212,15 +212,15 @@ QString Util::formatTemperature_short(float tempKelvin, bool withUnit) { QString unit = Util::getSetting("unitsTemp", tr("°C")).toString(); QString r; - if (unit == tr("°K")) { - r.sprintf("%d", qRound(tempKelvin) ); + if (unit == tr("°K")) { + r = QString::number(qRound(tempKelvin)); } - else if (unit == tr("°F")) { - r.sprintf("%d", qRound(1.8f*(tempKelvin-273.15f)+32.0f) ); + else if (unit == tr("°F")) { + r = QString::number(qRound(1.8f*(tempKelvin-273.15f)+32.0f)); } else { // if (unit == tr("°K")) - unit = tr("°C"); - r.sprintf("%d", qRound(tempKelvin-273.15f) ); + unit = tr("°C"); + r = QString::number(qRound(tempKelvin-273.15f)); } return (withUnit) ? r+""+unit : r; } @@ -228,20 +228,20 @@ QString Util::formatTemperature_short(float tempKelvin, bool withUnit) QString Util::formatSpeed (float meterspersecond, bool withUnit, QString unit) { QString r; - if (unit == "m/s") { - r.sprintf("%.1f ", meterspersecond); + if (unit == "m/s") { + r = QString::number(meterspersecond, 'f', 1); unit = tr("m/s"); } else if (unit == "m/min") { - r.sprintf("%d ", qRound(meterspersecond*60.f)); + r = QString::number(qRound(meterspersecond*60.f)); unit = tr("m/min"); } else if (unit == "km/h") { - r.sprintf("%.1f ", meterspersecond*3.6); + r = QString::number(meterspersecond*3.6, 'f', 1); unit = tr("km/h"); } - else { // if (unit == tr("kts")) - r.sprintf("%.1f ", meterspersecond*3.6/1.852); + else { // if (unit == tr("kts")) + r = QString::number(meterspersecond*3.6/1.852, 'f', 1); unit = tr("kts"); } return (withUnit) ? r+" "+unit : r; @@ -262,8 +262,8 @@ QString Util::formatSpeed_Current (float meterspersecond, bool withUnit) QString Util::formatDirection (float angle, bool withUnit) { QString unite = tr("°"); - QString r; - r.sprintf("%d", qRound(angle +0.5f)); + QString r; + r = QString::number(qRound(angle +0.5f)); return (withUnit) ? r+unite : r; } //---------------------------------------------------------------- @@ -280,12 +280,14 @@ QString Util::formatDistance (float mille, bool withUnit) unit = "NM"; d = mille; } - if (d<10) - r.sprintf("%5.2f", d); + if (d<10) + r = QString("%1").arg(d,5,'f',2); + else if (d<100) + r = QString("%1").arg(d,05,'f',1); else if (d<100) - r.sprintf("%5.1f", d); - else - r.sprintf("%5.0f", d); + r = QString("%1").arg(d,5,'f',1); + else + r = QString("%1").arg(d,5,'f',0); return (withUnit) ? r+" "+unit : r; } //---------------------------------------------------------------- @@ -445,8 +447,8 @@ QString Util::formatIsotherm0HGT (float meter, bool withUnit) QString unite = Util::getDataUnit (DataCode(GRB_GEOPOT_HGT,LV_ISOTHERM0,0)); double coef = Util::getDataCoef (DataCode(GRB_GEOPOT_HGT,LV_ISOTHERM0,0)); int d = (int) (meter*coef +0.5); - QString r; - r.sprintf("%d", d); + QString r; + r = QString::number(d); return (withUnit) ? r+" "+unite : r; } //---------------------------------------------------------------- @@ -456,7 +458,7 @@ QString Util::formatGeopotAltitude (float meter, bool withUnit) double coef = Util::getDataCoef (DataCode(GRB_GEOPOT_HGT,LV_ISOBARIC,0)); int d = (int) (meter*coef +0.5); QString r; - r.sprintf("%d", d); + r = QString::number(d); return (withUnit) ? r+" "+unite : r; } //---------------------------------------------------------------- @@ -466,9 +468,9 @@ QString Util::formatRain (float mmh, bool withUnit) QString unite = Util::getDataUnit (DataCode(GRB_PRECIP_TOT,LV_GND_SURF,0)); QString r; if (mmh<10) - r.sprintf("%.2f", mmh); - else - r.sprintf("%.1f", mmh); + r = QString::number(mmh, 'f', 2); + else + r = QString::number(mmh, 'f', 1); return (withUnit) ? r+" "+unite : r; } //---------------------------------------------------------------- @@ -477,10 +479,10 @@ QString Util::formatPressure (float pasc, bool withUnit, int precision) QString unite = Util::getDataUnit (DataCode(GRB_PRESSURE_MSL,LV_MSL,0)); QString r; if (GribDataIsDef(pasc)) { - if (precision > 0) - r.sprintf("%.1f", pasc/100.0f); - else - r.sprintf("%.0f", pasc/100.0f); + if (precision > 0) + r = QString::number(pasc/100.0f, 'f', precision); + else + r = QString::number(pasc/100.0f, 'f', 0); } return (withUnit) ? r+" "+unite : r; } @@ -489,7 +491,8 @@ QString Util::formatCAPEsfc (float jkg, bool withUnit) { QString unite = Util::getDataUnit (DataCode(GRB_CAPE,LV_GND_SURF,0)); QString r; - r.sprintf("%d", qRound(jkg)); + + r = QString::number(jkg, 'f', 0); return (withUnit) ? r+" "+unite : r; } //---------- added by david --------------------------------- @@ -497,7 +500,8 @@ QString Util::formatReflect(float dbz, bool withUnit) { QString unite = Util::getDataUnit (DataCode(GRB_COMP_REFL,LV_ATMOS_ALL,0)); QString r; - r.sprintf("%d", qRound(dbz)); + + r = QString::number(qRound(dbz)); return (withUnit) ? r+" "+unite : r; } //---------------------------------------------------------------- @@ -514,10 +518,10 @@ QString Util::formatWaveHeight (float meter, bool withUnit) unite = "ft"; d= meter/0.3048f; } - if (d < 10) - r.sprintf("%.1f", d); - else - r.sprintf("%.0f", d); + if (d < 10) + r = QString::number(d, 'f', 1); + else + r = QString::number(d, 'f', 1); return (withUnit) ? r+" "+unite : r; } //---------------------------------------------------------------- @@ -525,7 +529,8 @@ QString Util::formatWavePeriod (float second, bool withUnit) { QString unit = Util::getSetting("waveHeightPeriod", tr("s")).toString(); QString r; - r.sprintf("%.0f", second); + + r = QString::number(second, 'f', 0); return (withUnit) ? r+" "+unit : r; } //---------------------------------------------------------------- @@ -547,15 +552,15 @@ QString Util::formatSnowDepth (float meter, bool withUnit) if (unit == tr("m")) { unite = "cm"; d= meter*100.0f; - if (d < 10) - r.sprintf("%.1f", d); - else - r.sprintf("%.0f", d); + if (d < 10) + r = QString::number(d, 'f', 1); + else + r = QString::number(d, 'f', 0); } else { unite = "ft"; - d= meter/0.3048f; - r.sprintf("%.2f", d); + d= meter/0.3048f; + r = QString::number(d, 'f', 2); } return (withUnit) ? r+" "+unite : r; } @@ -563,19 +568,20 @@ QString Util::formatSnowDepth (float meter, bool withUnit) QString Util::formatDegres (float x, bool inf100) // 123.4 -> 123°24.00' { const char *cdeg = "°"; + QString tunit = Util::getSetting("unitsPosition", "").toString(); QString unit = (tunit=="") ? tr("dd°mm'ss\"") : tunit; - + QString r; if (unit == tr("dd°mm,mm'")) { int deg = (int) fabs(x); float min = (fabs(x) - deg)*60.0f; char sign = (x<0) ? '-' : ' '; - if (inf100) - r.sprintf("%c%02d%s%05.2f'", sign,deg,cdeg, min); - else - r.sprintf("%c%03d%s%05.2f'", sign,deg,cdeg, min); + if (inf100) + r = QString("%1%2%3%4'%5").arg(sign).arg(deg,2,10,QChar('0')).arg(cdeg).arg(min,5,'f',2,QChar('0')); + else + r = QString("%1%2%3%4'%5").arg(sign).arg(deg,3,10,QChar('0')).arg(cdeg).arg(min,5,'f',2,QChar('0')); } else if (unit == tr("dd°mm'ss\"")) { @@ -585,17 +591,17 @@ QString Util::formatDegres (float x, bool inf100) // 123.4 -> 123°24.00' min = min % 60; // reste en minutes sec = sec % 60; // reste en secondes char sign = (x<0) ? '-' : ' '; - if (inf100) - r.sprintf("%c%02d%s%02d'%02d\"", sign,deg,cdeg, min,sec); - else - r.sprintf("%c%03d%s%02d'%02d\"", sign,deg,cdeg, min,sec); + if (inf100) + r = QString("%1%2%3%4'%5").arg(sign).arg(deg,2,10,QChar('0')).arg(cdeg).arg(min,2,10,QChar('0')).arg(sec,2,10,QChar('0')); + else + r = QString("%1%2%3%4'%5").arg(sign).arg(deg,3,10,QChar('0')).arg(cdeg).arg(min,2,10,QChar('0')).arg(sec,2,10,QChar('0')); } else // if (unit == tr("dd,dd°")) { - if (inf100) - r.sprintf("%05.2f%s",x,cdeg); - else - r.sprintf("%06.2f%s",x,cdeg); + if (inf100) + r = QString("%1%2%3").arg(x,5,'f',2,QChar('0')).arg(cdeg); + else + r = QString("%1%2%3").arg(x,6,'f',2,QChar('0')).arg(cdeg); } return r; } @@ -668,10 +674,10 @@ QString Util::formatPercentValue(float prb, bool withUnit) QString unite = "%"; QString r; float v = inRange (0.0f, prb, 100.0f); - if (v < 10) - r.sprintf("%.1f", v); - else - r.sprintf("%.0f", v); + if (v < 10) + r = QString::number(v, 'f', 1); + else + r = QString::number(v, 'f', 0); return withUnit ? r+" "+unite : r; } @@ -717,7 +723,7 @@ QString Util::formatDateLong (time_t t, bool localTime) if (localTime) dt = applyTimeZone(t); else - dt.setTime_t(t); + dt.setSecsSinceEpoch(t); return formatDayName(dt.date())+" "+formatDateShort(t); } //--------------------------------------------------------------------- @@ -749,8 +755,8 @@ QString Util::formatTime (time_t t) //--------------------------------------------------------------------- QDateTime Util::applyTimeZone (time_t t, QString *suffix) { - QDateTime dt; - dt.setTime_t(t); + QDateTime dt; + dt.setSecsSinceEpoch(t); //dt.setTimeSpec(Qt::UTC); dt = dt.toUTC();