[QGIS Commit] r15159 - in trunk/qgis/src: app ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Feb 12 08:50:57 EST 2011


Author: jef
Date: 2011-02-12 05:50:57 -0800 (Sat, 12 Feb 2011)
New Revision: 15159

Modified:
   trunk/qgis/src/app/qgsprojectproperties.cpp
   trunk/qgis/src/app/qgsprojectproperties.h
   trunk/qgis/src/ui/qgsprojectpropertiesbase.ui
Log:
allow setting mapserver service properties in project properties

Modified: trunk/qgis/src/app/qgsprojectproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsprojectproperties.cpp	2011-02-12 13:49:25 UTC (rev 15158)
+++ trunk/qgis/src/app/qgsprojectproperties.cpp	2011-02-12 13:50:57 UTC (rev 15159)
@@ -31,11 +31,13 @@
 #include "qgsrenderer.h"
 #include "qgssnappingdialog.h"
 #include "qgsrasterlayer.h"
+#include "qgsgenericprojectionselector.h"
+#include "qgslogger.h"
 
 //qt includes
 #include <QColorDialog>
 #include <QHeaderView>  // Qt 4.4
-#include "qgslogger.h"
+#include <QMessageBox>
 
 //stdc++ includes
 
@@ -54,16 +56,16 @@
   // Properties stored in map canvas's QgsMapRenderer
   // these ones are propagated to QgsProject by a signal
 
-  QgsMapRenderer* myRender = mMapCanvas->mapRenderer();
-  QGis::UnitType myUnit = myRender->mapUnits();
+  QgsMapRenderer* myRenderer = mMapCanvas->mapRenderer();
+  QGis::UnitType myUnit = myRenderer->mapUnits();
   setMapUnits( myUnit );
 
   //see if the user wants on the fly projection enabled
-  bool myProjectionEnabled = myRender->hasCrsTransformEnabled();
+  bool myProjectionEnabled = myRenderer->hasCrsTransformEnabled();
   cbxProjectionEnabled->setChecked( myProjectionEnabled );
   btnGrpMapUnits->setEnabled( !myProjectionEnabled );
 
-  long myCRSID = myRender->destinationSrs().srsid();
+  long myCRSID = myRenderer->destinationSrs().srsid();
   QgsDebugMsg( "Read project CRSID: " + QString::number( myCRSID ) );
   projectionSelector->setSelectedCrsId( myCRSID );
 
@@ -161,6 +163,39 @@
     twIdentifyLayers->setCellWidget( i, 2, cb );
   }
 
+  grpWMSServiceCapabilities->setChecked( QgsProject::instance()->readBoolEntry( "WMSServiceCapabilities", "/", false ) );
+  mWMSTitle->setText( QgsProject::instance()->readEntry( "WMSServiceTitle", "/" ) );
+  mWMSContactOrganization->setText( QgsProject::instance()->readEntry( "WMSContactOrganization", "/", "" ) );
+  mWMSContactPerson->setText( QgsProject::instance()->readEntry( "WMSContactPerson", "/", "" ) );
+  mWMSContactMail->setText( QgsProject::instance()->readEntry( "WMSContactMail", "/", "" ) );
+  mWMSContactPhone->setText( QgsProject::instance()->readEntry( "WMSContactPhone", "/", "" ) );
+  mWMSAbstract->setPlainText( QgsProject::instance()->readEntry( "WMSServiceAbstract", "/", "" ) );
+
+  bool ok;
+  QStringList values;
+
+  mWMSExtMinX->setValidator( new QDoubleValidator( mWMSExtMinX ) );
+  mWMSExtMinY->setValidator( new QDoubleValidator( mWMSExtMinY ) );
+  mWMSExtMaxX->setValidator( new QDoubleValidator( mWMSExtMaxX ) );
+  mWMSExtMaxY->setValidator( new QDoubleValidator( mWMSExtMaxY ) );
+
+  values = QgsProject::instance()->readListEntry( "WMSExtent", "/", &ok );
+  grpWMSExt->setChecked( ok && values.size() == 4 );
+  if ( grpWMSExt->isChecked() )
+  {
+    mWMSExtMinX->setText( values[0] );
+    mWMSExtMinY->setText( values[1] );
+    mWMSExtMaxX->setText( values[2] );
+    mWMSExtMaxY->setText( values[3] );
+  }
+
+  values = QgsProject::instance()->readListEntry( "WMSEpsgList", "/", &ok );
+  grpWMSList->setChecked( ok && values.size() > 0 );
+  if ( grpWMSList->isChecked() )
+  {
+    mWMSList->addItems( values );
+  }
+
   restoreState();
 }
 
