Skip to content

Commit

Permalink
Merge pull request #1 from oalbers/qt6
Browse files Browse the repository at this point in the history
qt6
  • Loading branch information
oalbers authored Sep 3, 2024
2 parents 88c425c + 39eca8b commit 62058c1
Show file tree
Hide file tree
Showing 33 changed files with 309 additions and 278 deletions.
36 changes: 18 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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")
Expand All @@ -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"
Expand Down
92 changes: 49 additions & 43 deletions src/BoardPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//=====================================================================
void BoardPanel::showPosition (double x, double y)
{

if (cellPosition->isVisible()) {
lbLon.setText (Util::formatLongitude(x));
lbLat.setText (Util::formatLatitude (y));
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -190,7 +194,8 @@ void BoardPanel::showDataPointInfo (
for (int i=0; i<GEOPOTsize; i++)
{
int P = GEOPOThgt(i); // 925 850 700 600 500 400 300 200
shpa.sprintf("%3d", P);
//shpa.asprintf("%3d", P);
shpa = QString("%1").arg(P, 3);
if (GribDataIsDef(pf.hGeopot[i])) {
sgeopot = QString("%1")
.arg(Util::formatGeopotAltitude (pf.hGeopot[i],true), 9);
Expand Down Expand Up @@ -224,7 +229,8 @@ void BoardPanel::showDataPointInfo (

if (i>0 && 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;
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand All @@ -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 )
Expand Down
3 changes: 1 addition & 2 deletions src/DialogLoadGRIB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ void DialogLoadGRIB::slotGribLoadError (const QString& error)

//----------------------------------------------------
void DialogLoadGRIB::slotGribStartLoadData()
{
timeLoad.start();
{ timeLoad.start();
}

//----------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/DialogLoadGRIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DialogLoadGRIB : public DialogBoxBase
QString savedFileName;

bool loadInProgress;
QTime timeLoad;
QElapsedTimer timeLoad;
QCursor oldcursor;

QDoubleSpinBox *sbNorth;
Expand Down
21 changes: 11 additions & 10 deletions src/DialogSelectMetar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>

#include "DialogSelectMetar.h"
#include "Util.h"
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -110,15 +111,15 @@ void DialogSelectMetar::make_metar_tree ()
{
MetarWidgetFactory factory;

QSet <QString> allExpanded =
QSet <QString>::fromList
(Util::getSetting("metar_country_expanded", QStringList()).toStringList() );
QSet <QString> allSelected =
QSet <QString>::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 <QString> allExpanded = QSet <QString>(metarCountryExpanded.begin(), metarCountryExpanded.end());
QSet <QString> allSelected = QSet <QString>(metarSelected.begin(), metarSelected.end());
//QSet <QStringList> allSelected = QSet<QStringList>(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);
Expand All @@ -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);
Expand All @@ -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<QString,QString>(curCountry,curState)];
if (name == "")
DBGQS ("State name not found : "+curState);
Expand Down
2 changes: 1 addition & 1 deletion src/DialogSelectMetar.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QHeaderView>
#include <QDesktopWidget>
//#include <QDesktopWidget> qt5

#include "DialogBoxBase.h"
#include "Metar.h"
Expand Down
2 changes: 1 addition & 1 deletion src/DialogServerStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DialogServerStatus : public DialogBoxBase
QNetworkReply *reply_step1;
bool downloadError;

QTime timeLoad;
QElapsedTimer timeLoad;
QLabel *lbResponseStatus;

std::vector<QLabel* > ar_lbRunDate;
Expand Down
4 changes: 2 additions & 2 deletions src/DialogUnits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 62058c1

Please sign in to comment.