2017-04-27 18:26:05 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-05-17 19:13:41 +00:00
|
|
|
#ifndef LOCATIONINFORMATION_H
|
|
|
|
#define LOCATIONINFORMATION_H
|
|
|
|
|
2018-10-08 11:51:57 +00:00
|
|
|
#include "core/units.h"
|
2018-10-13 08:59:16 +00:00
|
|
|
#include "core/divesite.h"
|
2018-10-13 09:52:59 +00:00
|
|
|
#include "core/taxonomy.h"
|
2019-02-01 19:40:57 +00:00
|
|
|
#include "ui_locationinformation.h"
|
2018-10-08 17:01:45 +00:00
|
|
|
#include "qt-models/divelocationmodel.h"
|
2015-05-17 19:13:41 +00:00
|
|
|
#include <stdint.h>
|
2015-05-17 19:33:23 +00:00
|
|
|
#include <QAbstractListModel>
|
2015-09-21 17:01:58 +00:00
|
|
|
#include <QSortFilterProxyModel>
|
2015-05-17 19:33:23 +00:00
|
|
|
|
2015-05-17 19:13:41 +00:00
|
|
|
class LocationInformationWidget : public QGroupBox {
|
2019-03-12 06:24:54 +00:00
|
|
|
Q_OBJECT
|
2015-05-17 19:13:41 +00:00
|
|
|
public:
|
|
|
|
LocationInformationWidget(QWidget *parent = 0);
|
2018-09-29 20:13:44 +00:00
|
|
|
bool eventFilter(QObject*, QEvent*) override;
|
2018-10-13 06:57:46 +00:00
|
|
|
void initFields(dive_site *ds);
|
2015-09-01 00:11:28 +00:00
|
|
|
|
2015-05-17 20:14:23 +00:00
|
|
|
protected:
|
2017-11-26 22:26:46 +00:00
|
|
|
void enableLocationButtons(bool enable);
|
2015-05-26 20:36:06 +00:00
|
|
|
|
2015-05-17 19:13:41 +00:00
|
|
|
public slots:
|
|
|
|
void acceptChanges();
|
|
|
|
void rejectChanges();
|
2018-10-20 18:12:15 +00:00
|
|
|
void updateGpsCoordinates(const location_t &);
|
2015-05-17 19:13:41 +00:00
|
|
|
void markChangedWidget(QWidget *w);
|
|
|
|
void enableEdition();
|
|
|
|
void resetState();
|
|
|
|
void resetPallete();
|
2017-10-02 15:51:20 +00:00
|
|
|
void on_diveSiteCountry_textChanged(const QString& text);
|
2015-05-17 19:13:41 +00:00
|
|
|
void on_diveSiteCoordinates_textChanged(const QString& text);
|
2019-03-13 21:49:34 +00:00
|
|
|
void on_diveSiteDescription_editingFinished();
|
|
|
|
void on_diveSiteName_editingFinished();
|
2019-03-13 23:00:54 +00:00
|
|
|
void on_diveSiteNotes_editingFinished();
|
2015-08-25 21:45:29 +00:00
|
|
|
void reverseGeocode();
|
2015-09-01 00:35:17 +00:00
|
|
|
void mergeSelectedDiveSites();
|
2015-06-04 02:50:36 +00:00
|
|
|
private slots:
|
2015-07-25 16:03:14 +00:00
|
|
|
void updateLabels();
|
2017-11-26 22:26:46 +00:00
|
|
|
void updateLocationOnMap();
|
2019-03-12 22:51:39 +00:00
|
|
|
void diveSiteChanged(struct dive_site *ds, int field);
|
2015-05-17 19:13:41 +00:00
|
|
|
signals:
|
2015-06-04 02:50:36 +00:00
|
|
|
void endEditDiveSite();
|
2015-09-01 00:11:28 +00:00
|
|
|
|
2015-05-17 19:13:41 +00:00
|
|
|
private:
|
2017-10-06 19:06:13 +00:00
|
|
|
void clearLabels();
|
2015-05-17 19:13:41 +00:00
|
|
|
Ui::LocationInformation ui;
|
|
|
|
bool modified;
|
2015-10-02 21:30:21 +00:00
|
|
|
QAction *acceptAction, *rejectAction;
|
2018-10-08 17:01:45 +00:00
|
|
|
GPSLocationInformationModel filter_model;
|
2018-10-13 11:14:48 +00:00
|
|
|
dive_site *diveSite;
|
2018-10-13 09:52:59 +00:00
|
|
|
taxonomy_data taxonomy;
|
2015-05-17 19:13:41 +00:00
|
|
|
};
|
|
|
|
|
2015-09-21 17:01:58 +00:00
|
|
|
class DiveLocationFilterProxyModel : public QSortFilterProxyModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
DiveLocationFilterProxyModel(QObject *parent = 0);
|
2018-09-29 20:13:44 +00:00
|
|
|
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
|
|
|
|
bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override;
|
2015-09-21 17:01:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DiveLocationModel : public QAbstractTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
DiveLocationModel(QObject *o = 0);
|
|
|
|
void resetModel();
|
|
|
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
|
|
|
private:
|
|
|
|
QString new_ds_value[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
class DiveLocationListView : public QListView {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
DiveLocationListView(QWidget *parent = 0);
|
2015-09-25 16:21:23 +00:00
|
|
|
protected:
|
2018-09-29 20:13:44 +00:00
|
|
|
void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
|
2015-09-25 16:21:23 +00:00
|
|
|
signals:
|
|
|
|
void currentIndexChanged(const QModelIndex& current);
|
2015-09-21 17:01:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DiveLocationLineEdit : public QLineEdit {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-09-22 17:31:56 +00:00
|
|
|
enum DiveSiteType { NO_DIVE_SITE, NEW_DIVE_SITE, EXISTING_DIVE_SITE };
|
2015-09-21 17:01:58 +00:00
|
|
|
DiveLocationLineEdit(QWidget *parent =0 );
|
|
|
|
void refreshDiveSiteCache();
|
|
|
|
void setTemporaryDiveSiteName(const QString& s);
|
2015-09-21 19:51:39 +00:00
|
|
|
bool eventFilter(QObject*, QEvent*);
|
2015-09-21 20:18:52 +00:00
|
|
|
void itemActivated(const QModelIndex& index);
|
2015-09-22 17:31:56 +00:00
|
|
|
DiveSiteType currDiveSiteType() const;
|
2018-10-25 06:02:06 +00:00
|
|
|
struct dive_site *currDiveSite() const;
|
2015-09-23 19:03:28 +00:00
|
|
|
void fixPopupPosition();
|
2018-10-25 06:02:06 +00:00
|
|
|
void setCurrentDiveSite(struct dive_site *ds);
|
2015-09-25 16:11:44 +00:00
|
|
|
|
2015-09-23 17:46:29 +00:00
|
|
|
signals:
|
2018-10-24 19:14:57 +00:00
|
|
|
void diveSiteSelected();
|
2015-09-25 16:11:44 +00:00
|
|
|
void entered(const QModelIndex& index);
|
2015-09-25 16:21:23 +00:00
|
|
|
void currentChanged(const QModelIndex& index);
|
2015-09-23 17:46:29 +00:00
|
|
|
|
2015-09-21 19:08:58 +00:00
|
|
|
protected:
|
|
|
|
void keyPressEvent(QKeyEvent *ev);
|
2015-09-22 18:23:38 +00:00
|
|
|
void focusOutEvent(QFocusEvent *ev);
|
2015-09-21 19:08:58 +00:00
|
|
|
void showPopup();
|
2015-09-23 17:57:55 +00:00
|
|
|
|
2015-09-21 17:01:58 +00:00
|
|
|
private:
|
2015-09-25 17:51:10 +00:00
|
|
|
using QLineEdit::setText;
|
2015-09-21 17:01:58 +00:00
|
|
|
DiveLocationFilterProxyModel *proxy;
|
|
|
|
DiveLocationModel *model;
|
|
|
|
DiveLocationListView *view;
|
2015-09-22 17:31:56 +00:00
|
|
|
DiveSiteType currType;
|
2018-10-25 06:02:06 +00:00
|
|
|
struct dive_site *currDs;
|
2015-09-21 17:01:58 +00:00
|
|
|
};
|
|
|
|
|
2015-05-17 19:13:41 +00:00
|
|
|
#endif
|