diff --git a/src/app/qgsprojectproperties.cpp b/src/app/qgsprojectproperties.cpp
index 684436d2e07..37347a99057 100644
--- a/src/app/qgsprojectproperties.cpp
+++ b/src/app/qgsprojectproperties.cpp
@@ -50,6 +50,10 @@
#include "qgscolordialog.h"
#include "qgsexpressioncontext.h"
#include "qgsmapoverviewcanvas.h"
+#include "qgslayertreenode.h"
+#include "qgslayertreegroup.h"
+#include "qgslayertreelayer.h"
+#include "qgslayertreemodel.h"
#include "qgsmessagelog.h"
@@ -1462,6 +1466,63 @@ void QgsProjectProperties::on_pbnWCSLayersUnselectAll_clicked()
}
}
+void QgsProjectProperties::on_pbnLaunchOWSChecker_clicked()
+{
+ QString myStyle = QgsApplication::reportStyleSheet();
+ teOWSChecker->clear();
+ teOWSChecker->document()->setDefaultStyleSheet( myStyle );
+ teOWSChecker->setHtml( "
" + tr( "Start checking QGIS Server" ) + "
" );
+
+ QStringList owsNames, encodingMessages;
+ checkOWS( QgisApp::instance()->layerTreeView()->layerTreeModel()->rootGroup(), owsNames, encodingMessages );
+
+ QStringList duplicateNames, regExpMessages;
+ QRegExp snRegExp = QgsApplication::shortNameRegExp();
+ Q_FOREACH ( QString name, owsNames )
+ {
+ if ( !snRegExp.exactMatch( name ) )
+ regExpMessages << tr( "Use short name for \"%1\"" ).arg( name );
+ if ( duplicateNames.contains( name ) )
+ continue;
+ if ( owsNames.count( name ) > 1 )
+ duplicateNames << name;
+ }
+
+ if ( duplicateNames.size() != 0 )
+ {
+ QString nameMessage = "" + tr( "Some layers and groups have the same name or short name" ) + "
";
+ nameMessage += "" + tr( "Duplicate names:" ) + "
";
+ nameMessage += duplicateNames.join( "" ) + "";
+ teOWSChecker->setHtml( teOWSChecker->toHtml() + nameMessage );
+ }
+ else
+ {
+ teOWSChecker->setHtml( teOWSChecker->toHtml() + "" + tr( "All names and short names of layer and group are unique" ) + "
" );
+ }
+
+ if ( regExpMessages.size() != 0 )
+ {
+ QString encodingMessage = "" + tr( "Some layer short names have to be updated:" ) + "
- " + regExpMessages.join( "
- " ) + "
";
+ teOWSChecker->setHtml( teOWSChecker->toHtml() + encodingMessage );
+ }
+ else
+ {
+ teOWSChecker->setHtml( teOWSChecker->toHtml() + "" + tr( "All layer short names are well formed" ) + "
" );
+ }
+
+ if ( encodingMessages.size() != 0 )
+ {
+ QString encodingMessage = "" + tr( "Some layer encodings are not set:" ) + "
- " + encodingMessages.join( "
- " ) + "
";
+ teOWSChecker->setHtml( teOWSChecker->toHtml() + encodingMessage );
+ }
+ else
+ {
+ teOWSChecker->setHtml( teOWSChecker->toHtml() + "" + tr( "All layer encodings are set" ) + "
" );
+ }
+
+ teOWSChecker->setHtml( teOWSChecker->toHtml() + "" + tr( "Start checking QGIS Server" ) + "
" );
+}
+
void QgsProjectProperties::on_pbnAddScale_clicked()
{
int myScale = QInputDialog::getInt(
@@ -1696,6 +1757,41 @@ void QgsProjectProperties::resetPythonMacros()
"def closeProject():\n pass\n" );
}
+void QgsProjectProperties::checkOWS( QgsLayerTreeGroup* treeGroup, QStringList& owsNames, QStringList& encodingMessages )
+{
+ QList< QgsLayerTreeNode * > treeGroupChildren = treeGroup->children();
+ for ( int i = 0; i < treeGroupChildren.size(); ++i )
+ {
+ QgsLayerTreeNode* treeNode = treeGroupChildren.at( i );
+ if ( treeNode->nodeType() == QgsLayerTreeNode::NodeGroup )
+ {
+ QgsLayerTreeGroup* treeGroupChild = static_cast( treeNode );
+ QString shortName = treeGroupChild->customProperty( "wmsShortName" ).toString();
+ if ( shortName.isEmpty() )
+ owsNames << treeGroupChild->name();
+ else
+ owsNames << shortName;
+ checkOWS( treeGroupChild, owsNames, encodingMessages );
+ }
+ else
+ {
+ QgsLayerTreeLayer* treeLayer = static_cast( treeNode );
+ QgsMapLayer* l = treeLayer->layer();
+ QString shortName = l->shortName();
+ if ( shortName.isEmpty() )
+ owsNames << l->name();
+ else
+ owsNames << shortName;
+ if ( l->type() == QgsMapLayer::VectorLayer )
+ {
+ QgsVectorLayer* vl = dynamic_cast( l );
+ if ( vl->dataProvider()->encoding() == "System" )
+ encodingMessages << tr( "Update layer \"%1\" encoding" ).arg( l->name() );
+ }
+ }
+ }
+}
+
void QgsProjectProperties::populateEllipsoidList()
{
//
diff --git a/src/app/qgsprojectproperties.h b/src/app/qgsprojectproperties.h
index 165a2dc8a5f..57aa18a1206 100644
--- a/src/app/qgsprojectproperties.h
+++ b/src/app/qgsprojectproperties.h
@@ -27,6 +27,7 @@ class QgsMapCanvas;
class QgsRelationManagerDialog;
class QgsStyleV2;
class QgsExpressionContext;
+class QgsLayerTreeGroup;
/** Dialog to set project level properties
@@ -119,6 +120,11 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
void on_pbnWCSLayersSelectAll_clicked();
void on_pbnWCSLayersUnselectAll_clicked();
+ /*!
+ * Slots to launch OWS test
+ */
+ void on_pbnLaunchOWSChecker_clicked();
+
/*!
* Slots for Styles
*/
@@ -210,6 +216,9 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
QList mEllipsoidList;
int mEllipsoidIndex;
+ //! Check OWS configuration
+ void checkOWS( QgsLayerTreeGroup* treeGroup, QStringList& owsNames, QStringList& encodingMessages );
+
//! Populates list with ellipsoids from Sqlite3 db
void populateEllipsoidList();
diff --git a/src/ui/qgsprojectpropertiesbase.ui b/src/ui/qgsprojectpropertiesbase.ui
index 4b305910a13..e5ee26bb54b 100644
--- a/src/ui/qgsprojectpropertiesbase.ui
+++ b/src/ui/qgsprojectpropertiesbase.ui
@@ -2373,6 +2373,70 @@
+ -
+
+
+
+ 0
+ 3
+
+
+
+ Test configuration
+
+
+
-
+
+
-
+
+
+ Launch
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ true
+
+
+
+ 0
+ 200
+
+
+
+ true
+
+
+ 2
+
+
+ true
+
+
+ true
+
+
+
+
+
+
-