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