[QGIS Commit] r11156 - in branches/symbology-ng-branch: python/core python/gui src/app src/core/symbology-ng src/gui/symbology-ng src/ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Jul 23 10:05:43 EDT 2009


Author: wonder
Date: 2009-07-23 10:05:42 -0400 (Thu, 23 Jul 2009)
New Revision: 11156

Modified:
   branches/symbology-ng-branch/python/core/symbology-ng-core.sip
   branches/symbology-ng-branch/python/gui/symbology-ng-gui.sip
   branches/symbology-ng-branch/src/app/qgisapp.cpp
   branches/symbology-ng-branch/src/app/qgsvectorlayerproperties.cpp
   branches/symbology-ng-branch/src/core/symbology-ng/qgsstylev2.cpp
   branches/symbology-ng-branch/src/core/symbology-ng/qgsstylev2.h
   branches/symbology-ng-branch/src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp
   branches/symbology-ng-branch/src/gui/symbology-ng/qgsrendererv2propertiesdialog.h
   branches/symbology-ng-branch/src/ui/qgsvectorlayerpropertiesbase.ui
Log:
When using new symbology, embed renderer properties into vector layer properties, symbology tab.


Modified: branches/symbology-ng-branch/python/core/symbology-ng-core.sip
===================================================================
--- branches/symbology-ng-branch/python/core/symbology-ng-core.sip	2009-07-23 13:15:09 UTC (rev 11155)
+++ branches/symbology-ng-branch/python/core/symbology-ng-core.sip	2009-07-23 14:05:42 UTC (rev 11156)
@@ -573,6 +573,9 @@
   QgsStyleV2();
   ~QgsStyleV2();
   
+  //! return default application-wide style
+  static QgsStyleV2* defaultStyle();
+
   //! remove all contents of the style
   void clear();
   

Modified: branches/symbology-ng-branch/python/gui/symbology-ng-gui.sip
===================================================================
--- branches/symbology-ng-branch/python/gui/symbology-ng-gui.sip	2009-07-23 13:15:09 UTC (rev 11155)
+++ branches/symbology-ng-branch/python/gui/symbology-ng-gui.sip	2009-07-23 14:05:42 UTC (rev 11156)
@@ -34,7 +34,7 @@
 %End
 
 public:
-  QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent = NULL);
+  QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent = NULL, bool embedded = false);
   
 public slots:
   void changeSingleSymbol();

Modified: branches/symbology-ng-branch/src/app/qgisapp.cpp
===================================================================
--- branches/symbology-ng-branch/src/app/qgisapp.cpp	2009-07-23 13:15:09 UTC (rev 11155)
+++ branches/symbology-ng-branch/src/app/qgisapp.cpp	2009-07-23 14:05:42 UTC (rev 11156)
@@ -1038,25 +1038,8 @@
 #include "qgsrendererv2propertiesdialog.h"
 #include "qgsstylev2managerdialog.h"
 
-static QgsStyleV2* gStyleV2 = NULL;
 
-static void _initStyle()
-{
-  if (gStyleV2 == NULL)
-  {
-    QString styleFilename = QgsApplication::userStyleV2Path();
 
-    // copy default style if user style doesn't exist
-    if ( !QFile::exists( styleFilename ) )
-    {
-      QFile::copy( QgsApplication::defaultStyleV2Path(), styleFilename );
-    }
-
-    gStyleV2 = new QgsStyleV2;
-    gStyleV2->load( styleFilename );
-  }
-}
-
 void QgisApp::toggleRendererV2()
 {
   QgsMapLayer* layer = activeLayer();
@@ -1067,9 +1050,7 @@
   }
   QgsVectorLayer* vlayer = static_cast<QgsVectorLayer*>(layer);
   
-  _initStyle();
-  
-  QgsRendererV2PropertiesDialog dlg(vlayer, gStyleV2, this);
+  QgsRendererV2PropertiesDialog dlg(vlayer, QgsStyleV2::defaultStyle(), this);
   if (!dlg.exec())
     return;
   
@@ -1080,9 +1061,7 @@
 
 void QgisApp::showStyleManagerV2()
 {
-  _initStyle();
-
-  QgsStyleV2ManagerDialog dlg(gStyleV2, QgsApplication::userStyleV2Path(), this);
+  QgsStyleV2ManagerDialog dlg(QgsStyleV2::defaultStyle(), QgsApplication::userStyleV2Path(), this);
   dlg.exec();
 }
 

Modified: branches/symbology-ng-branch/src/app/qgsvectorlayerproperties.cpp
===================================================================
--- branches/symbology-ng-branch/src/app/qgsvectorlayerproperties.cpp	2009-07-23 13:15:09 UTC (rev 11155)
+++ branches/symbology-ng-branch/src/app/qgsvectorlayerproperties.cpp	2009-07-23 14:05:42 UTC (rev 11156)
@@ -56,6 +56,9 @@
 #include <QComboBox>
 #include <QCheckBox>
 
