Skip to content

Commit

Permalink
Merge pull request #1535 from Karry/poi-lookup-qt-less
Browse files Browse the repository at this point in the history
move POILookupModule to client library
  • Loading branch information
Framstag committed Dec 10, 2023
2 parents b55efc9 + 09d1a0f commit b307c36
Show file tree
Hide file tree
Showing 27 changed files with 456 additions and 370 deletions.
3 changes: 2 additions & 1 deletion Tests/src/HeaderCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ static const std::set<std::string> allowedDependencies{
"osmscoutclient => osmscout",
"osmscoutclient => osmscout.async",
"osmscoutclient => osmscout.db",
"osmscoutclient => osmscout.feature",
"osmscoutclient => osmscout.io",
"osmscoutclient => osmscout.poi",
"osmscoutclient => osmscout.routing",
"osmscoutclient => osmscout.util",
"osmscoutclient => osmscout.location",
Expand All @@ -157,7 +159,6 @@ static const std::set<std::string> allowedDependencies{
"osmscoutclientqt => osmscout.feature",
"osmscoutclientqt => osmscout.elevation",
"osmscoutclientqt => osmscout.location",
"osmscoutclientqt => osmscout.poi",
"osmscoutclientqt => osmscout.routing",
"osmscoutclientqt => osmscout.navigation",
"osmscoutclientqt => osmscout",
Expand Down
3 changes: 0 additions & 3 deletions libosmscout-client-qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(HEADER_FILES
include/osmscoutclientqt/AdminRegionInfo.h
include/osmscoutclientqt/ClientQtImportExport.h
include/osmscoutclientqt/ElevationChartWidget.h
include/osmscoutclientqt/ElevationModule.h
Expand Down Expand Up @@ -52,7 +51,6 @@ set(HEADER_FILES
include/osmscoutclientqt/QtStdConverters.h
include/osmscoutclientqt/RouteStep.h
include/osmscoutclientqt/NearPOIModel.h
include/osmscoutclientqt/POILookupModule.h
include/osmscoutclientqt/InstalledMapsModel.h
include/osmscoutclientqt/Voice.h
include/osmscoutclientqt/VoiceManager.h
Expand Down Expand Up @@ -108,7 +106,6 @@ set(SOURCE_FILES
src/osmscoutclientqt/QtSettingsStorage.cpp
src/osmscoutclientqt/QtStdConverters.cpp
src/osmscoutclientqt/NearPOIModel.cpp
src/osmscoutclientqt/POILookupModule.cpp
src/osmscoutclientqt/InstalledMapsModel.cpp
src/osmscoutclientqt/Voice.cpp
src/osmscoutclientqt/VoiceManager.cpp
Expand Down
2 changes: 0 additions & 2 deletions libosmscout-client-qt/include/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
osmscoutclientqtIncDir = include_directories('.')

osmscoutclientqtHeader = [
'osmscoutclientqt/AdminRegionInfo.h',
'osmscoutclientqt/ClientQtImportExport.h',
'osmscoutclientqt/ElevationChartWidget.h',
'osmscoutclientqt/ElevationModule.h',
Expand Down Expand Up @@ -50,7 +49,6 @@ osmscoutclientqtHeader = [
'osmscoutclientqt/TiledMapOverlay.h',
'osmscoutclientqt/TiledRenderingHelper.h',
'osmscoutclientqt/NearPOIModel.h',
'osmscoutclientqt/POILookupModule.h',
'osmscoutclientqt/InstalledMapsModel.h',
'osmscoutclientqt/Voice.h',
'osmscoutclientqt/VoiceManager.h',
Expand Down
19 changes: 8 additions & 11 deletions libosmscout-client-qt/include/osmscoutclientqt/LocationEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
#include <osmscout/location/LocationDescriptionService.h>
#include <osmscout/location/LocationService.h>

#include <osmscoutclient/LocationInfo.h>
#include <osmscoutclient/AdminRegionInfo.h>

#include <osmscoutclientqt/ClientQtImportExport.h>
#include <osmscoutclientqt/AdminRegionInfo.h>

namespace osmscout {

Expand All @@ -51,15 +53,8 @@ class OSMSCOUT_CLIENT_QT_API LocationEntry : public QObject
Q_PROPERTY(double lat READ getLat CONSTANT)
Q_PROPERTY(double lon READ getLon CONSTANT)

public:
enum Type {
typeNone,
typeObject,
typeCoordinate
};

private:
Type type;
LocationInfo::Type type;
QString label;
QString altName; // name in alternative language
QString objectType;
Expand All @@ -70,7 +65,7 @@ class OSMSCOUT_CLIENT_QT_API LocationEntry : public QObject
osmscout::GeoBox bbox;

public:
LocationEntry(Type type,
LocationEntry(LocationInfo::Type type,
const QString& label,
const QString& altName,
const QString& objectType,
Expand All @@ -84,6 +79,8 @@ class OSMSCOUT_CLIENT_QT_API LocationEntry : public QObject
const osmscout::GeoCoord& coord,
QObject* parent = nullptr);

explicit LocationEntry(const LocationInfo &info);

explicit LocationEntry(QObject* parent = nullptr);

//! copy constructor copies Qt ownership
Expand All @@ -104,7 +101,7 @@ class OSMSCOUT_CLIENT_QT_API LocationEntry : public QObject

Q_INVOKABLE double distanceTo(double lat, double lon) const;

Type getType() const;
LocationInfo::Type getType() const;
QString getTypeString() const;
QString getObjectType() const;
QString getLabel() const;
Expand Down
30 changes: 21 additions & 9 deletions libosmscout-client-qt/include/osmscoutclientqt/NearPOIModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <osmscoutclient/POILookupModule.h>

#include <osmscoutclientqt/LocationEntry.h>
#include <osmscoutclientqt/POILookupModule.h>

#include <osmscoutclientqt/ClientQtImportExport.h>

#include <QObject>
#include <QAbstractListModel>

#include <functional>
#include <optional>

namespace osmscout {

#define INVALID_COORD -1000.0
Expand Down Expand Up @@ -95,29 +99,37 @@ Q_OBJECT

void SearchingChanged(bool);

void lookupPOIRequest(int requestId,
osmscout::BreakerRef breaker,
osmscout::GeoCoord searchCenter,
QStringList types,
double maxDistance);
void lookupFinished(int requestId);
void lookupResult(int requestId, QList<LocationEntry> locations);

public slots:
void onLookupFinished(int requestId);
void onLookupResult(int requestId, QList<LocationEntry> locations);

private:
bool searching{false};
int currentRequest{0};
QList<LocationEntryRef> locations;
osmscout::GeoCoord searchCenter{INVALID_COORD,INVALID_COORD};
int resultLimit{100};
osmscout::BreakerRef breaker;
std::optional<POILookupModule::LookupFuture> future;
Distance maxDistance{Distance::Of<Kilometer>(1)};
QStringList types;

POILookupModule *poiModule{nullptr};
SettingsRef settings;

Slot<int> lookupFinishedSlot{ std::bind(&NearPOIModel::lookupFinished, this, std::placeholders::_1) };

Slot<int, POILookupModule::LookupResult> lookupResultSlot {
[this](int requestId, const POILookupModule::LookupResult &locationsVector) {
QList<LocationEntry> locations;
for (const auto &info: locationsVector) {
locations << LocationEntry(info);
}
emit lookupResult(requestId, locations);
}
};

public:
NearPOIModel();
~NearPOIModel() override;
Expand All @@ -134,7 +146,7 @@ public slots:

inline bool isSearching() const
{
return searching;
return future.has_value();
}

inline double GetLat() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <osmscoutclient/MapManager.h>
#include <osmscoutclient/DBThread.h>
#include <osmscoutclient/POILookupModule.h>

#include <osmscoutclientqt/LookupModule.h>
#include <osmscoutclientqt/MapDownloader.h>
Expand All @@ -34,7 +35,6 @@
#include <osmscoutclientqt/SearchModule.h>
#include <osmscoutclientqt/StyleModule.h>
#include <osmscoutclientqt/NavigationModule.h>
#include <osmscoutclientqt/POILookupModule.h>
#include <osmscoutclientqt/VoiceManager.h>
#include <osmscoutclientqt/ElevationModule.h>
#include <osmscoutclientqt/IconLookup.h>
Expand Down
70 changes: 0 additions & 70 deletions libosmscout-client-qt/include/osmscoutclientqt/POILookupModule.h

This file was deleted.

10 changes: 10 additions & 0 deletions libosmscout-client-qt/include/osmscoutclientqt/QtStdConverters.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ extern OSMSCOUT_CLIENT_QT_API QDateTime TimestampToQDateTime(const osmscout::Tim

extern OSMSCOUT_CLIENT_QT_API QList<QDir> PathVectorToQDirList(const std::vector<std::filesystem::path> &paths);

template <typename T>
QList<T> vectorToQList(const std::vector<T> &vec)
{
QList<T> result;
for (const auto &o: vec) {
result << o;
}
return result;
}

}

#endif //OSMSCOUT_CLIENT_QT_QTSTDCONVERTERS_H
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QObject>
#include <QThread>
#include <QMutex>
#include <QMap>

#include <osmscoutclient/DBThread.h>

Expand Down
1 change: 0 additions & 1 deletion libosmscout-client-qt/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ osmscoutclientqtSrc = [
'src/osmscoutclientqt/TiledMapOverlay.cpp',
'src/osmscoutclientqt/TiledRenderingHelper.cpp',
'src/osmscoutclientqt/NearPOIModel.cpp',
'src/osmscoutclientqt/POILookupModule.cpp',
'src/osmscoutclientqt/InstalledMapsModel.cpp',
'src/osmscoutclientqt/Voice.cpp',
'src/osmscoutclientqt/VoiceManager.cpp',
Expand Down
Loading

0 comments on commit b307c36

Please sign in to comment.