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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed May 13 07:31:35 EDT 2009


Author: wonder
Date: 2009-05-13 07:31:35 -0400 (Wed, 13 May 2009)
New Revision: 10781

Modified:
   branches/symbology-ng-branch/src/app/CMakeLists.txt
   branches/symbology-ng-branch/src/app/qgisapp.cpp
   branches/symbology-ng-branch/src/app/qgisapp.h
   branches/symbology-ng-branch/src/gui/symbology-ng/qgsstylev2managerdialog.cpp
   branches/symbology-ng-branch/src/gui/symbology-ng/qgsstylev2managerdialog.h
   branches/symbology-ng-branch/src/ui/qgsstylev2managerdialogbase.ui
Log:
Primitive integration of new symbology in qgis application.
Two new toolbar buttons (V2 and MGR) to allow setting new renderers and show style manager.


Modified: branches/symbology-ng-branch/src/app/CMakeLists.txt
===================================================================
--- branches/symbology-ng-branch/src/app/CMakeLists.txt	2009-05-13 11:28:16 UTC (rev 10780)
+++ branches/symbology-ng-branch/src/app/CMakeLists.txt	2009-05-13 11:31:35 UTC (rev 10781)
@@ -232,8 +232,8 @@
   ${CMAKE_CURRENT_BINARY_DIR}
   ${CMAKE_CURRENT_BINARY_DIR}/../ui
   ../core
-  ../core/composer ../core/raster ../core/renderer ../core/symbology
-  ../gui
+  ../core/composer ../core/raster ../core/renderer ../core/symbology ../core/symbology-ng
+  ../gui ../gui/symbology-ng
   ../plugins
   ../python
   ${PROJ_INCLUDE_DIR}

Modified: branches/symbology-ng-branch/src/app/qgisapp.cpp
===================================================================
--- branches/symbology-ng-branch/src/app/qgisapp.cpp	2009-05-13 11:28:16 UTC (rev 10780)
+++ branches/symbology-ng-branch/src/app/qgisapp.cpp	2009-05-13 11:31:35 UTC (rev 10781)
@@ -992,8 +992,70 @@
   mActionAbout->setStatusTip( tr( "About QGIS" ) );
   mActionAbout->setMenuRole( QAction::AboutRole ); // put in application menu on Mac OS X
   connect( mActionAbout, SIGNAL( triggered() ), this, SLOT( about() ) );
+
+  // %%%
+  mActionUseRendererV2 = new QAction( "V2", this );
+  mActionUseRendererV2->setStatusTip( tr( "Toggles renderer V2 for current layer" ) );
+  connect( mActionUseRendererV2, SIGNAL( triggered() ), this, SLOT( toggleRendererV2() ) );
+
+  // %%%
+  mActionStyleManagerV2 = new QAction( "MGR", this );
+  mActionStyleManagerV2->setStatusTip( tr( "Show style manager V2" ) );
+  connect( mActionStyleManagerV2, SIGNAL( triggered() ), this, SLOT( showStyleManagerV2() ) );
 }
 
