Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ jobs:
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.9.0
with:
clang-format-version: '18'
clang-format-version: '22'
check-path: '.'
19 changes: 6 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,37 @@
name: Build

on: [push]


jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
version: ['5.15.2']
version: ['6.8.1']
steps:
- uses: actions/checkout@v1

- uses: actions/checkout@v4
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: ${{ matrix.version }}
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2019_64'
arch: 'win64_msvc2022_64'
# modules: 'qtwebengine'
tools: 'tools_opensslv3_x64,qt.tools.opensslv3.win_x64'

- name: Build
if: startsWith(matrix.os, 'windows')
run: |
call "%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
call "%programfiles%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH="C:\Qt\5.15.2\msvc2019_64" -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_BUILD_TYPE=RELEASE -DDEPLOY_QT_LIBRARIES=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ..
cmake -DCMAKE_PREFIX_PATH="C:\Qt\6.8.1\msvc2022_64" -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_BUILD_TYPE=RELEASE -DDEPLOY_QT_LIBRARIES=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ..
cmake --build . --config Release
ctest -C Release .
cp *.qm ./Release
for /R c:\Qt\Tools\OpenSSL %%f in (*.dll) do copy %%f "%CD%\Release"
shell: cmd


- name: Archive build results
uses: actions/upload-artifact@v4
with:
name: editor
path: ./build/Release/*
path: ./build/Release/*
18 changes: 8 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.16)

project(editor LANGUAGES CXX)

Expand All @@ -8,7 +8,7 @@ set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand All @@ -19,8 +19,7 @@ include(FeatureSummary)
enable_testing()

find_package(Git QUIET REQUIRED)
find_package(Qt5QuickTest REQUIRED)

find_package(Qt6 COMPONENTS QuickTest REQUIRED)

execute_process(COMMAND
"${GIT_EXECUTABLE}" describe --dirty --broken --always --tags
Expand All @@ -31,8 +30,7 @@ execute_process(COMMAND

add_definitions( -DGIT_VERSION="${GIT_VERSION}" )

find_package(Qt5 COMPONENTS Core Quick Xml LinguistTools REQUIRED)
find_package(Qt5QuickCompiler)
find_package(Qt6 COMPONENTS Core Quick Xml LinguistTools REQUIRED)

SET(RESOURCES editor.qrc)

Expand Down Expand Up @@ -72,12 +70,12 @@ set_target_properties(atest-editor PROPERTIES COMPILE_DEFINITIONS RUN_TESTS=1)



QT5_ADD_TRANSLATION(QM_FILES ${TS_FILES}
qt6_add_translation(QM_FILES ${TS_FILES}
OPTIONS "-idbased")
add_custom_target(translations DEPENDS ${QM_FILES})
add_dependencies(editor translations)

QT5_CREATE_TRANSLATION(QT_FILES "${CMAKE_SOURCE_DIR}"
qt6_create_translation(QT_FILES "${CMAKE_SOURCE_DIR}"
OPTIONS "-no-obsolete")

install(FILES ${QM_FILES}
Expand All @@ -95,12 +93,12 @@ install(TARGETS editor RUNTIME
target_compile_definitions(editor
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(editor
PRIVATE Qt5::Core Qt5::Quick Qt5::Xml)
PRIVATE Qt6::Core Qt6::Quick Qt6::Xml)

target_compile_definitions(atest-editor
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(atest-editor
PRIVATE Qt5::Core Qt5::Quick Qt5::Xml Qt5::QuickTest)
PRIVATE Qt6::Core Qt6::Quick Qt6::Xml Qt6::QuickTest)



Expand Down
24 changes: 4 additions & 20 deletions cmake/DeployQt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

find_package(Qt5Core REQUIRED)
find_package(Qt6Core REQUIRED)

# Retrieve the absolute path to qmake and then use that path to find
# the windeployqt and macdeployqt binaries
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)

find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
Expand All @@ -37,29 +35,16 @@ if(APPLE AND NOT MACDEPLOYQT_EXECUTABLE)
message(FATAL_ERROR "macdeployqt not found")
endif()

# Add commands that copy the required Qt files to the same directory as the
# target after being built as well as including them in final installation
function(windeployqt target)

# Run windeployqt immediately after build
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E
env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
--verbose 0
--qmldir \"${CMAKE_CURRENT_SOURCE_DIR}\"
--no-compiler-runtime
\"$<TARGET_FILE:${target}>\"
COMMENT "Deploying Qt..."
)

# windeployqt doesn't work correctly with the system runtime libraries,
# so we fall back to one of CMake's own modules for copying them over

# Doing this with MSVC 2015 requires CMake 3.6+
if((MSVC_VERSION VERSION_EQUAL 1900 OR MSVC_VERSION VERSION_GREATER 1900)
AND CMAKE_VERSION VERSION_LESS "3.6")
message(WARNING "Deploying with MSVC 2015+ requires CMake 3.6+")
endif()
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
Expand All @@ -70,10 +55,9 @@ function(windeployqt target)
COMMENT "Copying ${filename}..."
)
endforeach()

endfunction()

# Add commands that copy the required Qt files to the application bundle
# represented by the target.
function(macdeployqt target)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${MACDEPLOYQT_EXECUTABLE}"
Expand All @@ -84,4 +68,4 @@ function(macdeployqt target)
)
endfunction()

mark_as_advanced(WINDEPLOYQT_EXECUTABLE MACDEPLOYQT_EXECUTABLE)
mark_as_advanced(WINDEPLOYQT_EXECUTABLE MACDEPLOYQT_EXECUTABLE)
2 changes: 0 additions & 2 deletions editor.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
<file>src/qml/components/ShadowElement.qml</file>
<file>src/qml/components/WorldFileImage.qml</file>
<file>src/qml/components/Waypoint.qml</file>
<file>src/qml/components/NativeText.qml</file>
<file>src/qml/components/NativeTextInput.qml</file>
<file>src/qml/components/TextFieldNumber.qml</file>
<file>src/qml/components/Ruler.qml</file>
<file>src/qml/GFWDialog.qml</file>
Expand Down
4 changes: 2 additions & 2 deletions src/filereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <QUrl>

#include <QString>
#include <QTextCodec>
#include <QStringConverter>
#include <QTextStream>

FileReader::FileReader(QObject* parent)
Expand Down Expand Up @@ -80,7 +80,7 @@ void FileReader::writeUTF8(const QUrl& filename, QByteArray data)
}

QTextStream streamFileOut(&file);
streamFileOut.setCodec(QTextCodec::codecForName("UTF-8"));
streamFileOut.setEncoding(QStringConverter::Utf8);
streamFileOut << QString::fromUtf8(data);
streamFileOut.flush();

Expand Down
8 changes: 4 additions & 4 deletions src/gpxjsonconvertor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ QString GpxJsonConvertor::gpxToJSONString_local(QString filename)
points = points + str;
}

points.remove(points.count() - 1, 1);
points.remove(points.length() - 1, 1);

QDomNodeList trks = root.elementsByTagName("trk");

Expand Down Expand Up @@ -81,19 +81,19 @@ QString GpxJsonConvertor::gpxToJSONString_local(QString filename)

str = str + QString("{\"lat\": %1,\"lon\":%2},").arg(latitude).arg(longitude);
}
str.remove(str.count() - 1, 1);
str.remove(str.length() - 1, 1);
poly = poly + QString("{\"name\": \"%1\", \"color\":\"%2\", \"points\":[%3]},").arg(encodeString(name)).arg(color).arg(str);
}

poly.remove(poly.count() - 1, 1);
poly.remove(poly.length() - 1, 1);

return QString("{\"points\": [%1], \"poly\": [%2]}").arg(points).arg(poly);
}

QString GpxJsonConvertor::encodeString(const QString& value)
{
QString result = "";
for (int i = 0; i < value.count(); i++) {
for (int i = 0; i < value.length(); i++) {
ushort chr = value.at(i).unicode();
if (chr < 32) {
switch (chr) {
Expand Down
30 changes: 13 additions & 17 deletions src/igc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ QVariant IgcFile::data(const QModelIndex& index, int role) const

/// Open a file with given path and
/// load it.
bool IgcFile::load(const QString& path, QTextCodec* codec)
bool IgcFile::load(const QString& path)
{
QUrl url(path);

Expand All @@ -94,23 +94,19 @@ bool IgcFile::load(const QString& path, QTextCodec* codec)
return false;
}

return load(&f, codec);
return load(&f);
}

/// Load a file from opened QIODevice.
bool IgcFile::load(QIODevice* dev, QTextCodec* codec)
bool IgcFile::load(QIODevice* dev, QStringConverter::Encoding codec)
{

clear();

file = dev;
previousRecord = '\0';

if (codec) {
activeCodec = codec;
} else {
activeCodec = QTextCodec::codecForName("Latin1");
}
activeCodec = codec;

if (!loadOneRecord()) {
clear();
Expand Down Expand Up @@ -362,9 +358,9 @@ bool IgcFile::processRecordH()
return false;
}
} else if (subtype == "CCL") {
competitionClass_ = activeCodec->toUnicode(value);
competitionClass_ = QStringDecoder(activeCodec).decode(value);
} else if (subtype == "CID") {
competitionId_ = activeCodec->toUnicode(value);
competitionId_ = QStringDecoder(activeCodec).decode(value);
} else if (subtype == "DTE") {
bool ok;
date_ = parseDate(data, &ok);
Expand All @@ -379,19 +375,19 @@ bool IgcFile::processRecordH()
} else if (subtype == "FTY") {
QList<QByteArray> list = value.split(',');
if (list.size() == 1) {
frType_ = activeCodec->toUnicode(list[0]);
frType_ = QStringDecoder(activeCodec).decode(list[0]);
} else {
manufacturer_ = activeCodec->toUnicode(list[0]);
frType_ = activeCodec->toUnicode(list[1]);
manufacturer_ = QStringDecoder(activeCodec).decode(list[0]);
frType_ = QStringDecoder(activeCodec).decode(list[1]);
}
} else if (subtype == "GID") {
gliderId_ = activeCodec->toUnicode(value);
gliderId_ = QStringDecoder(activeCodec).decode(value);
} else if (subtype == "GPS") {
gps_ = activeCodec->toUnicode(value.split(',')[0]);
gps_ = QStringDecoder(activeCodec).decode(value.split(',')[0]);
} else if (subtype == "GTY") {
gliderType_ = activeCodec->toUnicode(value);
gliderType_ = QStringDecoder(activeCodec).decode(value);
} else if (subtype == "PLT") {
pilot_ = activeCodec->toUnicode(value);
pilot_ = QStringDecoder(activeCodec).decode(value);
}

return true;
Expand Down
7 changes: 4 additions & 3 deletions src/igc.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef IGC__H
#define IGC__H

#include <QStringConverter>
#include <QtCore>

/// A single event from the igc file.
Expand Down Expand Up @@ -125,8 +126,8 @@ class IgcFile : public QAbstractListModel {
IgcFile(QObject* object = 0);
~IgcFile() { clear(); }

Q_INVOKABLE bool load(const QString& path, QTextCodec* codec = 0);
bool load(QIODevice* file, QTextCodec* codec = 0);
Q_INVOKABLE bool load(const QString& path);
bool load(QIODevice* file, QStringConverter::Encoding codec = QStringConverter::Latin1);
Q_INVOKABLE void clear();

int getCount() { return rowCount(); }
Expand Down Expand Up @@ -234,7 +235,7 @@ class IgcFile : public QAbstractListModel {

char previousRecord;
QIODevice* file;
QTextCodec* activeCodec;
QStringConverter::Encoding activeCodec;

/// Data extracted from IGC headers.
/// \{
Expand Down
Loading
Loading