@@ -243,12 +278,10 @@
     mapUnit = QGis::Degrees;
   }
 
-  QgsMapRenderer* myRender = mMapCanvas->mapRenderer();
+  QgsMapRenderer* myRenderer = mMapCanvas->mapRenderer();
+  myRenderer->setMapUnits( mapUnit );
+  myRenderer->setProjectionsEnabled( cbxProjectionEnabled->isChecked() );
 
-  myRender->setMapUnits( mapUnit );
-
-  myRender->setProjectionsEnabled( cbxProjectionEnabled->isChecked() );
-
   // Only change the projection if there is a node in the tree
   // selected that has an srid. This prevents error if the user
   // selects a top-level node rather than an actual coordinate
@@ -257,7 +290,7 @@
   if ( myCRSID )
   {
     QgsCoordinateReferenceSystem srs( myCRSID, QgsCoordinateReferenceSystem::InternalCrsId );
-    myRender->setDestinationSrs( srs );
+    myRenderer->setDestinationSrs( srs );
     QgsDebugMsg( QString( "Selected CRS " ) + srs.description() );
     // write the currently selected projections _proj string_ to project settings
     QgsDebugMsg( QString( "SpatialRefSys/ProjectCRSProj4String: %1" ).arg( projectionSelector->selectedProj4String() ) );
@@ -269,7 +302,7 @@
       // If we couldn't get the map units, default to the value in the
       // projectproperties dialog box (set above)
       if ( srs.mapUnits() != QGis::UnknownUnit )
-        myRender->setMapUnits( srs.mapUnits() );
+        myRenderer->setMapUnits( srs.mapUnits() );
     }
   }
 
@@ -314,6 +347,49 @@
 
   QgsProject::instance()->writeEntry( "Identify", "/disabledLayers", noIdentifyLayerList );
 
+  QgsProject::instance()->writeEntry( "WMSServiceCapabilities", "/", grpWMSServiceCapabilities->isChecked() );
+  QgsProject::instance()->writeEntry( "WMSServiceTitle", "/", mWMSTitle->text() );
+  QgsProject::instance()->writeEntry( "WMSContactOrganization", "/", mWMSContactOrganization->text() );
+  QgsProject::instance()->writeEntry( "WMSContactPerson", "/", mWMSContactPerson->text() );
+  QgsProject::instance()->writeEntry( "WMSContactMail", "/", mWMSContactMail->text() );
+  QgsProject::instance()->writeEntry( "WMSContactPhone", "/", mWMSContactPhone->text() );
+  QgsProject::instance()->writeEntry( "WMSServiceAbstract", "/", mWMSAbstract->toPlainText() );
+
+  if ( grpWMSExt->isChecked() )
+  {
+    QgsProject::instance()->writeEntry( "WMSExtent", "/",
+                                        QStringList()
+                                        << mWMSExtMinX->text()
+                                        << mWMSExtMinY->text()
+                                        << mWMSExtMaxX->text()
+                                        << mWMSExtMaxY->text() );
+  }
+  else
+  {
+    QgsProject::instance()->removeEntry( "WMSExtent", "/" );
+  }
+
+  if ( grpWMSList->isChecked() && mWMSList->count() == 0 )
+  {
+    QMessageBox::information( this, tr( "Coordinate System Restriction" ), tr( "No coordinate systems selected. Disabling restriction." ) );
+    grpWMSList->setChecked( false );
+  }
+
+  if ( grpWMSList->isChecked() )
+  {
+    QStringList crslist;
+    for ( int i = 0; i < mWMSList->count(); i++ )
+    {
+      crslist << mWMSList->item( i )->text();
+    }
+
+    QgsProject::instance()->writeEntry( "WMSEpsgList", "/", crslist );
+  }
+  else
+  {
+    QgsProject::instance()->removeEntry( "WMSEpsgList", "/" );
+  }
+
   //todo XXX set canvas color
   emit refresh();
 }
