Skip to content

Commit 9448b46

Browse files
author
wonder
committed
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
1 parent 22cfaa3 commit 9448b46

6 files changed

Lines changed: 98 additions & 7 deletions

File tree

src/app/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ INCLUDE_DIRECTORIES(
232232
${CMAKE_CURRENT_BINARY_DIR}
233233
${CMAKE_CURRENT_BINARY_DIR}/../ui
234234
../core
235-
../core/composer ../core/raster ../core/renderer ../core/symbology
236-
../gui
235+
../core/composer ../core/raster ../core/renderer ../core/symbology ../core/symbology-ng
236+
../gui ../gui/symbology-ng
237237
../plugins
238238
../python
239239
${PROJ_INCLUDE_DIR}

src/app/qgisapp.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,68 @@ void QgisApp::createActions()
992992
mActionAbout->setStatusTip( tr( "About QGIS" ) );
993993
mActionAbout->setMenuRole( QAction::AboutRole ); // put in application menu on Mac OS X
994994
connect( mActionAbout, SIGNAL( triggered() ), this, SLOT( about() ) );
995+
996+
// %%%
997+
mActionUseRendererV2 = new QAction( "V2", this );
998+
mActionUseRendererV2->setStatusTip( tr( "Toggles renderer V2 for current layer" ) );
999+
connect( mActionUseRendererV2, SIGNAL( triggered() ), this, SLOT( toggleRendererV2() ) );
1000+
1001+
// %%%
1002+
mActionStyleManagerV2 = new QAction( "MGR", this );
1003+
mActionStyleManagerV2->setStatusTip( tr( "Show style manager V2" ) );
1004+
connect( mActionStyleManagerV2, SIGNAL( triggered() ), this, SLOT( showStyleManagerV2() ) );
1005+
}
1006+
1007+
#include "qgsstylev2.h"
1008+
#include "qgssymbolv2.h"
1009+
#include "qgsrendererv2.h"
1010+
#include "qgsrendererv2propertiesdialog.h"
1011+
#include "qgsstylev2managerdialog.h"
1012+
1013+
static QgsStyleV2* gStyleV2 = NULL;
1014+
1015+
static void _initStyle()
1016+
{
1017+
if (gStyleV2 == NULL)
1018+
{
1019+
QString styleFilename = QgsApplication::userStyleV2Path();
1020+
1021+
// copy default style if user style doesn't exist
1022+
if ( !QFile::exists( styleFilename ) )
1023+
{
1024+
QFile::copy( QgsApplication::defaultStyleV2Path(), styleFilename );
1025+
}
1026+
1027+
gStyleV2 = new QgsStyleV2;
1028+
gStyleV2->load( styleFilename );
1029+
}
1030+
}
1031+
1032+
void QgisApp::toggleRendererV2()
1033+
{
1034+
QgsMapLayer* layer = activeLayer();
1035+
if (layer == NULL || layer->type() != QgsMapLayer::VectorLayer)
1036+
{
1037+
QMessageBox::information(this, "sorry", "Give me a vector layer!");
1038+
return;
1039+
}
1040+
QgsVectorLayer* vlayer = static_cast<QgsVectorLayer*>(layer);
1041+
1042+
_initStyle();
1043+
1044+
QgsRendererV2PropertiesDialog dlg(vlayer, gStyleV2, this);
1045+
if (!dlg.exec())
1046+
return;
1047+
1048+
refreshMapCanvas();
1049+
}
1050+
1051+
void QgisApp::showStyleManagerV2()
1052+
{
1053+
_initStyle();
1054+
1055+
QgsStyleV2ManagerDialog dlg(gStyleV2, QgsApplication::userStyleV2Path(), this);
1056+
dlg.exec();
9951057
}
9961058

9971059
void QgisApp::showPythonDialog()
@@ -1305,6 +1367,8 @@ void QgisApp::createToolBars()
13051367
mFileToolBar->addAction( mActionAddSpatiaLiteLayer );
13061368
#endif
13071369
mFileToolBar->addAction( mActionAddWmsLayer );
1370+
mFileToolBar->addAction( mActionUseRendererV2 );
1371+
mFileToolBar->addAction( mActionStyleManagerV2 );
13081372
mToolbarMenu->addAction( mFileToolBar->toggleViewAction() );
13091373
//
13101374
// Layer Toolbar

src/app/qgisapp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,9 @@ class QgisApp : public QMainWindow
597597
//! Stops rendering of the main map
598598
void stopRendering();
599599

600+
void toggleRendererV2();
601+
void showStyleManagerV2();
602+
600603
signals:
601604
/** emitted when a key is pressed and we want non widget sublasses to be able
602605
to pick up on this (e.g. maplayer) */
@@ -790,6 +793,9 @@ class QgisApp : public QMainWindow
790793
QAction *mActionHelpSeparator2;
791794
QAction *mActionAbout;
792795

796+
QAction *mActionUseRendererV2;
797+
QAction *mActionStyleManagerV2;
798+
793799
// action groups ----------------------------------
794800
QActionGroup *mMapToolGroup;
795801

src/gui/symbology-ng/qgsstylev2managerdialog.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <QStandardItemModel>
1515

1616
#include "qgsapplication.h"
17+
#include "qgslogger.h"
1718

1819

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

3031
///////
3132

32-
QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog(QgsStyleV2* style, QWidget* parent)
33-
: QDialog(parent), mStyle(style)
33+
QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog(QgsStyleV2* style, QString styleFilename, QWidget* parent)
34+
: QDialog(parent), mStyle(style), mStyleFilename(styleFilename)
3435
{
3536

3637
setupUi(this);
@@ -61,7 +62,9 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog(QgsStyleV2* style, QWidget* par
6162

6263
void QgsStyleV2ManagerDialog::onFinished()
6364
{
64-
// TODO: if modified, save the changes
65+
// TODO: save only when modified
66+
if (!mStyleFilename.isEmpty())
67+
mStyle->save(mStyleFilename);
6568
}
6669

6770
void QgsStyleV2ManagerDialog::populateTypes()

src/gui/symbology-ng/qgsstylev2managerdialog.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV2ManagerDia
1313
Q_OBJECT
1414

1515
public:
16-
QgsStyleV2ManagerDialog(QgsStyleV2* style, QWidget* parent = NULL);
16+
QgsStyleV2ManagerDialog(QgsStyleV2* style, QString styleFilename, QWidget* parent = NULL);
1717

1818
public slots:
1919
void addItem();
@@ -51,6 +51,7 @@ public slots:
5151

5252
QgsStyleV2* mStyle;
5353

54+
QString mStyleFilename;
5455
};
5556

5657
#endif

src/ui/qgsstylev2managerdialogbase.ui

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,22 @@
108108
<tabstop>buttonBox</tabstop>
109109
</tabstops>
110110
<resources/>
111-
<connections/>
111+
<connections>
112+
<connection>
113+
<sender>buttonBox</sender>
114+
<signal>rejected()</signal>
115+
<receiver>QgsStyleV2ManagerDialogBase</receiver>
116+
<slot>reject()</slot>
117+
<hints>
118+
<hint type="sourcelabel">
119+
<x>266</x>
120+
<y>350</y>
121+
</hint>
122+
<hint type="destinationlabel">
123+
<x>299</x>
124+
<y>351</y>
125+
</hint>
126+
</hints>
127+
</connection>
128+
</connections>
112129
</ui>

0 commit comments

Comments
 (0)