Commit graph

18 commits

Author SHA1 Message Date
jan Iversen
b0e48a5e8f qt-models: Change Q_UNUSED to no parameter name
C++ permits use of parameters without name, which signals unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 12:48:04 -07:00
Jan Mulder
803759efea cleanup: Uninitialized scalar field
CID 208317
CID 208325

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28 17:30:25 +01:00
Lubomir I. Ivanov
746874a78e map-widget: allow real-time updates of edited markers
This patch allows updating the location of map markers
while editing a dive site and updating the text in the
LocationInformationWidget in real-time.

Currently it is only possible to see the marker changes by
clicking 'Apply'.

The modification required the following changes:
- add the MapWidget::updateCurrentDiveSiteCoordinatesToMap() slot
and call it each time the GPS text updates
- separate the updateCurrentDiveSiteCoordinates(FromMap/ToMap) logic
by having the FromMap/ToMap suffix to method names
- make MapWidgetHelper::updateCurrentDiveSiteCoordinatesToMap()
call a new MapLocationModel::updateMapLocationCoordinates()
method, which updates selected location coordinates and the model
- add MapLocation::setCoordinateNoEmit() that does not emit
a signal when updating a coordinate

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-09 12:40:25 -08:00
Dirk Hohndel
c59cdd6efd Switch new files to unix line endings
I thought we had this automated, but Lubomirs commits introduced a few
files with dos line endings. This is purely a change of line endings, no
other changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-28 22:01:36 -07:00
Lubomir I. Ivanov
f6e269c07a maplocationmodel: fix getMapLocationForUuid()
This method did not return NULL properly if a MapLocation does
not exists in the list.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
0955a5b36a maplocationmodel: use READ method selectedUuid
Also emit the selectedUuidChanged signal.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
2dea6f5146 maplocation: add helpers for coordinate and uuid
getRole() returns a QVariant and the cast is a small overhead.
Using these helpers will reduce the overhead.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
be0d513324 maplocationmodel: add the "namer" property
The MapLocation QObject now has a QString property "name", which is
translating the dive_site->name member.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
5ea702199b maplocationmodel: make setSelectedUuid() accept "fromClick" flag
The idea of this flag is to be able to only to emit the
selectedLocationChanged() signal when the user clicked on the map
(fromClick == true).

MapWidgetHelper::selectedLocationChanged() listens for this signal
and only then it will select nearby dives based on a "small-cicle".

If "fromClick" is false, it's the backend or the dive list that
updated the selection and MapWidgetHelper::selectedLocationChanged()
should no be called.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
4a126b553f maplocationmodel: add the helper method getMapLocationForUuid()
getMapLocationForUuid() accepts a UUID, searches the MapLocation table
and returns a pointer.

Make use of the new method in setSelectedUuid().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
4b03216fdb maplocationmodel: add a "selectedUuid" property to MapLocationModel
Inside the QML Map class there is a MapItemView item.
This item uses a delegate that receive a "model" property from
the MapLocationModel, but infact that's a QObject with the MapLocation
defined properties. That's how MapItemView works.

The problem here is that "model" QObject cannot be cast back
to a MapLocation as the meta data in there does not include
a MapLocation sub-class, for some reason.

Even if using propery() on that QObject to fetch data like coordinates
works, instead of storing this strange object pointer, store the
MapLocation UUID (from dive_site) which is a uint32_t.

setSelectedUuid() deals with this oddity and finds the correct
MapLocation pointer in the table and dispatches a selectedLocationChanged()
signal for it.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
a9c0abd71a maplocationmodel: add a "uuid" property to MapLocation
The "uuid" property will be the one from the dive_site. At first it
will also be used to track the active marker/flag selection.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
de90480b46 maplocationmodel: use QVector for the MapLocation storage
QVector is faster, use it for "m_mapLocations" instead of QList.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
ffcfde3b62 maplocationmodel: small whitespace cleanup
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
6ed807f52d maplocationmodel: add the addList() method
This method should be used if many markers are added at once.
It's main purpose is to reduces the number of beingInsertRows()
calls.

Make MapWidgetHelper::reloadMapLocations() use it.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
f44645b6fe maplocationmodel: store the coordinate as QGeoCoordinate
Instead of maintaining a seperate latitude/longitude values
in C++ and passing them to QML separatelly, pass them as a QGeoCoordinate.

This reduces the number of model "roles" and also prevents the creations
of extra objects in QML (e.g. via QtPositioning.coordinate(..)).

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
f4e6df475e maplocationmodel: implement the clear() and add() methods
- add() will be used to add a MapLocation to the model with
beginInsertRows()...endInsertRows()
- clear() will be used to clear the model with beginRemoveRows()...
endRemoveRows()

NOTE: emiting dataChanged() does not seem to update the QML view for
this model so calling being<..>Rows() seems to be the "correct Qt
approach" to do this.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
fc6cb67626 qt-models/maplocationmodel: add new classes for map model based handling
The QML Map widget requires a QAbstractListModel based model to operate
with good performance. Technically gpslistmodel.cpp can be used for that
same purpose (e.g. has GPS coordinates), but the way it updates
may complicate the Map widget integration.

Thus, a new model is created - MapLocationModel, with items of type
MapLocation, for an attempt for a clean project structure on the C++ side.

For now it only handles latitude and longitude.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00