+#include "qgsstylev2.h"
+#include "qgssymbolv2.h"
+#include "qgsrendererv2.h"
+#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();
+  if (layer == NULL || layer->type() != QgsMapLayer::VectorLayer)
+  {
+    QMessageBox::information(this, "sorry", "Give me a vector layer!");
+    return;
+  }
+  QgsVectorLayer* vlayer = static_cast<QgsVectorLayer*>(layer);
+  
+  _initStyle();
+  
+  QgsRendererV2PropertiesDialog dlg(vlayer, gStyleV2, this);
+  if (!dlg.exec())
+    return;
+  
+  refreshMapCanvas();
+}
+
+void QgisApp::showStyleManagerV2()
+{
+  _initStyle();
+
+  QgsStyleV2ManagerDialog dlg(gStyleV2, QgsApplication::userStyleV2Path(), this);
+  dlg.exec();
+}
+
 void QgisApp::showPythonDialog()
 {
   if ( !mPythonUtils || !mPythonUtils->isEnabled() )
@@ -1305,6 +1367,8 @@
   mFileToolBar->addAction( mActionAddSpatiaLiteLayer );
 #endif
   mFileToolBar->addAction( mActionAddWmsLayer );
+  mFileToolBar->addAction( mActionUseRendererV2 );
+  mFileToolBar->addAction( mActionStyleManagerV2 );
   mToolbarMenu->addAction( mFileToolBar->toggleViewAction() );
   //
   // Layer Toolbar

Modified: branches/symbology-ng-branch/src/app/qgisapp.h
===================================================================
--- branches/symbology-ng-branch/src/app/qgisapp.h	2009-05-13 11:28:16 UTC (rev 10780)
+++ branches/symbology-ng-branch/src/app/qgisapp.h	2009-05-13 11:31:35 UTC (rev 10781)
@@ -597,6 +597,9 @@
     //! Stops rendering of the main map
     void stopRendering();
 
+    void toggleRendererV2();
+    void showStyleManagerV2();
+
   signals:
     /** emitted when a key is pressed and we want non widget sublasses to be able
       to pick up on this (e.g. maplayer) */
@@ -790,6 +793,9 @@
     QAction *mActionHelpSeparator2;
     QAction *mActionAbout;
 
+    QAction *mActionUseRendererV2;
+    QAction *mActionStyleManagerV2;
+
     // action groups ----------------------------------
     QActionGroup *mMapToolGroup;
 

Modified: branches/symbology-ng-branch/src/gui/symbology-ng/qgsstylev2managerdialog.cpp
===================================================================
--- branches/symbology-ng-branch/src/gui/symbology-ng/qgsstylev2managerdialog.cpp	2009-05-13 11:28:16 UTC (rev 10780)
+++ branches/symbology-ng-branch/src/gui/symbology-ng/qgsstylev2managerdialog.cpp	2009-05-13 11:31:35 UTC (rev 10781)
@@ -14,6 +14,7 @@
 #include <QStandardItemModel>
 
 #include "qgsapplication.h"
+#include "qgslogger.h"
 
 
 static QString iconPath(QString iconFile)
@@ -29,8 +30,8 @@
 
 ///////
 
-QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog(QgsStyleV2* style, QWidget* parent)
-  : QDialog(parent), mStyle(style)
+QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog(QgsStyleV2* style, QString styleFilename, QWidget* parent)
+  : QDialog(parent), mStyle(style), mStyleFilename(styleFilename)
 {
 
   setupUi(this);
@@ -61,7 +62,9 @@
 
 void QgsStyleV2ManagerDialog::onFinished()
 {
-  // TODO: if modified, save the changes
+  // TODO: save only when modified
+  if (!mStyleFilename.isEmpty())
+    mStyle->save(mStyleFilename);
 }
 
 void QgsStyleV2ManagerDialog::populateTypes()

Modified: branches/symbology-ng-branch/src/gui/symbology-ng/qgsstylev2managerdialog.h
===================================================================
--- branches/symbology-ng-branch/src/gui/symbology-ng/qgsstylev2managerdialog.h	2009-05-13 11:28:16 UTC (rev 10780)
+++ branches/symbology-ng-branch/src/gui/symbology-ng/qgsstylev2managerdialog.h	2009-05-13 11:31:35 UTC (rev 10781)
@@ -13,7 +13,7 @@
   Q_OBJECT
   
 public:
-  QgsStyleV2ManagerDialog(QgsStyleV2* style, QWidget* parent = NULL);
+  QgsStyleV2ManagerDialog(QgsStyleV2* style, QString styleFilename, QWidget* parent = NULL);
   
 public slots:
   void addItem();
@@ -51,6 +51,7 @@
   
   QgsStyleV2* mStyle;
 
+  QString mStyleFilename;
 };
 
 #endif

Modified: branches/symbology-ng-branch/src/ui/qgsstylev2managerdialogbase.ui
===================================================================
--- branches/symbology-ng-branch/src/ui/qgsstylev2managerdialogbase.ui	2009-05-13 11:28:16 UTC (rev 10780)
+++ branches/symbology-ng-branch/src/ui/qgsstylev2managerdialogbase.ui	2009-05-13 11:31:35 UTC (rev 10781)
@@ -108,5 +108,22 @@
   <tabstop>buttonBox</tabstop>
  </tabstops>
  <resources/>
- <connections/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>QgsStyleV2ManagerDialogBase</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>266</x>
+     <y>350</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>299</x>
+     <y>351</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
 </ui>



More information about the QGIS-commit mailing list