Skip to content
Permalink
Browse files

"Add symbol to style" functionality in symbol selector.

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11169 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jul 24, 2009
1 parent 92d7e23 commit b6682c5a7949e45f599ed103c714135573b9f045
@@ -7,9 +7,12 @@
#include "qgssymbollayerv2utils.h"
#include "qgsstylev2.h"

#include "qgsapplication.h"

#include <QColorDialog>
#include <QPainter>
#include <QStandardItemModel>
#include <QInputDialog>

QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog(QgsSymbolV2* symbol, QgsStyleV2* style, QWidget* parent, bool embedded)
: QDialog(parent)
@@ -45,6 +48,8 @@ QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog(QgsSymbolV2* symbol, QgsSty
connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(setMarkerSize(double)));
connect(spinWidth, SIGNAL(valueChanged(double)), this, SLOT(setLineWidth(double)));

connect(btnAddToStyle, SIGNAL(clicked()), this, SLOT(addSymbolToStyle()));
btnAddToStyle->setIcon( QIcon( QgsApplication::defaultThemePath() + "symbologyAdd.png" ) );
}

void QgsSymbolV2SelectorDialog::populateSymbolView()
@@ -183,3 +188,17 @@ void QgsSymbolV2SelectorDialog::setLineWidth(double width)
updateSymbolPreview();
emit symbolModified();
}

void QgsSymbolV2SelectorDialog::addSymbolToStyle()
{
bool ok;
QString name = QInputDialog::getText(this, "Symbol name",
"Please enter name for the symbol:", QLineEdit::Normal, "New symbol", &ok);
if (!ok || name.isEmpty())
return;

// add new symbol to style and re-populate the list
mStyle->addSymbol(name, mSymbol->clone());

populateSymbolView();
}
@@ -30,6 +30,7 @@ public slots:
void setMarkerAngle(double angle);
void setMarkerSize(double size);
void setLineWidth(double width);
void addSymbolToStyle();

signals:
void symbolModified();
@@ -6,17 +6,17 @@
<rect>
<x>0</x>
<y>0</y>
<width>477</width>
<width>452</width>
<height>397</height>
</rect>
</property>
<property name="windowTitle">
<string>Symbol selector</string>
</property>
<layout class="QVBoxLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout">
<item row="0" column="0" rowspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="3">
<widget class="QLabel" name="lblPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@@ -45,7 +45,7 @@
</property>
</widget>
</item>
<item row="0" column="2" rowspan="2">
<item row="0" column="2" rowspan="3">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>1</number>
@@ -116,28 +116,32 @@
</widget>
</item>
<item row="0" column="3" rowspan="2">
<spacer>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>81</height>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<item row="1" column="1" rowspan="2">
<widget class="QPushButton" name="btnSetColor">
<property name="text">
<string>Set color</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="btnAddToStyle">
<property name="text">
<string>Add to style</string>
</property>
</widget>
</item>
</layout>
</item>
<item>

0 comments on commit b6682c5

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