|
50 | 50 | #include "qgscolordialog.h"
|
51 | 51 | #include "qgsexpressioncontext.h"
|
52 | 52 | #include "qgsmapoverviewcanvas.h"
|
| 53 | +#include "qgslayertreenode.h" |
| 54 | +#include "qgslayertreegroup.h" |
| 55 | +#include "qgslayertreelayer.h" |
| 56 | +#include "qgslayertreemodel.h" |
53 | 57 |
|
54 | 58 | #include "qgsmessagelog.h"
|
55 | 59 |
|
@@ -1462,6 +1466,63 @@ void QgsProjectProperties::on_pbnWCSLayersUnselectAll_clicked()
|
1462 | 1466 | }
|
1463 | 1467 | }
|
1464 | 1468 |
|
| 1469 | +void QgsProjectProperties::on_pbnLaunchOWSChecker_clicked() |
| 1470 | +{ |
| 1471 | + QString myStyle = QgsApplication::reportStyleSheet(); |
| 1472 | + teOWSChecker->clear(); |
| 1473 | + teOWSChecker->document()->setDefaultStyleSheet( myStyle ); |
| 1474 | + teOWSChecker->setHtml( "<h1>" + tr( "Start checking QGIS Server" ) + "</h1>" ); |
| 1475 | + |
| 1476 | + QStringList owsNames, encodingMessages; |
| 1477 | + checkOWS( QgisApp::instance()->layerTreeView()->layerTreeModel()->rootGroup(), owsNames, encodingMessages ); |
| 1478 | + |
| 1479 | + QStringList duplicateNames, regExpMessages; |
| 1480 | + QRegExp snRegExp = QgsApplication::shortNameRegExp(); |
| 1481 | + Q_FOREACH ( QString name, owsNames ) |
| 1482 | + { |
| 1483 | + if ( !snRegExp.exactMatch( name ) ) |
| 1484 | + regExpMessages << tr( "Use short name for \"%1\"" ).arg( name ); |
| 1485 | + if ( duplicateNames.contains( name ) ) |
| 1486 | + continue; |
| 1487 | + if ( owsNames.count( name ) > 1 ) |
| 1488 | + duplicateNames << name; |
| 1489 | + } |
| 1490 | + |
| 1491 | + if ( duplicateNames.size() != 0 ) |
| 1492 | + { |
| 1493 | + QString nameMessage = "<h1>" + tr( "Some layers and groups have the same name or short name" ) + "</h1>"; |
| 1494 | + nameMessage += "<h2>" + tr( "Duplicate names:" ) + "</h2>"; |
| 1495 | + nameMessage += duplicateNames.join( "</li><li>" ) + "</li></ul>"; |
| 1496 | + teOWSChecker->setHtml( teOWSChecker->toHtml() + nameMessage ); |
| 1497 | + } |
| 1498 | + else |
| 1499 | + { |
| 1500 | + teOWSChecker->setHtml( teOWSChecker->toHtml() + "<h1>" + tr( "All names and short names of layer and group are unique" ) + "</h1>" ); |
| 1501 | + } |
| 1502 | + |
| 1503 | + if ( regExpMessages.size() != 0 ) |
| 1504 | + { |
| 1505 | + QString encodingMessage = "<h1>" + tr( "Some layer short names have to be updated:" ) + "</h1><ul><li>" + regExpMessages.join( "</li><li>" ) + "</li></ul>"; |
| 1506 | + teOWSChecker->setHtml( teOWSChecker->toHtml() + encodingMessage ); |
| 1507 | + } |
| 1508 | + else |
| 1509 | + { |
| 1510 | + teOWSChecker->setHtml( teOWSChecker->toHtml() + "<h1>" + tr( "All layer short names are well formed" ) + "</h1>" ); |
| 1511 | + } |
| 1512 | + |
| 1513 | + if ( encodingMessages.size() != 0 ) |
| 1514 | + { |
| 1515 | + QString encodingMessage = "<h1>" + tr( "Some layer encodings are not set:" ) + "</h1><ul><li>" + encodingMessages.join( "</li><li>" ) + "</li></ul>"; |
| 1516 | + teOWSChecker->setHtml( teOWSChecker->toHtml() + encodingMessage ); |
| 1517 | + } |
| 1518 | + else |
| 1519 | + { |
| 1520 | + teOWSChecker->setHtml( teOWSChecker->toHtml() + "<h1>" + tr( "All layer encodings are set" ) + "</h1>" ); |
| 1521 | + } |
| 1522 | + |
| 1523 | + teOWSChecker->setHtml( teOWSChecker->toHtml() + "<h1>" + tr( "Start checking QGIS Server" ) + "</h1>" ); |
| 1524 | +} |
| 1525 | + |
1465 | 1526 | void QgsProjectProperties::on_pbnAddScale_clicked()
|
1466 | 1527 | {
|
1467 | 1528 | int myScale = QInputDialog::getInt(
|
@@ -1696,6 +1757,41 @@ void QgsProjectProperties::resetPythonMacros()
|
1696 | 1757 | "def closeProject():\n pass\n" );
|
1697 | 1758 | }
|
1698 | 1759 |
|
| 1760 | +void QgsProjectProperties::checkOWS( QgsLayerTreeGroup* treeGroup, QStringList& owsNames, QStringList& encodingMessages ) |
| 1761 | +{ |
| 1762 | + QList< QgsLayerTreeNode * > treeGroupChildren = treeGroup->children(); |
| 1763 | + for ( int i = 0; i < treeGroupChildren.size(); ++i ) |
| 1764 | + { |
| 1765 | + QgsLayerTreeNode* treeNode = treeGroupChildren.at( i ); |
| 1766 | + if ( treeNode->nodeType() == QgsLayerTreeNode::NodeGroup ) |
| 1767 | + { |
| 1768 | + QgsLayerTreeGroup* treeGroupChild = static_cast<QgsLayerTreeGroup *>( treeNode ); |
| 1769 | + QString shortName = treeGroupChild->customProperty( "wmsShortName" ).toString(); |
| 1770 | + if ( shortName.isEmpty() ) |
| 1771 | + owsNames << treeGroupChild->name(); |
| 1772 | + else |
| 1773 | + owsNames << shortName; |
| 1774 | + checkOWS( treeGroupChild, owsNames, encodingMessages ); |
| 1775 | + } |
| 1776 | + else |
| 1777 | + { |
| 1778 | + QgsLayerTreeLayer* treeLayer = static_cast<QgsLayerTreeLayer *>( treeNode ); |
| 1779 | + QgsMapLayer* l = treeLayer->layer(); |
| 1780 | + QString shortName = l->shortName(); |
| 1781 | + if ( shortName.isEmpty() ) |
| 1782 | + owsNames << l->name(); |
| 1783 | + else |
| 1784 | + owsNames << shortName; |
| 1785 | + if ( l->type() == QgsMapLayer::VectorLayer ) |
| 1786 | + { |
| 1787 | + QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer *>( l ); |
| 1788 | + if ( vl->dataProvider()->encoding() == "System" ) |
| 1789 | + encodingMessages << tr( "Update layer \"%1\" encoding" ).arg( l->name() ); |
| 1790 | + } |
| 1791 | + } |
| 1792 | + } |
| 1793 | +} |
| 1794 | + |
1699 | 1795 | void QgsProjectProperties::populateEllipsoidList()
|
1700 | 1796 | {
|
1701 | 1797 | //
|
|
0 commit comments