2017-04-27 20:26:05 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-05-17 16:13:41 -03:00
|
|
|
#ifndef LOCATIONINFORMATION_H
|
|
|
|
#define LOCATIONINFORMATION_H
|
|
|
|
|
2018-10-08 13:51:57 +02:00
|
|
|
#include "core/units.h"
|
2018-10-13 10:59:16 +02:00
|
|
|
#include "core/divesite.h"
|
2018-10-13 11:52:59 +02:00
|
|
|
#include "core/taxonomy.h"
|
2015-05-17 16:13:41 -03:00
|
|
|
#include "ui_locationInformation.h"
|
2018-10-08 19:01:45 +02:00
|
|
|
#include "qt-models/divelocationmodel.h"
|
2015-05-17 16:13:41 -03:00
|
|
|
#include <stdint.h>
|
2015-05-17 16:33:23 -03:00
|
|
|
#include <QAbstractListModel>
|
2015-09-21 14:01:58 -03:00
|
|
|
#include <QSortFilterProxyModel>
|
2015-05-17 16:33:23 -03:00
|
|
|
|
2015-05-17 16:13:41 -03:00
|
|
|
class LocationInformationWidget : public QGroupBox {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
LocationInformationWidget(QWidget *parent = 0);
|
2018-09-29 22:13:44 +02:00
|
|
|
bool eventFilter(QObject*, QEvent*) override;
|
2018-10-13 08:57:46 +02:00
|
|
|
void initFields(dive_site *ds);
|
2015-08-31 21:11:28 -03:00
|
|
|
|
2015-05-17 17:14:23 -03:00
|
|
|
protected:
|
2017-11-27 00:26:46 +02:00
|
|
|
void enableLocationButtons(bool enable);
|
2015-05-26 17:36:06 -03:00
|
|
|
|
2015-05-17 16:13:41 -03:00
|
|
|
public slots:
|
|
|
|
void acceptChanges();
|
|
|
|
void rejectChanges();
|
2018-10-20 14:12:15 -04:00
|
|
|
void updateGpsCoordinates(const location_t &);
|
2015-05-17 16:13:41 -03:00
|
|
|
void markChangedWidget(QWidget *w);
|
|
|
|
void enableEdition();
|
|
|
|
void resetState();
|
|
|
|
void resetPallete();
|
2017-10-02 17:51:20 +02:00
|
|
|
void on_diveSiteCountry_textChanged(const QString& text);
|
2015-05-17 16:13:41 -03:00
|
|
|
void on_diveSiteCoordinates_textChanged(const QString& text);
|
|
|
|
void on_diveSiteDescription_textChanged(const QString& text);
|
|
|
|
void on_diveSiteName_textChanged(const QString& text);
|
|
|
|
void on_diveSiteNotes_textChanged();
|
2015-08-25 18:45:29 -03:00
|
|
|
void reverseGeocode();
|
2015-08-31 21:35:17 -03:00
|
|
|
void mergeSelectedDiveSites();
|
2015-06-03 23:50:36 -03:00
|
|
|
private slots:
|
2015-07-25 13:03:14 -03:00
|
|
|
void updateLabels();
|
2017-11-27 00:26:46 +02:00
|
|
|
void updateLocationOnMap();
|
2015-05-17 16:13:41 -03:00
|
|
|
signals:
|
2015-06-03 23:50:36 -03:00
|
|
|
void endEditDiveSite();
|
2017-11-26 10:42:22 +01:00
|
|
|
void nameChanged(const QString &oldName, const QString &newName);
|
2015-08-31 21:11:28 -03:00
|
|
|
|
2015-05-17 16:13:41 -03:00
|
|
|
private:
|
2017-10-06 12:06:13 -07:00
|
|
|
void clearLabels();
|
2015-05-17 16:13:41 -03:00
|
|
|
Ui::LocationInformation ui;
|
|
|
|
bool modified;
|
2015-10-02 17:30:21 -04:00
|
|
|
QAction *acceptAction, *rejectAction;
|
2018-10-08 19:01:45 +02:00
|
|
|
GPSLocationInformationModel filter_model;
|
2018-10-13 13:14:48 +02:00
|
|
|
dive_site *diveSite;
|
2018-10-13 11:52:59 +02:00
|
|
|
taxonomy_data taxonomy;
|
2015-05-17 16:13:41 -03:00
|
|
|
};
|
|
|
|
|
2015-09-21 14:01:58 -03:00
|
|
|
class DiveLocationFilterProxyModel : public QSortFilterProxyModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
DiveLocationFilterProxyModel(QObject *parent = 0);
|
2018-09-29 22:13:44 +02: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 14:01:58 -03: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 13:21:23 -03:00
|
|
|
protected:
|
2018-09-29 22:13:44 +02:00
|
|
|
void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
|
2015-09-25 13:21:23 -03:00
|
|
|
signals:
|
|
|
|
void currentIndexChanged(const QModelIndex& current);
|
2015-09-21 14:01:58 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
class DiveLocationLineEdit : public QLineEdit {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-09-22 14:31:56 -03:00
|
|
|
enum DiveSiteType { NO_DIVE_SITE, NEW_DIVE_SITE, EXISTING_DIVE_SITE };
|
2015-09-21 14:01:58 -03:00
|
|
|
DiveLocationLineEdit(QWidget *parent =0 );
|
|
|
|
void refreshDiveSiteCache();
|
|
|
|
void setTemporaryDiveSiteName(const QString& s);
|
2015-09-21 16:51:39 -03:00
|
|
|
bool eventFilter(QObject*, QEvent*);
|
2015-09-21 17:18:52 -03:00
|
|
|
void itemActivated(const QModelIndex& index);
|
2015-09-22 14:31:56 -03:00
|
|
|
DiveSiteType currDiveSiteType() const;
|
2018-10-25 08:02:06 +02:00
|
|
|
struct dive_site *currDiveSite() const;
|
2015-09-23 16:03:28 -03:00
|
|
|
void fixPopupPosition();
|
2018-10-25 08:02:06 +02:00
|
|
|
void setCurrentDiveSite(struct dive_site *ds);
|
2015-09-25 13:11:44 -03:00
|
|
|
|
2015-09-23 14:46:29 -03:00
|
|
|
signals:
|
2018-10-24 21:14:57 +02:00
|
|
|
void diveSiteSelected();
|
2015-09-25 13:11:44 -03:00
|
|
|
void entered(const QModelIndex& index);
|
2015-09-25 13:21:23 -03:00
|
|
|
void currentChanged(const QModelIndex& index);
|
2015-09-23 14:46:29 -03:00
|
|
|
|
2015-09-21 16:08:58 -03:00
|
|
|
protected:
|
|
|
|
void keyPressEvent(QKeyEvent *ev);
|
2015-09-22 15:23:38 -03:00
|
|
|
void focusOutEvent(QFocusEvent *ev);
|
2015-09-21 16:08:58 -03:00
|
|
|
void showPopup();
|
2015-09-23 14:57:55 -03:00
|
|
|
|
2015-09-21 14:01:58 -03:00
|
|
|
private:
|
2015-09-25 14:51:10 -03:00
|
|
|
using QLineEdit::setText;
|
2015-09-21 14:01:58 -03:00
|
|
|
DiveLocationFilterProxyModel *proxy;
|
|
|
|
DiveLocationModel *model;
|
|
|
|
DiveLocationListView *view;
|
2015-09-22 14:31:56 -03:00
|
|
|
DiveSiteType currType;
|
2018-10-25 08:02:06 +02:00
|
|
|
struct dive_site *currDs;
|
2015-09-21 14:01:58 -03:00
|
|
|
};
|
|
|
|
|
2015-05-17 16:13:41 -03:00
|
|
|
#endif
|