QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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 "qgsowssourceselect.h"
22
23#include "qgis.h"
25#include "qgsdataprovider.h"
26#include "qgsdatasourceuri.h"
27#include "qgsgui.h"
28#include "qgslogger.h"
30#include "qgsmessageviewer.h"
32#include "qgsowsconnection.h"
33#include "qgsproject.h"
35#include "qgsproviderregistry.h"
36#include "qgssettings.h"
37#include "qgstreewidgetitem.h"
38
39#include <QButtonGroup>
40#include <QDomDocument>
41#include <QFileDialog>
42#include <QHeaderView>
43#include <QImageReader>
44#include <QInputDialog>
45#include <QMap>
46#include <QMessageBox>
47#include <QNetworkReply>
48#include <QNetworkRequest>
49#include <QPicture>
50#include <QRadioButton>
51#include <QRegularExpression>
52#include <QString>
53#include <QUrl>
54#include <QValidator>
55
56#include "moc_qgsowssourceselect.cpp"
57
58using namespace Qt::StringLiterals;
59
60QgsOWSSourceSelect::QgsOWSSourceSelect( const QString &service, QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode theWidgetMode )
61 : QgsAbstractDataSourceWidget( parent, fl, theWidgetMode )
62 , mService( service )
63
64{
65 setupUi( this );
67 connect( mNewButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mNewButton_clicked );
68 connect( mEditButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mEditButton_clicked );
69 connect( mDeleteButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mDeleteButton_clicked );
70 connect( mSaveButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mSaveButton_clicked );
71 connect( mLoadButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mLoadButton_clicked );
72 connect( mConnectButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mConnectButton_clicked );
73 connect( mChangeCRSButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mChangeCRSButton_clicked );
74 connect( mLayersTreeWidget, &QTreeWidget::itemSelectionChanged, this, &QgsOWSSourceSelect::mLayersTreeWidget_itemSelectionChanged );
75 connect( mConnectionsComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsOWSSourceSelect::mConnectionsComboBox_activated );
76 connect( mAddDefaultButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mAddDefaultButton_clicked );
77 connect( mTilesetsTableWidget, &QTableWidget::itemClicked, this, &QgsOWSSourceSelect::mTilesetsTableWidget_itemClicked );
78 connect( mLayerUpButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mLayerUpButton_clicked );
79 connect( mLayerDownButton, &QPushButton::clicked, this, &QgsOWSSourceSelect::mLayerDownButton_clicked );
80 setupButtons( buttonBox );
81
82
83 setWindowTitle( tr( "Add Layer(s) from a %1 Server" ).arg( service ) );
84
85 clearCrs();
86
87 mCacheComboBox->addItem( tr( "Always Cache" ), QNetworkRequest::AlwaysCache );
88 mCacheComboBox->addItem( tr( "Prefer Cache" ), QNetworkRequest::PreferCache );
89 mCacheComboBox->addItem( tr( "Prefer Network" ), QNetworkRequest::PreferNetwork );
90 mCacheComboBox->addItem( tr( "Always Network" ), QNetworkRequest::AlwaysNetwork );
91
92 // 'Prefer network' is the default noted in the combobox's tool tip
93 mCacheComboBox->setCurrentIndex( mCacheComboBox->findData( QNetworkRequest::PreferNetwork ) );
94
96 {
97 //set the current project CRS if available
98 const QgsCoordinateReferenceSystem currentRefSys = QgsProject::instance()->crs();
99 //convert CRS id to epsg
100 if ( currentRefSys.isValid() )
101 {
102 mSelectedCRS = currentRefSys.authid();
103 }
104 }
105 else
106 {
107 mTabWidget->removeTab( mTabWidget->indexOf( mLayerOrderTab ) );
108 mTabWidget->removeTab( mTabWidget->indexOf( mTilesetsTab ) );
109 mTimeWidget->hide();
110 mFormatWidget->hide();
111 mCRSWidget->hide();
112 mCacheWidget->hide();
113 }
115
116 // set up the WMS connections we already know about
118}
119
125
127{
129 mSpatialExtentBox->setOutputCrs( crs );
130 QgsMapCanvas *canvas = mapCanvas();
131 if ( !canvas )
132 return;
133 QgsCoordinateReferenceSystem destinationCrs = canvas->mapSettings().destinationCrs();
134 mSpatialExtentBox->setCurrentExtent( canvas->extent(), destinationCrs );
135 mSpatialExtentBox->setOutputExtentFromCurrent();
136 mSpatialExtentBox->setMapCanvas( canvas );
137 mSpatialExtentBox->setChecked( false );
138}
139
144
146{
147 mLayersTreeWidget->clearSelection();
148}
149
151{
152 mFormatComboBox->clear();
153 mFormatComboBox->setEnabled( false );
154}
155
157{
158 // A server may offer more similar formats, which are mapped
159 // to the same GDAL format, e.g. GeoTIFF and TIFF
160 // -> recreate always buttons for all available formats, enable supported
161
162 clearFormats();
163
164 if ( mProviderFormats.isEmpty() )
165 {
166 mProviderFormats = providerFormats();
167 for ( int i = 0; i < mProviderFormats.size(); i++ )
168 {
169 // GDAL mime types may be image/tiff, image/png, ...
170 mMimeLabelMap.insert( mProviderFormats[i].format, mProviderFormats[i].label );
171 }
172 }
173
174 // selectedLayersFormats may come in various forms:
175 // image/tiff, GTiff, GeoTIFF, TIFF, geotiff_int16, geotiff_rgb,
176 // PNG, GTOPO30, ARCGRID, IMAGEMOSAIC
177 // and even any string defined in server configuration, for example the
178 // value used in UMN Mapserver for OUTPUTFORMAT->NAME is used in
179 // WCS 1.0.0 SupportedFormats/Format
180
181 // TODO: It is impossible to cover all possible formats coming from server
182 // -> enabled all formats, GDAL may be able to open them
183
184 QMap<QString, QString> formatsMap;
185 formatsMap.insert( u"geotiff"_s, u"tiff"_s );
186 formatsMap.insert( u"gtiff"_s, u"tiff"_s );
187 formatsMap.insert( u"tiff"_s, u"tiff"_s );
188 formatsMap.insert( u"tif"_s, u"tiff"_s );
189 formatsMap.insert( u"gif"_s, u"gif"_s );
190 formatsMap.insert( u"jpeg"_s, u"jpeg"_s );
191 formatsMap.insert( u"jpg"_s, u"jpeg"_s );
192 formatsMap.insert( u"png"_s, u"png"_s );
193
194 int preferred = -1;
195 const QStringList layersFormats = selectedLayersFormats();
196 for ( int i = 0; i < layersFormats.size(); i++ )
197 {
198 const QString format = layersFormats.value( i );
199 QgsDebugMsgLevel( "server format = " + format, 2 );
200 const QString simpleFormat = format.toLower().remove( u"image/"_s ).remove( QRegularExpression( "_.*" ) );
201 QgsDebugMsgLevel( "server simpleFormat = " + simpleFormat, 2 );
202 const QString mimeFormat = "image/" + formatsMap.value( simpleFormat );
203 QgsDebugMsgLevel( "server mimeFormat = " + mimeFormat, 2 );
204
205 QString label = format;
206
207 if ( mMimeLabelMap.contains( mimeFormat ) )
208 {
209 if ( format != mMimeLabelMap.value( mimeFormat ) )
210 {
211 // Append name of GDAL driver
212 label += " / " + mMimeLabelMap.value( mimeFormat );
213 }
214
215 if ( simpleFormat.contains( "tif"_L1 ) ) // prefer *tif*
216 {
217 if ( preferred < 0 || simpleFormat.startsWith( 'g' ) ) // prefer geotiff
218 {
219 preferred = i;
220 }
221 }
222 }
223 else
224 {
225 // We cannot always say that the format is not supported by GDAL because
226 // server can use strange names, but format itself is supported
227 QgsDebugMsgLevel( u"format %1 unknown"_s.arg( format ), 2 );
228 }
229
230 mFormatComboBox->insertItem( i, label );
231 }
232 // Set preferred
233 // TODO: all enabled for now, see above
234 preferred = preferred >= 0 ? preferred : 0;
235 mFormatComboBox->setCurrentIndex( preferred );
236
237 mFormatComboBox->setEnabled( true );
238}
239
241{
242 mTimeComboBox->clear();
243 mTimeComboBox->insertItems( 0, selectedLayersTimes() );
244 mTimeComboBox->setEnabled( !selectedLayersTimes().isEmpty() );
245}
246
248{
249 mTimeComboBox->clear();
250 mTimeComboBox->setEnabled( false );
251}
252
254{
255 mConnectionsComboBox->clear();
256 mConnectionsComboBox->addItems( QgsOwsConnection::connectionList( mService ) );
257
259}
260
262{
263 if ( string.compare( "wms"_L1, Qt::CaseInsensitive ) == 0 )
265 else if ( string.compare( "wfs"_L1, Qt::CaseInsensitive ) == 0 )
267 else if ( string.compare( "wcs"_L1, Qt::CaseInsensitive ) == 0 )
269 else
271}
272
273void QgsOWSSourceSelect::mNewButton_clicked()
274{
276 QgsNewHttpConnection *nc = new QgsNewHttpConnection( this, type, mService.toUpper(), QString(), QgsNewHttpConnection::FlagShowHttpSettings );
277
278 if ( nc->exec() )
279 {
281 emit connectionsChanged();
282 }
283
284 delete nc;
285}
286
287void QgsOWSSourceSelect::mEditButton_clicked()
288{
290 QgsNewHttpConnection *nc = new QgsNewHttpConnection( this, type, mService.toUpper(), mConnectionsComboBox->currentText(), QgsNewHttpConnection::FlagShowHttpSettings );
291
292 if ( nc->exec() )
293 {
295 emit connectionsChanged();
296 }
297
298 delete nc;
299}
300
301void QgsOWSSourceSelect::mDeleteButton_clicked()
302{
303 const QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" ).arg( mConnectionsComboBox->currentText() );
304 const QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Remove Connection" ), msg, QMessageBox::Yes | QMessageBox::No );
305 if ( result == QMessageBox::Yes )
306 {
307 QgsOwsConnection::deleteConnection( mService, mConnectionsComboBox->currentText() );
308 mConnectionsComboBox->removeItem( mConnectionsComboBox->currentIndex() ); // populateConnectionList();
310 emit connectionsChanged();
311 }
312}
313
314void QgsOWSSourceSelect::mSaveButton_clicked()
315{
316 QgsManageConnectionsDialog dlg( this, QgsManageConnectionsDialog::Export, QgsManageConnectionsDialog::WCS );
317 dlg.exec();
318}
319
320void QgsOWSSourceSelect::mLoadButton_clicked()
321{
322 const QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) );
323 if ( fileName.isEmpty() )
324 {
325 return;
326 }
327
328 QgsManageConnectionsDialog dlg( this, QgsManageConnectionsDialog::Import, QgsManageConnectionsDialog::WCS, fileName );
329 dlg.exec();
331 emit connectionsChanged();
332}
333
335 int id, const QStringList &names, QMap<int, QgsTreeWidgetItem *> &items, int &layerAndStyleCount, const QMap<int, int> &layerParents, const QMap<int, QStringList> &layerParentNames
336)
337{
338 QgsDebugMsgLevel( u"id = %1 layerAndStyleCount = %2 names = %3 "_s.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
366
367void QgsOWSSourceSelect::mConnectButton_clicked()
368{
369 mLayersTreeWidget->clear();
370 clearFormats();
371 clearTimes();
372 clearCrs();
373
374 mConnName = mConnectionsComboBox->currentText();
375
376 const QgsOwsConnection connection( mService, mConnectionsComboBox->currentText() );
377 mUri = connection.uri();
378
379 QApplication::setOverrideCursor( Qt::WaitCursor );
380
381 QgsDebugMsgLevel( u"call populateLayerList"_s, 3 );
383
384 QApplication::restoreOverrideCursor();
385}
386
388{}
389
390void QgsOWSSourceSelect::mChangeCRSButton_clicked()
391{
392 QStringList layers;
393 const auto constSelectedItems = mLayersTreeWidget->selectedItems();
394 for ( QTreeWidgetItem *item : constSelectedItems )
395 {
396 const QString layer = item->data( 0, Qt::UserRole + 0 ).toString();
397 if ( !layer.isEmpty() )
398 layers << layer;
399 }
400
401 QgsProjectionSelectionDialog *mySelector = new QgsProjectionSelectionDialog( this );
402 mySelector->setOgcWmsCrsFilter( mSelectedLayersCRSs );
403
404 const QgsCoordinateReferenceSystem defaultCRS = QgsProject::instance()->crs();
405 if ( defaultCRS.isValid() )
406 {
407 mySelector->setCrs( defaultCRS );
408 }
409 else
410 {
411 mySelector->showNoCrsForLayerMessage();
412 }
413
414 if ( !mySelector->exec() )
415 return;
416
417 mSelectedCRS = mySelector->crs().authid();
418 mSpatialExtentBox->setOutputCrs( mySelector->crs() );
419 delete mySelector;
420
421 mSelectedCRSLabel->setText( descriptionForAuthId( mSelectedCRS ) );
422
423 for ( int i = 0; i < mLayersTreeWidget->topLevelItemCount(); i++ )
424 {
425 enableLayersForCrs( mLayersTreeWidget->topLevelItem( i ) );
426 }
427
428 updateButtons();
429}
430
431void QgsOWSSourceSelect::mLayersTreeWidget_itemSelectionChanged()
432{}
433
435{
436 clearCrs();
437 mSelectedLayersCRSs = qgis::listToSet( selectedLayersCrses() );
438 mCRSLabel->setText( tr( "Coordinate Reference System (%n available)", "crs count", mSelectedLayersCRSs.count() ) + ':' );
439
440 mChangeCRSButton->setDisabled( mSelectedLayersCRSs.isEmpty() );
441
442 if ( !mSelectedLayersCRSs.isEmpty() )
443 {
444 // check whether current CRS is supported
445 // if not, use one of the available CRS
446 QString defaultCRS;
447 QSet<QString>::const_iterator it = mSelectedLayersCRSs.constBegin();
448 for ( ; it != mSelectedLayersCRSs.constEnd(); ++it )
449 {
450 if ( it->compare( mSelectedCRS, Qt::CaseInsensitive ) == 0 )
451 break;
452
453 // save first CRS in case the current CRS is not available
454 if ( it == mSelectedLayersCRSs.constBegin() )
455 defaultCRS = *it;
456
457 // prefer value of DEFAULT_GEO_EPSG_CRS_ID if available
458 if ( *it == Qgis::geographicCrsAuthId() )
459 defaultCRS = *it;
460 }
461
462 if ( it == mSelectedLayersCRSs.constEnd() )
463 {
464 if ( mSelectedLayersCRSs.constFind( QgsProject::instance()->crs().authid() ) != mSelectedLayersCRSs.constEnd() )
465 {
466 mSelectedCRS = QgsProject::instance()->crs().authid();
467 }
468 else
469 {
470 // not found
471 mSelectedCRS = defaultCRS;
472 }
473 }
474 mSpatialExtentBox->setOutputCrs( QgsCoordinateReferenceSystem( mSelectedCRS ) );
475 mSelectedCRSLabel->setText( descriptionForAuthId( mSelectedCRS ) );
476 mChangeCRSButton->setEnabled( true );
477 }
478 QgsDebugMsgLevel( "mSelectedCRS = " + mSelectedCRS, 2 );
479}
480
482{
483 mCRSLabel->setText( tr( "Coordinate Reference System" ) + ':' );
484 mSelectedCRS.clear();
485 mSelectedCRSLabel->clear();
486 mChangeCRSButton->setEnabled( false );
487}
488
489void QgsOWSSourceSelect::mTilesetsTableWidget_itemClicked( QTableWidgetItem *item )
490{
491 Q_UNUSED( item )
492
493 QTableWidgetItem *rowItem = mTilesetsTableWidget->item( mTilesetsTableWidget->currentRow(), 0 );
494 const bool wasSelected = mCurrentTileset == rowItem;
495
496 mTilesetsTableWidget->blockSignals( true );
497 mTilesetsTableWidget->clearSelection();
498 if ( !wasSelected )
499 {
500 QgsDebugMsgLevel( u"selecting current row %1"_s.arg( mTilesetsTableWidget->currentRow() ), 2 );
501 mTilesetsTableWidget->selectRow( mTilesetsTableWidget->currentRow() );
502 mCurrentTileset = rowItem;
503 }
504 else
505 {
506 mCurrentTileset = nullptr;
507 }
508 mTilesetsTableWidget->blockSignals( false );
509
510 updateButtons();
511}
512
513
515{
516 return mConnName;
517}
518
523
525{
526 return selectedLayersFormats().value( mFormatComboBox->currentIndex() );
527}
528
529QNetworkRequest::CacheLoadControl QgsOWSSourceSelect::selectedCacheLoadControl()
530{
531 const int cache = mCacheComboBox->currentData().toInt();
532 return static_cast<QNetworkRequest::CacheLoadControl>( cache );
533}
534
536{
537 return mSelectedCRS;
538}
539
541{
542 return mTimeComboBox->currentText();
543}
544
546{
547 const QString toSelect = QgsOwsConnection::selectedConnection( mService );
548
549 mConnectionsComboBox->setCurrentIndex( mConnectionsComboBox->findText( toSelect ) );
550
551 if ( mConnectionsComboBox->currentIndex() < 0 )
552 {
553 if ( toSelect.isNull() )
554 mConnectionsComboBox->setCurrentIndex( 0 );
555 else
556 mConnectionsComboBox->setCurrentIndex( mConnectionsComboBox->count() - 1 );
557 }
558
559 if ( mConnectionsComboBox->count() == 0 )
560 {
561 // No connections - disable various buttons
562 mConnectButton->setEnabled( false );
563 mEditButton->setEnabled( false );
564 mDeleteButton->setEnabled( false );
565 mSaveButton->setEnabled( false );
566 }
567 else
568 {
569 // Connections - enable various buttons
570 mConnectButton->setEnabled( true );
571 mEditButton->setEnabled( true );
572 mDeleteButton->setEnabled( true );
573 mSaveButton->setEnabled( true );
574 }
575
576 QgsOwsConnection::setSelectedConnection( mService, mConnectionsComboBox->currentText() );
577}
578
579void QgsOWSSourceSelect::showStatusMessage( QString const &message )
580{
581 mStatusLabel->setText( message );
582
583 // update the display of this widget
584 update();
585}
586
587
588void QgsOWSSourceSelect::showError( QString const &title, QString const &format, QString const &error )
589{
590 QgsMessageViewer *mv = new QgsMessageViewer( this );
591 mv->setWindowTitle( title );
592
593 if ( format == "text/html"_L1 )
594 {
595 mv->setMessageAsHtml( error );
596 }
597 else
598 {
599 mv->setMessageAsPlainText( tr( "Could not understand the response:\n%1" ).arg( error ) );
600 }
601 mv->showMessage( true ); // Is deleted when closed
602}
603
604void QgsOWSSourceSelect::mConnectionsComboBox_activated( int )
605{
606 // Remember which server was selected.
607 QgsOwsConnection::setSelectedConnection( mService, mConnectionsComboBox->currentText() );
608}
609
610void QgsOWSSourceSelect::mAddDefaultButton_clicked()
611{
613}
614
615QString QgsOWSSourceSelect::descriptionForAuthId( const QString &authId )
616{
617 if ( mCrsNames.contains( authId ) )
618 return mCrsNames[authId];
619
621 mCrsNames.insert( authId, qgisSrs.userFriendlyIdentifier() );
622 return qgisSrs.userFriendlyIdentifier();
623}
624
626{
627 QMap<QString, QString> exampleServers;
628 exampleServers[u"DM Solutions GMap"_s] = u"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap"_s;
629 exampleServers[u"Lizardtech server"_s] = u"http://wms.lizardtech.com/lizardtech/iserv/ows"_s;
630 // Nice to have the qgis users map, but I'm not sure of the URL at the moment.
631 // exampleServers["Qgis users map"] = "http://qgis.org/wms.cgi";
632
633 QgsSettings settings;
634 settings.beginGroup( "/qgis/connections-" + mService.toLower() );
635 QMap<QString, QString>::const_iterator i = exampleServers.constBegin();
636 for ( ; i != exampleServers.constEnd(); ++i )
637 {
638 // Only do a server if it's name doesn't already exist.
639 const QStringList keys = settings.childGroups();
640 if ( !keys.contains( i.key() ) )
641 {
642 const QString path = i.key();
643 settings.setValue( path + "/url", i.value() );
644 }
645 }
646 settings.endGroup();
648
649 QMessageBox::information(
650 this,
651 tr( "Add WMS Servers" ),
652 "<p>"
653 + tr(
654 "Several WMS servers have "
655 "been added to the server list. Note that if "
656 "you access the Internet via a web proxy, you will "
657 "need to set the proxy settings in the QGIS options dialog."
658 )
659 + "</p>"
660 );
661}
662
663void QgsOWSSourceSelect::mLayerUpButton_clicked()
664{
665 QList<QTreeWidgetItem *> selectionList = mLayerOrderTreeWidget->selectedItems();
666 if ( selectionList.empty() )
667 {
668 return;
669 }
670 const int selectedIndex = mLayerOrderTreeWidget->indexOfTopLevelItem( selectionList[0] );
671 if ( selectedIndex < 1 )
672 {
673 return; //item not existing or already on top
674 }
675
676 QTreeWidgetItem *selectedItem = mLayerOrderTreeWidget->takeTopLevelItem( selectedIndex );
677 mLayerOrderTreeWidget->insertTopLevelItem( selectedIndex - 1, selectedItem );
678 mLayerOrderTreeWidget->clearSelection();
679 selectedItem->setSelected( true );
680}
681
682void QgsOWSSourceSelect::mLayerDownButton_clicked()
683{
684 QList<QTreeWidgetItem *> selectionList = mLayerOrderTreeWidget->selectedItems();
685 if ( selectionList.empty() )
686 {
687 return;
688 }
689 const int selectedIndex = mLayerOrderTreeWidget->indexOfTopLevelItem( selectionList[0] );
690 if ( selectedIndex < 0 || selectedIndex > mLayerOrderTreeWidget->topLevelItemCount() - 2 )
691 {
692 return; //item not existing or already at bottom
693 }
694
695 QTreeWidgetItem *selectedItem = mLayerOrderTreeWidget->takeTopLevelItem( selectedIndex );
696 mLayerOrderTreeWidget->insertTopLevelItem( selectedIndex + 1, selectedItem );
697 mLayerOrderTreeWidget->clearSelection();
698 selectedItem->setSelected( true );
699}
700
701QList<QgsOWSSourceSelect::SupportedFormat> QgsOWSSourceSelect::providerFormats()
702{
703 return QList<SupportedFormat>();
704}
705
707{
708 return QStringList();
709}
710
712{
713 return QStringList();
714}
715
717{
718 return QStringList();
719}
720
721void QgsOWSSourceSelect::updateButtons()
722{}
static QString geographicCrsAuthId()
Geographic coordinate system auth:id string for a default geographic CRS (EPSG:4326).
Definition qgis.h:6714
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.
QgsAbstractDataSourceWidget(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode=QgsProviderRegistry::WidgetMode::Standalone)
Constructor.
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.
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.
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:224
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.
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
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)
@ 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 for OWS connections.
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:119
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().
Stores settings for use within QGIS.
Definition qgssettings.h:68
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.
#define QgsDebugMsgLevel(str, level)
Definition qgslogger.h:63
QgsNewHttpConnection::ConnectionType connectionTypeFromServiceString(const QString &string)