Marble

MapWizard.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2011 Utku Aydın <utkuaydin34@gmail.com>
4//
5
6#include "MapWizard.h"
7#include "ui_MapWizard.h"
8
9#include "MarbleGlobal.h"
10#include "MarbleDirs.h"
11#include "MarbleDebug.h"
12#include "ServerLayout.h"
13#include "GeoSceneDocument.h"
14#include "GeoSceneHead.h"
15#include "GeoSceneIcon.h"
16#include "GeoSceneZoom.h"
17#include "GeoSceneMap.h"
18#include "GeoSceneLayer.h"
19#include "GeoSceneTileDataset.h"
20#include "GeoSceneSettings.h"
21#include "GeoSceneProperty.h"
22#include "GeoSceneGeodata.h"
23#include "GeoSceneLegend.h"
24#include "GeoSceneSection.h"
25#include "GeoSceneItem.h"
26#include "GeoSceneVector.h"
27#include "GeoWriter.h"
28#include "DgmlElementDictionary.h"
29#include "MarbleWidget.h"
30#include "MarbleNavigator.h"
31#include "OwsServiceManager.h"
32
33#include <QBuffer>
34#include <QDir>
35#include <QFile>
36#include <QProcess>
37#include <QSharedPointer>
38#include <QTimer>
39#include <QPixmap>
40#include <QMessageBox>
41#include <QFileDialog>
42#include <QImageReader>
43#include <QDialogButtonBox>
44#include <QNetworkReply>
45#include <QNetworkRequest>
46#include <QDomElement>
47#include <QXmlStreamWriter>
48#include <QUrlQuery>
49#include <QStandardItemModel>
50#include <QSortFilterProxyModel>
51#include <QColorDialog>
52
53namespace Marble
54{
55
56int const layerIdRole = 1001;
57
58enum wizardPage
59{
60 WelcomePage,
61 WmsSelectionPage,
62 LayerSelectionPage,
63 GlobalSourceImagePage,
64 XYZUrlPage,
65 ThemeInfoPage,
66 LegendPage,
67 SummaryPage
68};
69
70class MapWizardPrivate
71{
72public:
73 MapWizardPrivate()
74 : m_serverCapabilitiesValid( false ),
75 m_levelZeroTileValid( false ),
76 m_previewImageValid( false ),
77 m_legendImageValid( false ),
78 mapProviderType(),
79 model(new QStandardItemModel()),
80 sortModel(new QSortFilterProxyModel())
81
82 {
84 sortModel->setSourceModel(model);
85 }
86
87 void pageEntered( int id );
88
89 Ui::MapWizard uiWidget;
90
91 QString mapTheme;
92
93 OwsServiceManager owsManager;
94
95 QStringList wmsServerList;
96 QStringList wmtsServerList;
97 QStringList staticUrlServerList;
98 bool m_serverCapabilitiesValid;
99 bool m_levelZeroTileValid;
100 bool m_previewImageValid;
101 bool m_legendImageValid;
102
103 enum mapType
104 {
105 NoMap,
106 StaticImageMap,
107 WmsMap,
108 WmtsMap,
109 StaticUrlMap
110 };
111 QStringList selectedLayers;
112 QString selectedProjection;
113
114 mapType mapProviderType;
115 QByteArray levelZero;
116 QByteArray preview;
117 QByteArray legend;
118 QImage levelZeroTile;
119 QImage previewImage;
120 QImage legendImage;
121
122 QString format;
123
124 QStringList wmsLegends;
125
126 QString sourceImage;
127
128 QStandardItemModel * model;
129 QSortFilterProxyModel * sortModel;
130};
131
132class PreviewDialog : public QDialog
133{
135public:
136 PreviewDialog( QWidget* parent, const QString& mapThemeId );
137 void closeEvent(QCloseEvent* e ) override;
138private:
139 bool deleteTheme( const QString& directory );
140 QString m_mapThemeId;
141};
142
143PreviewDialog::PreviewDialog( QWidget* parent, const QString& mapThemeId ) : QDialog( parent ), m_mapThemeId( mapThemeId )
144{
145 QGridLayout *layout = new QGridLayout();
146 MarbleWidget *widget = new MarbleWidget();
147 MarbleNavigator *navigator = new MarbleNavigator();
148
149 connect( navigator, SIGNAL(goHome()), widget, SLOT(goHome()) );
150 connect( navigator, SIGNAL(moveUp()), widget, SLOT(moveUp()) );
151 connect( navigator, SIGNAL(moveDown()), widget, SLOT(moveDown()) );
152 connect( navigator, SIGNAL(moveLeft()), widget, SLOT(moveLeft()) );
153 connect( navigator, SIGNAL(moveRight()), widget, SLOT(moveRight()) );
154 connect( navigator, SIGNAL(zoomIn()), widget, SLOT(zoomIn()) );
155 connect( navigator, SIGNAL(zoomOut()), widget, SLOT(zoomOut()) );
156 connect( navigator, SIGNAL(zoomChanged(int)), widget, SLOT(setZoom(int)) );
157
158 widget->setMapThemeId( m_mapThemeId );
159 widget->setZoom( 1000 );
160
161 layout->addWidget( navigator, 1, 1 );
162 layout->addWidget( widget, 1, 2 );
163 layout->setMargin( 0 );
164 layout->setSpacing( 0 );
165
166 this->setLayout( layout );
167 this->setMinimumSize( 640, 480 );
168 this->setWindowTitle( tr( "Preview Map" ) );
169}
170
171void PreviewDialog::closeEvent(QCloseEvent* e)
172{
173 const QString dgmlPath = MarbleDirs::localPath() + QLatin1String("/maps/") + m_mapThemeId;
174 const QString directory = dgmlPath.left(dgmlPath.lastIndexOf(QLatin1Char('/')));
175 this->deleteTheme( directory );
177}
178
179bool PreviewDialog::deleteTheme( const QString &directory )
180{
181 QDir dir(directory);
182 bool result = true;
183
184 if (dir.exists(directory)) {
185 for(const QFileInfo& info: dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) {
186 if (info.isDir()) {
187 result = deleteTheme(info.absoluteFilePath());
188 } else {
189 result = QFile::remove(info.absoluteFilePath());
190 }
191
192 if (!result) {
193 return result;
194 }
195 }
196 result = dir.rmdir(directory);
197 }
198
199 return result;
200}
201
202void MapWizardPrivate::pageEntered( int id )
203{
204 if ( id == WmsSelectionPage ) {
205 m_serverCapabilitiesValid = false;
206 uiWidget.lineEditWmsUrl->setFocus();
207 } else if ( id == LayerSelectionPage || id == GlobalSourceImagePage ) {
208 m_legendImageValid = false;
209 m_previewImageValid = false;
210 levelZero.clear();
211 uiWidget.comboBoxStaticUrlServer->clear();
212 uiWidget.comboBoxStaticUrlServer->addItems( staticUrlServerList );
213 uiWidget.comboBoxStaticUrlServer->addItem( "http://" );
214 } else if ( id == ThemeInfoPage ) {
215 m_legendImageValid = false;
216 if ( mapProviderType == MapWizardPrivate::StaticImageMap ) {
217 previewImage = QImage( uiWidget.lineEditSource->text() ).scaled( 136, 136, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
218 uiWidget.labelPreview->setPixmap( QPixmap::fromImage( previewImage ) );
219 }
220 } else if ( id == LegendPage ) {
221 m_levelZeroTileValid = false;
222 }
223}
224
225MapWizard::MapWizard( QWidget* parent ) : QWizard( parent ), d( new MapWizardPrivate )
226{
227 d->uiWidget.setupUi( this );
228
229 connect( this, SIGNAL(currentIdChanged(int)), this, SLOT(pageEntered(int)) );
230
231 connect( &d->owsManager, &OwsServiceManager::wmsCapabilitiesReady,
232 this, &MapWizard::processCapabilitiesResults);
233 connect( &d->owsManager, &OwsServiceManager::imageRequestResultReady,
234 this, &MapWizard::processImageResults);
235
236 connect( &d->owsManager, &OwsServiceManager::wmtsCapabilitiesReady,
237 this, &MapWizard::processCapabilitiesResults);
238
239
240 connect( d->uiWidget.pushButtonSource, &QAbstractButton::clicked, this, &MapWizard::querySourceImage );
241 connect( d->uiWidget.pushButtonPreview, &QAbstractButton::clicked, this, &MapWizard::queryPreviewImage );
242 connect( d->uiWidget.pushButtonLegend_2, &QAbstractButton::clicked, this, &MapWizard::queryLegendImage );
243
244 connect( d->uiWidget.comboBoxWmsServer, SIGNAL(activated(QString)), this, SLOT(setLineEditWms(QString)) );
245 connect( d->uiWidget.listViewWmsLayers, &QListView::pressed, this, &MapWizard::processSelectedLayerInformation );
246
247 connect( d->uiWidget.lineEditTitle, &QLineEdit::textChanged, d->uiWidget.labelSumMName, &QLabel::setText );
248 connect( d->uiWidget.lineEditTheme, &QLineEdit::textChanged, d->uiWidget.labelSumMTheme, &QLabel::setText );
249
250 connect( d->uiWidget.pushButtonPreviewMap, &QAbstractButton::clicked, this, &MapWizard::showPreview );
251 connect( d->uiWidget.lineEditWmsSearch, &QLineEdit::textChanged, this, &MapWizard::updateSearchFilter );
252 connect( d->uiWidget.comboBoxWmsMaps, SIGNAL(currentIndexChanged(int)), this, SLOT(updateBackdropCheckBox()) );
253 connect( d->uiWidget.checkBoxWmsBackdrop, &QCheckBox::stateChanged, this, &MapWizard::updateBackdropCheckBox );
254
255 connect( d->uiWidget.checkBoxWmsMultipleSelections, &QCheckBox::stateChanged, this, &MapWizard::updateListViewSelection);
256 connect( d->uiWidget.pushButtonColor, &QPushButton::clicked, this, &MapWizard::chooseBackgroundColor);
257 updateListViewSelection();
258
259 d->uiWidget.checkBoxWmsMultipleSelections->setVisible(true);
260 d->uiWidget.checkBoxWmsBackdrop->setVisible(true);
261 d->uiWidget.listViewWmsLayers->setModel(d->sortModel);
262 d->uiWidget.listViewWmsLayers->setSelectionMode(QAbstractItemView::ExtendedSelection);
263
264 d->uiWidget.progressBarWmsCapabilities->setVisible(false);
265 setLayerButtonsVisible(true);
266
267 d->uiWidget.tabWidgetLayers->setCurrentIndex(0);
268
269 QPalette p = d->uiWidget.labelBackgroundColor->palette();
270 p.setColor(QPalette::Window, d->uiWidget.labelBackgroundColor->text());
271 d->uiWidget.labelBackgroundColor->setAutoFillBackground(true);
272 d->uiWidget.labelBackgroundColor->setPalette(p);
273
274 d->uiWidget.radioButtonXYZServer->setVisible(false);
275}
276
277MapWizard::~MapWizard()
278{
279 delete d;
280}
281
282void MapWizard::processCapabilitiesResults()
283{
284 d->uiWidget.progressBarWmsCapabilities->setVisible(false);
285
286 button( MapWizard::NextButton )->setEnabled( true );
287
288 if (d->owsManager.capabilitiesStatus() == OwsCapabilitiesReplyUnreadable)
289 {
290 QMessageBox::critical( this, tr( "Error while parsing" ), tr( "Wizard cannot parse server's response" ) );
291 return;
292 }
293 if(d->owsManager.capabilitiesStatus() == OwsCapabilitiesNoOwsServer)
294 {
295 QMessageBox::critical( this, tr( "Error while parsing" ), tr( "Server is not an OWS Server." ) );
296 return;
297 }
298 d->model->clear();
299
300 OwsMappingCapabilities owsCapabilities;
301 if (d->owsManager.owsServiceType() == WmsType) {
302 owsCapabilities = d->owsManager.wmsCapabilities();
303 }
304 else if (d->owsManager.owsServiceType() == WmtsType) {
305 owsCapabilities = d->owsManager.wmtsCapabilities();
306 }
307
308 d->uiWidget.labelWmsTitle->setText(QString("Web Service: <b>%1</b>").arg(owsCapabilities.title() ) );
309 d->uiWidget.labelWmsTitle->setToolTip(QString("<small>%1</small>").arg(owsCapabilities.abstract() ) );
310
311 for (auto layer : owsCapabilities.layers()) {
312 if (!layer.isEmpty()) {
313 QStandardItem * item = new QStandardItem(owsCapabilities.title(layer));
314 item->setData(layer, layerIdRole);
315 item->setToolTip(owsCapabilities.abstract(layer));
316 d->model->appendRow(item);
317 }
318 }
319
320 // default to the first layer
321 d->uiWidget.listViewWmsLayers->setCurrentIndex( d->sortModel->index(0,0) );
322 d->uiWidget.lineEditWmsSearch->setText(QString());
323
324
325 d->uiWidget.comboBoxWmsFormat->clear();
326 if (d->owsManager.owsServiceType() == WmsType) {
327 d->uiWidget.comboBoxWmsFormat->addItems(d->owsManager.wmsCapabilities().formats());
328
329 // default to png or jpeg
330 d->uiWidget.comboBoxWmsFormat->setCurrentText("png");
331 if (d->uiWidget.comboBoxWmsFormat->currentText() != "png") {
332 d->uiWidget.comboBoxWmsFormat->setCurrentText("jpeg");
333 }
334 }
335
336 QString serviceInfo;
337 serviceInfo += "<html>";
338 serviceInfo += d->owsManager.wmsCapabilities().abstract();
339 serviceInfo += QString("<br><br><i>Contact:</i> %1").arg( d->owsManager.wmsCapabilities().contactInformation());
340 serviceInfo += QString("<br><br><i>Fees:</i> %1").arg( d->owsManager.wmsCapabilities().fees());
341 serviceInfo += "</html>";
342
343 d->uiWidget.textEditWmsServiceInfo->setText(serviceInfo);
344 d->uiWidget.tabServiceInfo->setEnabled(!serviceInfo.isEmpty());
345
346 if (d->uiWidget.listViewWmsLayers->model()->rowCount() > 0) {
347 processSelectedLayerInformation();
348 }
349
350 d->m_serverCapabilitiesValid = true;
351
352 if (d->owsManager.owsServiceType() == WmsType) {
353 if (!d->wmsServerList.contains(d->uiWidget.lineEditWmsUrl->text())) {
354 d->wmsServerList.append( d->uiWidget.lineEditWmsUrl->text() );
355 }
356 setWmsServers( d->wmsServerList );
357 }
358 else if (d->owsManager.owsServiceType() == WmtsType) {
359 if (!d->wmtsServerList.contains(d->uiWidget.lineEditWmsUrl->text())) {
360 d->wmtsServerList.append( d->uiWidget.lineEditWmsUrl->text() );
361 }
362 setWmtsServers( d->wmtsServerList );
363 }
364
365
366 next();
367
368 setSearchFieldVisible(d->model->rowCount() > 20);
369}
370
371void MapWizard::processSelectedLayerInformation()
372{
373 updateListViewSelection();
374
375 QStringList selectedList;
376 QModelIndexList selectedIndexes = d->uiWidget.listViewWmsLayers->selectionModel()->selectedIndexes();
377 for (auto selectedIndex : selectedIndexes) {
378 selectedList << d->sortModel->data(selectedIndex, layerIdRole).toString();
379 }
380 d->selectedLayers = selectedList;
381 OwsMappingCapabilities owsCapabilities;
382 if (d->owsManager.owsServiceType() == WmsType) {
383 owsCapabilities = d->owsManager.wmsCapabilities();
384 }
385 else if (d->owsManager.owsServiceType() == WmtsType) {
386 owsCapabilities = d->owsManager.wmtsCapabilities();
387 }
388 d->uiWidget.comboBoxWmsMaps->clear();
389 QMap<QString, QString> epsgToText;
390 epsgToText["epsg:3857"] = tr("Web Mercator (epsg:3857)");
391 epsgToText["epsg:4326"] = tr("Equirectangular (epsg:4326)");
392 epsgToText["crs:84"] = tr("Equirectangular (crs:84)");
393 QStringList projectionTextList;
394 if (d->selectedLayers.isEmpty()) {
395 return;
396 }
397
398 if (d->owsManager.owsServiceType() == WmsType) {
399 WmsCapabilities capabilities = d->owsManager.wmsCapabilities();
400 for (auto projection : capabilities.projections(d->selectedLayers.first())) {
401 projectionTextList << epsgToText[projection];
402 }
403 d->uiWidget.labelWmsTileProjection->setText(tr("Tile Projection:"));
404 d->uiWidget.comboBoxWmsMaps->addItems(projectionTextList);
405
406 // default to Web Mercator
407 d->uiWidget.comboBoxWmsMaps->setCurrentText(tr("Web Mercator (epsg:3857)"));
408
409 updateBackdropCheckBox(); // align the backdrop checkbox state with the available/selected projection
410
411 // bool projectionSelectionVisible = d->uiWidget.comboBoxWmsMaps->count() > 0;
412 // d->uiWidget.comboBoxWmsMaps->setVisible(projectionSelectionVisible);
413 // d->uiWidget.labelWmsTileProjection->setVisible(projectionSelectionVisible);
414 // d->uiWidget.comboBoxWmsMaps->setEnabled(d->uiWidget.comboBoxWmsMaps->count() > 1);
415 }
416 if (d->owsManager.owsServiceType() == WmtsType) {
417 WmtsCapabilities capabilities = d->owsManager.wmtsCapabilities();
418 QString selectedLayer = d->selectedLayers.first();
419 d->uiWidget.labelWmsTileProjection->setText(tr("Tile Matrix Set:"));
420 d->uiWidget.comboBoxWmsMaps->addItems(capabilities.wmtsTileMatrixSets()[selectedLayer]);
421 d->uiWidget.comboBoxWmsFormat->addItems(capabilities.wmtsTileResource()[selectedLayer].keys());
422 // default to png or jpeg
423 d->uiWidget.comboBoxWmsFormat->setCurrentText("png");
424 if (d->uiWidget.comboBoxWmsFormat->currentText() != "png") {
425 d->uiWidget.comboBoxWmsFormat->setCurrentText("jpeg");
426 }
427 }
428
429
430 d->uiWidget.lineEditTitle->setText( owsCapabilities.title(d->selectedLayers.first()) );
431
432 // Remove all invalid characters from the theme-String
433 // that will make the TileLoader malfunction.
434 QString themeString = d->selectedLayers.first();
435 themeString.remove(QRegExp("[:\"\\\\/]"));
436 d->uiWidget.lineEditTheme->setText( themeString );
437 QRegularExpression rx("^[^:\"\\\\/]*$");
438 QValidator *validator = new QRegularExpressionValidator(rx, this);
439 d->uiWidget.lineEditTheme->setValidator(validator);
440
441 QString description;
442 description += "<html>";
443 description += owsCapabilities.abstract(d->selectedLayers.first());
444 if (d->owsManager.owsServiceType() == WmsType) {
445 description += QString("<br><br><i>Contact:</i> %1").arg( d->owsManager.wmsCapabilities().contactInformation());
446 description += QString("<br><br><i>Fees:</i> %1").arg( d->owsManager.wmsCapabilities().fees());
447 }
448 description += "</html>";
449 d->uiWidget.textEditDesc->setText(description);
450
451 QString layerInfo;
452 layerInfo += owsCapabilities.abstract(d->selectedLayers.first());
453 d->uiWidget.tabLayerInfo->setEnabled(!layerInfo.isEmpty());
454 d->uiWidget.textEditWmsLayerInfo->setText(layerInfo);
455}
456
457void MapWizard::processImageResults()
458{
459 setLayerButtonsVisible(true);
460 QString imageType;
461 if (d->owsManager.imageRequestResult().resultType() == PreviewImage) {
462 d->m_previewImageValid = true;
463 imageType = tr("Preview Image");
464 }
465 if (d->owsManager.imageRequestResult().resultType() == LevelZeroTile) {
466 d->m_levelZeroTileValid = true;
467 imageType = tr("Base Tile");
468 }
469 if (d->owsManager.imageRequestResult().resultType() == LevelZeroTile) {
470 d->m_legendImageValid = true;
471 imageType = tr("Legend Image");
472 }
473
474 button( MapWizard::NextButton )->setEnabled( true );
475
476 if (d->owsManager.imageRequestResult().imageStatus() == WmsImageFailed ) {
478 tr( "%1" ).arg(imageType),
479 tr( "The %1 could not be downloaded." ).arg(imageType) );
480 if (imageType == PreviewImage) d->m_previewImageValid = false;
481 if (imageType == LevelZeroTile) d->m_levelZeroTileValid = false;
482 if (imageType == LegendImage) d->m_legendImageValid = false;
483 }
484 else if (d->owsManager.imageRequestResult().imageStatus() == WmsImageFailedServerMessage ) {
486 tr( "%1" ).arg(imageType),
487 tr( "The %1 could not be downloaded successfully. The server replied:\n\n%2" ).arg( imageType, QString( d->owsManager.resultRaw() ) ) );
488 if (imageType == PreviewImage) d->m_previewImageValid = false;
489 if (imageType == LevelZeroTile) d->m_levelZeroTileValid = false;
490 if (imageType == LegendImage) d->m_legendImageValid = false;
491 }
492 else {
493 if (d->owsManager.imageRequestResult().resultType() == PreviewImage) {
494 d->previewImage = d->owsManager.resultImage().scaled( 100, 100, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
495 QPixmap previewPixmap = QPixmap::fromImage( d->previewImage );
496 d->uiWidget.labelThumbnail->setPixmap( previewPixmap );
497 d->uiWidget.labelThumbnail->resize( QSize(100, 100) );
498 d->uiWidget.labelPreview->setPixmap( previewPixmap );
499 d->uiWidget.labelPreview->resize( QSize(100, 100) );
500 }
501 if (d->owsManager.imageRequestResult().resultType() == LevelZeroTile) {
502 d->levelZeroTile = d->owsManager.resultImage();
503 d->levelZero = d->owsManager.resultRaw();
504 }
505 if (d->owsManager.imageRequestResult().resultType() == LegendImage) {
506 d->legendImage = d->owsManager.resultImage();
507 d->legend = d->owsManager.resultRaw();
508 QPixmap legendPixmap = QPixmap::fromImage( d->legendImage );
509 d->uiWidget.labelLegendImage->resize(legendPixmap.size());
510 d->uiWidget.labelLegendImage->setPixmap( legendPixmap );
511 }
512 next();
513 }
514}
515
516void MapWizard::createWmsLegend()
517{
518 QDir map(MarbleDirs::localPath() + QLatin1String("/maps/earth/") + d->mapTheme);
519 if( !map.exists( "legend" ) ) {
520 map.mkdir( "legend" );
521 }
522
523 QFile image(map.absolutePath() + QLatin1String("/legend/legend.png"));
524 image.open( QIODevice::ReadWrite );
525 image.write( d->legend );
526 image.close();
527
528 const QString legendHtml = createLegendHtml();
529 createLegendFile( legendHtml );
530}
531
532void MapWizard::setWmsServers( const QStringList& uris )
533{
534 d->wmsServerList = uris;
535}
536
537QStringList MapWizard::wmtsServers() const
538{
539 return d->wmtsServerList;
540}
541
542void MapWizard::setWmtsServers(const QStringList &uris)
543{
544 d->wmtsServerList = uris;
545}
546
547QStringList MapWizard::wmsServers() const
548{
549 return d->wmsServerList;
550}
551
552QStringList MapWizard::staticUrlServers() const
553{
554 return d->staticUrlServerList;
555}
556
557void MapWizard::setStaticUrlServers( const QStringList& uris )
558{
559 d->staticUrlServerList = uris;
560}
561
562
563void MapWizard::setLineEditWms(const QString &text)
564{
565 if (text == tr("Custom")) {
566 d->uiWidget.lineEditWmsUrl->setText(QString());
567 }
568 else {
569 d->uiWidget.lineEditWmsUrl->setText(text);
570 }
571}
572
573void MapWizard::setLayerButtonsVisible(bool visible)
574{
575 d->uiWidget.checkBoxWmsMultipleSelections->setVisible(visible);
576 d->uiWidget.checkBoxWmsBackdrop->setVisible(visible);
577 d->uiWidget.comboBoxWmsFormat->setVisible(visible);
578 d->uiWidget.comboBoxWmsMaps->setVisible(visible);
579 d->uiWidget.labelWmsTileFormat->setVisible(visible);
580 d->uiWidget.labelWmsTileProjection->setVisible(visible);
581 d->uiWidget.progressBarWmsLayers->setVisible(!visible);
582}
583
584void MapWizard::setSearchFieldVisible(bool visible)
585{
586 d->uiWidget.labelWmsSearch->setVisible(visible);
587 d->uiWidget.lineEditWmsSearch->setText(QString());
588 d->uiWidget.lineEditWmsSearch->setVisible(visible);
589 d->uiWidget.lineEditWmsSearch->setFocus();
590}
591
592bool MapWizard::createFiles( const GeoSceneDocument* document )
593{
594 // Create directories
595 QDir maps(MarbleDirs::localPath() + QLatin1String("/maps/earth/"));
596 if( !maps.exists( document->head()->theme() ) )
597 {
598 maps.mkdir( document->head()->theme() );
599
600 if( d->mapProviderType == MapWizardPrivate::StaticImageMap )
601 {
602 // Source image
603 QFile sourceImage( d->sourceImage );
604 d->format = d->sourceImage.right(d->sourceImage.length() - d->sourceImage.lastIndexOf(QLatin1Char('.')) - 1).toLower();
605 sourceImage.copy( QString( "%1/%2/%2.%3" ).arg( maps.absolutePath(),
606 document->head()->theme(),
607 d->format ) );
608 }
609
610 else if( d->mapProviderType == MapWizardPrivate::WmsMap || d->mapProviderType == MapWizardPrivate::WmtsMap )
611 {
612 maps.mkdir( QString( "%1/0/" ).arg( document->head()->theme() ) );
613 maps.mkdir( QString( "%1/0/0" ).arg( document->head()->theme() ) );
614 const QString path = QString( "%1/%2/0/0/0.%3" ).arg( maps.absolutePath(),
615 document->head()->theme(),
616 d->owsManager.resultFormat() );
617 QFile baseTile( path );
618 baseTile.open( QFile::WriteOnly );
619 baseTile.write( d->levelZero );
620 }
621
622 else if( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
623 {
624 maps.mkdir( QString( "%1/0/" ).arg( document->head()->theme() ) );
625 maps.mkdir( QString( "%1/0/0" ).arg( document->head()->theme() ) );
626 const QString path = QString( "%1/%2/0/0/0.%3" ).arg( maps.absolutePath(),
627 document->head()->theme(),
628 d->format );
629 QFile baseTile( path );
630 baseTile.open( QFile::WriteOnly );
631 baseTile.write( d->levelZero );
632 }
633
634 // Preview image
635 QString pixmapPath = QString( "%1/%2/%3" ).arg( maps.absolutePath(),
636 document->head()->theme(),
637 document->head()->icon()->pixmap() );
638 d->previewImage.save( pixmapPath );
639
640 // DGML
641 QFile file( QString( "%1/%2/%2.dgml" ).arg( maps.absolutePath(),
642 document->head()->theme() ) );
643 file.open( QIODevice::ReadWrite );
644 GeoWriter geoWriter;
645 geoWriter.setDocumentType( dgml::dgmlTag_nameSpace20 );
646 geoWriter.write( &file, document );
647 file.close();
648
649 return true;
650 }
651
652 else
653 return false;
654}
655
656QString MapWizard::createLegendHtml( const QString& image )
657{
658 QString htmlOutput;
659 QXmlStreamWriter stream( &htmlOutput );
660 stream.writeStartDocument();
661 stream.writeStartElement( "html" );
662 stream.writeStartElement( "head" );
663
664 stream.writeTextElement( "title", "Marble: Legend" );
665 stream.writeStartElement( "link" );
666 stream.writeAttribute( "href", "legend.css" );
667 stream.writeAttribute( "rel", "stylesheet" );
668 stream.writeAttribute( "type", "text/css" );
669 stream.writeEndElement();
670
671 stream.writeStartElement( "body" );
672 stream.writeStartElement( "img" );
673 stream.writeAttribute( "src", image );
674 stream.writeEndElement();
675 stream.writeComment( " ##customLegendEntries:all## " );
676 stream.writeEndElement();
677 stream.writeEndElement();
678
679 return htmlOutput;
680}
681
682void MapWizard::createLegendFile( const QString& legendHtml )
683{
684 QDir map(MarbleDirs::localPath() + QLatin1String("/maps/earth/") + d->mapTheme);
685
686 QFile html(map.absolutePath() + QLatin1String("/legend.html"));
687 html.open( QIODevice::ReadWrite );
688 html.write( legendHtml.toLatin1().data() );
689 html.close();
690}
691
692void MapWizard::createLegend()
693{
694 QDir map(MarbleDirs::localPath() + QLatin1String("/maps/earth/") + d->mapTheme);
695 if( !map.exists( "legend" ) ) {
696 map.mkdir( "legend" );
697 }
698
699 QFile image;
700 image.setFileName( d->uiWidget.lineEditLegend_2->text() );
701 image.copy(map.absolutePath() + QLatin1String("/legend/legend.png"));
702
703 const QString legendHtml = createLegendHtml();
704 createLegendFile( legendHtml );
705}
706
707void MapWizard::querySourceImage()
708{
709 d->uiWidget.lineEditSource->setText( QFileDialog::getOpenFileName() );
710}
711
712void MapWizard::queryPreviewImage()
713{
715 d->previewImage = QImage( fileName );
716
717 QPixmap preview = QPixmap::fromImage( d->previewImage );
718 d->uiWidget.labelThumbnail->setPixmap( preview );
719 d->uiWidget.labelThumbnail->resize( preview.width(), preview.height() );
720}
721
722void MapWizard::queryLegendImage()
723{
725 d->uiWidget.lineEditLegend_2->setText(fileName);
726 QImage legendImage(fileName);
727 QPixmap legendPixmap = QPixmap::fromImage( legendImage );
728 d->uiWidget.labelLegendImage->setPixmap(legendPixmap);
729}
730
731QString MapWizard::createArchive( QWidget *parent, const QString& mapId )
732{
733 QStringList splitMapId( mapId.split(QLatin1Char('/')) );
734 QString body = splitMapId[0];
735 QString theme = splitMapId[1];
736 QDir themeDir;
737
738 QStringList tarArgs;
739 tarArgs.append( "--create" );
740 tarArgs.append( "--gzip" );
741 tarArgs.append( "--file" );
742 tarArgs.append( QString( "%1/%2.tar.gz" ).arg( QDir::tempPath(), theme ) );
743 tarArgs.append( "--directory" );
744
745 if( QFile::exists( QString( "%1/maps/%2" ).arg( MarbleDirs::localPath(), mapId ) ) )
746 {
747 tarArgs.append( QString( "%1/maps/" ).arg( MarbleDirs::localPath() ) );
748 themeDir.cd( QString( "%1/maps/%2/%3" ).arg( MarbleDirs::localPath(), body, theme ) );
749 }
750
751 else if( QFile::exists( QString( "%1/maps/%2" ).arg( MarbleDirs::systemPath(), mapId ) ) )
752 {
753 tarArgs.append( QString( "%1/maps/" ).arg( MarbleDirs::systemPath() ) );
754 themeDir.cd( QString( "%1/maps/%2/%3" ).arg( MarbleDirs::systemPath(), body, theme ) );
755 }
756
757 if( QFile::exists( QString( "%1/%2.dgml" ).arg( themeDir.absolutePath(), theme ) ) )
758 {
759 tarArgs.append( QString( "%1/%2/%2.dgml" ).arg( body, theme ) );
760 }
761
762 if( QFile::exists( QString( "%1/legend.html" ).arg( themeDir.absolutePath() ) ) )
763 {
764 tarArgs.append( QString( "%1/%2/legend.html" ).arg( body, theme ) );
765 }
766
767 if( QFile::exists( QString( "%1/legend" ).arg( themeDir.absolutePath() ) ) )
768 {
769 tarArgs.append( QString( "%1/%2/legend" ).arg( body, theme ) );
770 }
771
772 if( QFile::exists( QString( "%1/0/000000" ).arg( themeDir.absolutePath() ) ) )
773 {
774 tarArgs.append( QString( "%1/%2/0/000000" ).arg( body, theme ) );
775 }
776
777 QStringList previewFilters;
778 previewFilters << "preview.*";
779 QStringList preview = themeDir.entryList( previewFilters );
780 if( !preview.isEmpty() ) {
781 tarArgs.append( QString( "%1/%2/%3" ).arg( body ).arg( theme, preview[0] ) );
782 }
783
784 QStringList sourceImgFilters;
785 sourceImgFilters << theme + QLatin1String(".jpg") << theme + QLatin1String(".png") << theme + QLatin1String(".jpeg");
786 QStringList sourceImg = themeDir.entryList( sourceImgFilters );
787 if( !sourceImg.isEmpty() ) {
788 tarArgs.append( QString( "%1/%2/%3" ).arg( body ).arg( theme, sourceImg[0] ) );
789 }
790
791 QProcess archiver;
792 switch( archiver.execute( "tar", tarArgs ) )
793 {
794 case -2:
795 QMessageBox::critical( parent, tr( "Archiving failed" ), tr( "Archiving process cannot be started." ) );
796 break;
797 case -1:
798 QMessageBox::critical( parent, tr( "Archiving failed" ), tr( "Archiving process crashed." ) );
799 break;
800 case 0:
801 mDebug() << "Archived the theme successfully.";
802 break;
803 }
804 archiver.waitForFinished();
805 return QString( "%1/%2.tar.gz" ).arg( QDir::tempPath(), theme );
806}
807
808void MapWizard::deleteArchive( const QString& mapId )
809{
810 QStringList splitMapId( mapId.split(QLatin1Char('/')) );
811 QString theme = splitMapId[1];
812 QFile::remove( QString( "%1/%2.tar.gz" ).arg( QDir::tempPath(), theme ) );
813}
814
815bool MapWizard::validateCurrentPage()
816{
817 if (currentId() == WelcomePage) {
818 updateOwsServiceType();
819 return true;
820 }
821 if ( currentId() == WmsSelectionPage && !d->m_serverCapabilitiesValid ) {
822 d->uiWidget.progressBarWmsCapabilities->setVisible(true);
823 QString serviceString = d->uiWidget.radioButtonWms->isChecked()
824 ? "WMS" : d->uiWidget.radioButtonWmts->isChecked() ? "WMTS" : "";
825 d->owsManager.queryOwsCapabilities(QUrl(d->uiWidget.lineEditWmsUrl->text()), serviceString);
826 button( MapWizard::NextButton )->setEnabled( false );
827 return false;
828 }
829
830 if ( (currentId() == LayerSelectionPage && !d->m_previewImageValid)
831 || (currentId() == XYZUrlPage && !d->m_previewImageValid ) ){
832 if( d->mapProviderType == MapWizardPrivate::WmsMap && d->uiWidget.listViewWmsLayers->currentIndex().isValid())
833 {
834 QStringList selectedList;
835 QModelIndexList selectedIndexes = d->uiWidget.listViewWmsLayers->selectionModel()->selectedIndexes();
836 for (auto selectedIndex : selectedIndexes) {
837 selectedList << d->sortModel->data(selectedIndex, layerIdRole).toString();
838 }
839 d->selectedLayers = selectedList;
840
841 QString projection;
842 if (d->uiWidget.comboBoxWmsMaps->currentText() == tr("Equirectangular (epsg:4326)"))
843 projection = "epsg:4326";
844 else if (d->uiWidget.comboBoxWmsMaps->currentText() == tr("Equirectangular (crs:84)"))
845 projection = "crs:84";
846 else
847 projection = "epsg:3857";
848 d->selectedProjection = projection;
849 QString format = d->uiWidget.comboBoxWmsFormat->currentText();
850 QStringList styles = d->owsManager.wmsCapabilities().styles(d->selectedLayers);
851 d->owsManager.queryWmsPreviewImage(QUrl(d->uiWidget.lineEditWmsUrl->text()),
852 d->selectedLayers.join(','), projection, format, styles.join(','));
853 setLayerButtonsVisible(false);
854 button( MapWizard::NextButton )->setEnabled( false );
855 }
856 else if( d->mapProviderType == MapWizardPrivate::WmtsMap && d->uiWidget.listViewWmsLayers->currentIndex().isValid())
857 {
858 QStringList selectedList;
859 QModelIndexList selectedIndexes = d->uiWidget.listViewWmsLayers->selectionModel()->selectedIndexes();
860 for (auto selectedIndex : selectedIndexes) {
861 selectedList << d->sortModel->data(selectedIndex, layerIdRole).toString();
862 }
863 d->selectedLayers = selectedList;
864
865 QString tileMatrixSet = d->uiWidget.comboBoxWmsMaps->currentText();
866 QString tileFormat = d->uiWidget.comboBoxWmsFormat->currentText();
867 QString url = d->owsManager.wmtsCapabilities().wmtsTileResource()[d->selectedLayers.first()][tileFormat];
868 QString style = d->owsManager.wmtsCapabilities().style(d->selectedLayers.first());
869 d->owsManager.queryWmtsPreviewImage(url, style, tileMatrixSet);
870 setLayerButtonsVisible(false);
871 button( MapWizard::NextButton )->setEnabled( false );
872 }
873 else if( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
874 {
875 QString urlString = d->uiWidget.comboBoxStaticUrlServer->currentText();
876 d->owsManager.queryXYZPreviewImage(urlString);
877 d->staticUrlServerList.removeAll( urlString );
878 d->staticUrlServerList.prepend( urlString );
879 // Reset the Theme Description page
880 d->uiWidget.lineEditTitle->clear();
881 d->uiWidget.lineEditTheme->clear();
882 d->uiWidget.textEditDesc->clear();
883 d->uiWidget.labelPreview->clear();
884 d->uiWidget.lineEditTitle->setFocus();
885 button( MapWizard::NextButton )->setEnabled( false );
886 }
887 return false;
888 }
889
890 if ( currentId() == GlobalSourceImagePage ) {
891 d->sourceImage = d->uiWidget.lineEditSource->text();
892 if ( d->sourceImage.isEmpty() ) {
894 tr( "Source Image" ),
895 tr( "Please specify a source image." ) );
896 d->uiWidget.lineEditSource->setFocus();
897 return false;
898 }
899
900 if ( !QFileInfo::exists(d->sourceImage) ) {
902 tr( "Source Image" ),
903 tr( "The source image you specified does not exist. Please specify a different one." ) );
904 d->uiWidget.lineEditSource->setFocus();
905 d->uiWidget.lineEditSource->selectAll();
906 return false;
907 }
908
909 if ( QImage( d->sourceImage ).isNull() ) {
911 tr( "Source Image" ),
912 tr( "The source image you specified does not seem to be an image. Please specify a different image file." ) );
913 d->uiWidget.lineEditSource->setFocus();
914 d->uiWidget.lineEditSource->selectAll();
915 return false;
916 }
917 // Reset the Theme Description page
918 d->uiWidget.lineEditTitle->clear();
919 d->uiWidget.lineEditTheme->clear();
920 d->uiWidget.textEditDesc->clear();
921 d->uiWidget.labelPreview->clear();
922 d->previewImage = QImage( d->sourceImage ).scaled( 100, 100, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );;
923 QPixmap previewPixmap = QPixmap::fromImage( d->previewImage );
924 d->uiWidget.labelPreview->setPixmap( previewPixmap );
925 d->uiWidget.labelPreview->resize( QSize(100, 100) );
926 d->uiWidget.labelThumbnail->setPixmap( previewPixmap );
927 d->uiWidget.labelThumbnail->resize( QSize(100, 100) );
928 }
929
930 if ( currentId() == ThemeInfoPage ) {
931 if( d->mapProviderType == MapWizardPrivate::WmsMap && !d->m_legendImageValid )
932 {
933 QString legendUrl = d->owsManager.wmsCapabilities().legendUrl(d->selectedLayers.first());
934 if (!legendUrl.isEmpty()) {
935 d->m_legendImageValid = true;
936 d->owsManager.queryWmsLegendImage(QUrl(legendUrl));
937 button( MapWizard::NextButton )->setEnabled( false );
938 return false;
939 }
940 }
941 if ( d->uiWidget.lineEditTitle->text().isEmpty() ) {
942 QMessageBox::information( this, tr( "Map Title" ), tr( "Please specify a map title." ) );
943 d->uiWidget.lineEditTitle->setFocus();
944 return false;
945 }
946
947 d->mapTheme = d->uiWidget.lineEditTheme->text();
948 if ( d->mapTheme.isEmpty() ) {
949 QMessageBox::information( this, tr( "Map Name" ), tr( "Please specify a map name." ) );
950 d->uiWidget.lineEditTheme->setFocus();
951 return false;
952 }
953
954 const QDir destinationDir( QString( "%1/maps/earth/%2" ).arg( MarbleDirs::localPath(), d->mapTheme ) );
955 if ( destinationDir.exists() ) {
957 tr( "Map Name" ),
958 tr( "Please specify another map name, since there is already a map named \"%1\"." ).arg( d->mapTheme ) );
959 d->uiWidget.lineEditTheme->setFocus();
960 d->uiWidget.lineEditTheme->selectAll();
961 return false;
962 }
963
964 if ( d->previewImage.isNull() ) {
965 QMessageBox::information( this, tr( "Preview Image" ), tr( "Please specify a preview image." ) );
966 d->uiWidget.pushButtonPreview->setFocus();
967 return false;
968 }
969 }
970 if (currentId() == LegendPage && !d->m_levelZeroTileValid
971 && d->mapProviderType != MapWizardPrivate::StaticImageMap ) {
972 if( d->mapProviderType == MapWizardPrivate::WmsMap )
973 {
974 QString projection;
975 if (d->uiWidget.comboBoxWmsMaps->currentText() == tr("Equirectangular (epsg:4326)"))
976 projection = "epsg:4326";
977 else if (d->uiWidget.comboBoxWmsMaps->currentText() == tr("Equirectangular (crs:84)"))
978 projection = "crs:84";
979 else
980 projection = "epsg:3857";
981 d->selectedProjection = projection;
982 QString format = d->uiWidget.comboBoxWmsFormat->currentText();
983 QStringList styles = d->owsManager.wmsCapabilities().styles(d->selectedLayers);
984 d->owsManager.queryWmsLevelZeroTile(QUrl(d->uiWidget.lineEditWmsUrl->text()),
985 d->selectedLayers.first(), projection, format, styles.first());
986 }
987 else if( d->mapProviderType == MapWizardPrivate::WmtsMap)
988 {
989 QStringList selectedList;
990 QModelIndexList selectedIndexes = d->uiWidget.listViewWmsLayers->selectionModel()->selectedIndexes();
991 for (auto selectedIndex : selectedIndexes) {
992 selectedList << d->sortModel->data(selectedIndex, layerIdRole).toString();
993 }
994 d->selectedLayers = selectedList;
995
996 QString tileMatrixSet = d->uiWidget.comboBoxWmsMaps->currentText();
997 QString tileFormat = d->uiWidget.comboBoxWmsFormat->currentText();
998 QString url = d->owsManager.wmtsCapabilities().wmtsTileResource()[d->selectedLayers.first()][tileFormat];
999 QString style = d->owsManager.wmtsCapabilities().style(d->selectedLayers.first());
1000 d->owsManager.queryWmtsLevelZeroTile(url, style, tileMatrixSet);
1001 }
1002 else if( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
1003 {
1004 QString urlString = d->uiWidget.comboBoxStaticUrlServer->currentText();
1005 d->owsManager.queryXYZLevelZeroTile(urlString);
1006 }
1007 button( MapWizard::NextButton )->setEnabled( false );
1008 return false;
1009 }
1010
1012}
1013
1014int MapWizard::nextId() const
1015{
1016 switch( currentId() )
1017 {
1018 case WelcomePage:
1019 if( d->uiWidget.radioButtonWms->isChecked() ) {
1020 d->mapProviderType = MapWizardPrivate::WmsMap;
1021 return WmsSelectionPage;
1022 }
1023 else if( d->uiWidget.radioButtonWmts->isChecked() ) {
1024 d->mapProviderType = MapWizardPrivate::WmtsMap;
1025 return WmsSelectionPage;
1026 } else if( d->uiWidget.radioButtonBitmap->isChecked() ) {
1027 d->mapProviderType = MapWizardPrivate::StaticImageMap;
1028 return GlobalSourceImagePage;
1029 } else if( d->uiWidget.radioButtonStaticUrl->isChecked() ) {
1030 d->mapProviderType = MapWizardPrivate::StaticUrlMap;
1031 return XYZUrlPage;
1032 }
1033 break;
1034
1035 case WmsSelectionPage: // WMS Servers
1036 return LayerSelectionPage;
1037
1038 case LayerSelectionPage: // WMS Layers
1039 return ThemeInfoPage;
1040
1041 case GlobalSourceImagePage: // Static Image
1042 return ThemeInfoPage;
1043
1044 case ThemeInfoPage:
1045 return LegendPage;
1046
1047 case LegendPage:
1048 return SummaryPage;
1049
1050 case SummaryPage: // Finish
1051 return -1;
1052
1053 default:
1054 break;
1055 }
1056
1057 return currentId() + 1;
1058}
1059
1060void MapWizard::cleanupPage(int id)
1061{
1062 if ( d->mapProviderType == MapWizardPrivate::StaticUrlMap ) {
1063 if (id == ThemeInfoPage) {
1064 d->levelZero.clear();
1065 d->preview.clear();
1066 }
1067 }
1069}
1070
1071GeoSceneDocument* MapWizard::createDocument()
1072{
1073 GeoSceneDocument *document = new GeoSceneDocument;
1074
1075 GeoSceneHead *head = document->head();
1076 head->setName( d->uiWidget.lineEditTitle->text() );
1077 head->setTheme( d->uiWidget.lineEditTheme->text() );
1078 head->setTarget( "earth" );
1079 head->setDescription( d->uiWidget.textEditDesc->document()->toHtml() );
1080 head->setVisible( true );
1081
1082 GeoSceneIcon *icon = head->icon();
1083 icon->setPixmap( QString("%1-preview.png").arg(document->head()->theme()) );
1084
1085 GeoSceneZoom *zoom = head->zoom();
1086 zoom->setMinimum( 900 );
1087 zoom->setMaximum( 3500 );
1088 zoom->setDiscrete( false );
1089
1090 GeoSceneTileDataset *backdropTexture = nullptr;
1091 bool isBackdropTextureAvailable = d->uiWidget.checkBoxWmsBackdrop->isEnabled()
1092 && d->uiWidget.checkBoxWmsBackdrop->isChecked()
1093 && d->uiWidget.radioButtonOpenStreetMap->isChecked();
1094 if (isBackdropTextureAvailable) {
1095 if (d->uiWidget.radioButtonXYZServer) {
1096 backdropTexture = new GeoSceneTileDataset( "backdrop" );
1097 backdropTexture->setExpire( 31536000 );
1098 backdropTexture->setSourceDir(QLatin1String("earth/openstreetmap"));
1099 backdropTexture->setFileFormat( "PNG" );
1100 backdropTexture->addDownloadPolicy( DownloadBrowse, 20 );
1101 backdropTexture->addDownloadPolicy( DownloadBulk, 2 );
1102 backdropTexture->addDownloadUrl( QUrl("https://tile.openstreetmap.org/") );
1103 backdropTexture->setMaximumTileLevel( 20 );
1104 backdropTexture->setTileSize(QSize(256, 256));
1105 backdropTexture->setLevelZeroRows( 1 );
1106 backdropTexture->setLevelZeroColumns( 1 );
1107 backdropTexture->setServerLayout( new OsmServerLayout( backdropTexture ) );
1108 backdropTexture->setTileProjection(GeoSceneAbstractTileProjection::Mercator);
1109 }
1110 }
1111
1112 GeoSceneTileDataset *texture = new GeoSceneTileDataset( "map" );
1113 texture->setExpire( 31536000 );
1114 texture->setSourceDir(QLatin1String("earth/") + document->head()->theme());
1115 if( d->mapProviderType == MapWizardPrivate::WmsMap )
1116 {
1117 texture->setFileFormat( d->owsManager.resultFormat() );
1118 QStringList styles = d->owsManager.wmsCapabilities().styles(d->selectedLayers);
1119 QUrl downloadUrl = QUrl( d->uiWidget.lineEditWmsUrl->text() );
1120 QUrlQuery urlQuery;
1121 urlQuery.addQueryItem( "layers", d->selectedLayers.join(',') );
1122 urlQuery.addQueryItem( "styles", styles.join(",") );
1123 bool isBackdropAvailable = d->uiWidget.checkBoxWmsBackdrop->isEnabled()
1124 && d->uiWidget.checkBoxWmsBackdrop->isChecked();
1125 urlQuery.addQueryItem( "transparent", isBackdropTextureAvailable ? "true" : "false" );
1126
1127 if (d->uiWidget.checkBoxWmsBackdrop->isChecked() && d->uiWidget.radioButtonColor->isChecked()) {
1128 QString bgColorName = d->uiWidget.labelBackgroundColor->palette().color(QPalette::Window).name();
1129 bgColorName = bgColorName.remove("#");
1130 bgColorName = "0x" + bgColorName;
1131 urlQuery.addQueryItem( "bgcolor", bgColorName);
1132 }
1133 downloadUrl.setQuery( urlQuery );
1134 texture->addDownloadUrl( downloadUrl );
1135 texture->setMaximumTileLevel( 20 );
1136 texture->setTileSize(QSize(256, 256));
1137 texture->setLevelZeroRows( 1 );
1138 texture->setLevelZeroColumns( 1 );
1139 texture->setServerLayout( new WmsServerLayout( texture ) );
1140 if (d->uiWidget.comboBoxWmsMaps->currentText() == tr("Web Mercator (epsg:3857)")) {
1141 texture->setTileProjection(GeoSceneAbstractTileProjection::Mercator);
1142 }
1143 else {
1144 texture->setTileProjection(GeoSceneAbstractTileProjection::Equirectangular);
1145 }
1146 if (isBackdropAvailable) {
1147 texture->setBlending("AlphaBlending");
1148 }
1149 }
1150 if( d->mapProviderType == MapWizardPrivate::WmtsMap )
1151 {
1152 QString format = d->uiWidget.comboBoxWmsFormat->currentText();
1153 texture->setFileFormat( format );
1154 QString selectedLayer = d->selectedLayers.first();
1155 QString urlString = d->owsManager.wmtsCapabilities().wmtsTileResource()[selectedLayer][format];
1156 urlString.replace(urlString.indexOf(QLatin1String("{Time}")), 6, "current");
1157 urlString.replace(urlString.indexOf(QLatin1String("{style}")), 7, d->owsManager.wmtsCapabilities().style(selectedLayer));
1158 urlString.replace(urlString.indexOf(QLatin1String("{Style}")), 7, d->owsManager.wmtsCapabilities().style(selectedLayer));
1159 urlString.replace(urlString.indexOf(QLatin1String("{TileMatrixSet}")), 15, d->uiWidget.comboBoxWmsMaps->currentText());
1160 QUrl downloadUrl = QUrl( urlString );
1161 texture->addDownloadPolicy( DownloadBrowse, 20 );
1162 texture->addDownloadPolicy( DownloadBulk, 2 );
1163 texture->addDownloadUrl( downloadUrl );
1164 texture->setMaximumTileLevel( 20 );
1165 texture->setTileSize(QSize(256, 256));
1166 texture->setLevelZeroRows( 1 );
1167 texture->setLevelZeroColumns( 1 );
1168 texture->setServerLayout( new WmtsServerLayout( texture ) );
1169 texture->setTileProjection(GeoSceneAbstractTileProjection::Mercator);
1170 }
1171
1172 else if( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
1173 {
1174 texture->setFileFormat( d->format );
1175 QUrl downloadUrl = QUrl( d->uiWidget.comboBoxStaticUrlServer->currentText() );
1176 texture->addDownloadPolicy( DownloadBrowse, 20 );
1177 texture->addDownloadPolicy( DownloadBulk, 2 );
1178 texture->addDownloadUrl( downloadUrl );
1179 texture->setMaximumTileLevel( 20 );
1180 texture->setTileSize(QSize(256, 256));
1181 texture->setLevelZeroRows( 1 );
1182 texture->setLevelZeroColumns( 1 );
1183 texture->setServerLayout( new CustomServerLayout( texture ) );
1184 texture->setTileProjection(GeoSceneAbstractTileProjection::Mercator);
1185 }
1186
1187 else if( d->mapProviderType == MapWizardPrivate::StaticImageMap )
1188 {
1189 QString image = d->uiWidget.lineEditSource->text();
1190 d->format = image.right(image.length() - image.lastIndexOf(QLatin1Char('.')) - 1).toLower();
1191 texture->setFileFormat( d->format.toUpper() );
1192 texture->setInstallMap(document->head()->theme() + QLatin1Char('.') + d->format);
1193 texture->setServerLayout( new MarbleServerLayout( texture ) );
1194 texture->setTileProjection(GeoSceneAbstractTileProjection::Equirectangular);
1195 int imageWidth = QImage( image ).width();
1196 int tileSize = c_defaultTileSize;
1197
1198 float approxMaxTileLevel = log( imageWidth / ( 2.0 * tileSize ) ) / log( 2.0 );
1199 int maxTileLevel = 0;
1200 if ( approxMaxTileLevel == int( approxMaxTileLevel ) ) {
1201 maxTileLevel = static_cast<int>( approxMaxTileLevel );
1202 } else {
1203 maxTileLevel = static_cast<int>( approxMaxTileLevel + 1 );
1204 }
1205 texture->setMaximumTileLevel( maxTileLevel );
1206 }
1207
1208 GeoSceneLayer *layer = new GeoSceneLayer( d->uiWidget.lineEditTheme->text() );
1209 layer->setBackend( "texture" );
1210 layer->addDataset( backdropTexture );
1211 layer->addDataset( texture );
1212
1213 GeoSceneLayer* secondLayer = new GeoSceneLayer( "standardplaces" );
1214 secondLayer->setBackend( "geodata" );
1215
1216 GeoSceneGeodata* cityplacemarks = new GeoSceneGeodata( "cityplacemarks" );
1217 cityplacemarks->setSourceFile( "cityplacemarks.kml" );
1218 secondLayer->addDataset( cityplacemarks );
1219
1220 GeoSceneGeodata* baseplacemarks = new GeoSceneGeodata( "baseplacemarks" );
1221 baseplacemarks->setSourceFile( "baseplacemarks.kml" );
1222 secondLayer->addDataset( baseplacemarks );
1223
1224 GeoSceneGeodata* elevplacemarks = new GeoSceneGeodata( "elevplacemarks" );
1225 elevplacemarks->setSourceFile( "elevplacemarks.kml" );
1226 secondLayer->addDataset( elevplacemarks );
1227
1228 GeoSceneGeodata* observatoryplacemarks = new GeoSceneGeodata( "observatoryplacemarks" );
1229 observatoryplacemarks->setSourceFile( "observatoryplacemarks.kml" );
1230 secondLayer->addDataset( observatoryplacemarks );
1231
1232 GeoSceneGeodata* otherplacemarks = new GeoSceneGeodata( "otherplacemarks" );
1233 otherplacemarks->setSourceFile( "otherplacemarks.kml" );
1234 secondLayer->addDataset( otherplacemarks );
1235
1236 GeoSceneGeodata* boundaryplacemarks = new GeoSceneGeodata( "boundaryplacemarks" );
1237 boundaryplacemarks->setSourceFile( "boundaryplacemarks.kml" );
1238 secondLayer->addDataset( boundaryplacemarks );
1239
1240 GeoSceneMap *map = document->map();
1241
1242 if( d->mapProviderType == MapWizardPrivate::WmsMap )
1243 {
1244 QString bbox;
1245 bbox = d->owsManager.wmsCapabilities().boundingBoxNSEWDegrees(d->selectedLayers, d->selectedProjection);
1246 QStringList bboxList = bbox.split(',');
1247 // Only center if the bbox does not cover roughly the whole earth
1248 if (bboxList.at(0).toDouble() < 85 && bboxList.at(1).toDouble() > -85
1249 && bboxList.at(2).toDouble() < 179 && bboxList.at(3).toDouble() > -179) {
1250 map->setCenter(bbox);
1251 }
1252 }
1253
1254 map->addLayer( layer );
1255 map->addLayer( secondLayer );
1256
1257 GeoSceneSettings *settings = document->settings();
1258// GeoSceneLegend *legend = document->legend();
1259
1260 /*
1261 if( d->uiWidget.checkBoxCoord->checkState() == Qt::Checked )
1262 {
1263 GeoSceneProperty *coorGrid = new GeoSceneProperty( "coordinate-grid" );
1264 coorGrid->setDefaultValue( true );
1265 coorGrid->setAvailable( true );
1266 settings->addProperty( coorGrid );
1267
1268 GeoSceneSection *coorSection = new GeoSceneSection( "coordinate-grid" );
1269 coorSection->setHeading( "Coordinate Grid" );
1270 coorSection->setCheckable( true );
1271 coorSection->setConnectTo( "coordinate-grid" );
1272 coorSection->setSpacing( 12 );
1273 legend->addSection( coorSection );
1274 }
1275
1276 if( d->uiWidget.checkBoxInterest->checkState() == Qt::Checked )
1277 {
1278 GeoSceneProperty *poiProperty = new GeoSceneProperty( "otherplaces" );
1279 poiProperty->setDefaultValue( true );
1280 poiProperty->setAvailable( true );
1281 settings->addProperty( poiProperty );
1282
1283 GeoSceneSection *poiSection = new GeoSceneSection( "otherplaces" );
1284 poiSection->setHeading( "Places of Interest" );
1285 poiSection->setCheckable( true );
1286 poiSection->setConnectTo( "otherplaces" );
1287 poiSection->setSpacing( 12 );
1288
1289 GeoSceneItem *geoPole = new GeoSceneItem( "geographic-pole" );
1290 GeoSceneIcon *geoPoleIcon = geoPole->icon();
1291 geoPole->setText( tr("Geographic Pole") );
1292 geoPoleIcon->setPixmap( "bitmaps/pole_1.png" );
1293 poiSection->addItem( geoPole );
1294
1295 GeoSceneItem *magPole = new GeoSceneItem( "magnetic-pole" );
1296 GeoSceneIcon *magPoleIcon = magPole->icon();
1297 magPole->setText( tr("Magnetic Pole") );
1298 magPoleIcon->setPixmap( "bitmaps/pole_2.png" );
1299 poiSection->addItem( magPole );
1300
1301 GeoSceneItem *airport = new GeoSceneItem( "airport" );
1302 GeoSceneIcon *airportIcon = airport->icon();
1303 airport->setText( tr("Airport") );
1304 airportIcon->setPixmap( "bitmaps/airport.png" );
1305 poiSection->addItem( airport );
1306
1307 GeoSceneItem *shipwreck = new GeoSceneItem( "shipwreck" );
1308 GeoSceneIcon *shipwreckIcon = shipwreck->icon();
1309 shipwreck->setText( tr("Shipwreck") );
1310 shipwreckIcon->setPixmap( "bitmaps/shipwreck.png" );
1311 poiSection->addItem( shipwreck );
1312
1313 GeoSceneItem *observatory = new GeoSceneItem( "observatory" );
1314 GeoSceneIcon *observatoryIcon = observatory->icon();
1315 observatory->setText( tr("Observatory") );
1316 observatoryIcon->setPixmap( "bitmaps/observatory.png" );
1317 poiSection->addItem( observatory );
1318
1319 legend->addSection( poiSection );
1320 }
1321
1322 if( d->uiWidget.checkBoxTer->checkState() == Qt::Checked )
1323 {
1324 GeoSceneProperty *terrainProperty = new GeoSceneProperty( "terrain" );
1325 terrainProperty->setDefaultValue( true );
1326 terrainProperty->setAvailable( true );
1327 settings->addProperty( terrainProperty );
1328
1329 GeoSceneSection *terrainSection = new GeoSceneSection( "terrain" );
1330 terrainSection->setHeading( "Terrain" );
1331 terrainSection->setCheckable( true );
1332 terrainSection->setConnectTo( "terrain" );
1333 terrainSection->setSpacing( 12 );
1334
1335 GeoSceneItem *mountain = new GeoSceneItem( "mountain" );
1336 GeoSceneIcon *mountainIcon = mountain->icon();
1337 mountain->setText( tr("Mountain") );
1338 mountainIcon->setPixmap( "bitmaps/mountain_1.png" );
1339 terrainSection->addItem( mountain );
1340
1341 GeoSceneItem *volcano = new GeoSceneItem( "volcano" );
1342 GeoSceneIcon *volcanoIcon = volcano->icon();
1343 volcano->setText( tr("Volcano") );
1344 volcanoIcon->setPixmap( "bitmaps/volcano_1.png" );
1345 terrainSection->addItem( volcano );
1346
1347 legend->addSection( terrainSection );
1348
1349 }
1350
1351 if( d->uiWidget.checkBoxPop->checkState() == Qt::Checked )
1352 {
1353 GeoSceneProperty *placesProperty = new GeoSceneProperty( "places" );
1354 placesProperty->setDefaultValue( true );
1355 placesProperty->setAvailable( true );
1356 settings->addProperty( placesProperty );
1357
1358 GeoSceneProperty *citiesProperty = new GeoSceneProperty( "cities" );
1359 citiesProperty->setDefaultValue( true );
1360 citiesProperty->setAvailable( true );
1361 settings->addProperty( citiesProperty );
1362 }
1363
1364 if( d->uiWidget.checkBoxBorder->checkState() == Qt::Checked )
1365 {
1366 GeoSceneSection *bordersSection = new GeoSceneSection( "borders" );
1367 bordersSection->setHeading( "Boundaries" );
1368 bordersSection->setCheckable( true );
1369 bordersSection->setConnectTo( "borders" );
1370 bordersSection->setSpacing( 12 );
1371
1372 GeoSceneItem *internationalBoundary = new GeoSceneItem( "international-boundary" );
1373 GeoSceneIcon *internationalBoundaryIcon = internationalBoundary->icon();
1374 internationalBoundary->setText( tr("International") );
1375 internationalBoundaryIcon->setPixmap( "bitmaps/border_1.png" );
1376 bordersSection->addItem( internationalBoundary );
1377
1378 GeoSceneItem *stateBoundary = new GeoSceneItem( "state" );
1379 GeoSceneIcon *stateBoundaryIcon = stateBoundary->icon();
1380 stateBoundary->setText( tr("State") );
1381 stateBoundaryIcon->setPixmap( "bitmaps/border_2.png" );
1382 bordersSection->addItem( stateBoundary );
1383
1384 GeoSceneProperty *bordersProperty = new GeoSceneProperty( "borders" );
1385 bordersProperty->setDefaultValue( false );
1386 bordersProperty->setAvailable( true );
1387 settings->addProperty( bordersProperty );
1388
1389 GeoSceneProperty *intBoundariesProperty = new GeoSceneProperty( "international-boundaries" );
1390 intBoundariesProperty->setDefaultValue( false );
1391 intBoundariesProperty->setAvailable( true );
1392 settings->addProperty( intBoundariesProperty );
1393
1394 GeoSceneProperty *stateBounderiesProperty = new GeoSceneProperty( "state-boundaries" );
1395 stateBounderiesProperty->setDefaultValue( false );
1396 stateBounderiesProperty->setAvailable( true );
1397 settings->addProperty( stateBounderiesProperty );
1398
1399 legend->addSection( bordersSection );
1400
1401 GeoSceneLayer* mwdbii = new GeoSceneLayer( "mwdbii" );
1402 mwdbii->setBackend( "vector" );
1403 mwdbii->setRole( "polyline" );
1404
1405 GeoSceneVector* vector = new GeoSceneVector( "pdiffborder" );
1406 vector->setFeature( "border" );
1407 vector->setFileFormat( "PNT" );
1408 vector->setSourceFile( "earth/mwdbii/PDIFFBORDER.PNT" );
1409 vector->pen().setColor( "#ffe300" );
1410 mwdbii->addDataset( vector );
1411 map->addLayer( mwdbii );
1412 }
1413 */
1414 GeoSceneProperty *overviewmap = new GeoSceneProperty( "overviewmap" );
1415 overviewmap->setDefaultValue( true );
1416 overviewmap->setAvailable( true );
1417 settings->addProperty( overviewmap );
1418
1419 GeoSceneProperty *compass = new GeoSceneProperty( "compass" );
1420 compass->setDefaultValue( true );
1421 compass->setAvailable( true );
1422 settings->addProperty( compass );
1423
1424 GeoSceneProperty *scalebar = new GeoSceneProperty( "scalebar" );
1425 scalebar->setDefaultValue( true );
1426 scalebar->setAvailable( true );
1427 settings->addProperty( scalebar );
1428
1429 return document;
1430}
1431
1432void MapWizard::accept()
1433{
1434 Q_ASSERT( d->mapProviderType != MapWizardPrivate::NoMap );
1435
1436 Q_ASSERT( d->format == d->format.toLower() );
1437 Q_ASSERT( !d->mapTheme.isEmpty() );
1438
1439 if ( d->mapProviderType == MapWizardPrivate::StaticImageMap )
1440 {
1441 d->sourceImage = d->uiWidget.lineEditSource->text();
1442 Q_ASSERT( !d->sourceImage.isEmpty() );
1443 Q_ASSERT( QFile( d->sourceImage ).exists() );
1444 }
1445 else if ( d->mapProviderType == MapWizardPrivate::WmsMap )
1446 {
1447 Q_ASSERT( !d->owsManager.wmsCapabilities().layers().isEmpty() );
1448 Q_ASSERT( !d->levelZero.isNull() );
1449 }
1450 else if ( d->mapProviderType == MapWizardPrivate::WmtsMap )
1451 {
1452 Q_ASSERT( !d->owsManager.wmtsCapabilities().layers().isEmpty() );
1453 Q_ASSERT( !d->levelZero.isNull() );
1454 }
1455 else if ( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
1456 {
1457 Q_ASSERT( !d->levelZero.isNull() );
1458 Q_ASSERT( !QImage::fromData( d->levelZero ).isNull() );
1459 }
1460
1461 QSharedPointer<GeoSceneDocument> document( createDocument() );
1462 Q_ASSERT( !document->head()->description().isEmpty() );
1463 Q_ASSERT( !document->head()->name().isEmpty() );
1464
1465 if( createFiles( document.data() ) )
1466 {
1467 if( d->mapProviderType == MapWizardPrivate::WmsMap )
1468 {
1469 if( !d->owsManager.wmsCapabilities().legendUrl(d->sortModel->data(d->uiWidget.listViewWmsLayers->currentIndex(), layerIdRole).toString()).isEmpty() )
1470 {
1471 createWmsLegend();
1472 }
1473 } else if( d->mapProviderType == MapWizardPrivate::StaticImageMap || d->mapProviderType == MapWizardPrivate::StaticUrlMap ) {
1474 createLegend();
1475 }
1476
1478 d->uiWidget.lineEditTitle->clear();
1479 d->uiWidget.lineEditTheme->clear();
1480 d->uiWidget.textEditDesc->clear();
1481 d->uiWidget.labelPreview->clear();
1482 d->uiWidget.lineEditSource->clear();
1483 QTimer::singleShot( 0, this, SLOT(restart()) );
1484 }
1485
1486 else
1487 {
1488 QMessageBox::critical( this, tr( "Problem while creating files" ), tr( "Check if a theme with the same name exists." ) );
1489 return;
1490 }
1491}
1492
1493void MapWizard::showPreview()
1494{
1495 QSharedPointer<GeoSceneDocument> document( createDocument() );
1496
1497 if( createFiles( document.data() ) )
1498 {
1499 if( d->mapProviderType == MapWizardPrivate::WmsMap )
1500 {
1501 if( !d->owsManager.wmsCapabilities().legendUrl(d->sortModel->data(d->uiWidget.listViewWmsLayers->currentIndex(), layerIdRole).toString()).isEmpty() )
1502 {
1503 createWmsLegend();
1504 }
1505 } else if( d->mapProviderType == MapWizardPrivate::StaticImageMap || d->mapProviderType == MapWizardPrivate::StaticUrlMap ) {
1506 createLegend();
1507 }
1508 }
1509
1510 QPointer<PreviewDialog> previewDialog = new PreviewDialog( this, document.data()->head()->mapThemeId() );
1511 previewDialog->exec();
1512 delete previewDialog;
1513}
1514
1515void MapWizard::updateSearchFilter(const QString &text)
1516{
1517 d->sortModel->setFilterFixedString(text);
1518}
1519
1520void MapWizard::updateListViewSelection()
1521{
1522 QAbstractItemView::SelectionMode selectionModeWMS =
1523 d->uiWidget.checkBoxWmsMultipleSelections->isChecked()
1526 QAbstractItemView::SelectionMode selectionMode =
1527 d->owsManager.owsServiceType() == WmtsType
1529 : selectionModeWMS;
1530 d->uiWidget.listViewWmsLayers->setSelectionMode(selectionMode);
1531 d->uiWidget.checkBoxWmsMultipleSelections->setVisible(d->uiWidget.radioButtonWms->isChecked());
1532}
1533
1534void MapWizard::updateBackdropCheckBox()
1535{
1536 // The only backdrop supported is the Mercator-based OSM tile server map
1537 bool isMercator = d->uiWidget.comboBoxWmsMaps->currentText() == "Web Mercator (epsg:3857)";
1538 d->uiWidget.checkBoxWmsBackdrop->setEnabled(isMercator);
1539 d->uiWidget.tabCustomizeBackdrop->setEnabled(isMercator && d->uiWidget.checkBoxWmsBackdrop->isChecked());
1540}
1541
1542void MapWizard::updateOwsServiceType()
1543{
1544 if (d->uiWidget.radioButtonWms->isChecked()) {
1545 d->uiWidget.labelWmsServer->setText(tr("WMS Server"));
1546 d->uiWidget.labelOwsServiceHeader->setText(tr("<h4>WMS Server</h4>Please choose a <a href=\"https://en.wikipedia.org/wiki/Web_Map_Service\">WMS</a> server or enter a custom server URL."));
1547 d->uiWidget.comboBoxWmsServer->clear();
1548 d->uiWidget.comboBoxWmsServer->addItems( d->wmsServerList );
1549 d->uiWidget.comboBoxWmsServer->addItem( tr( "Custom" ), "http://" );
1550 d->uiWidget.comboBoxWmsServer->setCurrentText( tr( "Custom" ) );
1551
1552 }
1553 else if (d->uiWidget.radioButtonWmts->isChecked()) {
1554 d->uiWidget.labelWmsServer->setText(tr("WMTS Server"));
1555 d->uiWidget.labelOwsServiceHeader->setText(tr("<h4>WMTS Server</h4>Please choose a <a href=\"https://de.wikipedia.org/wiki/Web_Map_Tile_Service\">WMTS</a> server or enter a custom server URL."));
1556 d->uiWidget.comboBoxWmsServer->clear();
1557 d->uiWidget.comboBoxWmsServer->addItems( d->wmtsServerList );
1558 d->uiWidget.comboBoxWmsServer->addItem( tr( "Custom" ), "http://" );
1559 d->uiWidget.comboBoxWmsServer->setCurrentText( tr( "Custom" ) );
1560 }
1561 else if (d->uiWidget.radioButtonStaticUrl->isChecked()) {
1562 d->uiWidget.comboBoxStaticUrlServer->clear();
1563 d->uiWidget.comboBoxStaticUrlServer->addItems( d->staticUrlServerList );
1564// d->uiWidget.comboBoxWmsServer->addItem( tr( "Custom" ), "http://" );
1565// d->uiWidget.comboBoxWmsServer->setCurrentText( tr( "Custom" ) );
1566 }
1567}
1568
1569void MapWizard::chooseBackgroundColor()
1570{
1571 QColor selectedColor = QColorDialog::getColor(d->uiWidget.pushButtonColor->text());
1572 if (selectedColor.isValid()) {
1573 d->uiWidget.labelBackgroundColor->setText(selectedColor.name());
1574 QPalette p = d->uiWidget.labelBackgroundColor->palette();
1575 p.setColor(QPalette::Window, selectedColor);
1576 d->uiWidget.labelBackgroundColor->setPalette(p);
1577 }
1578}
1579
1580
1581}
1582
1583#include "moc_MapWizard.cpp"
1584#include "MapWizard.moc" // needed for Q_OBJECT here in source
This file contains the header for MapWizard.
This file contains the header for MarbleNavigator.
This file contains the headers for MarbleWidget.
Capabilities capabilities()
QAction * restart(const QObject *recvr, const char *slot, QObject *parent)
QString path(const QString &relativePath)
KIOCORE_EXPORT QString dir(const QString &fileClass)
QAction * zoomIn(const QObject *recvr, const char *slot, QObject *parent)
QAction * zoomOut(const QObject *recvr, const char *slot, QObject *parent)
QAction * next(const QObject *recvr, const char *slot, QObject *parent)
QAction * zoom(const QObject *recvr, const char *slot, QObject *parent)
Binds a QML item to a specific geodetic location in screen coordinates.
void clicked(bool checked)
void pressed(const QModelIndex &index)
bool isEnabled() const const
char * data()
void stateChanged(int state)
bool isValid() const const
QString name(NameFormat format) const const
QColor getColor(const QColor &initial, QWidget *parent, const QString &title, ColorDialogOptions options)
virtual void accept()
virtual void closeEvent(QCloseEvent *e) override
QString absolutePath() const const
bool cd(const QString &dirName)
QStringList entryList(Filters filters, SortFlags sort) const const
QString tempPath()
bool copy(const QString &fileName, const QString &newName)
bool exists(const QString &fileName)
bool exists() const const
bool remove()
void setFileName(const QString &name)
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, Options options)
bool exists() const const
void addWidget(QWidget *widget, int fromRow, int fromColumn, int rowSpan, int columnSpan, Qt::Alignment alignment)
virtual void setSpacing(int spacing) override
QImage fromData(QByteArrayView data, const char *format)
bool isNull() const const
QImage scaled(const QSize &size, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const const
int width() const const
void setText(const QString &)
void textChanged(const QString &text)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
void clear()
pointer data()
T & first()
bool isEmpty() const const
StandardButton critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons, StandardButton defaultButton)
StandardButton information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons, StandardButton defaultButton)
Q_OBJECTQ_OBJECT
QObject * parent() const const
void setColor(ColorGroup group, ColorRole role, const QColor &color)
QPixmap fromImage(QImage &&image, Qt::ImageConversionFlags flags)
int height() const const
QSize size() const const
int width() const const
int execute(const QString &program, const QStringList &arguments)
bool waitForFinished(int msecs)
void setFilterCaseSensitivity(Qt::CaseSensitivity cs)
virtual void setSourceModel(QAbstractItemModel *sourceModel) override
virtual void setData(const QVariant &value, int role)
void setToolTip(const QString &toolTip)
QString arg(Args &&... args) const const
void clear()
QString first(qsizetype n) const const
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) const const
qsizetype length() const const
QString & prepend(QChar ch)
QString & remove(QChar ch, Qt::CaseSensitivity cs)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString right(qsizetype n) const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QByteArray toLatin1() const const
QString toLower() const const
QString join(QChar separator) const const
IgnoreAspectRatio
CaseInsensitive
SmoothTransformation
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setQuery(const QString &query, ParsingMode mode)
void addQueryItem(const QString &key, const QString &value)
void setupUi(QWidget *widget)
virtual void cleanupPage(int id)
virtual bool validateCurrentPage()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:00:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.