[Marble-commits] KDE/kdeedu/marble/src/lib
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Mon Jan 3 15:56:53 CET 2011
SVN commit 1211289 by beschow:
use next button to query WMS server capabilities in MapWizard
M +59 -12 MapWizard.cpp
M +6 -3 MapWizard.h
M +36 -14 MapWizard.ui
--- trunk/KDE/kdeedu/marble/src/lib/MapWizard.cpp #1211288:1211289
@@ -46,6 +46,12 @@
class MapWizardPrivate
{
public:
+ MapWizardPrivate()
+ : m_serverCapabilitiesValid( false )
+ {}
+
+ void pageEntered( int id );
+
Ui::MapWizard uiWidget;
QString mapTheme;
@@ -54,6 +60,7 @@
QNetworkAccessManager legendAccessManager;
QNetworkAccessManager levelZeroAccessManager;
QStringList wmsServerList;
+ bool m_serverCapabilitiesValid;
enum mapType
{
@@ -85,6 +92,15 @@
QString dgmlOutput;
};
+void MapWizardPrivate::pageEntered( int id )
+{
+ if ( id == 1 ) {
+ m_serverCapabilitiesValid = false;
+ } else if ( id == 2 ) {
+ levelZero = QImage();
+ }
+}
+
MapWizard::MapWizard( QWidget* parent ) : QWizard( parent ), d( new MapWizardPrivate )
{
d->uiWidget.setupUi( this );
@@ -94,6 +110,8 @@
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* ) ) );
connect( &( d->legendAccessManager ), SIGNAL( finished( QNetworkReply* ) ), this, SLOT( createWmsLegend( QNetworkReply* ) ) );
connect( &( d->levelZeroAccessManager ), SIGNAL( finished( QNetworkReply* ) ), this, SLOT( createLevelZero( QNetworkReply* ) ) );
@@ -102,7 +120,6 @@
connect( d->uiWidget.pushButtonPreview, SIGNAL( clicked( bool ) ), this, SLOT( queryPreviewImage() ) );
connect( d->uiWidget.pushButtonLegend, SIGNAL( clicked( bool ) ), this, SLOT( queryLegendImage() ) );
connect( d->uiWidget.pushButtonStaticUrlLegend, SIGNAL( clicked( bool ) ), this, SLOT( queryStaticUrlLegendImage() ) );
- connect( d->uiWidget.pushButtonWmsInspect, SIGNAL( clicked( bool ) ), this, SLOT( queryServerCapabilities() ) );
connect( d->uiWidget.pushButtonStaticUrlTest, SIGNAL( clicked( bool ) ), this, SLOT( downloadLevelZero() ) );
connect( d->uiWidget.pushButtonSuggest, SIGNAL( clicked( bool ) ), this, SLOT( downloadLevelZero() ) );
@@ -130,20 +147,20 @@
d->xmlAccessManager.get( request );
}
-bool MapWizard::parseServerCapabilities( QNetworkReply* reply )
+void MapWizard::parseServerCapabilities( QNetworkReply* reply )
{
QString result( reply->readAll() );
QDomDocument xml;
if( !xml.setContent( result ) )
{
QMessageBox::critical( this, tr( "Error while parsing" ), tr( "Wizard can't parse server's response" ) );
- return false;
+ return;
}
if( xml.documentElement().firstChildElement().tagName().isNull() )
{
QMessageBox::critical( this, tr( "Error while parsing" ), tr( "Server is not a Web Map Server." ) );
- return false;
+ return;
}
QDomElement firstLayer = xml.documentElement().firstChildElement( "Capability" ).firstChildElement( "Layer" );
@@ -178,9 +195,11 @@
if( !d->uiWidget.comboBoxWmsMap->currentText().isEmpty() && !d->wmsServerList.contains( d->uiWidget.lineEditWmsUrl->text() ) ) {
d->wmsServerList.append( d->uiWidget.lineEditWmsUrl->text() );
+ setWmsServers( d->wmsServerList );
}
- return true;
+ d->m_serverCapabilitiesValid = true;
+ next();
}
void MapWizard::createWmsLegend( QNetworkReply* reply )
@@ -205,6 +224,7 @@
d->uiWidget.comboBoxWmsServer->clear();
d->uiWidget.comboBoxWmsServer->addItems( d->wmsServerList );
+ d->uiWidget.comboBoxWmsServer->addItem( tr( "Custom" ), "http://" );
}
QStringList MapWizard::wmsServers() const
@@ -458,6 +478,7 @@
QUrl downloadUrl( d->uiWidget.lineEditWmsUrl->text() );
downloadUrl.addQueryItem( "request", "GetMap" );
+ downloadUrl.addQueryItem( "version", "1.1.1" );
downloadUrl.addQueryItem( "layers", d->uiWidget.comboBoxWmsMap->itemData( selected ).toString() );
downloadUrl.addQueryItem( "srs", "EPSG:4326" );
downloadUrl.addQueryItem( "width", "400" );
@@ -499,6 +520,17 @@
{
d->levelZero = reply->readAll();
+ if ( d->mapProviderType == MapWizardPrivate::WmsMap )
+ {
+ if ( d->levelZero.isNull() ) {
+ QMessageBox::information( this,
+ tr( "Base Tile" ),
+ tr( "The base tile could not be downloaded. The server replied:\n\n%1" ).arg( QString( result ) ) );
+ } else if ( currentId() == 2 ) {
+ next();
+ }
+ }
+
if( d->mapProviderType == MapWizardPrivate::StaticUrlMap )
{
QImage testImage = QImage::fromData( d->levelZero );
@@ -629,6 +661,21 @@
QFile::remove( QString( "%1/%2.tar.gz" ).arg( QDir::tempPath() ).arg( theme ) );
}
+bool MapWizard::validateCurrentPage()
+{
+ if ( currentId() == 1 && !d->m_serverCapabilitiesValid ) {
+ queryServerCapabilities();
+ return false;
+ }
+
+ if ( currentId() == 2 && d->levelZero.isNull() ) {
+ downloadLevelZero();
+ return false;
+ }
+
+ return QWizard::validateCurrentPage();
+}
+
int MapWizard::nextId() const
{
switch( currentId() )
@@ -639,22 +686,22 @@
return 1;
} else if( d->uiWidget.radioButtonBitmap->isChecked() ) {
d->mapProviderType = MapWizardPrivate::StaticImageMap;
- return 2;
+ return 3;
} else if( d->uiWidget.radioButtonStaticUrl->isChecked() ) {
d->mapProviderType = MapWizardPrivate::StaticUrlMap;
- return 3;
+ return 4;
}
break;
- case 1:
- return 4;
+ case 2: // WMS
+ return 5;
break;
- case 2:
- return 4;
+ case 3: // Static Image
+ return 5;
break;
- case 5:
+ case 6: // Finish
return -1;
break;
--- trunk/KDE/kdeedu/marble/src/lib/MapWizard.h #1211288:1211289
@@ -45,13 +45,14 @@
void deleteArchive( QString mapId );
// QWizard's functions
- int nextId() const;
- void accept();
+ virtual void accept();
+ virtual bool validateCurrentPage();
+ virtual int nextId() const;
public slots:
// WMS protocol
void queryServerCapabilities();
- bool parseServerCapabilities( QNetworkReply* reply );
+ void parseServerCapabilities( QNetworkReply* reply );
void createWmsLegend( QNetworkReply* reply );
// Open file dialogs
@@ -67,6 +68,8 @@
void suggestPreviewImage();
private:
+ Q_PRIVATE_SLOT( d, void pageEntered( int ) )
+
GeoSceneDocument* createDocument();
void createDgml( const GeoSceneDocument* document );
bool createFiles( const GeoSceneHead* head );
--- trunk/KDE/kdeedu/marble/src/lib/MapWizard.ui #1211288:1211289
@@ -96,8 +96,7 @@
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">WMS Server</span></p>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Please choose a <a href="http://en.wikipedia.org/wiki/Web_Map_Service"><span style=" text-decoration: underline; color:#0057ae;">WMS</span></a> server or enter the server URL manually. Then press the &quot;Inspect&quot; button to query available maps and select one of the results.</p>
-<p style="-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html></string>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Please choose a <a href="http://en.wikipedia.org/wiki/Web_Map_Service"><span style=" text-decoration: underline; color:#0057ae;">WMS</span></a> server or enter a custom server URL.</p></body></html></string>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -105,18 +104,31 @@
</widget>
</item>
<item>
- <layout class="QGridLayout" name="gridLayout_3">
+ <spacer name="verticalSpacer_10">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelWmsServer">
<property name="text">
- <string>Server:</string>
+ <string>WMS Server:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
- <item row="0" column="1" colspan="2">
+ <item row="0" column="1">
<widget class="QComboBox" name="comboBoxWmsServer">
<item>
<property name="text">
@@ -142,26 +154,36 @@
</property>
</widget>
</item>
- <item row="1" column="2">
- <widget class="QPushButton" name="pushButtonWmsInspect">
- <property name="text">
- <string>Inspect</string>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_9">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
</property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</widget>
- </item>
- <item row="2" column="0">
+ <widget class="QWizardPage" name="wizardPage">
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <item>
<widget class="QLabel" name="labelWmsMaps">
<property name="text">
<string>Available Maps:</string>
</property>
</widget>
</item>
- <item row="2" column="1" colspan="2">
+ <item>
<widget class="QComboBox" name="comboBoxWmsMap"/>
</item>
</layout>
- </item>
- </layout>
</widget>
<widget class="QWizardPage" name="wizardPageBitmap">
<layout class="QVBoxLayout" name="verticalLayout_2">
More information about the Marble-commits
mailing list