+#include "qgsrendererv2propertiesdialog.h"
+#include "qgsstylev2.h"
+
 #if QT_VERSION < 0x040300
 #define toPlainText() text()
 #endif
@@ -439,10 +442,24 @@
       legendtypecombobox->addItem( tr( "Unique Value" ) );
     }
   }
-
+  
   //find out the type of renderer in the vectorlayer, create a dialog with these settings and add it to the form
   delete mRendererDialog;
   mRendererDialog = 0;
+  
+  if (layer->isUsingRendererV2())
+  {
+    mRendererDialog = new QgsRendererV2PropertiesDialog(layer, QgsStyleV2::defaultStyle(), NULL, true);
+
+    // hide unused widgets
+    legendtypecombobox->hide();
+    legendtypelabel->hide();
+    lblTransparencyPercent->hide();
+    sliderTransparency->hide();
+  }
+  else
+  {
+  
   QString rtype = layer->renderer()->name();
   if ( rtype == "Single Symbol" )
   {
@@ -465,16 +482,17 @@
     legendtypecombobox->setCurrentIndex( 3 );
   }
 
+  QObject::connect( legendtypecombobox, SIGNAL( activated( const QString & ) ), this,
+                    SLOT( alterLayerDialog( const QString & ) ) );
+
+  }
+
   if ( mRendererDialog )
   {
     widgetStackRenderers->addWidget( mRendererDialog );
     widgetStackRenderers->setCurrentWidget( mRendererDialog );
   }
 
-
-  QObject::connect( legendtypecombobox, SIGNAL( activated( const QString & ) ), this,
-                    SLOT( alterLayerDialog( const QString & ) ) );
-
   // reset fields in label dialog
   layer->label()->setFields( layer->pendingFields() );
 
@@ -611,32 +629,43 @@
     }
   }
 
-  QgsSingleSymbolDialog *sdialog =
-    dynamic_cast < QgsSingleSymbolDialog * >( widgetStackRenderers->currentWidget() );
-  QgsGraduatedSymbolDialog *gdialog =
-    dynamic_cast < QgsGraduatedSymbolDialog * >( widgetStackRenderers->currentWidget() );
-  QgsContinuousColorDialog *cdialog =
-    dynamic_cast < QgsContinuousColorDialog * >( widgetStackRenderers->currentWidget() );
-  QgsUniqueValueDialog* udialog =
-    dynamic_cast< QgsUniqueValueDialog * >( widgetStackRenderers->currentWidget() );
-
-  if ( sdialog )
+  if (layer->isUsingRendererV2())
   {
-    sdialog->apply();
+    QgsRendererV2PropertiesDialog* dlg =
+      static_cast<QgsRendererV2PropertiesDialog*>(widgetStackRenderers->currentWidget());
+    dlg->apply();
   }
-  else if ( gdialog )
+  else
   {
-    gdialog->apply();
+
+    QgsSingleSymbolDialog *sdialog =
+      dynamic_cast < QgsSingleSymbolDialog * >( widgetStackRenderers->currentWidget() );
+    QgsGraduatedSymbolDialog *gdialog =
+      dynamic_cast < QgsGraduatedSymbolDialog * >( widgetStackRenderers->currentWidget() );
+    QgsContinuousColorDialog *cdialog =
+      dynamic_cast < QgsContinuousColorDialog * >( widgetStackRenderers->currentWidget() );
+    QgsUniqueValueDialog* udialog =
+      dynamic_cast< QgsUniqueValueDialog * >( widgetStackRenderers->currentWidget() );
+
+    if ( sdialog )
+    {
+      sdialog->apply();
+    }
+    else if ( gdialog )
+    {
+      gdialog->apply();
+    }
+    else if ( cdialog )
+    {
+      cdialog->apply();
+    }
+    else if ( udialog )
+    {
+      udialog->apply();
+    }
+    layer->setTransparency( static_cast < unsigned int >( 255 - sliderTransparency->value() ) );
+
   }
-  else if ( cdialog )
-  {
-    cdialog->apply();
-  }
-  else if ( udialog )
-  {
-    udialog->apply();
-  }
-  layer->setTransparency( static_cast < unsigned int >( 255 - sliderTransparency->value() ) );
 
   //apply overlay dialogs
   for ( QList<QgsApplyDialog*>::iterator it = mOverlayDialogs.begin(); it != mOverlayDialogs.end(); ++it )

Modified: branches/symbology-ng-branch/src/core/symbology-ng/qgsstylev2.cpp
===================================================================
--- branches/symbology-ng-branch/src/core/symbology-ng/qgsstylev2.cpp	2009-07-23 13:15:09 UTC (rev 11155)
+++ branches/symbology-ng-branch/src/core/symbology-ng/qgsstylev2.cpp	2009-07-23 14:05:42 UTC (rev 11156)
@@ -6,6 +6,7 @@
 
 #include "qgssymbollayerv2registry.h"
 
