26 : QDialog( parent, f )
28 , mLayerName( layerName )
32 QApplication::setOverrideCursor( Qt::ArrowCursor );
37 restoreGeometry( settings.value(
"/Windows/DatumTransformDialog/geometry" ).toByteArray() );
38 mHideDeprecatedCheckBox->setChecked( settings.value(
"/Windows/DatumTransformDialog/hideDeprecated",
false ).toBool() );
39 mRememberSelectionCheckBox->setChecked( settings.value(
"/Windows/DatumTransformDialog/rememberSelection",
false ).toBool() );
41 mLabelSrcDescription->setText(
"" );
42 mLabelDstDescription->setText(
"" );
44 for (
int i = 0; i < 2; i++ )
46 mDatumTransformTreeWidget->setColumnWidth( i, settings.value( QString(
"/Windows/DatumTransformDialog/columnWidths/%1" ).arg( i ), mDatumTransformTreeWidget->columnWidth( i ) ).toInt() );
52 void QgsDatumTransformDialog::load()
56 mDatumTransformTreeWidget->clear();
58 QList< QList< int > >::const_iterator it = mDt.constBegin();
59 for ( ; it != mDt.constEnd(); ++it )
61 QTreeWidgetItem *item =
new QTreeWidgetItem();
62 bool itemDisabled =
false;
63 bool itemHidden =
false;
65 for (
int i = 0; i < 2 && i < it->size(); ++i )
68 item->setData( i, Qt::UserRole, nr );
75 QString srcGeoProj, destGeoProj, remarks, scope;
77 bool preferred, deprecated;
81 if ( mHideDeprecatedCheckBox->isChecked() && deprecated )
86 QString toolTipString;
87 if ( gridShiftTransformation( item->text( i ) ) )
89 toolTipString.append( QString(
"<p><b>NTv2</b></p>" ) );
93 toolTipString.append( QString(
"<p><b>EPSG Transformations Code:</b> %1</p>" ).arg( epsgNr ) );
95 toolTipString.append( QString(
"<p><b>Source CRS:</b> %1</p><p><b>Destination CRS:</b> %2</p>" ).arg( srcGeoProj ).arg( destGeoProj ) );
97 if ( !remarks.isEmpty() )
98 toolTipString.append( QString(
"<p><b>Remarks:</b> %1</p>" ).arg( remarks ) );
99 if ( !scope.isEmpty() )
100 toolTipString.append( QString(
"<p><b>Scope:</b> %1</p>" ).arg( scope ) );
102 toolTipString.append(
"<p><b>Preferred transformation</b></p>" );
104 toolTipString.append(
"<p><b>Deprecated transformation</b></p>" );
106 item->setToolTip( i, toolTipString );
108 if ( gridShiftTransformation( item->text( i ) ) && !testGridShiftFileAvailability( item, i ) )
116 item->setDisabled( itemDisabled );
117 mDatumTransformTreeWidget->addTopLevelItem( item );
129 settings.setValue(
"/Windows/DatumTransformDialog/geometry", saveGeometry() );
130 settings.setValue(
"/Windows/DatumTransformDialog/hideDeprecated", mHideDeprecatedCheckBox->isChecked() );
131 settings.setValue(
"/Windows/DatumTransformDialog/rememberSelection", mRememberSelectionCheckBox->isChecked() );
133 for (
int i = 0; i < 2; i++ )
135 settings.setValue( QString(
"/Windows/DatumTransformDialog/columnWidths/%1" ).arg( i ), mDatumTransformTreeWidget->columnWidth( i ) );
138 QApplication::restoreOverrideCursor();
143 mSrcCRSauthId = srcCRSauthId;
144 mDestCRSauthId = destCRSauthId;
151 QTreeWidgetItem * item = mDatumTransformTreeWidget->currentItem();
154 for (
int i = 0; i < 2; ++i )
156 int transformNr = item->data( i, Qt::UserRole ).toInt();
165 return mRememberSelectionCheckBox->isChecked();
168 bool QgsDatumTransformDialog::gridShiftTransformation(
const QString& itemText )
const
170 return !itemText.isEmpty() && !itemText.contains(
"towgs84", Qt::CaseInsensitive );
173 bool QgsDatumTransformDialog::testGridShiftFileAvailability( QTreeWidgetItem* item,
int col )
const
180 QString itemText = item->text( col );
181 if ( itemText.isEmpty() )
186 char* projLib = getenv(
"PROJ_LIB" );
192 QStringList itemEqualSplit = itemText.split(
"=" );
194 for (
int i = 1; i < itemEqualSplit.size(); ++i )
198 filename.append(
"=" );
200 filename.append( itemEqualSplit.at( i ) );
203 QDir projDir( projLib );
204 if ( projDir.exists() )
207 QStringList fileList = projDir.entryList();
208 QStringList::const_iterator fileIt = fileList.constBegin();
209 for ( ; fileIt != fileList.constEnd(); ++fileIt )
211 #if defined(Q_OS_WIN)
212 if ( fileIt->compare( filename, Qt::CaseInsensitive ) == 0 )
214 if ( fileIt->compare( filename ) == 0 )
220 item->setToolTip( col,
tr(
"File '%1' not found in directory '%2'" ).arg( filename ).arg( projDir.absolutePath() ) );
233 mLabelSrcDescription->setText( current->toolTip( 0 ) );
234 mLabelDstDescription->setText( current->toolTip( 1 ) );
237 void QgsDatumTransformDialog::updateTitle()
239 mLabelLayer->setText( mLayerName );
242 mLabelSrcCrs->setText( QString(
"%1 - %2" ).arg( mSrcCRSauthId ).arg( crs.
isValid() ? crs.
description() :
tr(
"unknown" ) ) );
244 mLabelDstCrs->setText( QString(
"%1 - %2" ).arg( mDestCRSauthId ).arg( crs.
isValid() ? crs.
description() :
tr(
"unknown" ) ) );