@@ -403,3 +479,81 @@
   restoreGeometry( settings.value( "/Windows/ProjectProperties/geometry" ).toByteArray() );
   tabWidget->setCurrentIndex( settings.value( "/Windows/ProjectProperties/tab" ).toInt() );
 }
+
+/*!
+ * Set WMS default extent to current canvas extent
+ */
+void QgsProjectProperties::on_pbnWMSExtCanvas_clicked()
+{
+  QgsRectangle ext = mMapCanvas->extent();
+  mWMSExtMinX->setText( QString::number( ext.xMinimum() ) );
+  mWMSExtMinY->setText( QString::number( ext.yMinimum() ) );
+  mWMSExtMaxX->setText( QString::number( ext.xMaximum() ) );
+  mWMSExtMaxY->setText( QString::number( ext.yMaximum() ) );
+}
+
+void QgsProjectProperties::on_pbnWMSAddSRS_clicked()
+{
+  QgsGenericProjectionSelector *mySelector = new QgsGenericProjectionSelector( this );
+  mySelector->setMessage();
+  if ( mySelector->exec() )
+  {
+    long crs = mySelector->selectedEpsg();
+
+    if ( crs > 0 )
+    {
+      QList<QListWidgetItem *> items = mWMSList->findItems( QString::number( crs ), Qt::MatchFixedString );
+      if ( items.size() == 0 )
+      {
+        mWMSList->addItem( QString::number( crs ) );
+      }
+      else
+      {
+        QMessageBox::information( this, tr( "Coordinate System Restriction" ), tr( "CRS %1 was already selected" ).arg( crs ) );
+      }
+    }
+    else
+    {
+      QMessageBox::information( this, tr( "Coordinate System Restriction" ), tr( "Selected CRS is not a EPSG coordinate system." ) );
+    }
+  }
+
+  delete mySelector;
+}
+
+void QgsProjectProperties::on_pbnWMSRemoveSRS_clicked()
+{
+  foreach( QListWidgetItem *item, mWMSList->selectedItems() )
+  delete item;
+}
+
+void QgsProjectProperties::on_pbnWMSSetUsedSRS_clicked()
+{
+  if ( mWMSList->count() > 1 )
+  {
+    if ( QMessageBox::question( this,
+                                tr( "Coordinate System Restrictions" ),
+                                tr( "The current selection of coordinate systems will be lost.\nProceed?" ) ) == QMessageBox::No )
+      return;
+  }
+
+  QSet<QString> crsList;
+
+  if ( cbxProjectionEnabled->isChecked() )
+  {
+    QgsCoordinateReferenceSystem srs( projectionSelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
+    if ( srs.epsg() > 0 )
+      crsList << QString::number( srs.epsg() );
+  }
+
+  const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
+  for ( QMap<QString, QgsMapLayer*>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); it++ )
+  {
+    long crs = it.value()->crs().epsg();
+    if ( crs > 0 )
+      crsList << QString::number( crs );
+  }
+
+  mWMSList->clear();
+  mWMSList->addItems( crsList.values() );
+}

Modified: trunk/qgis/src/app/qgsprojectproperties.h
===================================================================
--- trunk/qgis/src/app/qgsprojectproperties.h	2011-02-12 13:49:25 UTC (rev 15158)
+++ trunk/qgis/src/app/qgsprojectproperties.h	2011-02-12 13:50:57 UTC (rev 15159)
@@ -85,6 +85,14 @@
     void on_pbnCanvasColor_clicked();
 
     /*!
+     * Slots for WMS project settings
+     */
+    void on_pbnWMSExtCanvas_clicked();
+    void on_pbnWMSAddSRS_clicked();
+    void on_pbnWMSRemoveSRS_clicked();
+    void on_pbnWMSSetUsedSRS_clicked();
+
+    /*!
      * Slot to show the context help for this dialog
      */
     void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

