/
qgsdatumtransformtablewidget.h
115 lines (89 loc) · 3.38 KB
/
qgsdatumtransformtablewidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/***************************************************************************
qgsdatumtransformtablewidget.h
--------------------------------------
Date : 28.11.2017
Copyright : (C) 2017 Denis Rouzaud
Email : denis.rouzaud@gmail.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSDATUMTRANSFORMTABLEWIDGET_H
#define QGSDATUMTRANSFORMTABLEWIDGET_H
#include <QAbstractTableModel>
#include <QWidget>
#include "ui_qgsdatumtransformtablewidgetbase.h"
#include "qgis_app.h"
#include "qgscoordinatetransformcontext.h"
/**
* The QgsDatumTransformTableModel class is a table model to display and edit
* datum transformations.
*
* \since 3.0
*/
class APP_EXPORT QgsDatumTransformTableModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum TableColumns
{
#if PROJ_VERSION_MAJOR>=6
SourceCrsColumn = 0,
DestinationCrsColumn,
ProjDefinitionColumn,
AllowFallbackColumn,
#else
SourceCrsColumn = 0,
SourceTransformColumn,
DestinationCrsColumn,
DestinationTransformColumn,
#endif
};
QgsDatumTransformTableModel( QObject *parent = nullptr );
void setTransformContext( const QgsCoordinateTransformContext &context );
QgsCoordinateTransformContext transformContext() const
{
return mTransformContext;
}
/**
* remove the transformation at given indexes
*/
void removeTransform( const QModelIndexList &indexes );
int rowCount( const QModelIndex &parent ) const override;
int columnCount( const QModelIndex &parent ) const override;
QVariant data( const QModelIndex &index, int role ) const override;
QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
private:
QgsCoordinateTransformContext mTransformContext;
};
class APP_EXPORT QgsDatumTransformTableWidget : public QWidget, private Ui::QgsDatumTransformTableWidgetBase
{
Q_OBJECT
public:
explicit QgsDatumTransformTableWidget( QWidget *parent = nullptr );
~QgsDatumTransformTableWidget() override;
void setTransformContext( const QgsCoordinateTransformContext &context )
{
mModel->setTransformContext( context );
}
QgsCoordinateTransformContext transformContext() const
{
return mModel->transformContext();
}
public slots:
//! add a new datum transform
void addDatumTransform();
//! remove currently selected datum transform
void removeDatumTransform();
//! edit currently selected datum transform
void editDatumTransform( const QModelIndex &index );
private slots:
void selectionChanged( const QItemSelection &selected = QItemSelection(), const QItemSelection &deselected = QItemSelection() );
private:
QgsDatumTransformTableModel *mModel = nullptr;
};
#endif // QGSDATUMTRANSFORMTABLEWIDGET_H