12 #include "ui_MapWizard.h"
41 #include <QSharedPointer>
43 #include <QTemporaryFile>
45 #include <QMessageBox>
46 #include <QFileDialog>
47 #include <QImageReader>
48 #include <QDialogButtonBox>
49 #include <QNetworkAccessManager>
50 #include <QNetworkReply>
51 #include <QNetworkRequest>
52 #include <QDomElement>
53 #include <QXmlStreamWriter>
54 #if QT_VERSION >= 0x050000
61 class MapWizardPrivate
65 : m_serverCapabilitiesValid( false ),
69 void pageEntered(
int id );
71 Ui::MapWizard uiWidget;
81 bool m_serverCapabilitiesValid;
91 mapType mapProviderType;
102 class PreviewDialog :
public QDialog
108 bool deleteTheme(
QString directory );
112 PreviewDialog::PreviewDialog(
QWidget* parent,
QString mapThemeId ) :
QDialog( parent ), m_mapThemeId( mapThemeId )
116 MarbleNavigator *navigator =
new MarbleNavigator();
118 connect( navigator, SIGNAL(goHome()), widget, SLOT(goHome()) );
119 connect( navigator, SIGNAL(moveUp()), widget, SLOT(moveUp()) );
120 connect( navigator, SIGNAL(moveDown()), widget, SLOT(moveDown()) );
121 connect( navigator, SIGNAL(moveLeft()), widget, SLOT(moveLeft()) );
122 connect( navigator, SIGNAL(moveRight()), widget, SLOT(moveRight()) );
123 connect( navigator, SIGNAL(zoomIn()), widget, SLOT(zoomIn()) );
124 connect( navigator, SIGNAL(zoomOut()), widget, SLOT(zoomOut()) );
125 connect( navigator, SIGNAL(zoomChanged(
int)), widget, SLOT(setZoom(
int)) );
128 widget->setZoom( 1000 );
144 this->deleteTheme( directory );
148 bool PreviewDialog::deleteTheme(
QString directory )
153 if (dir.exists(directory)) {
154 Q_FOREACH(
QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) {
165 result = dir.rmdir(directory);
171 void MapWizardPrivate::pageEntered(
int id )
174 m_serverCapabilitiesValid =
false;
175 }
else if (
id == 2 ||
id == 4 ) {
177 uiWidget.comboBoxStaticUrlServer->clear();
178 uiWidget.comboBoxStaticUrlServer->addItems( staticUrlServerList );
179 uiWidget.comboBoxStaticUrlServer->addItem(
"http://" );
180 }
else if (
id == 5 ) {
181 if ( mapProviderType == MapWizardPrivate::StaticImageMap ) {
182 previewImage =
QImage( uiWidget.lineEditSource->text() ).scaled( 136, 136, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
184 previewImage =
QImage::fromData( levelZero ).
scaled( 136, 136, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
187 }
else if (
id == 7 ) {
194 d->uiWidget.setupUi(
this );
206 connect( d->uiWidget.comboBoxWmsServer, SIGNAL(currentIndexChanged(
QString)), d->uiWidget.lineEditWmsUrl, SLOT(setText(
QString)) );
209 connect( d->uiWidget.lineEditTitle, SIGNAL(textChanged(
QString)), d->uiWidget.labelSumMName, SLOT(setText(
QString)) );
210 connect( d->uiWidget.lineEditTheme, SIGNAL(textChanged(
QString)), d->uiWidget.labelSumMTheme, SLOT(setText(
QString)) );
212 connect( d->uiWidget.pushButtonPreviewMap, SIGNAL(clicked(
bool)),
this, SLOT(
showPreview()) );
223 QUrl url( d->uiWidget.lineEditWmsUrl->text() );
224 #if QT_VERSION < 0x050000
226 url.addQueryItem(
"request",
"GetCapabilities" );
229 urlQuery.addQueryItem(
"service",
"WMS" );
230 urlQuery.addQueryItem(
"request",
"GetCapabilities" );
231 url.setQuery(urlQuery);
237 d->xmlAccessManager.get( request );
246 if( !xml.setContent( result ) )
252 if( xml.documentElement().firstChildElement().tagName().isNull() )
261 d->uiWidget.listWidgetWmsMaps->clear();
262 d->wmsFetchedMaps.clear();
264 for(
int i = 0; i < layers.
size(); ++i )
269 d->wmsFetchedMaps[ theme ] = title;
271 d->wmsLegends.clear();
272 if( legendUrl.
isNull() ) {
273 d->wmsLegends.append(
QString() );
279 d->uiWidget.listWidgetWmsMaps->addItems( d->wmsFetchedMaps.values() );
286 if( d->format ==
"jpeg" ) {
290 if( !d->wmsFetchedMaps.isEmpty() && !d->wmsServerList.contains( d->uiWidget.lineEditWmsUrl->text() ) ) {
291 d->wmsServerList.append( d->uiWidget.lineEditWmsUrl->text() );
295 d->m_serverCapabilitiesValid =
true;
303 if( !map.exists(
"legend" ) ) {
304 map.mkdir(
"legend" );
307 QFile image(
QString(
"%1/legend/legend.png" ).arg( map.absolutePath() ) );
308 image.
open( QIODevice::ReadWrite );
309 image.
write( result );
312 const QString legendHtml = createLegendHtml();
313 createLegendFile( legendHtml );
318 d->wmsServerList = uris;
320 d->uiWidget.comboBoxWmsServer->clear();
321 d->uiWidget.comboBoxWmsServer->addItems( d->wmsServerList );
322 d->uiWidget.comboBoxWmsServer->addItem(
tr(
"Custom" ),
"http://" );
327 return d->wmsServerList;
332 return d->staticUrlServerList;
337 d->staticUrlServerList = uris;
342 QString selected = d->uiWidget.listWidgetWmsMaps->currentItem()->text();
343 d->uiWidget.lineEditTitle->setText( selected );
344 d->uiWidget.lineEditTheme->setText( d->wmsFetchedMaps.key( selected ) );
351 if( !maps.exists( document->
head()->
theme() ) )
355 if( d->mapProviderType == MapWizardPrivate::StaticImageMap )
358 QFile sourceImage( d->sourceImage );
359 d->format = d->sourceImage.right( d->sourceImage.length() - d->sourceImage.lastIndexOf(
'.' ) - 1 ).toLower();
360 sourceImage.copy(
QString(
"%1/%2/%2.%3" ).arg( maps.absolutePath() )
365 else if( d->mapProviderType == MapWizardPrivate::WmsMap )
372 QFile baseTile( path );
373 baseTile.open( QFile::WriteOnly );
374 baseTile.write( d->levelZero );
377 else if( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
384 QFile baseTile( path );
385 baseTile.open( QFile::WriteOnly );
386 baseTile.write( d->levelZero );
393 d->previewImage.save( pixmapPath );
396 QFile file(
QString(
"%1/%2/%2.dgml" ).arg( maps.absolutePath() )
398 file.open( QIODevice::ReadWrite );
401 geoWriter.write( &file, document );
415 stream.writeStartDocument();
416 stream.writeStartElement(
"html" );
417 stream.writeStartElement(
"head" );
419 stream.writeTextElement(
"title",
"Marble: Legend" );
420 stream.writeStartElement(
"link" );
421 stream.writeAttribute(
"href",
"legend.css" );
422 stream.writeAttribute(
"rel",
"stylesheet" );
423 stream.writeAttribute(
"type",
"text/css" );
424 stream.writeEndElement();
426 stream.writeStartElement(
"body" );
427 stream.writeStartElement(
"img" );
428 stream.writeAttribute(
"src", image );
429 stream.writeEndElement();
430 stream.writeComment(
" ##customLegendEntries:all## " );
431 stream.writeEndElement();
432 stream.writeEndElement();
437 void MapWizard::createLegendFile(
const QString& legendHtml )
442 html.open( QIODevice::ReadWrite );
447 void MapWizard::downloadLegend(
const QString& url )
449 QUrl downloadUrl( url );
451 d->legendAccessManager.get( request );
456 if( d->mapProviderType == MapWizardPrivate::WmsMap )
458 QString selected = d->uiWidget.listWidgetWmsMaps->currentItem()->text();
460 #if QT_VERSION < 0x050000
461 QUrl downloadUrl( d->uiWidget.lineEditWmsUrl->text() );
463 QUrl finalDownloadUrl( d->uiWidget.lineEditWmsUrl->text() );
464 QUrlQuery downloadUrl;
467 downloadUrl.addQueryItem(
"version",
"1.1.1" );
468 downloadUrl.addQueryItem(
"layers", d->wmsFetchedMaps.key( selected ) );
469 downloadUrl.addQueryItem(
"srs",
"EPSG:4326" );
470 downloadUrl.addQueryItem(
"width",
"400" );
471 downloadUrl.addQueryItem(
"height",
"200" );
472 downloadUrl.addQueryItem(
"bbox",
"-180,-90,180,90" );
473 downloadUrl.addQueryItem(
"format",
"image/jpeg" );
474 downloadUrl.addQueryItem(
"styles",
"" );
476 #if QT_VERSION < 0x050000
479 finalDownloadUrl.setQuery( downloadUrl );
484 d->levelZeroAccessManager.get( request );
487 else if( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
489 QString server = d->uiWidget.comboBoxStaticUrlServer->currentText();
495 downloadUrl.
setUrl( server );
498 d->levelZeroAccessManager.get( request );
506 d->levelZero = reply->
readAll();
509 if ( d->levelZero.isNull() ) {
512 tr(
"The base tile could not be downloaded." ) );
516 if ( testImage.
isNull() ) {
519 tr(
"The base tile could not be downloaded successfully. The server replied:\n\n%1" ).arg(
QString( d->levelZero ) ) );
520 d->levelZero.clear();
524 QBuffer testBuffer( &d->levelZero );
527 if ( d->mapProviderType == MapWizardPrivate::StaticUrlMap ) {
528 const QString url = d->uiWidget.comboBoxStaticUrlServer->currentText();
529 d->staticUrlServerList.removeAll( url );
530 d->staticUrlServerList.prepend( url );
536 void MapWizard::createLegend()
539 if( !map.exists(
"legend" ) ) {
540 map.mkdir(
"legend" );
544 image.
setFileName( d->uiWidget.lineEditLegend_2->text() );
545 image.
copy(
QString(
"%1/legend/legend.png" ).arg( map.absolutePath() ) );
547 const QString legendHtml = createLegendHtml();
548 createLegendFile( legendHtml );
559 d->previewImage =
QImage( fileName );
562 d->uiWidget.labelThumbnail->setPixmap( preview );
563 d->uiWidget.labelThumbnail->resize( preview.
width(), preview.
height() );
569 d->uiWidget.lineEditLegend_2->setText( fileName );
570 const QString legendHtml = createLegendHtml( d->uiWidget.lineEditLegend_2->text() );
571 d->uiWidget.textBrowserLegend->setHtml( legendHtml );
582 tarArgs.
append(
"--create" );
583 tarArgs.
append(
"--gzip" );
584 tarArgs.
append(
"--file" );
586 tarArgs.
append(
"--directory" );
602 tarArgs.
append(
QString(
"%1/%2/%2.dgml" ).arg( body ).arg( theme ) );
607 tarArgs.
append(
QString(
"%1/%2/legend.html" ).arg( body ).arg( theme ) );
612 tarArgs.
append(
QString(
"%1/%2/legend" ).arg( body ).arg( theme ) );
617 tarArgs.
append(
QString(
"%1/%2/0/000000" ).arg( body ).arg( theme ) );
621 previewFilters <<
"preview.*";
624 tarArgs.
append(
QString(
"%1/%2/%3" ).arg( body ).arg( theme ).arg( preview[0] ) );
631 tarArgs.
append(
QString(
"%1/%2/%3" ).arg( body ).arg( theme ).arg( sourceImg[0] ) );
635 switch( archiver.
execute(
"tar", tarArgs ) )
644 mDebug() <<
"Archived the theme successfully.";
660 if (
currentId() == 1 && !d->m_serverCapabilitiesValid ) {
673 d->sourceImage = d->uiWidget.lineEditSource->text();
674 if ( d->sourceImage.isEmpty() ) {
676 tr(
"Source Image" ),
677 tr(
"Please specify a source image." ) );
678 d->uiWidget.lineEditSource->setFocus();
684 tr(
"Source Image" ),
685 tr(
"The source image you specified does not exist. Please specify a different one." ) );
686 d->uiWidget.lineEditSource->setFocus();
687 d->uiWidget.lineEditSource->selectAll();
693 tr(
"Source Image" ),
694 tr(
"The source image you specified does not seem to be an image. Please specify a different image file." ) );
695 d->uiWidget.lineEditSource->setFocus();
696 d->uiWidget.lineEditSource->selectAll();
702 if ( d->uiWidget.lineEditTitle->text().isEmpty() ) {
704 d->uiWidget.lineEditTitle->setFocus();
708 d->mapTheme = d->uiWidget.lineEditTheme->text();
709 if ( d->mapTheme.isEmpty() ) {
711 d->uiWidget.lineEditTheme->setFocus();
716 if ( destinationDir.
exists() ) {
719 tr(
"Please specify another map name, since there is already a map named \"%1\"." ).arg( d->mapTheme ) );
720 d->uiWidget.lineEditTheme->setFocus();
721 d->uiWidget.lineEditTheme->selectAll();
725 if ( d->previewImage.isNull() ) {
727 d->uiWidget.pushButtonPreview->setFocus();
740 if( d->uiWidget.radioButtonWms->isChecked() ) {
741 d->mapProviderType = MapWizardPrivate::WmsMap;
743 }
else if( d->uiWidget.radioButtonBitmap->isChecked() ) {
744 d->mapProviderType = MapWizardPrivate::StaticImageMap;
746 }
else if( d->uiWidget.radioButtonStaticUrl->isChecked() ) {
747 d->mapProviderType = MapWizardPrivate::StaticUrlMap;
777 head->
setName( d->uiWidget.lineEditTitle->text() );
778 head->
setTheme( d->uiWidget.lineEditTheme->text() );
780 head->
setDescription( d->uiWidget.textEditDesc->document()->toHtml() );
794 if( d->mapProviderType == MapWizardPrivate::WmsMap )
797 QString layer = d->wmsFetchedMaps.key( d->uiWidget.listWidgetWmsMaps->currentItem()->text() );
798 QUrl downloadUrl =
QUrl( d->uiWidget.lineEditWmsUrl->text() );
799 #if QT_VERSION < 0x050000
803 urlQuery.addQueryItem(
"layers", layer );
814 else if( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
817 QUrl downloadUrl =
QUrl( d->uiWidget.comboBoxStaticUrlServer->currentText() );
828 else if( d->mapProviderType == MapWizardPrivate::StaticImageMap )
830 QString image = d->uiWidget.lineEditSource->text();
839 float approxMaxTileLevel = log( imageWidth / ( 2.0 * tileSize ) ) / log( 2.0 );
840 int maxTileLevel = 0;
841 if ( approxMaxTileLevel ==
int( approxMaxTileLevel ) ) {
842 maxTileLevel =
static_cast<int>( approxMaxTileLevel );
844 maxTileLevel =
static_cast<int>( approxMaxTileLevel + 1 );
849 GeoSceneLayer *layer =
new GeoSceneLayer( d->uiWidget.lineEditTheme->text() );
850 layer->setBackend(
"texture" );
851 layer->addDataset( texture );
853 GeoSceneLayer* secondLayer =
new GeoSceneLayer(
"standardplaces" );
854 secondLayer->setBackend(
"geodata" );
856 GeoSceneGeodata* cityplacemarks =
new GeoSceneGeodata(
"cityplacemarks" );
857 cityplacemarks->setSourceFile(
"cityplacemarks.kml" );
858 secondLayer->addDataset( cityplacemarks );
860 GeoSceneGeodata* baseplacemarks =
new GeoSceneGeodata(
"baseplacemarks" );
861 baseplacemarks->setSourceFile(
"baseplacemarks.kml" );
862 secondLayer->addDataset( baseplacemarks );
864 GeoSceneGeodata* elevplacemarks =
new GeoSceneGeodata(
"elevplacemarks" );
865 elevplacemarks->setSourceFile(
"elevplacemarks.kml" );
866 secondLayer->addDataset( elevplacemarks );
868 GeoSceneGeodata* observatoryplacemarks =
new GeoSceneGeodata(
"observatoryplacemarks" );
869 observatoryplacemarks->setSourceFile(
"observatoryplacemarks.kml" );
870 secondLayer->addDataset( observatoryplacemarks );
872 GeoSceneGeodata* otherplacemarks =
new GeoSceneGeodata(
"otherplacemarks" );
873 otherplacemarks->setSourceFile(
"otherplacemarks.kml" );
874 secondLayer->addDataset( otherplacemarks );
876 GeoSceneGeodata* boundaryplacemarks =
new GeoSceneGeodata(
"boundaryplacemarks" );
877 boundaryplacemarks->setSourceFile(
"boundaryplacemarks.kml" );
878 secondLayer->addDataset( boundaryplacemarks );
880 GeoSceneMap *
map = document->
map();
882 map->addLayer( secondLayer );
884 GeoSceneSettings *settings = document->
settings();
885 GeoSceneLegend *legend = document->
legend();
887 if( d->uiWidget.checkBoxCoord->checkState() == Qt::Checked )
889 GeoSceneProperty *coorGrid =
new GeoSceneProperty(
"coordinate-grid" );
890 coorGrid->setDefaultValue(
true );
891 coorGrid->setAvailable(
true );
892 settings->addProperty( coorGrid );
894 GeoSceneSection *coorSection =
new GeoSceneSection(
"coordinate-grid" );
895 coorSection->setHeading(
"Coordinate Grid" );
896 coorSection->setCheckable(
true );
897 coorSection->setConnectTo(
"coordinate-grid" );
898 coorSection->setSpacing( 12 );
899 legend->addSection( coorSection );
902 if( d->uiWidget.checkBoxInterest->checkState() == Qt::Checked )
904 GeoSceneProperty *poiProperty =
new GeoSceneProperty(
"otherplaces" );
905 poiProperty->setDefaultValue(
true );
906 poiProperty->setAvailable(
true );
907 settings->addProperty( poiProperty );
909 GeoSceneSection *poiSection =
new GeoSceneSection(
"otherplaces" );
910 poiSection->setHeading(
"Places of Interest" );
911 poiSection->setCheckable(
true );
912 poiSection->setConnectTo(
"otherplaces" );
913 poiSection->setSpacing( 12 );
915 GeoSceneItem *geoPole =
new GeoSceneItem(
"geographic-pole" );
916 GeoSceneIcon *geoPoleIcon = geoPole->icon();
917 geoPole->setText(
tr(
"Geographic Pole") );
918 geoPoleIcon->setPixmap(
"bitmaps/pole_1.png" );
919 poiSection->addItem( geoPole );
921 GeoSceneItem *magPole =
new GeoSceneItem(
"magnetic-pole" );
922 GeoSceneIcon *magPoleIcon = magPole->icon();
923 magPole->setText(
tr(
"Magnetic Pole") );
924 magPoleIcon->setPixmap(
"bitmaps/pole_2.png" );
925 poiSection->addItem( magPole );
927 GeoSceneItem *airport =
new GeoSceneItem(
"airport" );
928 GeoSceneIcon *airportIcon = airport->icon();
929 airport->setText(
tr(
"Airport") );
930 airportIcon->setPixmap(
"bitmaps/airport.png" );
931 poiSection->addItem( airport );
933 GeoSceneItem *shipwreck =
new GeoSceneItem(
"shipwreck" );
934 GeoSceneIcon *shipwreckIcon = shipwreck->icon();
935 shipwreck->setText(
tr(
"Shipwreck") );
936 shipwreckIcon->setPixmap(
"bitmaps/shipwreck.png" );
937 poiSection->addItem( shipwreck );
939 GeoSceneItem *observatory =
new GeoSceneItem(
"observatory" );
940 GeoSceneIcon *observatoryIcon = observatory->icon();
941 observatory->setText(
tr(
"Observatory") );
942 observatoryIcon->setPixmap(
"bitmaps/observatory.png" );
943 poiSection->addItem( observatory );
945 legend->addSection( poiSection );
948 if( d->uiWidget.checkBoxTer->checkState() == Qt::Checked )
950 GeoSceneProperty *terrainProperty =
new GeoSceneProperty(
"terrain" );
951 terrainProperty->setDefaultValue(
true );
952 terrainProperty->setAvailable(
true );
953 settings->addProperty( terrainProperty );
955 GeoSceneSection *terrainSection =
new GeoSceneSection(
"terrain" );
956 terrainSection->setHeading(
"Terrain" );
957 terrainSection->setCheckable(
true );
958 terrainSection->setConnectTo(
"terrain" );
959 terrainSection->setSpacing( 12 );
961 GeoSceneItem *mountain =
new GeoSceneItem(
"mountain" );
962 GeoSceneIcon *mountainIcon = mountain->icon();
963 mountain->setText(
tr(
"Mountain") );
964 mountainIcon->setPixmap(
"bitmaps/mountain_1.png" );
965 terrainSection->addItem( mountain );
967 GeoSceneItem *volcano =
new GeoSceneItem(
"volcano" );
968 GeoSceneIcon *volcanoIcon = volcano->icon();
969 volcano->setText(
tr(
"Volcano") );
970 volcanoIcon->setPixmap(
"bitmaps/volcano_1.png" );
971 terrainSection->addItem( volcano );
973 legend->addSection( terrainSection );
977 if( d->uiWidget.checkBoxPop->checkState() == Qt::Checked )
979 GeoSceneProperty *placesProperty =
new GeoSceneProperty(
"places" );
980 placesProperty->setDefaultValue(
true );
981 placesProperty->setAvailable(
true );
982 settings->addProperty( placesProperty );
984 GeoSceneProperty *citiesProperty =
new GeoSceneProperty(
"cities" );
985 citiesProperty->setDefaultValue(
true );
986 citiesProperty->setAvailable(
true );
987 settings->addProperty( citiesProperty );
990 if( d->uiWidget.checkBoxBorder->checkState() == Qt::Checked )
992 GeoSceneSection *bordersSection =
new GeoSceneSection(
"borders" );
993 bordersSection->setHeading(
"Boundaries" );
994 bordersSection->setCheckable(
true );
995 bordersSection->setConnectTo(
"borders" );
996 bordersSection->setSpacing( 12 );
998 GeoSceneItem *internationalBoundary =
new GeoSceneItem(
"international-boundary" );
999 GeoSceneIcon *internationalBoundaryIcon = internationalBoundary->icon();
1000 internationalBoundary->setText(
tr(
"International") );
1001 internationalBoundaryIcon->setPixmap(
"bitmaps/border_1.png" );
1002 bordersSection->addItem( internationalBoundary );
1004 GeoSceneItem *stateBoundary =
new GeoSceneItem(
"state" );
1005 GeoSceneIcon *stateBoundaryIcon = stateBoundary->icon();
1006 stateBoundary->setText(
tr(
"State") );
1007 stateBoundaryIcon->setPixmap(
"bitmaps/border_2.png" );
1008 bordersSection->addItem( stateBoundary );
1010 GeoSceneProperty *bordersProperty =
new GeoSceneProperty(
"borders" );
1011 bordersProperty->setDefaultValue(
false );
1012 bordersProperty->setAvailable(
true );
1013 settings->addProperty( bordersProperty );
1015 GeoSceneProperty *intBoundariesProperty =
new GeoSceneProperty(
"international-boundaries" );
1016 intBoundariesProperty->setDefaultValue(
false );
1017 intBoundariesProperty->setAvailable(
true );
1018 settings->addProperty( intBoundariesProperty );
1020 GeoSceneProperty *stateBounderiesProperty =
new GeoSceneProperty(
"state-boundaries" );
1021 stateBounderiesProperty->setDefaultValue(
false );
1022 stateBounderiesProperty->setAvailable(
true );
1023 settings->addProperty( stateBounderiesProperty );
1025 legend->addSection( bordersSection );
1027 GeoSceneLayer* mwdbii =
new GeoSceneLayer(
"mwdbii" );
1028 mwdbii->setBackend(
"vector" );
1029 mwdbii->setRole(
"polyline" );
1031 GeoSceneVector* vector =
new GeoSceneVector(
"pdiffborder" );
1032 vector->setFeature(
"border" );
1033 vector->setFileFormat(
"PNT" );
1034 vector->setSourceFile(
"earth/mwdbii/PDIFFBORDER.PNT" );
1035 vector->pen().setColor(
"#ffe300" );
1036 mwdbii->addDataset( vector );
1037 map->addLayer( mwdbii );
1040 GeoSceneProperty *overviewmap =
new GeoSceneProperty(
"overviewmap" );
1041 overviewmap->setDefaultValue(
true );
1042 overviewmap->setAvailable(
true );
1043 settings->addProperty( overviewmap );
1045 GeoSceneProperty *compass =
new GeoSceneProperty(
"compass" );
1046 compass->setDefaultValue(
true );
1047 compass->setAvailable(
true );
1048 settings->addProperty( compass );
1050 GeoSceneProperty *scalebar =
new GeoSceneProperty(
"scalebar" );
1051 scalebar->setDefaultValue(
true );
1052 scalebar->setAvailable(
true );
1053 settings->addProperty( scalebar );
1060 Q_ASSERT( d->mapProviderType != MapWizardPrivate::NoMap );
1062 Q_ASSERT( d->format == d->format.toLower() );
1063 Q_ASSERT( !d->mapTheme.isEmpty() );
1065 if ( d->mapProviderType == MapWizardPrivate::StaticImageMap )
1067 d->sourceImage = d->uiWidget.lineEditSource->text();
1068 Q_ASSERT( !d->sourceImage.isEmpty() );
1071 else if ( d->mapProviderType == MapWizardPrivate::WmsMap )
1073 Q_ASSERT( !d->wmsFetchedMaps.isEmpty() );
1074 Q_ASSERT( !d->levelZero.isNull() );
1077 else if ( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
1079 Q_ASSERT( !d->levelZero.isNull() );
1084 Q_ASSERT( !document->head()->description().isEmpty() );
1085 Q_ASSERT( !document->head()->name().isEmpty() );
1087 if( createFiles( document.
data() ) )
1089 if( d->mapProviderType == MapWizardPrivate::WmsMap )
1091 if( d->wmsLegends.isEmpty() && d->wmsLegends.at( d->uiWidget.listWidgetWmsMaps->currentRow() ).isEmpty() )
1093 downloadLegend( d->wmsLegends.at( d->uiWidget.listWidgetWmsMaps->currentRow() ) );
1095 }
else if( d->mapProviderType == MapWizardPrivate::StaticImageMap || d->mapProviderType == MapWizardPrivate::StaticUrlMap ) {
1100 d->uiWidget.lineEditTitle->clear();
1101 d->uiWidget.lineEditTheme->clear();
1102 d->uiWidget.textEditDesc->clear();
1103 d->uiWidget.labelPreview->clear();
1104 d->uiWidget.lineEditSource->clear();
1110 QMessageBox::critical(
this,
tr(
"Problem while creating files" ),
tr(
"Check if a theme with the same name exists." ) );
1119 if( createFiles( document.
data() ) )
1121 if( d->mapProviderType == MapWizardPrivate::WmsMap )
1123 if( d->wmsLegends.isEmpty() && d->wmsLegends.at( d->uiWidget.listWidgetWmsMaps->currentRow() ).isEmpty() )
1125 downloadLegend( d->wmsLegends.at( d->uiWidget.listWidgetWmsMaps->currentRow() ) );
1127 }
else if( d->mapProviderType == MapWizardPrivate::StaticImageMap || d->mapProviderType == MapWizardPrivate::StaticUrlMap ) {
1133 previewDialog->exec();
1134 delete previewDialog;
1140 #include "MapWizard.moc"
int execute(const QString &program, const QStringList &arguments)
virtual bool validateCurrentPage()
QDomNodeList elementsByTagName(const QString &tagname) const
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
Icon properties of a GeoScene document.
const GeoSceneMap * map() const
void setServerLayout(const ServerLayout *)
virtual void closeEvent(QCloseEvent *e)
void setQuery(const QString &txt)
QImage fromData(const uchar *data, int size, const char *format)
void setUrl(const QUrl &url)
void setMaximum(int target)
void setWmsServers(const QStringList &uris)
General properties and identifiers of a GeoScene document.
QString attribute(const QString &name, const QString &defValue) const
void createWmsLegend(QNetworkReply *reply)
static QString createArchive(QWidget *parent, QString mapId)
QStringList wmsServers() const
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
void setTarget(const QString &target)
void setStaticUrlServers(const QStringList &uris)
void setInstallMap(const QString &installMap)
void parseServerCapabilities(QNetworkReply *reply)
void setFileName(const QString &name)
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
Browsing mode, normal operation of Marble, like a web browser.
static QString localPath()
void setVisible(bool visible)
void setLevelZeroColumns(const int)
void setSourceDir(const QString &sourceDir)
QString tr(const char *sourceText, const char *disambiguation, int n)
bool copy(const QString &newName)
void setName(const QString &name)
void setSpacing(int spacing)
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
This file contains the header for MapWizard.
void setDescription(const QString &)
static void deleteArchive(QString mapId)
void finished(int result)
void currentIdChanged(int id)
const GeoSceneLegend * legend() const
void setProjection(const Projection)
QString number(int n, int base)
void append(const T &value)
void setPixmap(const QString &)
const unsigned int c_defaultTileSize
void setUrl(const QString &url)
bool cd(const QString &dirName)
QString absoluteFilePath() const
const char * dgmlTag_nameSpace20
void setTheme(const QString &theme)
QFuture< void > map(Sequence &sequence, MapFunction function)
void setMargin(int margin)
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
QString right(int n) const
const GeoSceneHead * head() const
A container for features parsed from the DGML file.
QStringList staticUrlServers() const
virtual int nextId() const
QString & replace(int position, int n, QChar after)
void addLayer(GeoSceneLayer *)
Add a new layer to the map.
void setFileFormat(const QString &fileFormat)
QByteArray toLatin1() const
const GeoSceneIcon * icon() const
This file contains the header for MarbleNavigator.
QString absolutePath() const
void setExpire(int expire)
QStringList entryList(QFlags< QDir::Filter > filters, QFlags< QDir::SortFlag > sort) const
QDomElement firstChildElement(const QString &tagName) const
void createLevelZero(QNetworkReply *reply=0)
StandardButton critical(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
void setMinimum(int name)
QString left(int n) const
qint64 write(const char *data, qint64 maxSize)
const GeoSceneZoom * zoom() const
void addQueryItem(const QString &key, const QString &value)
static QString systemPath()
Zoom properties of a GeoScene document.
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFlags< QFileDialog::Option > options)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
void addDownloadUrl(const QUrl &)
void setLevelZeroRows(const int)
QDebug mDebug()
a function to replace qDebug() in Marble library code
void setMaximumTileLevel(const int)
QImage scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const
const GeoSceneSettings * settings() const
void setDiscrete(bool theme)
virtual bool validateCurrentPage()
Bulk download, for example "File/Download region".
QDomNode at(int index) const
MapWizard(QWidget *parent=0)
void addDownloadPolicy(const DownloadUsage usage, const int maximumConnections)
void queryServerCapabilities()
bool waitForFinished(int msecs)