Modified: trunk/qgis/src/ui/qgsprojectpropertiesbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsprojectpropertiesbase.ui	2011-02-12 13:49:25 UTC (rev 15158)
+++ trunk/qgis/src/ui/qgsprojectpropertiesbase.ui	2011-02-12 13:50:57 UTC (rev 15159)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>651</width>
-    <height>538</height>
+    <width>678</width>
+    <height>690</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -20,6 +20,16 @@
    <bool>true</bool>
   </property>
   <layout class="QGridLayout" name="gridLayout_2">
+   <item row="1" column="0">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
    <item row="0" column="0">
     <widget class="QTabWidget" name="tabWidget">
      <property name="currentIndex">
@@ -353,18 +363,247 @@
        </item>
       </layout>
      </widget>
+     <widget class="QWidget" name="tab">
+      <attribute name="title">
+       <string>WMS</string>
+      </attribute>
+      <layout class="QGridLayout" name="gridLayout_3">
+       <item row="0" column="0" colspan="2">
+        <widget class="QGroupBox" name="grpWMSServiceCapabilities">
+         <property name="title">
+          <string>Service Capabilitities</string>
+         </property>
+         <property name="checkable">
+          <bool>true</bool>
+         </property>
+         <property name="checked">
+          <bool>false</bool>
+         </property>
+         <layout class="QGridLayout" name="gridLayout">
+          <item row="0" column="0">
+           <widget class="QLabel" name="label_6">
+            <property name="text">
+             <string>Title</string>
+            </property>
+            <property name="buddy">
+             <cstring>mWMSTitle</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="2">
+           <widget class="QLineEdit" name="mWMSTitle"/>
+          </item>
+          <item row="2" column="0">
+           <widget class="QLabel" name="label_7">
+            <property name="text">
+             <string>Person</string>
+            </property>
+            <property name="buddy">
+             <cstring>mWMSContactPerson</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="2" column="2">
+           <widget class="QLineEdit" name="mWMSContactPerson"/>
+          </item>
+          <item row="5" column="0">
+           <widget class="QLabel" name="label_8">
+            <property name="text">
+             <string>Phone</string>
+            </property>
+            <property name="buddy">
+             <cstring>mWMSContactPhone</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="5" column="2">
+           <widget class="QLineEdit" name="mWMSContactPhone"/>
+          </item>
+          <item row="7" column="2">
+           <widget class="QTextEdit" name="mWMSAbstract"/>
+          </item>
+          <item row="7" column="0">
+           <widget class="QLabel" name="label_5">
+            <property name="text">
+             <string>Abstract</string>
+            </property>
+            <property name="buddy">
+             <cstring>mWMSAbstract</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="4" column="0">
+           <widget class="QLabel" name="label_13">
+            <property name="text">
+             <string>E-Mail</string>
+            </property>
+           </widget>
+          </item>
+          <item row="4" column="2">
+           <widget class="QLineEdit" name="mWMSContactMail"/>
+          </item>
+          <item row="1" column="0">
+           <widget class="QLabel" name="label_4">
+            <property name="text">
+             <string>Organization</string>
+            </property>
+            <property name="buddy">
+             <cstring>mWMSContactOrganization</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="2">
+           <widget class="QLineEdit" name="mWMSContactOrganization"/>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item row="3" column="0">
+        <widget class="QGroupBox" name="grpWMSExt">
+         <property name="title">
+          <string>Advertised Extent</string>
+         </property>
+         <property name="checkable">
+          <bool>true</bool>
+         </property>
+         <property name="checked">
+          <bool>false</bool>
+         </property>
+         <layout class="QGridLayout" name="gridLayout_4">
+          <item row="0" column="0">
+           <widget class="QLabel" name="label_11">
+            <property name="text">
+             <string>Min. X</string>
+            </property>
+            <property name="buddy">
+             <cstring>mWMSExtMinX</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="1">
+           <widget class="QLineEdit" name="mWMSExtMinX">
+            <property name="text">
+             <string/>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="0">
+           <widget class="QLabel" name="label_12">
+            <property name="text">
+             <string>Min. Y</string>
+            </property>
+            <property name="buddy">
+             <cstring>mWMSExtMinY</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1">
+           <widget class="QLineEdit" name="mWMSExtMinY">
+            <property name="text">
+             <string/>
+            </property>
+           </widget>
+          </item>
+          <item row="2" column="0">
+           <widget class="QLabel" name="label_9">
+            <property name="text">
+             <string>Max. X</string>
+            </property>
+            <property name="buddy">
+             <cstring>mWMSExtMaxX</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="2" column="1">
+           <widget class="QLineEdit" name="mWMSExtMaxX">
+            <property name="text">
+             <string/>
+            </property>
+           </widget>
+          </item>
+          <item row="3" column="0">
+           <widget class="QLabel" name="label_10">
+            <property name="text">
+             <string>Max. Y</string>
+            </property>
+            <property name="buddy">
+             <cstring>mWMSExtMaxY</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="3" column="1">
+           <widget class="QLineEdit" name="mWMSExtMaxY">
+            <property name="text">
+             <string/>
+            </property>
+           </widget>
+          </item>
+          <item row="4" column="0" colspan="2">
+           <widget class="QPushButton" name="pbnWMSExtCanvas">
+            <property name="text">
+             <string>Use Current Canvas Extent</string>
+            </property>
+           </widget>
+          </item>
+          <item row="5" column="0" colspan="2">
+           <spacer name="verticalSpacer">
+            <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="3" column="1">
+        <widget class="QGroupBox" name="grpWMSList">
+         <property name="title">
+          <string>Coordinate Systems Restrictions</string>
+         </property>
+         <property name="checkable">
+          <bool>true</bool>
+         </property>
+         <property name="checked">
+          <bool>false</bool>
+         </property>
+         <layout class="QGridLayout" name="gridLayout_5">
+          <item row="0" column="0" colspan="3">
+           <widget class="QListWidget" name="mWMSList"/>
+          </item>
+          <item row="1" column="0">
+           <widget class="QPushButton" name="pbnWMSAddSRS">
+            <property name="text">
+             <string>Add</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="2">
+           <widget class="QPushButton" name="pbnWMSRemoveSRS">
+            <property name="text">
+             <string>Remove</string>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1">
+           <widget class="QPushButton" name="pbnWMSSetUsedSRS">
+            <property name="text">
+             <string>Used</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+      </layout>
+     </widget>
     </widget>
    </item>