+#include "qgsapplication.h"
 #include "qgslogger.h"
 
 #include <QDomDocument>
@@ -15,7 +16,9 @@
 
 #define STYLE_CURRENT_VERSION  "0"
 
+QgsStyleV2* QgsStyleV2::mDefaultStyle = NULL;
 
+
 QgsStyleV2::QgsStyleV2()
 {
 }
@@ -25,6 +28,25 @@
   clear();
 }
 
+QgsStyleV2* QgsStyleV2::defaultStyle() // static
+{
+  if (mDefaultStyle == NULL)
+  {
+    QString styleFilename = QgsApplication::userStyleV2Path();
+
+    // copy default style if user style doesn't exist
+    if ( !QFile::exists( styleFilename ) )
+    {
+      QFile::copy( QgsApplication::defaultStyleV2Path(), styleFilename );
+    }
+
+    mDefaultStyle = new QgsStyleV2;
+    mDefaultStyle->load( styleFilename );
+  }
+  return mDefaultStyle;
+}
+
+
 void QgsStyleV2::clear()
 {
   for (QMap<QString, QgsSymbolV2*>::iterator its = mSymbols.begin(); its != mSymbols.end(); ++its)

Modified: branches/symbology-ng-branch/src/core/symbology-ng/qgsstylev2.h
===================================================================
--- branches/symbology-ng-branch/src/core/symbology-ng/qgsstylev2.h	2009-07-23 13:15:09 UTC (rev 11155)
+++ branches/symbology-ng-branch/src/core/symbology-ng/qgsstylev2.h	2009-07-23 14:05:42 UTC (rev 11156)
@@ -23,6 +23,9 @@
   
   QgsStyleV2();
   ~QgsStyleV2();
+
+  //! return default application-wide style
+  static QgsStyleV2* defaultStyle();
   
   //! remove all contents of the style
   void clear();
@@ -90,6 +93,8 @@
   QgsVectorColorRampV2Map mColorRamps;
   
   QString mErrorString;
+
+  static QgsStyleV2* mDefaultStyle;
 };
 
 

Modified: branches/symbology-ng-branch/src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp
===================================================================
--- branches/symbology-ng-branch/src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp	2009-07-23 13:15:09 UTC (rev 11155)
+++ branches/symbology-ng-branch/src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp	2009-07-23 14:05:42 UTC (rev 11156)
@@ -17,7 +17,7 @@
 #include <QStandardItemModel>
 #include <QStandardItem>
 
-QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent)
+QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent, bool embedded)
   : QDialog(parent), mStyle(style)
 {
   mLayer = layer;
@@ -33,6 +33,12 @@
   
   setupUi(this);
 
+  // can be embedded in vector layer properties
+  if (embedded)
+  {
+    buttonBox->hide();
+  }
+
   connect(buttonBox, SIGNAL(accepted()), this, SLOT(onOK()));
 
   connect(btnSymbolLevels, SIGNAL(clicked()), this, SLOT(symbolLevels()));
@@ -91,11 +97,15 @@
   delete mRenderer;
 }
 
-void QgsRendererV2PropertiesDialog::onOK()
+void QgsRendererV2PropertiesDialog::apply()
 {
   mLayer->setRendererV2(mRenderer);
   mRenderer = NULL;
+}
 
+void QgsRendererV2PropertiesDialog::onOK()
+{
+  apply();
   accept();
 }
 

Modified: branches/symbology-ng-branch/src/gui/symbology-ng/qgsrendererv2propertiesdialog.h
===================================================================
--- branches/symbology-ng-branch/src/gui/symbology-ng/qgsrendererv2propertiesdialog.h	2009-07-23 13:15:09 UTC (rev 11155)
+++ branches/symbology-ng-branch/src/gui/symbology-ng/qgsrendererv2propertiesdialog.h	2009-07-23 14:05:42 UTC (rev 11156)
@@ -18,7 +18,7 @@
   Q_OBJECT
 
 public:
-  QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent = NULL);
+  QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent = NULL, bool embedded = false);
   ~QgsRendererV2PropertiesDialog();
   
 public slots:
@@ -39,6 +39,7 @@
   void symbolLevels();
 
   void onOK();
+  void apply();
 
 protected:
   

Modified: branches/symbology-ng-branch/src/ui/qgsvectorlayerpropertiesbase.ui
===================================================================
--- branches/symbology-ng-branch/src/ui/qgsvectorlayerpropertiesbase.ui	2009-07-23 13:15:09 UTC (rev 11155)
+++ branches/symbology-ng-branch/src/ui/qgsvectorlayerpropertiesbase.ui	2009-07-23 14:05:42 UTC (rev 11156)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>839</width>
-    <height>675</height>
+    <width>500</width>
+    <height>600</height>
    </rect>
   </property>
   <property name="minimumSize" >



More information about the QGIS-commit mailing list