QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsowssourceselect.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsowssourceselect.cpp - selector for WMS,WFS,WCS
3  -------------------
4  begin : 3 April 2005
5  copyright :
6  original : (C) 2005 by Brendan Morley email : morb at ozemail dot com dot au
7  wms search : (C) 2009 Mathias Walker <mwa at sourcepole.ch>, Sourcepole AG
8  wms-c support : (C) 2010 Juergen E. Fischer < jef at norbit dot de >, norBIT GmbH
9 
10  generalized : (C) 2012 Radim Blazek, based on qgswmssourceselect.cpp
11 
12  ***************************************************************************/
13 
14 /***************************************************************************
15  * *
16  * This program is free software; you can redistribute it and/or modify *
17  * it under the terms of the GNU General Public License as published by *
18  * the Free Software Foundation; either version 2 of the License, or *
19  * (at your option) any later version. *
20  * *
21  ***************************************************************************/
22 
23 #include "qgis.h" // GEO_EPSG_CRS_ID
25 #include "qgsdatasourceuri.h"
27 #include "qgslogger.h"
29 #include "qgsmessageviewer.h"
30 #include "qgsnewhttpconnection.h"
31 #include "qgstreewidgetitem.h"
32 #include "qgsproject.h"
33 #include "qgsproviderregistry.h"
34 #include "qgsowsconnection.h"
35 #include "qgsdataprovider.h"
36 #include "qgsowssourceselect.h"
38 #include "qgsapplication.h"
39 #include "qgssettings.h"
40 #include "qgsgui.h"
41 
42 #include <QButtonGroup>
43 #include <QFileDialog>
44 #include <QRadioButton>
45 #include <QDomDocument>
46 #include <QHeaderView>
47 #include <QImageReader>
48 #include <QInputDialog>
49 #include <QMap>
50 #include <QMessageBox>
51 #include <QPicture>
52 #include <QUrl>
53 #include <QValidator>
54 #include <QNetworkRequest>
55 #include <QNetworkReply>
56 
57 QgsOWSSourceSelect::QgsOWSSourceSelect( const QString &service, QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode theWidgetMode )
58  : QgsAbstractDataSourceWidget( parent, fl, theWidgetMode )
59  , mService( service )
60 
61 {
62  setupUi( this );
64  connect( mNewButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mNewButton_clicked );
65  connect( mEditButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mEditButton_clicked );
66  connect( mDeleteButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mDeleteButton_clicked );
67  connect( mSaveButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mSaveButton_clicked );
68  connect( mLoadButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mLoadButton_clicked );
69  connect( mConnectButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mConnectButton_clicked );
70  connect( mChangeCRSButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mChangeCRSButton_clicked );
71  connect( mLayersTreeWidget, &QTreeWidget::itemSelectionChanged, this, &QgsOWSSourceSelect::mLayersTreeWidget_itemSelectionChanged );
72  connect( mConnectionsComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsOWSSourceSelect::mConnectionsComboBox_activated );
73  connect( mAddDefaultButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mAddDefaultButton_clicked );
74  connect( mTilesetsTableWidget, &QTableWidget::itemClicked, this, &QgsOWSSourceSelect::mTilesetsTableWidget_itemClicked );
75  connect( mLayerUpButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mLayerUpButton_clicked );
76  connect( mLayerDownButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mLayerDownButton_clicked );
77  setupButtons( buttonBox );
78 
79 
80  setWindowTitle( tr( "Add Layer(s) from a %1 Server" ).arg( service ) );
81 
82  clearCrs();
83 
84  mTileWidthLineEdit->setValidator( new QIntValidator( 0, 9999, this ) );
85  mTileHeightLineEdit->setValidator( new QIntValidator( 0, 9999, this ) );
86  mFeatureCountLineEdit->setValidator( new QIntValidator( 0, 9999, this ) );
87 
88  mCacheComboBox->addItem( tr( "Always Cache" ), QNetworkRequest::AlwaysCache );
89  mCacheComboBox->addItem( tr( "Prefer Cache" ), QNetworkRequest::PreferCache );
90  mCacheComboBox->addItem( tr( "Prefer Network" ), QNetworkRequest::PreferNetwork );
91  mCacheComboBox->addItem( tr( "Always Network" ), QNetworkRequest::AlwaysNetwork );
92 
93  // 'Prefer network' is the default noted in the combobox's tool tip
94  mCacheComboBox->setCurrentIndex( mCacheComboBox->findData( QNetworkRequest::PreferNetwork ) );
95 
96  if ( widgetMode() != QgsProviderRegistry::WidgetMode::Manager )
97  {
98  //set the current project CRS if available
100  //convert CRS id to epsg
101  if ( currentRefSys.isValid() )
102  {
103  mSelectedCRS = currentRefSys.authid();
104  }
105  }
106  else
107  {
108  mTabWidget->removeTab( mTabWidget->indexOf( mLayerOrderTab ) );
109  mTabWidget->removeTab( mTabWidget->indexOf( mTilesetsTab ) );
110  mTimeWidget->hide();
111  mFormatWidget->hide();
112  mCRSWidget->hide();
113  mCacheWidget->hide();
114  }
115 
116  // set up the WMS connections we already know about
118 }
119 
121 {
123 }
124 
126 {
127  mLayersTreeWidget->clearSelection();
128 }
129 
131 {
132  mFormatComboBox->clear();
133  mFormatComboBox->setEnabled( false );
134 }
135 
137 {
138 
139  // A server may offer more similar formats, which are mapped
140  // to the same GDAL format, e.g. GeoTIFF and TIFF
141  // -> recreate always buttons for all available formats, enable supported
142 
143  clearFormats();
144 
145  if ( mProviderFormats.isEmpty() )
146  {
147  mProviderFormats = providerFormats();
148  for ( int i = 0; i < mProviderFormats.size(); i++ )
149  {
150  // GDAL mime types may be image/tiff, image/png, ...
151  mMimeLabelMap.insert( mProviderFormats[i].format, mProviderFormats[i].label );
152  }
153  }
154 
155  // selectedLayersFormats may come in various forms:
156  // image/tiff, GTiff, GeoTIFF, TIFF, geotiff_int16, geotiff_rgb,
157  // PNG, GTOPO30, ARCGRID, IMAGEMOSAIC
158  // and even any string defined in server configuration, for example the
159  // value used in UMN Mapserver for OUTPUTFORMAT->NAME is used in
160  // WCS 1.0.0 SupportedFormats/Format
161 
162  // TODO: It is impossible to cover all possible formats coming from server
163  // -> enabled all formats, GDAL may be able to open them
164 
165  QMap<QString, QString> formatsMap;
166  formatsMap.insert( QStringLiteral( "geotiff" ), QStringLiteral( "tiff" ) );
167  formatsMap.insert( QStringLiteral( "gtiff" ), QStringLiteral( "tiff" ) );
168  formatsMap.insert( QStringLiteral( "tiff" ), QStringLiteral( "tiff" ) );
169  formatsMap.insert( QStringLiteral( "tif" ), QStringLiteral( "tiff" ) );
170  formatsMap.insert( QStringLiteral( "gif" ), QStringLiteral( "gif" ) );
171  formatsMap.insert( QStringLiteral( "jpeg" ), QStringLiteral( "jpeg" ) );
172  formatsMap.insert( QStringLiteral( "jpg" ), QStringLiteral( "jpeg" ) );
173  formatsMap.insert( QStringLiteral( "png" ), QStringLiteral( "png" ) );
174 
175  int preferred = -1;
176  QStringList layersFormats = selectedLayersFormats();
177  for ( int i = 0; i < layersFormats.size(); i++ )
178  {
179  QString format = layersFormats.value( i );
180  QgsDebugMsg( "server format = " + format );
181  QString simpleFormat = format.toLower().remove( QStringLiteral( "image/" ) ).remove( QRegExp( "_.*" ) );
182  QgsDebugMsg( "server simpleFormat = " + simpleFormat );
183  QString mimeFormat = "image/" + formatsMap.value( simpleFormat );
184  QgsDebugMsg( "server mimeFormat = " + mimeFormat );
185 
186  QString label = format;
187 
188  if ( mMimeLabelMap.contains( mimeFormat ) )
189  {
190  if ( format != mMimeLabelMap.value( mimeFormat ) )
191  {
192  // Append name of GDAL driver
193  label += " / " + mMimeLabelMap.value( mimeFormat );
194  }
195 
196  if ( simpleFormat.contains( QLatin1String( "tif" ) ) ) // prefer *tif*
197  {
198  if ( preferred < 0 || simpleFormat.startsWith( 'g' ) ) // prefer geotiff
199  {
200  preferred = i;
201  }
202  }
203  }
204  else
205  {
206  // We cannot always say that the format is not supported by GDAL because
207  // server can use strange names, but format itself is supported
208  QgsDebugMsg( QStringLiteral( "format %1 unknown" ).arg( format ) );
209  }
210 
211  mFormatComboBox->insertItem( i, label );
212  }
213  // Set preferred
214  // TODO: all enabled for now, see above
215  preferred = preferred >= 0 ? preferred : 0;
216  mFormatComboBox->setCurrentIndex( preferred );
217 
218  mFormatComboBox->setEnabled( true );
219 }
220 
222 {
223  mTimeComboBox->clear();
224  mTimeComboBox->insertItems( 0, selectedLayersTimes() );
225  mTimeComboBox->setEnabled( !selectedLayersTimes().isEmpty() );
226 }
227 
229 {
230  mTimeComboBox->clear();
231  mTimeComboBox->setEnabled( false );
232 }
233 
235 {
236  mConnectionsComboBox->clear();
237  mConnectionsComboBox->addItems( QgsOwsConnection::connectionList( mService ) );
238 
240 }
241 
243 {
244  if ( string.compare( QLatin1String( "wms" ), Qt::CaseInsensitive ) == 0 )
246  else if ( string.compare( QLatin1String( "wfs" ), Qt::CaseInsensitive ) == 0 )
248  else if ( string.compare( QLatin1String( "wcs" ), Qt::CaseInsensitive ) == 0 )
250  else
252 }
253 
254 void QgsOWSSourceSelect::mNewButton_clicked()
255 {
257  QgsNewHttpConnection *nc = new QgsNewHttpConnection( this, type, "/qgis/connections-" + mService.toLower() + '/' );
258 
259  if ( nc->exec() )
260  {
262  emit connectionsChanged();
263  }
264 
265  delete nc;
266 }
267 
268 void QgsOWSSourceSelect::mEditButton_clicked()
269 {
271  QgsNewHttpConnection *nc = new QgsNewHttpConnection( this, type, "/qgis/connections-" + mService.toLower() + '/', mConnectionsComboBox->currentText() );
272 
273  if ( nc->exec() )
274  {
276  emit connectionsChanged();
277  }
278 
279  delete nc;
280 }
281 
282 void QgsOWSSourceSelect::mDeleteButton_clicked()
283 {
284  QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
285  .arg( mConnectionsComboBox->currentText() );
286  QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Delete Connection" ), msg, QMessageBox::Yes | QMessageBox::No );
287  if ( result == QMessageBox::Yes )
288  {
289  QgsOwsConnection::deleteConnection( mService, mConnectionsComboBox->currentText() );
290  mConnectionsComboBox->removeItem( mConnectionsComboBox->currentIndex() ); // populateConnectionList();
292  emit connectionsChanged();
293  }
294 }
295 
296 void QgsOWSSourceSelect::mSaveButton_clicked()
297 {
299  dlg.exec();
300 }
301 
302 void QgsOWSSourceSelect::mLoadButton_clicked()
303 {
304  QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QDir::homePath(),
305  tr( "XML files (*.xml *.XML)" ) );
306  if ( fileName.isEmpty() )
307  {
308  return;
309  }
310 
312  dlg.exec();
314  emit connectionsChanged();
315 }
316 
318  int id,
319  const QStringList &names,
320  QMap<int, QgsTreeWidgetItem *> &items,
321  int &layerAndStyleCount,
322  const QMap<int, int> &layerParents,
323  const QMap<int, QStringList> &layerParentNames )
324 {
325  QgsDebugMsg( QStringLiteral( "id = %1 layerAndStyleCount = %2 names = %3 " ).arg( id ).arg( layerAndStyleCount ).arg( names.join( "," ) ) );
326  if ( items.contains( id ) )
327  return items[id];
328 
329 
330  QgsTreeWidgetItem *item = nullptr;
331  if ( layerParents.contains( id ) )
332  {
333  // it has parent -> create first its parent
334  int parent = layerParents[ id ];
335  item = new QgsTreeWidgetItem( createItem( parent, layerParentNames[ parent ], items, layerAndStyleCount, layerParents, layerParentNames ) );
336  }
337  else
338  item = new QgsTreeWidgetItem( mLayersTreeWidget );
339 
340  item->setText( 0, QString::number( ++layerAndStyleCount ) );
341  item->setText( 1, names[0].simplified() );
342  item->setText( 2, names[1].simplified() );
343  item->setText( 3, names[2].simplified() );
344  item->setToolTip( 3, "<font color=black>" + names[2].simplified() + "</font>" );
345 
346  items[ id ] = item;
347 
348  return item;
349 }
350 
352 {
353 }
354 
355 void QgsOWSSourceSelect::mConnectButton_clicked()
356 {
357 
358  mLayersTreeWidget->clear();
359  clearFormats();
360  clearTimes();
361  clearCrs();
362 
363  mConnName = mConnectionsComboBox->currentText();
364 
365  QgsOwsConnection connection( mService, mConnectionsComboBox->currentText() );
366  mUri = connection.uri();
367 
368  QApplication::setOverrideCursor( Qt::WaitCursor );
369 
370  QgsDebugMsg( QStringLiteral( "call populateLayerList" ) );
372 
373  QApplication::restoreOverrideCursor();
374 }
375 
376 void QgsOWSSourceSelect::enableLayersForCrs( QTreeWidgetItem * )
377 {
378 }
379 
380 void QgsOWSSourceSelect::mChangeCRSButton_clicked()
381 {
382  QStringList layers;
383  const auto constSelectedItems = mLayersTreeWidget->selectedItems();
384  for ( QTreeWidgetItem *item : constSelectedItems )
385  {
386  QString layer = item->data( 0, Qt::UserRole + 0 ).toString();
387  if ( !layer.isEmpty() )
388  layers << layer;
389  }
390 
392  mySelector->setOgcWmsCrsFilter( mSelectedLayersCRSs );
393 
395  if ( defaultCRS.isValid() )
396  {
397  mySelector->setCrs( defaultCRS );
398  }
399  else
400  {
401  mySelector->showNoCrsForLayerMessage();
402  }
403 
404  if ( !mySelector->exec() )
405  return;
406 
407  mSelectedCRS = mySelector->crs().authid();
408  delete mySelector;
409 
410  mSelectedCRSLabel->setText( descriptionForAuthId( mSelectedCRS ) );
411 
412  for ( int i = 0; i < mLayersTreeWidget->topLevelItemCount(); i++ )
413  {
414  enableLayersForCrs( mLayersTreeWidget->topLevelItem( i ) );
415  }
416 
417  updateButtons();
418 }
419 
420 void QgsOWSSourceSelect::mLayersTreeWidget_itemSelectionChanged()
421 {
422 }
423 
425 {
426  clearCrs();
427  mSelectedLayersCRSs = qgis::listToSet( selectedLayersCrses() );
428  mCRSLabel->setText( tr( "Coordinate Reference System (%n available)", "crs count", mSelectedLayersCRSs.count() ) + ':' );
429 
430  mChangeCRSButton->setDisabled( mSelectedLayersCRSs.isEmpty() );
431 
432  if ( !mSelectedLayersCRSs.isEmpty() )
433  {
434  // check whether current CRS is supported
435  // if not, use one of the available CRS
436  QString defaultCRS;
437  QSet<QString>::const_iterator it = mSelectedLayersCRSs.constBegin();
438  for ( ; it != mSelectedLayersCRSs.constEnd(); ++it )
439  {
440  if ( it->compare( mSelectedCRS, Qt::CaseInsensitive ) == 0 )
441  break;
442 
443  // save first CRS in case the current CRS is not available
444  if ( it == mSelectedLayersCRSs.constBegin() )
445  defaultCRS = *it;
446 
447  // prefer value of DEFAULT_GEO_EPSG_CRS_ID if available
448  if ( *it == geoEpsgCrsAuthId() )
449  defaultCRS = *it;
450  }
451 
452  if ( it == mSelectedLayersCRSs.constEnd() )
453  {
454  // not found
455  mSelectedCRS = defaultCRS;
456  }
457  mSelectedCRSLabel->setText( descriptionForAuthId( mSelectedCRS ) );
458  mChangeCRSButton->setEnabled( true );
459  }
460  QgsDebugMsg( "mSelectedCRS = " + mSelectedCRS );
461 }
462 
464 {
465  mCRSLabel->setText( tr( "Coordinate Reference System" ) + ':' );
466  mSelectedCRS.clear();
467  mSelectedCRSLabel->clear();
468  mChangeCRSButton->setEnabled( false );
469 }
470 
471 void QgsOWSSourceSelect::mTilesetsTableWidget_itemClicked( QTableWidgetItem *item )
472 {
473  Q_UNUSED( item )
474 
475  QTableWidgetItem *rowItem = mTilesetsTableWidget->item( mTilesetsTableWidget->currentRow(), 0 );
476  bool wasSelected = mCurrentTileset == rowItem;
477 
478  mTilesetsTableWidget->blockSignals( true );
479  mTilesetsTableWidget->clearSelection();
480  if ( !wasSelected )
481  {
482  QgsDebugMsg( QStringLiteral( "selecting current row %1" ).arg( mTilesetsTableWidget->currentRow() ) );
483  mTilesetsTableWidget->selectRow( mTilesetsTableWidget->currentRow() );
484  mCurrentTileset = rowItem;
485  }
486  else
487  {
488  mCurrentTileset = nullptr;
489  }
490  mTilesetsTableWidget->blockSignals( false );
491 
492  updateButtons();
493 }
494 
495 
496 
498 {
499  return mConnName;
500 }
501 
503 {
504  return mConnectionInfo;
505 }
506 
508 {
509  return selectedLayersFormats().value( mFormatComboBox->currentIndex() );
510 }
511 
512 QNetworkRequest::CacheLoadControl QgsOWSSourceSelect::selectedCacheLoadControl()
513 {
514  int cache = mCacheComboBox->currentData().toInt();
515  return static_cast<QNetworkRequest::CacheLoadControl>( cache );
516 }
517 
519 {
520  return mSelectedCRS;
521 }
522 
524 {
525  return mTimeComboBox->currentText();
526 }
527 
529 {
530  QString toSelect = QgsOwsConnection::selectedConnection( mService );
531 
532  mConnectionsComboBox->setCurrentIndex( mConnectionsComboBox->findText( toSelect ) );
533 
534  if ( mConnectionsComboBox->currentIndex() < 0 )
535  {
536  if ( toSelect.isNull() )
537  mConnectionsComboBox->setCurrentIndex( 0 );
538  else
539  mConnectionsComboBox->setCurrentIndex( mConnectionsComboBox->count() - 1 );
540  }
541 
542  if ( mConnectionsComboBox->count() == 0 )
543  {
544  // No connections - disable various buttons
545  mConnectButton->setEnabled( false );
546  mEditButton->setEnabled( false );
547  mDeleteButton->setEnabled( false );
548  mSaveButton->setEnabled( false );
549  }
550  else
551  {
552  // Connections - enable various buttons
553  mConnectButton->setEnabled( true );
554  mEditButton->setEnabled( true );
555  mDeleteButton->setEnabled( true );
556  mSaveButton->setEnabled( true );
557  }
558 
559  QgsOwsConnection::setSelectedConnection( mService, mConnectionsComboBox->currentText() );
560 }
561 
562 void QgsOWSSourceSelect::showStatusMessage( QString const &message )
563 {
564  mStatusLabel->setText( message );
565 
566  // update the display of this widget
567  update();
568 }
569 
570 
571 void QgsOWSSourceSelect::showError( QString const &title, QString const &format, QString const &error )
572 {
573  QgsMessageViewer *mv = new QgsMessageViewer( this );
574  mv->setWindowTitle( title );
575 
576  if ( format == QLatin1String( "text/html" ) )
577  {
578  mv->setMessageAsHtml( error );
579  }
580  else
581  {
582  mv->setMessageAsPlainText( tr( "Could not understand the response:\n%1" ).arg( error ) );
583  }
584  mv->showMessage( true ); // Is deleted when closed
585 }
586 
587 void QgsOWSSourceSelect::mConnectionsComboBox_activated( int )
588 {
589  // Remember which server was selected.
590  QgsOwsConnection::setSelectedConnection( mService, mConnectionsComboBox->currentText() );
591 }
592 
593 void QgsOWSSourceSelect::mAddDefaultButton_clicked()
594 {
596 }
597 
598 QString QgsOWSSourceSelect::descriptionForAuthId( const QString &authId )
599 {
600  if ( mCrsNames.contains( authId ) )
601  return mCrsNames[ authId ];
602 
604  mCrsNames.insert( authId, qgisSrs.userFriendlyIdentifier() );
605  return qgisSrs.userFriendlyIdentifier();
606 }
607 
609 {
610  QMap<QString, QString> exampleServers;
611  exampleServers[QStringLiteral( "DM Solutions GMap" )] = QStringLiteral( "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap" );
612  exampleServers[QStringLiteral( "Lizardtech server" )] = QStringLiteral( "http://wms.lizardtech.com/lizardtech/iserv/ows" );
613  // Nice to have the qgis users map, but I'm not sure of the URL at the moment.
614  // exampleServers["Qgis users map"] = "http://qgis.org/wms.cgi";
615 
616  QgsSettings settings;
617  settings.beginGroup( "/qgis/connections-" + mService.toLower() );
618  QMap<QString, QString>::const_iterator i = exampleServers.constBegin();
619  for ( ; i != exampleServers.constEnd(); ++i )
620  {
621  // Only do a server if it's name doesn't already exist.
622  QStringList keys = settings.childGroups();
623  if ( !keys.contains( i.key() ) )
624  {
625  QString path = i.key();
626  settings.setValue( path + "/url", i.value() );
627  }
628  }
629  settings.endGroup();
631 
632  QMessageBox::information( this, tr( "Add WMS Servers" ), "<p>" + tr( "Several WMS servers have "
633  "been added to the server list. Note that if "
634  "you access the Internet via a web proxy, you will "
635  "need to set the proxy settings in the QGIS options dialog." ) + "</p>" );
636 }
637 
638 void QgsOWSSourceSelect::mLayerUpButton_clicked()
639 {
640  QList<QTreeWidgetItem *> selectionList = mLayerOrderTreeWidget->selectedItems();
641  if ( selectionList.empty() )
642  {
643  return;
644  }
645  int selectedIndex = mLayerOrderTreeWidget->indexOfTopLevelItem( selectionList[0] );
646  if ( selectedIndex < 1 )
647  {
648  return; //item not existing or already on top
649  }
650 
651  QTreeWidgetItem *selectedItem = mLayerOrderTreeWidget->takeTopLevelItem( selectedIndex );
652  mLayerOrderTreeWidget->insertTopLevelItem( selectedIndex - 1, selectedItem );
653  mLayerOrderTreeWidget->clearSelection();
654  selectedItem->setSelected( true );
655 }
656 
657 void QgsOWSSourceSelect::mLayerDownButton_clicked()
658 {
659  QList<QTreeWidgetItem *> selectionList = mLayerOrderTreeWidget->selectedItems();
660  if ( selectionList.empty() )
661  {
662  return;
663  }
664  int selectedIndex = mLayerOrderTreeWidget->indexOfTopLevelItem( selectionList[0] );
665  if ( selectedIndex < 0 || selectedIndex > mLayerOrderTreeWidget->topLevelItemCount() - 2 )
666  {
667  return; //item not existing or already at bottom
668  }
669 
670  QTreeWidgetItem *selectedItem = mLayerOrderTreeWidget->takeTopLevelItem( selectedIndex );
671  mLayerOrderTreeWidget->insertTopLevelItem( selectedIndex + 1, selectedItem );
672  mLayerOrderTreeWidget->clearSelection();
673  selectedItem->setSelected( true );
674 }
675 
676 QList<QgsOWSSourceSelect::SupportedFormat> QgsOWSSourceSelect::providerFormats()
677 {
678  return QList<SupportedFormat>();
679 }
680 
682 {
683  return QStringList();
684 }
685 
687 {
688  return QStringList();
689 }
690 
692 {
693  return QStringList();
694 }
695 
696 void QgsOWSSourceSelect::updateButtons()
697 {
698 }
QgsOWSSourceSelect::refresh
void refresh() override
Triggered when the provider's connections need to be refreshed.
Definition: qgsowssourceselect.cpp:120
QgsOWSSourceSelect::createItem
QgsTreeWidgetItem * createItem(int id, const QStringList &names, QMap< int, QgsTreeWidgetItem * > &items, int &layerAndStyleCount, const QMap< int, int > &layerParents, const QMap< int, QStringList > &layerParentNames)
create an item including possible parents
Definition: qgsowssourceselect.cpp:317
QgsOWSSourceSelect::mService
QString mService
Service name.
Definition: qgsowssourceselect.h:131
qgsowssourceselect.h
QgsManageConnectionsDialog
Definition: qgsmanageconnectionsdialog.h:32
QgsAbstractDataSourceWidget
Abstract base Data Source Widget to create connections and add layers This class provides common func...
Definition: qgsabstractdatasourcewidget.h:43
QgsSettings::endGroup
void endGroup()
Resets the group to what it was before the corresponding beginGroup() call.
Definition: qgssettings.cpp:97
QgsOWSSourceSelect::descriptionForAuthId
QString descriptionForAuthId(const QString &authId)
Returns a textual description for the authority id.
Definition: qgsowssourceselect.cpp:598
QgsOWSSourceSelect::selectedLayersFormats
virtual QStringList selectedLayersFormats()
List of formats supported for currently selected layer item(s)
Definition: qgsowssourceselect.cpp:681
QgsOWSSourceSelect::populateTimes
void populateTimes()
Populate times.
Definition: qgsowssourceselect.cpp:221
QgsCoordinateReferenceSystem::userFriendlyIdentifier
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS.
Definition: qgscoordinatereferencesystem.cpp:1338
qgsmanageconnectionsdialog.h
QgsOWSSourceSelect::selectedFormat
QString selectedFormat()
Returns currently selected format.
Definition: qgsowssourceselect.cpp:507
QgsNewHttpConnection
Dialog to allow the user to configure and save connection information for an HTTP Server for WMS,...
Definition: qgsnewhttpconnection.h:34
qgsgui.h
QgsCoordinateReferenceSystem::fromOgcWmsCrs
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
Definition: qgscoordinatereferencesystem.cpp:200
QgsOWSSourceSelect::selectedCacheLoadControl
QNetworkRequest::CacheLoadControl selectedCacheLoadControl()
Returns currently selected cache load control.
Definition: qgsowssourceselect.cpp:512
QgsNewHttpConnection::ConnectionWfs
@ ConnectionWfs
WFS connection.
Definition: qgsnewhttpconnection.h:45
QgsProjectionSelectionDialog
A generic dialog to prompt the user for a Coordinate Reference System.
Definition: qgsprojectionselectiondialog.h:52
QgsProjectionSelectionDialog::crs
QgsCoordinateReferenceSystem crs() const
Returns the CRS currently selected in the widget.
Definition: qgsprojectionselectiondialog.cpp:80
qgis.h
geoEpsgCrsAuthId
CONSTLATIN1STRING geoEpsgCrsAuthId()
Geographic coord sys from EPSG authority.
Definition: qgis.h:709
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:468
qgsowsconnection.h
QgsProjectionSelectionDialog::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the initial crs to show within the dialog.
Definition: qgsprojectionselectiondialog.cpp:85
QgsSettings
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
QgsOWSSourceSelect::mCrsNames
QMap< QString, QString > mCrsNames
Definition: qgsowssourceselect.h:157
QgsTreeWidgetItem
QTreeWidgetItem subclass with custom handling for item sorting.
Definition: qgstreewidgetitem.h:37
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsOWSSourceSelect::QgsOWSSourceSelect
QgsOWSSourceSelect(const QString &service, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode=QgsProviderRegistry::WidgetMode::None)
Constructor.
Definition: qgsowssourceselect.cpp:57
QgsAbstractDataSourceWidget::connectionsChanged
void connectionsChanged()
Emitted when the provider's connections have changed This signal is normally forwarded the app and us...
QgsProjectionSelectionDialog::setOgcWmsCrsFilter
void setOgcWmsCrsFilter(const QSet< QString > &crsFilter)
filters this dialog by the given CRSs
Definition: qgsprojectionselectiondialog.cpp:90
QgsProjectionSelectionDialog::showNoCrsForLayerMessage
void showNoCrsForLayerMessage()
When called, the dialog will show a default "layer has no CRS set" message above the projection selec...
Definition: qgsprojectionselectiondialog.cpp:57
qgsapplication.h
qgsprojectionselectiondialog.h
QgsGui::enableAutoGeometryRestore
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
Definition: qgsgui.cpp:139
QgsProviderRegistry::WidgetMode
WidgetMode
Different ways a source select dialog can be used.
Definition: qgsproviderregistry.h:65
connectionTypeFromServiceString
QgsNewHttpConnection::ConnectionType connectionTypeFromServiceString(const QString &string)
Definition: qgsowssourceselect.cpp:242
QgsNewHttpConnection::ConnectionWcs
@ ConnectionWcs
WCS connection.
Definition: qgsnewhttpconnection.h:47
QgsOwsConnection
Connections management.
Definition: qgsowsconnection.h:36
QgsOWSSourceSelect::selectedLayersCrses
virtual QStringList selectedLayersCrses()
Server CRS supported for currently selected layer item(s)
Definition: qgsowssourceselect.cpp:686
QgsOwsConnection::selectedConnection
static QString selectedConnection(const QString &service)
Retrieves the selected connection for the specified service.
Definition: qgsowsconnection.cpp:170
QgsOWSSourceSelect::reset
void reset() override
Called when this source select widget is being shown in a "new and clean" dialog.
Definition: qgsowssourceselect.cpp:125
qgsproviderregistry.h
QgsOWSSourceSelect::connName
QString connName()
Connection name.
Definition: qgsowssourceselect.cpp:497
qgsdatasourceuri.h
QgsOwsConnection::deleteConnection
static void deleteConnection(const QString &service, const QString &name)
Deletes the connection for the specified service with the specified name.
Definition: qgsowsconnection.cpp:196
QgsManageConnectionsDialog::Import
@ Import
Definition: qgsmanageconnectionsdialog.h:39
qgsnetworkaccessmanager.h
QgsOWSSourceSelect::populateConnectionList
void populateConnectionList()
Populate the connection list combo box.
Definition: qgsowssourceselect.cpp:234
qgsmessageviewer.h
QgsCoordinateReferenceSystem::authid
QString authid() const
Returns the authority identifier for the CRS.
Definition: qgscoordinatereferencesystem.cpp:1321
QgsOWSSourceSelect::mConnectionInfo
QString mConnectionInfo
Connection info for selected connection.
Definition: qgsowssourceselect.h:180
QgsNewHttpConnection::ConnectionWms
@ ConnectionWms
WMS connection.
Definition: qgsnewhttpconnection.h:46
QgsCoordinateReferenceSystem::isValid
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Definition: qgscoordinatereferencesystem.cpp:924
QgsOWSSourceSelect::enableLayersForCrs
virtual void enableLayersForCrs(QTreeWidgetItem *item)
Definition: qgsowssourceselect.cpp:376
QgsOWSSourceSelect::showError
void showError(const QString &title, const QString &format, const QString &error)
show whatever error is exposed.
Definition: qgsowssourceselect.cpp:571
QgsSettings::setValue
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Definition: qgssettings.cpp:289
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsManageConnectionsDialog::Export
@ Export
Definition: qgsmanageconnectionsdialog.h:38
QgsAbstractDataSourceWidget::setupButtons
void setupButtons(QDialogButtonBox *buttonBox)
Connect the ok and apply/add buttons to the slots.
Definition: qgsabstractdatasourcewidget.cpp:38
QgsOWSSourceSelect::clearFormats
void clearFormats()
Clear previously set formats.
Definition: qgsowssourceselect.cpp:130
qgsnewhttpconnection.h
QgsOWSSourceSelect::addDefaultServers
void addDefaultServers()
Add a few example servers to the list.
Definition: qgsowssourceselect.cpp:608
QgsOWSSourceSelect::selectedTime
QString selectedTime()
Returns currently selected time.
Definition: qgsowssourceselect.cpp:523
QgsManageConnectionsDialog::WCS
@ WCS
Definition: qgsmanageconnectionsdialog.h:49
QgsOWSSourceSelect::providerFormats
virtual QList< QgsOWSSourceSelect::SupportedFormat > providerFormats()
List of image formats (encodings) supported by provider.
Definition: qgsowssourceselect.cpp:676
QgsOWSSourceSelect::setConnectionListPosition
void setConnectionListPosition()
Sets the server connection combo box to that stored in the config file.
Definition: qgsowssourceselect.cpp:528
QgsGui::instance
static QgsGui * instance()
Returns a pointer to the singleton instance.
Definition: qgsgui.cpp:63
QgsSettings::beginGroup
void beginGroup(const QString &prefix, QgsSettings::Section section=QgsSettings::NoSection)
Appends prefix to the current group.
Definition: qgssettings.cpp:87
QgsOWSSourceSelect::mUri
QgsDataSourceUri mUri
URI for selected connection.
Definition: qgsowssourceselect.h:183
qgstreewidgetitem.h
QgsOWSSourceSelect::mConnName
QString mConnName
Name for selected connection.
Definition: qgsowssourceselect.h:177
QgsOWSSourceSelect::populateFormats
void populateFormats()
Populate supported formats.
Definition: qgsowssourceselect.cpp:136
QgsOWSSourceSelect::clearCrs
void clearCrs()
Clear CRSs.
Definition: qgsowssourceselect.cpp:463
QgsNewHttpConnection::ConnectionType
ConnectionType
Available connection types for configuring in the dialog.
Definition: qgsnewhttpconnection.h:44
qgssettings.h
QgsOWSSourceSelect::selectedCrs
QString selectedCrs()
Returns currently selected Crs.
Definition: qgsowssourceselect.cpp:518
QgsOwsConnection::connectionList
static QStringList connectionList(const QString &service)
Returns the list of connections for the specified service.
Definition: qgsowsconnection.cpp:163
qgsdataprovider.h
QgsDataSourceUri::uri
QString uri(bool expandAuthConfig=true) const
Returns the complete URI as a string.
Definition: qgsdatasourceuri.cpp:538
QgsOWSSourceSelect::selectedLayersTimes
virtual QStringList selectedLayersTimes()
List of times (temporalDomain timePosition/timePeriod for currently selected layer item(s)
Definition: qgsowssourceselect.cpp:691
QgsAbstractDataSourceWidget::widgetMode
QgsProviderRegistry::WidgetMode widgetMode() const
Returns the widget mode.
Definition: qgsabstractdatasourcewidget.cpp:28
qgslogger.h
QgsOWSSourceSelect::populateCrs
void populateCrs()
Sets supported CRSs.
Definition: qgsowssourceselect.cpp:424
QgsOWSSourceSelect::populateLayerList
virtual void populateLayerList()
Populate the layer list.
Definition: qgsowssourceselect.cpp:351
QgsOWSSourceSelect::clearTimes
void clearTimes()
Clear times.
Definition: qgsowssourceselect.cpp:228
QgsOWSSourceSelect::showStatusMessage
void showStatusMessage(const QString &message)
Sets status message to theMessage.
Definition: qgsowssourceselect.cpp:562
QgsOWSSourceSelect::connectionInfo
QString connectionInfo()
Connection info (uri)
Definition: qgsowssourceselect.cpp:502
qgscoordinatereferencesystem.h
QgsProject::crs
QgsCoordinateReferenceSystem crs
Definition: qgsproject.h:100
qgsproject.h
QgsOWSSourceSelect::mCurrentTileset
QTableWidgetItem * mCurrentTileset
Definition: qgsowssourceselect.h:174
QgsSettings::childGroups
QStringList childGroups() const
Returns a list of all key top-level groups that contain keys that can be read using the QSettings obj...
Definition: qgssettings.cpp:144
QgsOwsConnection::setSelectedConnection
static void setSelectedConnection(const QString &service, const QString &name)
Marks the specified connection for the specified service as selected.
Definition: qgsowsconnection.cpp:176