@@ -57,34 +57,49 @@ void QgsDatumTransformTableModel::removeTransform( const QModelIndexList &indexe
57
57
int QgsDatumTransformTableModel::rowCount ( const QModelIndex &parent ) const
58
58
{
59
59
Q_UNUSED ( parent )
60
+ #if PROJ_VERSION_MAJOR>=6
61
+ return mTransformContext .coordinateOperations ().count ();
62
+ #else
60
63
Q_NOWARN_DEPRECATED_PUSH
61
64
return mTransformContext .sourceDestinationDatumTransforms ().count ();
62
65
Q_NOWARN_DEPRECATED_POP
66
+ #endif
63
67
}
64
68
65
69
int QgsDatumTransformTableModel::columnCount ( const QModelIndex &parent ) const
66
70
{
67
71
Q_UNUSED ( parent )
72
+ #if PROJ_VERSION_MAJOR>=6
73
+ return 3 ;
74
+ #else
68
75
return 4 ;
76
+ #endif
69
77
}
70
78
71
79
QVariant QgsDatumTransformTableModel::data ( const QModelIndex &index, int role ) const
72
80
{
73
81
QString sourceCrs;
74
82
QString destinationCrs;
83
+ #if PROJ_VERSION_MAJOR>=6
84
+ QPair< QString, QString> crses = mTransformContext .coordinateOperations ().keys ().at ( index.row () );
85
+ #else
75
86
int sourceTransform = -1 ;
76
87
int destinationTransform = -1 ;
77
-
78
88
Q_NOWARN_DEPRECATED_PUSH
79
89
QPair< QString, QString> crses = mTransformContext .sourceDestinationDatumTransforms ().keys ().at ( index.row () );
80
90
Q_NOWARN_DEPRECATED_POP
91
+ #endif
81
92
sourceCrs = crses.first ;
82
93
destinationCrs = crses.second ;
94
+ #if PROJ_VERSION_MAJOR>=6
95
+ const QString proj = mTransformContext .coordinateOperations ().value ( crses );
96
+ #else
83
97
Q_NOWARN_DEPRECATED_PUSH
84
98
const QgsDatumTransform::TransformPair transforms = mTransformContext .sourceDestinationDatumTransforms ().value ( crses );
85
99
Q_NOWARN_DEPRECATED_POP
86
100
sourceTransform = transforms.sourceTransformId ;
87
101
destinationTransform = transforms.destinationTransformId ;
102
+ #endif
88
103
89
104
switch ( role )
90
105
{
@@ -100,6 +115,13 @@ QVariant QgsDatumTransformTableModel::data( const QModelIndex &index, int role )
100
115
{
101
116
case SourceCrsColumn:
102
117
return sourceCrs;
118
+ case DestinationCrsColumn:
119
+ return destinationCrs;
120
+
121
+ #if PROJ_VERSION_MAJOR>=6
122
+ case ProjDefinitionColumn:
123
+ return proj;
124
+ #else
103
125
case SourceTransformColumn:
104
126
if ( sourceTransform != -1 )
105
127
{
@@ -108,8 +130,7 @@ QVariant QgsDatumTransformTableModel::data( const QModelIndex &index, int role )
108
130
Q_NOWARN_DEPRECATED_POP
109
131
}
110
132
break ;
111
- case DestinationCrsColumn:
112
- return destinationCrs;
133
+
113
134
case DestinationTransformColumn:
114
135
if ( destinationTransform != -1 )
115
136
{
@@ -118,11 +139,16 @@ QVariant QgsDatumTransformTableModel::data( const QModelIndex &index, int role )
118
139
Q_NOWARN_DEPRECATED_POP
119
140
}
120
141
break ;
142
+ #endif
143
+
121
144
default :
122
145
break ;
123
146
}
124
147
break ;
125
148
case Qt::UserRole:
149
+ #if PROJ_VERSION_MAJOR>=6
150
+ return proj;
151
+ #else
126
152
switch ( index.column () )
127
153
{
128
154
case SourceTransformColumn:
@@ -133,6 +159,7 @@ QVariant QgsDatumTransformTableModel::data( const QModelIndex &index, int role )
133
159
break ;
134
160
}
135
161
break ;
162
+ #endif
136
163
default :
137
164
break ;
138
165
}
@@ -153,12 +180,18 @@ QVariant QgsDatumTransformTableModel::headerData( int section, Qt::Orientation o
153
180
{
154
181
case SourceCrsColumn :
155
182
return tr ( " Source CRS" );
156
- case SourceTransformColumn:
157
- return tr ( " Source Datum Transform" );
158
183
case DestinationCrsColumn:
159
184
return tr ( " Destination CRS" );
185
+
186
+ #if PROJ_VERSION_MAJOR>=6
187
+ case ProjDefinitionColumn:
188
+ return tr ( " Operation" );
189
+ #else
190
+ case SourceTransformColumn:
191
+ return tr ( " Source Datum Transform" );
160
192
case DestinationTransformColumn:
161
193
return tr ( " Destination Datum Transform" );
194
+ #endif
162
195
default :
163
196
break ;
164
197
}
@@ -203,6 +236,7 @@ void QgsDatumTransformTableWidget::addDatumTransform()
203
236
Q_NOWARN_DEPRECATED_PUSH
204
237
context.addSourceDestinationDatumTransform ( dt.sourceCrs , dt.destinationCrs , dt.sourceTransformId , dt.destinationTransformId );
205
238
Q_NOWARN_DEPRECATED_POP
239
+ context.addCoordinateOperation ( dt.sourceCrs , dt.destinationCrs , dt.proj );
206
240
mModel ->setTransformContext ( context );
207
241
selectionChanged ();
208
242
}
@@ -225,6 +259,7 @@ void QgsDatumTransformTableWidget::editDatumTransform()
225
259
{
226
260
QgsCoordinateReferenceSystem sourceCrs;
227
261
QgsCoordinateReferenceSystem destinationCrs;
262
+ QString proj;
228
263
int sourceTransform = -1 ;
229
264
int destinationTransform = -1 ;
230
265
for ( QModelIndexList::const_iterator it = selectedIndexes.constBegin (); it != selectedIndexes.constEnd (); it ++ )
@@ -237,20 +272,31 @@ void QgsDatumTransformTableWidget::editDatumTransform()
237
272
case QgsDatumTransformTableModel::DestinationCrsColumn:
238
273
destinationCrs = QgsCoordinateReferenceSystem ( mModel ->data ( *it, Qt::DisplayRole ).toString () );
239
274
break ;
275
+ #if PROJ_VERSION_MAJOR>=6
276
+ case QgsDatumTransformTableModel::ProjDefinitionColumn:
277
+ proj = mModel ->data ( *it, Qt::UserRole ).toString ();
278
+ break ;
279
+ #else
240
280
case QgsDatumTransformTableModel::SourceTransformColumn:
241
281
sourceTransform = mModel ->data ( *it, Qt::UserRole ).toInt ();
242
282
break ;
243
283
case QgsDatumTransformTableModel::DestinationTransformColumn:
244
284
destinationTransform = mModel ->data ( *it, Qt::UserRole ).toInt ();
245
285
break ;
286
+ #endif
246
287
default :
247
288
break ;
248
289
}
249
290
}
291
+
292
+ #if PROJ_VERSION_MAJOR>=6
293
+ if ( sourceCrs.isValid () && destinationCrs.isValid () && !proj.isEmpty () )
294
+ #else
250
295
if ( sourceCrs.isValid () && destinationCrs.isValid () &&
251
296
( sourceTransform != -1 || destinationTransform != -1 ) )
297
+ #endif
252
298
{
253
- QgsDatumTransformDialog dlg ( sourceCrs, destinationCrs, true , false , false , qMakePair ( sourceTransform, destinationTransform ) );
299
+ QgsDatumTransformDialog dlg ( sourceCrs, destinationCrs, true , false , false , qMakePair ( sourceTransform, destinationTransform ), nullptr , nullptr , proj );
254
300
if ( dlg.exec () )
255
301
{
256
302
const QgsDatumTransformDialog::TransformInfo dt = dlg.selectedDatumTransform ();
@@ -259,6 +305,7 @@ void QgsDatumTransformTableWidget::editDatumTransform()
259
305
Q_NOWARN_DEPRECATED_PUSH
260
306
context.addSourceDestinationDatumTransform ( sourceCrs, destinationCrs, dt.sourceTransformId , dt.destinationTransformId );
261
307
Q_NOWARN_DEPRECATED_POP
308
+ context.addCoordinateOperation ( sourceCrs, destinationCrs, dt.proj );
262
309
mModel ->setTransformContext ( context );
263
310
}
264
311
}
0 commit comments