Marble

SearchBackend.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2015 Gábor Péterffy <peterffy95@gmail.com>
4//
5
6#ifndef MARBLE_SEARCHBACKEND_H
7#define MARBLE_SEARCHBACKEND_H
8
9#include <QObject>
10#include <QSortFilterProxyModel>
11#include <qqmlregistration.h>
12
13#include "MarblePlacemarkModel.h"
14#include "MarbleQuickItem.h"
15#include "Placemark.h"
16
17class QCompleter;
18
19namespace Marble
20{
21class SearchRunnerManager;
22
23class SearchBackend : public QObject
24{
26 QML_ELEMENT
27
28 Q_PROPERTY(QObject *marbleQuickItem READ marbleQuickItem WRITE setMarbleQuickItem NOTIFY marbleQuickItemChanged)
29 Q_PROPERTY(MarblePlacemarkModel *completionModel READ completionModel NOTIFY completionModelChanged)
30 Q_PROPERTY(Placemark *selectedPlacemark READ selectedPlacemark NOTIFY selectedPlacemarkChanged)
31
32public:
33 explicit SearchBackend(QObject *parent = nullptr);
34 Q_INVOKABLE void search(const QString &place);
35 Q_INVOKABLE void setCompletionPrefix(const QString &prefix);
36 QObject *marbleQuickItem();
37 MarblePlacemarkModel *completionModel();
38 const QObject *marbleQuickItem() const;
39 Placemark *selectedPlacemark();
40
42 void marbleQuickItemChanged(QObject *marbleQuickItem);
43 void completionModelChanged(MarblePlacemarkModel *model);
44 void searchResultChanged(MarblePlacemarkModel *model);
45 void searchFinished(const QString &searchTerm);
46 void selectedPlacemarkChanged(Placemark *selectedPlacemark);
47
48public Q_SLOTS:
49 Q_INVOKABLE void setSelectedPlacemark(int placemarkIndex);
50 void setMarbleQuickItem(QObject *marbleQuickItem);
51 void updateSearchResult(QAbstractItemModel *result);
52
53private:
54 static GeoDataPlacemark *placemarkFromQVariant(const QVariant &data);
56 SearchRunnerManager *m_searchManager = nullptr;
57 MarbleQuickItem *m_marbleQuickItem = nullptr;
58 MarblePlacemarkModel *m_placemarkModel = nullptr;
59 QCompleter *m_completer = nullptr;
60 MarblePlacemarkModel *const m_completionModel;
61 QList<GeoDataPlacemark *> *m_completionContainer = nullptr;
62 Placemark m_selectedPlacemark;
63 QString m_lastSuccessfulCompletion;
64};
65
66}
67#endif
Binds a QML item to a specific geodetic location in screen coordinates.
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.