-   <item row="1" column="0">
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
-     </property>
-    </widget>
-   </item>
   </layout>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
@@ -397,6 +636,24 @@
   <tabstop>twIdentifyLayers</tabstop>
   <tabstop>tabWidget</tabstop>
   <tabstop>buttonBox</tabstop>
+  <tabstop>grpWMSServiceCapabilities</tabstop>
+  <tabstop>mWMSTitle</tabstop>
+  <tabstop>mWMSContactOrganization</tabstop>
+  <tabstop>mWMSContactPerson</tabstop>
+  <tabstop>mWMSContactMail</tabstop>
+  <tabstop>mWMSContactPhone</tabstop>
+  <tabstop>mWMSAbstract</tabstop>
+  <tabstop>grpWMSExt</tabstop>
+  <tabstop>mWMSExtMinX</tabstop>
+  <tabstop>mWMSExtMinY</tabstop>
+  <tabstop>mWMSExtMaxX</tabstop>
+  <tabstop>mWMSExtMaxY</tabstop>
+  <tabstop>pbnWMSExtCanvas</tabstop>
+  <tabstop>grpWMSList</tabstop>
+  <tabstop>mWMSList</tabstop>
+  <tabstop>pbnWMSAddSRS</tabstop>
+  <tabstop>pbnWMSSetUsedSRS</tabstop>
+  <tabstop>pbnWMSRemoveSRS</tabstop>
  </tabstops>
  <resources>
   <include location="../../images/images.qrc"/>



More information about the QGIS-commit mailing list