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
|
|
|
|
|
|
|
|
#include "ui_locationInformation.h"
|
|
|
|
#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 {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
LocationInformationWidget(QWidget *parent = 0);
|
2018-09-29 20:13:44 +00:00
|
|
|
bool eventFilter(QObject*, QEvent*) override;
|
2015-09-01 00:11:28 +00:00
|
|
|
|
2015-05-17 20:14:23 +00:00
|
|
|
protected:
|
|
|
|
void showEvent(QShowEvent *);
|
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();
|
2015-06-04 02:50:36 +00:00
|
|
|
void updateGpsCoordinates();
|
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);
|
|
|
|
void on_diveSiteDescription_textChanged(const QString& text);
|
|
|
|
void on_diveSiteName_textChanged(const QString& text);
|
|
|
|
void on_diveSiteNotes_textChanged();
|
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();
|
2015-05-17 19:13:41 +00:00
|
|
|
signals:
|
2015-06-04 02:50:36 +00:00
|
|
|
void startEditDiveSite(uint32_t uuid);
|
|
|
|
void endEditDiveSite();
|
2015-05-26 20:36:06 +00:00
|
|
|
void startFilterDiveSite(uint32_t uuid);
|
2015-05-26 20:42:45 +00:00
|
|
|
void stopFilterDiveSite();
|
2015-07-31 01:10:01 +00:00
|
|
|
void requestCoordinates();
|
|
|
|
void endRequestCoordinates();
|
2017-11-26 09:42:22 +00:00
|
|
|
void nameChanged(const QString &oldName, const QString &newName);
|
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;
|
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;
|
|
|
|
uint32_t currDiveSiteUuid() const;
|
2015-09-23 19:03:28 +00:00
|
|
|
void fixPopupPosition();
|
2015-09-25 17:51:10 +00:00
|
|
|
void setCurrentDiveSiteUuid(uint32_t uuid);
|
2015-09-25 16:11:44 +00:00
|
|
|
|
2015-09-23 17:46:29 +00:00
|
|
|
signals:
|
|
|
|
void diveSiteSelected(uint32_t uuid);
|
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;
|
|
|
|
uint32_t currUuid;
|
2015-09-21 17:01:58 +00:00
|
|
|
};
|
|
|
|
|
2015-05-17 19:13:41 +00:00
|
|
|
#endif
|