Skip to content
Permalink
Browse files

Primitive integration of new symbology in qgis application.

Two new toolbar buttons (V2 and MGR) to allow setting new renderers and show style manager.


git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@10781 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed May 13, 2009
1 parent 22cfaa3 commit 9448b467c02a612956bb00f32044fb4e4a7af077
@@ -232,8 +232,8 @@ INCLUDE_DIRECTORIES(
${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}
@@ -992,6 +992,68 @@ void QgisApp::createActions()
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()
@@ -1305,6 +1367,8 @@ void QgisApp::createToolBars()
mFileToolBar->addAction( mActionAddSpatiaLiteLayer );
#endif
mFileToolBar->addAction( mActionAddWmsLayer );
mFileToolBar->addAction( mActionUseRendererV2 );
mFileToolBar->addAction( mActionStyleManagerV2 );
mToolbarMenu->addAction( mFileToolBar->toggleViewAction() );
//
// Layer Toolbar
@@ -597,6 +597,9 @@ class QgisApp : public QMainWindow
//! 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 @@ class QgisApp : public QMainWindow
QAction *mActionHelpSeparator2;
QAction *mActionAbout;

QAction *mActionUseRendererV2;
QAction *mActionStyleManagerV2;

// action groups ----------------------------------
QActionGroup *mMapToolGroup;

@@ -14,6 +14,7 @@
#include <QStandardItemModel>

#include "qgsapplication.h"
#include "qgslogger.h"


static QString iconPath(QString iconFile)
@@ -29,8 +30,8 @@ static QString iconPath(QString iconFile)

///////

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 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog(QgsStyleV2* style, QWidget* par

void QgsStyleV2ManagerDialog::onFinished()
{
// TODO: if modified, save the changes
// TODO: save only when modified
if (!mStyleFilename.isEmpty())
mStyle->save(mStyleFilename);
}

void QgsStyleV2ManagerDialog::populateTypes()
@@ -13,7 +13,7 @@ class QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV2ManagerDia
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 @@ public slots:

QgsStyleV2* mStyle;

QString mStyleFilename;
};

#endif
@@ -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>

0 comments on commit 9448b46

Please sign in to comment.
You can’t perform that action at this time.