Skip to content

Commit

Permalink
Primitive integration of new symbology in qgis application.
Browse files Browse the repository at this point in the history
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 committed May 13, 2009
1 parent 22cfaa3 commit 9448b46
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
64 changes: 64 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down Expand Up @@ -790,6 +793,9 @@ class QgisApp : public QMainWindow
QAction *mActionHelpSeparator2;
QAction *mActionAbout;

QAction *mActionUseRendererV2;
QAction *mActionStyleManagerV2;

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

Expand Down
9 changes: 6 additions & 3 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <QStandardItemModel>

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


static QString iconPath(QString iconFile)
Expand All @@ -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);
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/gui/symbology-ng/qgsstylev2managerdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -51,6 +51,7 @@ public slots:

QgsStyleV2* mStyle;

QString mStyleFilename;
};

#endif
19 changes: 18 additions & 1 deletion src/ui/qgsstylev2managerdialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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.