[Marble-commits] KDE/kdeedu/marble/src/lib

Bernhard Beschow bbeschow at cs.tu-berlin.de
Sun Feb 20 16:55:06 CET 2011


SVN commit 1221817 by beschow:

MapWizard: remove image format combo and always require the full URL (incl. file extension) to be provided

* clarifies what data is required from users (always full URL, no magic completion of the URL in case of OSM-like server)
* the image format is determined automatically -> no need for combo, which was error-prone

 M  +6 -14     MapWizard.cpp  
 M  +3 -31     MapWizard.ui  


--- trunk/KDE/kdeedu/marble/src/lib/MapWizard.cpp #1221816:1221817
@@ -32,7 +32,7 @@
 #include "GeoWriter.h"
 #include "DgmlElementDictionary.h"
 
-#include <stdlib.h>
+#include <QtCore/QBuffer>
 #include <QtCore/QDir>
 #include <QtCore/QFile>
 #include <QtCore/QProcess>
@@ -124,12 +124,7 @@
 MapWizard::MapWizard( QWidget* parent ) : QWizard( parent ), d( new MapWizardPrivate )
 {
     d->uiWidget.setupUi( this );
-    QListIterator<QByteArray> i( QImageReader::supportedImageFormats() );
 
-    while( i.hasNext() ) {
-        d->uiWidget.comboBoxStaticUrlFormat->addItem( QString( i.next() ) );
-    }
-    
     connect( this, SIGNAL( currentIdChanged( int ) ), this, SLOT( pageEntered( int ) ) );
 
     connect( &( d->xmlAccessManager ), SIGNAL( finished( QNetworkReply* ) ), this, SLOT( parseServerCapabilities( QNetworkReply* ) ) );
@@ -305,7 +300,7 @@
             maps.mkdir( QString( "%1/0/0" ).arg( document->head()->theme() ) );
             const QString path = QString( "%1/%2/0/0/0.%3" ).arg( maps.absolutePath() )
                                                             .arg( document->head()->theme() )
-                                                            .arg( d->uiWidget.comboBoxStaticUrlFormat->currentText() );
+                                                            .arg( d->format );
             QFile baseTile( path );
             baseTile.open( QFile::WriteOnly );
             baseTile.write( d->levelZero );
@@ -399,18 +394,12 @@
     else if( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
     {
         QString server = d->uiWidget.comboBoxStaticUrlServer->currentText();
-        QString format = d->uiWidget.comboBoxStaticUrlFormat->currentText();
         QUrl downloadUrl;
 
-        if( server.indexOf( "{x}" ) != -1 && server.indexOf( "{y}" ) != -1 )
-        {
             server.replace( server.indexOf( "{x}" ), 3,  QString::number( 0 ) );
             server.replace( server.indexOf( "{y}" ), 3,  QString::number( 0 ) );
             server.replace( server.indexOf( "{zoomLevel}" ), 11,  QString::number( 0 ) );
             downloadUrl.setUrl( server );
-        } else {
-            downloadUrl.setUrl( QString( "%1/0/0/0.%2" ).arg( server ).arg( format ) );
-        }
 
         QNetworkRequest request( downloadUrl );
         d->levelZeroAccessManager.get( request );
@@ -439,6 +428,9 @@
         return;
     }
 
+    QBuffer testBuffer( &d->levelZero );
+    d->format = QImageReader( &testBuffer ).format();
+
     if ( d->mapProviderType == MapWizardPrivate::StaticUrlMap ) {
         const QString url = d->uiWidget.comboBoxStaticUrlServer->currentText();
         d->staticUrlServerList.removeAll( url );
@@ -707,7 +699,7 @@
     
     else if( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
     {
-        texture->setFileFormat( d->uiWidget.comboBoxStaticUrlFormat->currentText() );
+        texture->setFileFormat( d->format );
         QUrl downloadUrl = QUrl( d->uiWidget.comboBoxStaticUrlServer->currentText() );
         texture->addDownloadPolicy( DownloadBrowse, 20 );
         texture->addDownloadPolicy( DownloadBulk, 2 );
--- trunk/KDE/kdeedu/marble/src/lib/MapWizard.ui #1221816:1221817
@@ -281,6 +281,9 @@
     </item>
     <item>
      <layout class="QFormLayout" name="formLayout_4">
+      <property name="fieldGrowthPolicy">
+       <enum>QFormLayout::ExpandingFieldsGrow</enum>
+      </property>
       <item row="0" column="0">
        <widget class="QLabel" name="labelStaticUrlServer">
         <property name="text">
@@ -288,37 +291,6 @@
         </property>
        </widget>
       </item>
-      <item row="2" column="0">
-       <widget class="QLabel" name="labelStaticUrlFormat">
-        <property name="text">
-         <string>Image Format:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="1">
-       <layout class="QHBoxLayout" name="horizontalLayout_6">
-        <item>
-         <widget class="QComboBox" name="comboBoxStaticUrlFormat">
-          <property name="toolTip">
-           <string>Image format of the tiles.</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <spacer name="horizontalSpacer_4">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>40</width>
-            <height>20</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-       </layout>
-      </item>
       <item row="0" column="1">
        <widget class="QComboBox" name="comboBoxStaticUrlServer">
         <property name="sizePolicy">


More information about the Marble-commits mailing list