Skip to content
Permalink
Browse files

Add line edit to select svg marker

  • Loading branch information
mhugent committed Jun 20, 2011
1 parent 3fcdc4c commit a21e1db9885865b143da952adec852c67622c373
@@ -14,7 +14,9 @@
#include <QAbstractButton>
#include <QColorDialog>
#include <QDir>
#include <QFileDialog>
#include <QPainter>
#include <QSettings>
#include <QStandardItemModel>
#include <QSvgRenderer>

@@ -618,8 +620,9 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2Widget::symbolLayer()

void QgsSvgMarkerSymbolLayerV2Widget::setName( const QModelIndex& idx )
{
mLayer->setPath( idx.data( Qt::UserRole ).toString() );

QString name = idx.data( Qt::UserRole ).toString();
mLayer->setPath( name );
mFileLineEdit->setText( name );
emit changed();
}

@@ -641,6 +644,31 @@ void QgsSvgMarkerSymbolLayerV2Widget::setOffset()
emit changed();
}

void QgsSvgMarkerSymbolLayerV2Widget::on_mFileToolButton_clicked()
{
QSettings s;
QString file = QFileDialog::getOpenFileName( 0, tr( "Select SVG file" ), s.value( "/UI/lastSVGMarkerDir" ).toString(), "SVG files (*.svg)" );
QFileInfo fi( file );
if ( file.isEmpty() || !fi.exists() )
{
return;
}
mFileLineEdit->setText( file );
mLayer->setPath( file );
s.setValue( "/UI/lastSVGMarkerDir", fi.absolutePath() );
emit changed();
}

void QgsSvgMarkerSymbolLayerV2Widget::on_mFileLineEdit_textEdited( const QString& text )
{
if ( !QFileInfo( text ).exists() )
{
return;
}
mLayer->setPath( text );
emit changed();
}

///////////////

QgsLineDecorationSymbolLayerV2Widget::QgsLineDecorationSymbolLayerV2Widget( QWidget* parent )
@@ -179,6 +179,8 @@ class GUI_EXPORT QgsSvgMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget
void setSize();
void setAngle();
void setOffset();
void on_mFileToolButton_clicked();
void on_mFileLineEdit_textEdited( const QString& text );

protected:

@@ -13,8 +13,8 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
@@ -120,14 +120,14 @@
</item>
</layout>
</item>
<item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>SVG Image</string>
</property>
</widget>
</item>
<item>
<item row="2" column="0">
<widget class="QListView" name="viewImages">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
@@ -167,6 +167,20 @@
</property>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="mFileLineEdit"/>
</item>
<item>
<widget class="QToolButton" name="mFileToolButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>

0 comments on commit a21e1db

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