From 89ccee343eb1046f9c0d18963087350ae7a3cf13 Mon Sep 17 00:00:00 2001 From: "S. Kozyr" Date: Tue, 6 Jun 2023 11:30:34 +0300 Subject: [PATCH 01/10] [iOS] Show all supported coordinates at PlacePage Signed-off-by: S. Kozyr --- .../PlacePageData/Common/PlacePageInfoData.h | 3 +- .../PlacePageData/Common/PlacePageInfoData.mm | 8 +++- .../Common/PlacePagePreviewData.mm | 2 +- .../PlacePageInfoViewController.swift | 38 +++++++++---------- map/place_page_info.cpp | 38 +++++++++++++++++-- map/place_page_info.hpp | 14 ++++++- 6 files changed, 74 insertions(+), 29 deletions(-) diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h index a5da3f0f29..bac5c47163 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h @@ -23,8 +23,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly, nullable) NSString *cuisine; @property(nonatomic, readonly, nullable) NSString *ppOperator; @property(nonatomic, readonly, nullable) NSString *address; -@property(nonatomic, readonly, nullable) NSString *rawCoordinates; -@property(nonatomic, readonly, nullable) NSString *formattedCoordinates; +@property(nonatomic, readonly, nullable) NSArray *coordFormats; @property(nonatomic, readonly, nullable) NSString *wifiAvailable; @property(nonatomic, readonly, nullable) NSString *level; diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm index 22690d7f60..2d4d6adcf0 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm @@ -71,8 +71,12 @@ using namespace osm; }); _address = rawData.GetAddress().empty() ? nil : @(rawData.GetAddress().c_str()); - _rawCoordinates = @(rawData.GetFormattedCoordinate(true).c_str()); - _formattedCoordinates = @(rawData.GetFormattedCoordinate(false).c_str()); + _coordFormats = @[@(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::LatLonDMS).c_str()), + @(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::LatLonDecimal).c_str()), + @(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::OLCFull).c_str()), + @(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::OSMLink).c_str()), + @(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::UTM).c_str()), + @(rawData.GetFormattedCoordinate(place_page::CoordinatesFormat::MGRS).c_str())]; } return self; } diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm index bce287318d..6e12561cb0 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePagePreviewData.mm @@ -91,7 +91,7 @@ static PlacePageDataHotelType convertHotelType(std::optional 0; diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift index 0120536276..36f3153d16 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift @@ -64,7 +64,7 @@ protocol PlacePageInfoViewControllerDelegate: AnyObject { class PlacePageInfoViewController: UIViewController { private struct Const { - static let coordinatesKey = "PlacePageInfoViewController_coordinatesKey" + static let coordFormatIdKey = "PlacePageInfoViewController_coordFormatIdKey" } private typealias TapHandler = InfoItemViewController.TapHandler private typealias Style = InfoItemViewController.Style @@ -95,15 +95,15 @@ class PlacePageInfoViewController: UIViewController { var placePageInfoData: PlacePageInfoData! weak var delegate: PlacePageInfoViewControllerDelegate? - var showFormattedCoordinates: Bool { + var coordinatesFormatId: Int { get { - UserDefaults.standard.bool(forKey: Const.coordinatesKey) + UserDefaults.standard.integer(forKey: Const.coordFormatIdKey) } set { - UserDefaults.standard.set(newValue, forKey: Const.coordinatesKey) + UserDefaults.standard.set(newValue, forKey: Const.coordFormatIdKey) } } - + override func viewDidLoad() { super.viewDidLoad() @@ -202,24 +202,24 @@ class PlacePageInfoViewController: UIViewController { addressView?.canShowMenu = true } - if let formattedCoordinates = placePageInfoData.formattedCoordinates, - let rawCoordinates = placePageInfoData.rawCoordinates { - let coordinates = showFormattedCoordinates ? formattedCoordinates : rawCoordinates - coordinatesView = createInfoItem(coordinates, icon: UIImage(named: "ic_placepage_coordinate")) { + var formatId = self.coordinatesFormatId + if let coordFormats = self.placePageInfoData.coordFormats as? Array { + if formatId >= coordFormats.count { + formatId = 0 + } + + coordinatesView = createInfoItem(coordFormats[formatId], icon: UIImage(named: "ic_placepage_coordinate")) { [unowned self] in - self.showFormattedCoordinates = !self.showFormattedCoordinates - let coordinates = self.showFormattedCoordinates ? formattedCoordinates : rawCoordinates + let formatId = (self.coordinatesFormatId + 1) % coordFormats.count + self.coordinatesFormatId = formatId + let coordinates:String = coordFormats[formatId] self.coordinatesView?.infoLabel.text = coordinates } - } else if let formattedCoordinates = placePageInfoData.formattedCoordinates { - coordinatesView = createInfoItem(formattedCoordinates, icon: UIImage(named: "ic_placepage_coordinate")) - } else if let rawCoordinates = placePageInfoData.rawCoordinates { - coordinatesView = createInfoItem(rawCoordinates, icon: UIImage(named: "ic_placepage_coordinate")) - } - coordinatesView?.accessoryImage.image = UIImage(named: "ic_placepage_change") - coordinatesView?.accessoryImage.isHidden = false - coordinatesView?.canShowMenu = true + coordinatesView?.accessoryImage.image = UIImage(named: "ic_placepage_change") + coordinatesView?.accessoryImage.isHidden = false + coordinatesView?.canShowMenu = true + } } // MARK: private diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index 4491bb550a..d185e914ce 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -11,12 +11,14 @@ #include "indexer/feature_utils.hpp" #include "indexer/road_shields_parser.hpp" +#include "platform/localization.hpp" #include "platform/measurement_utils.hpp" #include "platform/preferred_languages.hpp" -#include "platform/localization.hpp" #include "base/assert.hpp" +#include "3party/open-location-code/openlocationcode.h" + #include namespace place_page @@ -284,11 +286,39 @@ std::string Info::FormatStars() const return stars; } -std::string Info::GetFormattedCoordinate(bool isDMS) const +std::string Info::GetFormattedCoordinate(CoordinatesFormat coordsFormat) const { auto const & ll = GetLatLon(); - return isDMS ? measurement_utils::FormatLatLon(ll.m_lat, ll.m_lon, true) - : measurement_utils::FormatLatLonAsDMS(ll.m_lat, ll.m_lon, false, 2); + auto const lat = ll.m_lat; + auto const lon = ll.m_lon; + switch (coordsFormat) + { + default: + case CoordinatesFormat::LatLonDMS: // DMS, comma separated + return measurement_utils::FormatLatLonAsDMS(lat, lon, false /*withComma*/, 2); + case CoordinatesFormat::LatLonDecimal: // Decimal, comma separated + return measurement_utils::FormatLatLon(lat, lon, true /* withComma */); + case CoordinatesFormat::OLCFull: // Open location code, long format + return openlocationcode::Encode({lat, lon}); + case CoordinatesFormat::OSMLink: // Link to osm.org + return measurement_utils::FormatOsmLink(lat, lon, 14); + case CoordinatesFormat::UTM: // Universal Transverse Mercator + { + std::string utmCoords = utm_mgrs_utils::FormatUTM(lat, lon); + if (utmCoords.empty()) + return "UTM: N/A"; + else + return "UTM: " + utmCoords; + } + case CoordinatesFormat::MGRS: // Military Grid Reference System + { + std::string mgrsCoords = utm_mgrs_utils::FormatMGRS(lat, lon, 5); + if (mgrsCoords.empty()) + return "MGRS: N/A"; + else + return "MGRS: " + mgrsCoords; + } + } } void Info::SetRoadType(RoadWarningMarkType type, std::string const & localizedType, std::string const & distance) diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp index 576ea588fe..232cad2061 100644 --- a/map/place_page_info.hpp +++ b/map/place_page_info.hpp @@ -16,6 +16,8 @@ #include "geometry/point2d.hpp" +#include "platform/utm_mgrs_utils.hpp" + #include #include #include @@ -32,6 +34,16 @@ enum class OpeningMode Full }; +enum class CoordinatesFormat +{ + LatLonDMS = 0, // DMS, comma separated + LatLonDecimal, // Decimal, comma separated + OLCFull, // Open location code, long format + OSMLink, // Link to osm.org + UTM, // Universal Transverse Mercator + MGRS // Military Grid Reference System +}; + struct BuildInfo { enum class Source : uint8_t @@ -129,7 +141,7 @@ public: std::string const & GetAddress() const { return m_uiAddress; } std::string const & GetDescription() const { return m_description; } /// @returns coordinate in DMS format if isDMS is true - std::string GetFormattedCoordinate(bool isDMS) const; + std::string GetFormattedCoordinate(CoordinatesFormat format) const; /// UI setters void SetCustomName(std::string const & name); -- 2.45.3 From 7c0b0c5af4498e3a82abb45c3bbd59e9e16453a6 Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Thu, 8 Jun 2023 19:41:00 -0300 Subject: [PATCH 02/10] [qt] Migrated on Qt6. Signed-off-by: Viktor Govako --- .github/workflows/linux-check.yaml | 12 ++++++++---- .github/workflows/macos-check.yaml | 2 +- CMakeLists.txt | 14 +++----------- cmake/OmimHelpers.cmake | 2 +- docs/INSTALL.md | 13 ++++++++----- drape/drape_tests/CMakeLists.txt | 2 -- .../openlr_assessment_tool/traffic_mode.cpp | 4 ++-- platform/CMakeLists.txt | 4 ++-- qt/CMakeLists.txt | 2 +- qt/build_style/build_common.cpp | 17 ++++++++++------- qt/build_style/build_common.h | 1 - qt/draw_widget.cpp | 1 - qt/mainwindow.cpp | 3 +-- qt/popup_menu_holder.hpp | 2 +- qt/qt_common/CMakeLists.txt | 8 +++++--- qt/qt_common/map_widget.cpp | 17 +++++++++++------ qt/qt_common/map_widget.hpp | 3 ++- qt/qt_common/qtoglcontext.hpp | 3 ++- qt/qt_common/qtoglcontextfactory.hpp | 1 - qt/screenshoter.hpp | 2 +- qt/search_panel.cpp | 6 +++--- qt_tstfrm/CMakeLists.txt | 4 ++-- .../assessment_tool/feature_info_dialog.cpp | 2 +- .../assessment_tool/main_view.cpp | 1 - .../assessment_tool/samples_view.cpp | 2 +- skin_generator/CMakeLists.txt | 6 +++--- skin_generator/generator.cpp | 4 ++-- skin_generator/generator.hpp | 2 -- skin_generator/main.cpp | 3 --- 29 files changed, 71 insertions(+), 72 deletions(-) diff --git a/.github/workflows/linux-check.yaml b/.github/workflows/linux-check.yaml index bc47cd7b39..18cc9584ec 100644 --- a/.github/workflows/linux-check.yaml +++ b/.github/workflows/linux-check.yaml @@ -54,8 +54,10 @@ jobs: sudo apt update -y sudo apt install -y \ ninja-build \ - qtbase5-dev \ - libqt5svg5-dev + libgl1-mesa-dev \ + libglvnd-dev \ + qt6-base-dev \ + libqt6svg6-dev - name: Configure shell: bash @@ -105,8 +107,10 @@ jobs: g++-12 \ gcc-12 \ ninja-build \ - qtbase5-dev \ - libqt5svg5-dev + libgl1-mesa-dev \ + libglvnd-dev \ + qt6-base-dev \ + libqt6svg6-dev - name: Configure shell: bash diff --git a/.github/workflows/macos-check.yaml b/.github/workflows/macos-check.yaml index cdc158389b..9fb137b210 100644 --- a/.github/workflows/macos-check.yaml +++ b/.github/workflows/macos-check.yaml @@ -49,7 +49,7 @@ jobs: - name: Install build tools and dependencies shell: bash run: | - brew install ninja qt@5 + brew install ninja qt@6 - name: Configure shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 34978954ce..67608fc50c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,18 +238,10 @@ if (NOT PLATFORM_IPHONE AND NOT PLATFORM_ANDROID) list(APPEND qt_components Widgets) endif() if (NOT SKIP_DESKTOP) - list(APPEND qt_components Gui Xml Svg) - endif() - if (DEFINED ENV{HOMEBREW_PREFIX}) - set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) - else() - set(HOMEBREW_PREFIX /opt/homebrew) - endif() - # PATHS are hard-coded hints where to look for qt5 in addition to other places. - find_package(Qt5 COMPONENTS REQUIRED ${qt_components} PATHS $ENV{QT_PATH} ${HOMEBREW_PREFIX}/opt/qt@5 /usr/local/opt/qt@5 /usr/lib/x86_64-linux-gnu/qt5) - if (Qt5_VERSION VERSION_LESS 5.5.0) - message(FATAL_ERROR "Minimum supported Qt5 version is 5.5") + list(APPEND qt_components Gui Xml Svg OpenGL OpenGLWidgets) endif() + # PATHS are hard-coded hints where to look for qt6 in addition to other places. + find_package(Qt6 COMPONENTS REQUIRED ${qt_components} PATHS $ENV{QT_PATH} /opt/homebrew/opt/qt@6 /usr/local/opt/qt@6 /usr/lib/x86_64-linux-gnu/qt6) endif() find_library(LIBZ NAMES z) diff --git a/cmake/OmimHelpers.cmake b/cmake/OmimHelpers.cmake index 91af2e6f6b..bc2f535c69 100644 --- a/cmake/OmimHelpers.cmake +++ b/cmake/OmimHelpers.cmake @@ -114,7 +114,7 @@ endfunction() function(omim_add_test_with_qt_event_loop executable) omim_add_test_impl(NO ${executable} ${ARGN}) target_compile_definitions(${executable} PRIVATE OMIM_UNIT_TEST_WITH_QT_EVENT_LOOP) - target_link_libraries(${executable} Qt5::Widgets) + target_link_libraries(${executable} Qt6::Widgets) endfunction() function(omim_add_test_no_platform_init executable) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index a2c5612cc4..951bdeff70 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -97,12 +97,13 @@ sudo apt update && sudo apt install -y \ clang \ ninja-build \ python3 \ - qtbase5-dev \ + qt6-base-dev \ libc++-dev \ libfreetype-dev \ - libglu1-mesa-dev \ + libglvnd-dev \ + libgl1-mesa-dev \ libicu-dev \ - libqt5svg5-dev \ + libqt6svg6-dev \ libsqlite3-dev \ zlib1g-dev ``` @@ -129,8 +130,10 @@ sudo dnf install -y \ freetype-devel \ libicu-devel \ libstdc++-devel \ - qt5-qtbase-devel \ - qt5-qtsvg-devel \ + libgl1-mesa-devel \ + libglvnd-devel \ + qt6-qtbase-devel \ + qt6-qtsvg-devel \ sqlite-devel ``` diff --git a/drape/drape_tests/CMakeLists.txt b/drape/drape_tests/CMakeLists.txt index d93f200b32..377426e8cd 100644 --- a/drape/drape_tests/CMakeLists.txt +++ b/drape/drape_tests/CMakeLists.txt @@ -40,6 +40,4 @@ target_link_libraries(${PROJECT_NAME} indexer # For StyleReader in static_texture_tests drape gmock - gtest - Qt5::Core ) diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp index 9020535baa..0cec12a32a 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp @@ -273,8 +273,8 @@ QVariant TrafficMode::headerData(int section, Qt::Orientation orientation, void TrafficMode::OnItemSelected(QItemSelection const & selected, QItemSelection const &) { - CHECK(!selected.empty(), ("The selection should not be empty. RTFM for qt5.")); - CHECK(!m_segments.empty(), ("No segments are loaded, can't select.")); + ASSERT(!selected.empty(), ()); + ASSERT(!m_segments.empty(), ()); auto const row = selected.front().top(); diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt index 20284baec6..06cc41ecb3 100644 --- a/platform/CMakeLists.txt +++ b/platform/CMakeLists.txt @@ -170,8 +170,8 @@ endif() target_link_libraries(${PROJECT_NAME} geometry # mercator::YToLat coding - $<$:Qt5::Core> - $<$:Qt5::Network> + $<$:Qt6::Core> + $<$:Qt6::Network> $<$:-framework\ Foundation -framework\ SystemConfiguration -framework\ CoreLocation -framework\ CFNetwork> ) diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 194371f976..d9a44d1f6c 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -1,6 +1,6 @@ project(desktop) -QT5_ADD_RESOURCES(RES_SOURCES res/resources.qrc) +QT6_ADD_RESOURCES(RES_SOURCES res/resources.qrc) set(SRC about.cpp diff --git a/qt/build_style/build_common.cpp b/qt/build_style/build_common.cpp index 4dd5db1a72..8ef0ad88a5 100644 --- a/qt/build_style/build_common.cpp +++ b/qt/build_style/build_common.cpp @@ -2,15 +2,17 @@ #include "platform/platform.hpp" +#include "base/file_name_utils.hpp" + #include #include #include #include #include -#include #include #include // std::quoted +#include #include QString ExecProcess(QString const & program, std::initializer_list args, QProcessEnvironment const * env) @@ -23,7 +25,7 @@ QString ExecProcess(QString const & program, std::initializer_list args QProcess p; if (nullptr != env) p.setProcessEnvironment(*env); - + p.start(program, qargs, QIODevice::ReadOnly); p.waitForFinished(-1); @@ -111,11 +113,12 @@ QString GetExternalPath(QString const & name, QString const & primaryPath, // Special case for looking for in application folder. if (!QFileInfo::exists(path) && secondaryPath.isEmpty()) { - QString const appPath = QCoreApplication::applicationDirPath(); - QRegExp rx("(/[^/]*\\.app)", Qt::CaseInsensitive); - int i = rx.indexIn(appPath); - if (i >= 0) - path = JoinPathQt({appPath.left(i), name}); + std::string const appPath = QCoreApplication::applicationDirPath().toStdString(); + + std::regex re("(/[^/]*\\.app)"); + std::smatch m; + if (std::regex_search(appPath, m, re) && m.size() > 0) + path.fromStdString(base::JoinPath(m[0], name.toStdString())); } return path; } diff --git a/qt/build_style/build_common.h b/qt/build_style/build_common.h index 474d3c3df2..a73beef8e3 100644 --- a/qt/build_style/build_common.h +++ b/qt/build_style/build_common.h @@ -6,7 +6,6 @@ #include #include -class QStringList; class QProcessEnvironment; // Returns stdout output of the program, throws std::runtime_error in case of non-zero exit code. diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index d3d245368d..42c16e44ea 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index f93ffbcdd2..e651a857ea 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -35,7 +35,6 @@ #endif // BUILD_DESIGNER #include -#include #include #include #include @@ -208,7 +207,7 @@ MainWindow::MainWindow(Framework & framework, #endif // NO_DOWNLOADER m_pDrawWidget->UpdateAfterSettingsChanged(); - + RoutingSettings::LoadSession(m_pDrawWidget->GetFramework()); } diff --git a/qt/popup_menu_holder.hpp b/qt/popup_menu_holder.hpp index f9155f1429..7ef29b7e5d 100644 --- a/qt/popup_menu_holder.hpp +++ b/qt/popup_menu_holder.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/qt/qt_common/CMakeLists.txt b/qt/qt_common/CMakeLists.txt index 5af5189912..ba4d9f199a 100644 --- a/qt/qt_common/CMakeLists.txt +++ b/qt/qt_common/CMakeLists.txt @@ -1,6 +1,6 @@ project(qt_common) -QT5_ADD_RESOURCES(RESOURCES res/resources_common.qrc) +QT6_ADD_RESOURCES(RESOURCES res/resources_common.qrc) set_property(SOURCE qrc_resources_common.cpp PROPERTY SKIP_AUTOGEN ON) @@ -33,6 +33,8 @@ target_compile_options(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} map - Qt5::Gui - Qt5::Widgets + Qt6::Gui + Qt6::Widgets + Qt6::OpenGL + Qt6::OpenGLWidgets ) diff --git a/qt/qt_common/map_widget.cpp b/qt/qt_common/map_widget.cpp index bebba3c812..bbe4b97136 100644 --- a/qt/qt_common/map_widget.cpp +++ b/qt/qt_common/map_widget.cpp @@ -15,15 +15,15 @@ #include #include +#include +#include +#include + #include #include -#include -#include +#include #include -#include -#include - namespace qt { namespace common @@ -506,7 +506,12 @@ void MapWidget::wheelEvent(QWheelEvent * e) return; QOpenGLWidget::wheelEvent(e); - m_framework.Scale(exp(e->delta() / 360.0), m2::PointD(L2D(e->x()), L2D(e->y())), false); + + QPointF const pos = e->position(); + + // https://doc-snapshots.qt.io/qt6-dev/qwheelevent.html#angleDelta, angleDelta() returns in eighths of a degree. + /// @todo Here you can tune the speed of zooming. + m_framework.Scale(exp(e->angleDelta().y() / 3.0 / 360.0), m2::PointD(L2D(pos.x()), L2D(pos.y())), false); } search::ReverseGeocoder::Address GetFeatureAddressInfo(Framework const & framework, diff --git a/qt/qt_common/map_widget.hpp b/qt/qt_common/map_widget.hpp index 537c71dfbd..c2ffd32c33 100644 --- a/qt/qt_common/map_widget.hpp +++ b/qt/qt_common/map_widget.hpp @@ -10,8 +10,9 @@ #include "indexer/feature.hpp" +#include + #include -#include #include diff --git a/qt/qt_common/qtoglcontext.hpp b/qt/qt_common/qtoglcontext.hpp index c0deeb9ac5..4186dc252b 100644 --- a/qt/qt_common/qtoglcontext.hpp +++ b/qt/qt_common/qtoglcontext.hpp @@ -2,8 +2,9 @@ #include "drape/oglcontext.hpp" +#include + #include -#include #include #include diff --git a/qt/qt_common/qtoglcontextfactory.hpp b/qt/qt_common/qtoglcontextfactory.hpp index 7c82095689..d672f09561 100644 --- a/qt/qt_common/qtoglcontextfactory.hpp +++ b/qt/qt_common/qtoglcontextfactory.hpp @@ -4,7 +4,6 @@ #include "qt/qt_common/qtoglcontext.hpp" #include -#include #include diff --git a/qt/screenshoter.hpp b/qt/screenshoter.hpp index 4a9201ac76..d61a23058c 100644 --- a/qt/screenshoter.hpp +++ b/qt/screenshoter.hpp @@ -6,7 +6,7 @@ #include "geometry/rect2d.hpp" -#include +#include #include #include diff --git a/qt/search_panel.cpp b/qt/search_panel.cpp index 0bbb898003..0675766b29 100644 --- a/qt/search_panel.cpp +++ b/qt/search_panel.cpp @@ -141,14 +141,14 @@ void SearchPanel::OnEverywhereSearchResults(uint64_t timestamp, search::Results for (size_t r = 0; r < res.GetHighlightRangesCount(); ++r) { std::pair const & range = res.GetHighlightRange(r); - strHigh.append(name.midRef(pos, range.first - pos)); + strHigh.append(name.mid(pos, range.first - pos)); strHigh.append(""); - strHigh.append(name.midRef(range.first, range.second)); + strHigh.append(name.mid(range.first, range.second)); strHigh.append(""); pos = range.first + range.second; } - strHigh.append(name.midRef(pos)); + strHigh.append(name.mid(pos)); int const rowCount = m_pTable->rowCount(); m_pTable->insertRow(rowCount); diff --git a/qt_tstfrm/CMakeLists.txt b/qt_tstfrm/CMakeLists.txt index 8a773abe65..3992c6c4d4 100644 --- a/qt_tstfrm/CMakeLists.txt +++ b/qt_tstfrm/CMakeLists.txt @@ -14,6 +14,6 @@ target_compile_options(${PROJECT_NAME} ) target_link_libraries(${PROJECT_NAME} - Qt5::Core - Qt5::Widgets + Qt6::Core + Qt6::Widgets ) diff --git a/search/search_quality/assessment_tool/feature_info_dialog.cpp b/search/search_quality/assessment_tool/feature_info_dialog.cpp index b7f5f501cd..579580fddf 100644 --- a/search/search_quality/assessment_tool/feature_info_dialog.cpp +++ b/search/search_quality/assessment_tool/feature_info_dialog.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include diff --git a/search/search_quality/assessment_tool/main_view.cpp b/search/search_quality/assessment_tool/main_view.cpp index 6f399246c4..e7de4c0d52 100644 --- a/search/search_quality/assessment_tool/main_view.cpp +++ b/search/search_quality/assessment_tool/main_view.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/search/search_quality/assessment_tool/samples_view.cpp b/search/search_quality/assessment_tool/samples_view.cpp index 8f4f3865d1..9194475794 100644 --- a/search/search_quality/assessment_tool/samples_view.cpp +++ b/search/search_quality/assessment_tool/samples_view.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/skin_generator/CMakeLists.txt b/skin_generator/CMakeLists.txt index 2b04dde9e2..adab22765d 100644 --- a/skin_generator/CMakeLists.txt +++ b/skin_generator/CMakeLists.txt @@ -11,7 +11,7 @@ omim_add_executable(${PROJECT_NAME} ${SRC}) target_link_libraries(${PROJECT_NAME} geometry gflags::gflags - Qt5::Xml - Qt5::Svg - Qt5::Widgets + Qt6::Xml + Qt6::Svg + Qt6::Widgets ) diff --git a/skin_generator/generator.cpp b/skin_generator/generator.cpp index dd65107aeb..b1bb25278c 100644 --- a/skin_generator/generator.cpp +++ b/skin_generator/generator.cpp @@ -241,8 +241,8 @@ bool SkinGenerator::WriteToFileNewStyle(std::string const &skinName) if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate)) return false; QTextStream ts(&file); - ts.setCodec("UTF-8"); + ts.setEncoding(QStringConverter::Utf8); ts << doc.toString(); return true; } -} +} // namespace tools diff --git a/skin_generator/generator.hpp b/skin_generator/generator.hpp index c8c328c79c..8bcd370f93 100644 --- a/skin_generator/generator.hpp +++ b/skin_generator/generator.hpp @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include #include diff --git a/skin_generator/main.cpp b/skin_generator/main.cpp index 4e0b7d6361..89f0c1e2dc 100644 --- a/skin_generator/main.cpp +++ b/skin_generator/main.cpp @@ -8,9 +8,6 @@ #include #include -#include -#include - #include DEFINE_string(fontFileName, "../../data/01_dejavusans.ttf", "path to TrueType font file"); -- 2.45.3 From ab06075bfbb665efa9e2d22b247d5ed25b962ff2 Mon Sep 17 00:00:00 2001 From: endim8 Date: Fri, 9 Jun 2023 04:20:38 +0100 Subject: [PATCH 03/10] Update INSTALL.md, some missing qt6 strings Signed-off-by: Harry Bond --- docs/INSTALL.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 951bdeff70..6f99e547ee 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -85,7 +85,7 @@ You need a Linux or a Mac machine to build a desktop version of Organic Maps. [W Ensure that you have at least 20GB of free space. -Install Cmake (**3.22.1** minimum), Boost, Qt 5 and other dependencies. +Install Cmake (**3.22.1** minimum), Boost, Qt 6 and other dependencies. Installing *ccache* can speed up active development. @@ -140,7 +140,7 @@ sudo dnf install -y \ _macOS:_ ```bash -brew install cmake ninja qt@5 +brew install cmake ninja qt@6 ``` ### Windows @@ -148,7 +148,7 @@ brew install cmake ninja qt@5 We haven't compiled Organic Maps on Windows *natively* in a long time, though it is possible. Some files should be updated. There is a work in progress on [windows](https://github.com/organicmaps/organicmaps/tree/windows) branch. Please contribute if you have time. -You'll need to have python3, cmake, ninja, and QT5 in the PATH, and Visual Studio 2022 or Visual Studio 2022 Build Tools installed. Use [Visual Studio Developer Command Prompt](https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022) or generate Visual Studio project files with CMake to build the project. +You'll need to have python3, cmake, ninja, and QT6 in the PATH, and Visual Studio 2022 or Visual Studio 2022 Build Tools installed. Use [Visual Studio Developer Command Prompt](https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022) or generate Visual Studio project files with CMake to build the project. However, it is possible to use the WSL (Windows Subsystem for Linux) to run GUI applications. -- 2.45.3 From cece7b15d9a847680bbb4457ecfd406f922c9fbf Mon Sep 17 00:00:00 2001 From: cyber-toad Date: Sat, 10 Jun 2023 22:32:48 +0200 Subject: [PATCH 04/10] [gpx] Use string_view for bookmark file extensions Signed-off-by: cyber-toad --- android/jni/app/organicmaps/Framework.cpp | 2 +- map/bookmark_helpers.cpp | 24 +++++++++++++++-------- map/bookmark_helpers.hpp | 10 +++++----- map/bookmark_manager.cpp | 6 +++--- map/bookmark_manager.hpp | 2 +- map/map_tests/bookmarks_test.cpp | 2 +- platform/platform.cpp | 6 +++--- platform/platform.hpp | 2 +- 8 files changed, 31 insertions(+), 23 deletions(-) diff --git a/android/jni/app/organicmaps/Framework.cpp b/android/jni/app/organicmaps/Framework.cpp index ac5ad0a6af..5940a3075d 100644 --- a/android/jni/app/organicmaps/Framework.cpp +++ b/android/jni/app/organicmaps/Framework.cpp @@ -1106,7 +1106,7 @@ Java_app_organicmaps_Framework_nativeGetMovableFilesExts(JNIEnv * env, jclass) JNIEXPORT jobjectArray JNICALL Java_app_organicmaps_Framework_nativeGetBookmarksFilesExts(JNIEnv * env, jclass) { - const vector exts = { kKmzExtension, kKmlExtension, kKmbExtension, kGpxExtension }; + std::array exts = { kKmzExtension, kKmlExtension, kKmbExtension, kGpxExtension }; return jni::ToJavaStringArray(env, exts); } diff --git a/map/bookmark_helpers.cpp b/map/bookmark_helpers.cpp index 15c9512a71..c56335db6d 100644 --- a/map/bookmark_helpers.cpp +++ b/map/bookmark_helpers.cpp @@ -245,17 +245,25 @@ std::string RemoveInvalidSymbols(std::string const & name) return strings::ToUtf8(filtered); } -std::string GenerateUniqueFileName(const std::string & path, std::string name, std::string const & ext) + +std::string GenerateUniqueFileName(std::string const & path, std::string name, std::string_view const ext) { // Remove extension, if file name already contains it. if (strings::EndsWith(name, ext)) name.resize(name.size() - ext.size()); size_t counter = 1; - std::string suffix; - while (Platform::IsFileExistsByFullPath(base::JoinPath(path, name + suffix + ext))) + std::string suffix, res; + do + { + res = name; + res = base::JoinPath(path, res.append(suffix).append(ext)); + if (!Platform::IsFileExistsByFullPath(res)) + break; suffix = strings::to_string(counter++); - return base::JoinPath(path, name + suffix + ext); + } while (true); + + return res; } std::string GenerateValidAndUniqueFilePathForKML(std::string const & fileName) @@ -267,10 +275,10 @@ std::string GenerateValidAndUniqueFilePathForKML(std::string const & fileName) return GenerateUniqueFileName(GetBookmarksDirectory(), std::move(filePath)); } -std::string const kKmzExtension = ".kmz"; -std::string const kKmlExtension = ".kml"; -std::string const kKmbExtension = ".kmb"; -std::string const kGpxExtension = ".gpx"; +std::string_view const kKmzExtension = ".kmz"; +std::string_view const kKmlExtension = ".kml"; +std::string_view const kKmbExtension = ".kmb"; +std::string_view const kGpxExtension = ".gpx"; std::string const kDefaultBookmarksFileName = "Bookmarks"; // Populate empty category & track names based on file name: assign file name to category name, diff --git a/map/bookmark_helpers.hpp b/map/bookmark_helpers.hpp index e539988b95..91d2a16c79 100644 --- a/map/bookmark_helpers.hpp +++ b/map/bookmark_helpers.hpp @@ -65,10 +65,10 @@ enum class BookmarkBaseType : uint16_t Count }; -extern std::string const kKmzExtension; -extern std::string const kKmlExtension; -extern std::string const kKmbExtension; -extern std::string const kGpxExtension; +extern std::string_view const kKmzExtension; +extern std::string_view const kKmlExtension; +extern std::string_view const kKmbExtension; +extern std::string_view const kGpxExtension; extern std::string const kDefaultBookmarksFileName; enum class KmlFileType @@ -93,7 +93,7 @@ inline std::string DebugPrint(KmlFileType fileType) /// @{ std::string GetBookmarksDirectory(); std::string RemoveInvalidSymbols(std::string const & name); -std::string GenerateUniqueFileName(const std::string & path, std::string name, std::string const & ext = kKmlExtension); +std::string GenerateUniqueFileName(const std::string & path, std::string name, std::string_view ext = kKmlExtension); std::string GenerateValidAndUniqueFilePathForKML(std::string const & fileName); /// @} diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 34ecb9cb0c..687403bd1b 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -81,7 +81,7 @@ BookmarkManager::SharingResult GetFileForSharing(BookmarkManager::KMLDataCollect if (fileName.empty()) fileName = base::GetNameFromFullPathWithoutExt(kmlToShare.first); - auto const filePath = base::JoinPath(GetPlatform().TmpDir(), fileName + kKmlExtension); + auto const filePath = base::JoinPath(GetPlatform().TmpDir(), fileName.append(kKmlExtension)); SCOPE_GUARD(fileGuard, std::bind(&base::DeleteFileX, filePath)); auto const categoryId = kmlToShare.second->m_categoryData.m_id; @@ -92,7 +92,7 @@ BookmarkManager::SharingResult GetFileForSharing(BookmarkManager::KMLDataCollect "Bookmarks file does not exist."); } - auto const tmpFilePath = base::JoinPath(GetPlatform().TmpDir(), fileName + kKmzExtension); + auto const tmpFilePath = base::JoinPath(GetPlatform().TmpDir(), fileName.append(kKmzExtension)); if (!CreateZipFromPathDeflatedAndDefaultCompression(filePath, tmpFilePath)) { return BookmarkManager::SharingResult(categoryId, BookmarkManager::SharingResult::Code::ArchiveError, @@ -1798,7 +1798,7 @@ void BookmarkManager::ClearCategories() } BookmarkManager::KMLDataCollectionPtr BookmarkManager::LoadBookmarks( - std::string const & dir, std::string const & ext, KmlFileType fileType, + std::string const & dir, std::string_view const ext, KmlFileType fileType, BookmarksChecker const & checker) { Platform::FilesList files; diff --git a/map/bookmark_manager.hpp b/map/bookmark_manager.hpp index 0e2d4f497e..c18767ea46 100644 --- a/map/bookmark_manager.hpp +++ b/map/bookmark_manager.hpp @@ -603,7 +603,7 @@ private: void LoadBookmarkRoutine(std::string const & filePath, bool isTemporaryFile); using BookmarksChecker = std::function; - KMLDataCollectionPtr LoadBookmarks(std::string const & dir, std::string const & ext, + KMLDataCollectionPtr LoadBookmarks(std::string const & dir, std::string_view const ext, KmlFileType fileType, BookmarksChecker const & checker); void GetDirtyGroups(kml::GroupIdSet & dirtyGroups) const; diff --git a/map/map_tests/bookmarks_test.cpp b/map/map_tests/bookmarks_test.cpp index 1c687b7a8c..2d4613b948 100644 --- a/map/map_tests/bookmarks_test.cpp +++ b/map/map_tests/bookmarks_test.cpp @@ -494,7 +494,7 @@ UNIT_TEST(Bookmarks_UniqueFileName) { string const BASE = "SomeUniqueFileName"; string const FILEBASE = "./" + BASE; - string const FILENAME = FILEBASE + kKmlExtension; + string const FILENAME = FILEBASE + std::string(kKmlExtension); { FileWriter file(FILENAME); diff --git a/platform/platform.cpp b/platform/platform.cpp index e14ca2c295..6b3eec2a55 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -214,13 +214,13 @@ void Platform::GetFontNames(FilesList & res) const LOG(LINFO, ("Available font files:", (res))); } -void Platform::GetFilesByExt(std::string const & directory, std::string const & ext, FilesList & outFiles) +void Platform::GetFilesByExt(std::string const & directory, std::string_view const ext, FilesList & outFiles) { // Transform extension mask to regexp (.mwm -> \.mwm$) ASSERT ( !ext.empty(), () ); ASSERT_EQUAL ( ext[0], '.' , () ); - - GetFilesByRegExp(directory, '\\' + ext + '$', outFiles); + std::string regexp = "\\"; + GetFilesByRegExp(directory, regexp.append(ext).append("$"), outFiles); } // static diff --git a/platform/platform.hpp b/platform/platform.hpp index d185c60228..a53fb545cf 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -210,7 +210,7 @@ public: /// @param directory directory path with slash at the end //@{ /// @param ext files extension to find, like ".mwm". - static void GetFilesByExt(std::string const & directory, std::string const & ext, + static void GetFilesByExt(std::string const & directory, std::string_view const ext, FilesList & outFiles); static void GetFilesByRegExp(std::string const & directory, std::string const & regexp, FilesList & outFiles); -- 2.45.3 From 2d281f9553a87d1bfa64bedaf9618ffb9e7d27c9 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Sun, 11 Jun 2023 00:36:27 +0200 Subject: [PATCH 05/10] Fixed string_view to string conversion Signed-off-by: Alexander Borsuk --- android/jni/app/organicmaps/Framework.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/android/jni/app/organicmaps/Framework.cpp b/android/jni/app/organicmaps/Framework.cpp index 5940a3075d..7a790c7afb 100644 --- a/android/jni/app/organicmaps/Framework.cpp +++ b/android/jni/app/organicmaps/Framework.cpp @@ -1103,11 +1103,14 @@ Java_app_organicmaps_Framework_nativeGetMovableFilesExts(JNIEnv * env, jclass) return jni::ToJavaStringArray(env, exts); } +std::array const kBookmarkExtensions = { + std::string{kKmzExtension}, std::string{kKmlExtension}, std::string{kKmbExtension}, std::string{kGpxExtension} +}; + JNIEXPORT jobjectArray JNICALL Java_app_organicmaps_Framework_nativeGetBookmarksFilesExts(JNIEnv * env, jclass) { - std::array exts = { kKmzExtension, kKmlExtension, kKmbExtension, kGpxExtension }; - return jni::ToJavaStringArray(env, exts); + return jni::ToJavaStringArray(env, kBookmarkExtensions); } JNIEXPORT void JNICALL -- 2.45.3 From 1457e3753a1d1b787c2a6e860cee171a5467bef8 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Sun, 11 Jun 2023 00:54:57 +0200 Subject: [PATCH 06/10] Follow-up fixes Signed-off-by: Alexander Borsuk --- map/bookmark_helpers.cpp | 21 +++++---------------- map/bookmark_helpers.hpp | 8 ++++---- map/bookmark_manager.cpp | 4 ++-- map/bookmark_manager.hpp | 2 +- map/map_tests/bookmarks_test.cpp | 2 +- platform/platform.cpp | 2 +- platform/platform.hpp | 2 +- 7 files changed, 15 insertions(+), 26 deletions(-) diff --git a/map/bookmark_helpers.cpp b/map/bookmark_helpers.cpp index c56335db6d..0dcd7cc116 100644 --- a/map/bookmark_helpers.cpp +++ b/map/bookmark_helpers.cpp @@ -246,24 +246,17 @@ std::string RemoveInvalidSymbols(std::string const & name) } -std::string GenerateUniqueFileName(std::string const & path, std::string name, std::string_view const ext) +std::string GenerateUniqueFileName(std::string const & path, std::string name, std::string_view ext) { // Remove extension, if file name already contains it. if (strings::EndsWith(name, ext)) name.resize(name.size() - ext.size()); size_t counter = 1; - std::string suffix, res; - do - { - res = name; - res = base::JoinPath(path, res.append(suffix).append(ext)); - if (!Platform::IsFileExistsByFullPath(res)) - break; + std::string suffix; + while (Platform::IsFileExistsByFullPath(base::JoinPath(path, name.append(suffix).append(ext)))) suffix = strings::to_string(counter++); - } while (true); - - return res; + return base::JoinPath(path, name.append(suffix).append(ext)); } std::string GenerateValidAndUniqueFilePathForKML(std::string const & fileName) @@ -272,13 +265,9 @@ std::string GenerateValidAndUniqueFilePathForKML(std::string const & fileName) if (filePath.empty()) filePath = kDefaultBookmarksFileName; - return GenerateUniqueFileName(GetBookmarksDirectory(), std::move(filePath)); + return GenerateUniqueFileName(GetBookmarksDirectory(), std::move(filePath), kKmlExtension); } -std::string_view const kKmzExtension = ".kmz"; -std::string_view const kKmlExtension = ".kml"; -std::string_view const kKmbExtension = ".kmb"; -std::string_view const kGpxExtension = ".gpx"; std::string const kDefaultBookmarksFileName = "Bookmarks"; // Populate empty category & track names based on file name: assign file name to category name, diff --git a/map/bookmark_helpers.hpp b/map/bookmark_helpers.hpp index 91d2a16c79..e2cabe2a5e 100644 --- a/map/bookmark_helpers.hpp +++ b/map/bookmark_helpers.hpp @@ -65,10 +65,10 @@ enum class BookmarkBaseType : uint16_t Count }; -extern std::string_view const kKmzExtension; -extern std::string_view const kKmlExtension; -extern std::string_view const kKmbExtension; -extern std::string_view const kGpxExtension; +std::string_view constexpr kKmzExtension = ".kmz"; +std::string_view constexpr kKmlExtension = ".kml"; +std::string_view constexpr kKmbExtension = ".kmb"; +std::string_view constexpr kGpxExtension = ".gpx"; extern std::string const kDefaultBookmarksFileName; enum class KmlFileType diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 687403bd1b..945fcf497f 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -1798,7 +1798,7 @@ void BookmarkManager::ClearCategories() } BookmarkManager::KMLDataCollectionPtr BookmarkManager::LoadBookmarks( - std::string const & dir, std::string_view const ext, KmlFileType fileType, + std::string const & dir, std::string_view ext, KmlFileType fileType, BookmarksChecker const & checker) { Platform::FilesList files; @@ -2588,7 +2588,7 @@ BookmarkManager::KMLDataCollectionPtr BookmarkManager::PrepareToSaveBookmarks( if (name.empty()) name = kDefaultBookmarksFileName; - file = GenerateUniqueFileName(fileDir, std::move(name)); + file = GenerateUniqueFileName(fileDir, std::move(name), kKmlExtension); group->SetFileName(file); } diff --git a/map/bookmark_manager.hpp b/map/bookmark_manager.hpp index c18767ea46..e8882fc7f7 100644 --- a/map/bookmark_manager.hpp +++ b/map/bookmark_manager.hpp @@ -603,7 +603,7 @@ private: void LoadBookmarkRoutine(std::string const & filePath, bool isTemporaryFile); using BookmarksChecker = std::function; - KMLDataCollectionPtr LoadBookmarks(std::string const & dir, std::string_view const ext, + KMLDataCollectionPtr LoadBookmarks(std::string const & dir, std::string_view ext, KmlFileType fileType, BookmarksChecker const & checker); void GetDirtyGroups(kml::GroupIdSet & dirtyGroups) const; diff --git a/map/map_tests/bookmarks_test.cpp b/map/map_tests/bookmarks_test.cpp index 2d4613b948..b4de2529d4 100644 --- a/map/map_tests/bookmarks_test.cpp +++ b/map/map_tests/bookmarks_test.cpp @@ -494,7 +494,7 @@ UNIT_TEST(Bookmarks_UniqueFileName) { string const BASE = "SomeUniqueFileName"; string const FILEBASE = "./" + BASE; - string const FILENAME = FILEBASE + std::string(kKmlExtension); + string const FILENAME = FILEBASE.append(kKmlExtension); { FileWriter file(FILENAME); diff --git a/platform/platform.cpp b/platform/platform.cpp index 6b3eec2a55..54f65002da 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -214,7 +214,7 @@ void Platform::GetFontNames(FilesList & res) const LOG(LINFO, ("Available font files:", (res))); } -void Platform::GetFilesByExt(std::string const & directory, std::string_view const ext, FilesList & outFiles) +void Platform::GetFilesByExt(std::string const & directory, std::string_view ext, FilesList & outFiles) { // Transform extension mask to regexp (.mwm -> \.mwm$) ASSERT ( !ext.empty(), () ); diff --git a/platform/platform.hpp b/platform/platform.hpp index a53fb545cf..e18ff07000 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -210,7 +210,7 @@ public: /// @param directory directory path with slash at the end //@{ /// @param ext files extension to find, like ".mwm". - static void GetFilesByExt(std::string const & directory, std::string_view const ext, + static void GetFilesByExt(std::string const & directory, std::string_view ext, FilesList & outFiles); static void GetFilesByRegExp(std::string const & directory, std::string const & regexp, FilesList & outFiles); -- 2.45.3 From 281c0d9ffe7ac77e46517663a886575a553ff990 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Tue, 13 Jun 2023 19:57:54 +0200 Subject: [PATCH 07/10] Review fixes Signed-off-by: Alexander Borsuk --- android/jni/app/organicmaps/Framework.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/android/jni/app/organicmaps/Framework.cpp b/android/jni/app/organicmaps/Framework.cpp index 7a790c7afb..34c64a2835 100644 --- a/android/jni/app/organicmaps/Framework.cpp +++ b/android/jni/app/organicmaps/Framework.cpp @@ -1103,13 +1103,16 @@ Java_app_organicmaps_Framework_nativeGetMovableFilesExts(JNIEnv * env, jclass) return jni::ToJavaStringArray(env, exts); } -std::array const kBookmarkExtensions = { - std::string{kKmzExtension}, std::string{kKmlExtension}, std::string{kKmbExtension}, std::string{kGpxExtension} -}; - JNIEXPORT jobjectArray JNICALL Java_app_organicmaps_Framework_nativeGetBookmarksFilesExts(JNIEnv * env, jclass) { + static std::array const kBookmarkExtensions = { + std::string{kKmzExtension}, + std::string{kKmlExtension}, + std::string{kKmbExtension}, + std::string{kGpxExtension} + }; + return jni::ToJavaStringArray(env, kBookmarkExtensions); } -- 2.45.3 From 042705d0cddb06fc14945eb1649629d096a75983 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Tue, 13 Jun 2023 21:02:59 +0200 Subject: [PATCH 08/10] Compile fix Signed-off-by: Alexander Borsuk --- map/map_tests/bookmarks_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map/map_tests/bookmarks_test.cpp b/map/map_tests/bookmarks_test.cpp index b4de2529d4..c37f9e66f0 100644 --- a/map/map_tests/bookmarks_test.cpp +++ b/map/map_tests/bookmarks_test.cpp @@ -494,7 +494,7 @@ UNIT_TEST(Bookmarks_UniqueFileName) { string const BASE = "SomeUniqueFileName"; string const FILEBASE = "./" + BASE; - string const FILENAME = FILEBASE.append(kKmlExtension); + string const FILENAME = FILEBASE + string{kKmlExtension}; { FileWriter file(FILENAME); -- 2.45.3 From afa1c948fd670d27286152a2313f95a88d8455be Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Tue, 13 Jun 2023 22:44:36 +0200 Subject: [PATCH 09/10] append does not create a temporary :) Signed-off-by: Alexander Borsuk --- map/bookmark_helpers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/map/bookmark_helpers.cpp b/map/bookmark_helpers.cpp index 0dcd7cc116..8d5330d768 100644 --- a/map/bookmark_helpers.cpp +++ b/map/bookmark_helpers.cpp @@ -254,9 +254,9 @@ std::string GenerateUniqueFileName(std::string const & path, std::string name, s size_t counter = 1; std::string suffix; - while (Platform::IsFileExistsByFullPath(base::JoinPath(path, name.append(suffix).append(ext)))) + while (Platform::IsFileExistsByFullPath(base::JoinPath(path, (name + suffix).append(ext)))) suffix = strings::to_string(counter++); - return base::JoinPath(path, name.append(suffix).append(ext)); + return base::JoinPath(path, (name +suffix).append(ext)); } std::string GenerateValidAndUniqueFilePathForKML(std::string const & fileName) -- 2.45.3 From 0fad89c09be0555bf9359f1137232ffb6677d8a2 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Wed, 14 Jun 2023 06:52:45 +0200 Subject: [PATCH 10/10] Avoid duplicate path Signed-off-by: Alexander Borsuk --- map/bookmark_helpers.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/map/bookmark_helpers.cpp b/map/bookmark_helpers.cpp index 8d5330d768..d1b54efc59 100644 --- a/map/bookmark_helpers.cpp +++ b/map/bookmark_helpers.cpp @@ -253,10 +253,17 @@ std::string GenerateUniqueFileName(std::string const & path, std::string name, s name.resize(name.size() - ext.size()); size_t counter = 1; - std::string suffix; - while (Platform::IsFileExistsByFullPath(base::JoinPath(path, (name + suffix).append(ext)))) + std::string suffix, res; + do + { + res = name; + res = base::JoinPath(path, res.append(suffix).append(ext)); + if (!Platform::IsFileExistsByFullPath(res)) + break; suffix = strings::to_string(counter++); - return base::JoinPath(path, (name +suffix).append(ext)); + } while (true); + + return res; } std::string GenerateValidAndUniqueFilePathForKML(std::string const & fileName) -- 2.45.3