[QGIS Commit] r11844 - in trunk/qgis/src: app core core/symbology ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Oct 26 01:36:53 EDT 2009
Author: timlinux
Date: 2009-10-26 01:36:52 -0400 (Mon, 26 Oct 2009)
New Revision: 11844
Modified:
trunk/qgis/src/app/qgisapp.cpp
trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp
trunk/qgis/src/app/qgsoptions.cpp
trunk/qgis/src/app/qgsoptions.h
trunk/qgis/src/core/qgsapplication.cpp
trunk/qgis/src/core/qgsapplication.h
trunk/qgis/src/core/symbology/qgsmarkercatalogue.cpp
trunk/qgis/src/core/symbology/qgssymbol.cpp
trunk/qgis/src/ui/qgsoptionsbase.ui
Log:
Added user selectable svg paths management to qgsoptions. Currently this is only working when svgs are in nested dirs of paths specified - will update soon so that it will look in the root dir of paths too.
Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp 2009-10-25 16:39:53 UTC (rev 11843)
+++ trunk/qgis/src/app/qgisapp.cpp 2009-10-26 05:36:52 UTC (rev 11844)
@@ -463,7 +463,10 @@
show();
qApp->processEvents();
//finally show all the application settings as initialised above
- QgsApplication::showSettings();
+
+ QgsDebugMsg( "\n\n\nApplication Settings:\n--------------------------\n");
+ QgsDebugMsg( QgsApplication::showSettings() );
+ QgsDebugMsg( "\n--------------------------\n\n\n");
mMapCanvas->freeze( false );
} // QgisApp ctor
Modified: trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp 2009-10-25 16:39:53 UTC (rev 11843)
+++ trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp 2009-10-26 05:36:52 UTC (rev 11844)
@@ -347,8 +347,8 @@
{
if ( last_it != quantileBorders.end() )
{
- lowerString = QVariant( *last_it ).toString();
- upperString = QVariant( *it ).toString();
+ lowerString = QString::number( QVariant( *last_it ).toDouble(), 'f', 3 );
+ upperString = QString::number( QVariant( *it ).toDouble(), 'f', 3 );
( *symbol_it )->setLowerValue( lowerString );
( *symbol_it )->setUpperValue( upperString );
@@ -371,8 +371,8 @@
//switch if attribute is int or double
double lower = minimum + ( maximum - minimum ) / numberofclassesspinbox->value() * i;
double upper = minimum + ( maximum - minimum ) / numberofclassesspinbox->value() * ( i + 1 );
- lowerString = QVariant( lower ).toString();
- upperString = QVariant( upper ).toString();
+ lowerString = QString::number( lower, 'f', 3 );
+ upperString = QString::number( upper, 'f', 3 );
( *symbol_it )->setLowerValue( lowerString );
( *symbol_it )->setUpperValue( upperString );
listBoxText = lowerString + " - " + upperString;
Modified: trunk/qgis/src/app/qgsoptions.cpp
===================================================================
--- trunk/qgis/src/app/qgsoptions.cpp 2009-10-25 16:39:53 UTC (rev 11843)
+++ trunk/qgis/src/app/qgsoptions.cpp 2009-10-26 05:36:52 UTC (rev 11844)
@@ -62,6 +62,22 @@
QgsDebugMsg( QString( "Standard Identify radius setting read from settings file: %1" ).arg( identifyValue ) );
spinBoxIdentifyValue->setValue( identifyValue );
+
+ //local directories to search when looking for an SVG with a given basename
+ QString myPaths = settings.value( "svg/searchPathsForSVG", "" ).toString();
+ if ( !myPaths.isEmpty() )
+ {
+ QStringList myPathList = myPaths.split( "|" );
+ QStringList::const_iterator pathIt = myPathList.constBegin();
+ for ( ; pathIt != myPathList.constEnd(); ++pathIt )
+ {
+ QListWidgetItem* newItem = new QListWidgetItem( mListSVGPaths );
+ newItem->setText( *pathIt );
+ newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
+ mListSVGPaths->addItem( newItem );
+ }
+ }
+
//Web proxy settings
grpProxy->setChecked( settings.value( "proxy/proxyEnabled", "0" ).toBool() );
leProxyHost->setText( settings.value( "proxy/proxyHost", "" ).toString() );
@@ -336,6 +352,19 @@
void QgsOptions::saveOptions()
{
QSettings settings;
+
+ //search directories for svgs
+ QString myPaths;
+ for ( int i = 0; i < mListSVGPaths->count(); ++i )
+ {
+ if ( i != 0 )
+ {
+ myPaths += "|";
+ }
+ myPaths += mListSVGPaths->item( i )->text();
+ }
+ settings.setValue( "svg/searchPathsForSVG", myPaths );
+
//Web proxy settings
settings.setValue( "proxy/proxyEnabled", grpProxy->isChecked() );
settings.setValue( "proxy/proxyHost", leProxyHost->text() );
@@ -344,6 +373,7 @@
settings.setValue( "proxy/proxyPassword", leProxyPassword->text() );
settings.setValue( "proxy/proxyType", mProxyTypeComboBox->currentText() );
+
//url to exclude from proxys
QString proxyExcludeString;
for ( int i = 0; i < mExcludeUrlListWidget->count(); ++i )
@@ -677,6 +707,31 @@
return myList;
}
+void QgsOptions::on_mBtnAddSVGPath_clicked()
+{
+ QString myDir = QFileDialog::getExistingDirectory(
+ this,
+ tr( "Choose a directory" ),
+ QDir::toNativeSeparators( QDir::homePath() ),
+ QFileDialog::ShowDirsOnly
+ );
+ if ( ! myDir.isEmpty() )
+ {
+ QListWidgetItem* newItem = new QListWidgetItem( mListSVGPaths );
+ newItem->setText( myDir );
+ newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
+ mListSVGPaths->addItem( newItem );
+ mListSVGPaths->setCurrentItem( newItem );
+ }
+}
+
+void QgsOptions::on_mBtnRemoveSVGPath_clicked()
+{
+ int currentRow = mListSVGPaths->currentRow();
+ QListWidgetItem* itemToRemove = mListSVGPaths->takeItem( currentRow );
+ delete itemToRemove;
+}
+
void QgsOptions::on_mAddUrlPushButton_clicked()
{
QListWidgetItem* newItem = new QListWidgetItem( mExcludeUrlListWidget );
Modified: trunk/qgis/src/app/qgsoptions.h
===================================================================
--- trunk/qgis/src/app/qgsoptions.h 2009-10-25 16:39:53 UTC (rev 11843)
+++ trunk/qgis/src/app/qgsoptions.h 2009-10-26 05:36:52 UTC (rev 11844)
@@ -88,6 +88,18 @@
/**Remove an URL to exclude from Proxy*/
void on_mRemoveUrlPushButton_clicked();
+ /* Let the user add a path to the list of search paths
+ * used for finding SVG files.
+ * @note added in QGIS 1.4
+ */
+ void on_mBtnAddSVGPath_clicked();
+
+ /* Let the user remove a path to the list of search paths
+ * used for finding SVG files.
+ * @note added in QGIS 1.4
+ */
+ void on_mBtnRemoveSVGPath_clicked();
+
protected:
//! Populates combo box with ellipsoids
void getEllipsoidList();
Modified: trunk/qgis/src/core/qgsapplication.cpp
===================================================================
--- trunk/qgis/src/core/qgsapplication.cpp 2009-10-25 16:39:53 UTC (rev 11843)
+++ trunk/qgis/src/core/qgsapplication.cpp 2009-10-26 05:36:52 UTC (rev 11844)
@@ -21,6 +21,7 @@
#include <QDir>
#include <QMessageBox>
#include <QPalette>
+#include <QSettings>
#include "qgsconfig.h"
@@ -285,9 +286,21 @@
*/
const QStringList QgsApplication::svgPaths()
{
- return QStringList()
- << mPkgDataPath + QString( "/svg/" )
- << qgisSettingsDirPath() + QString( "svg/" );
+ //local directories to search when looking for an SVG with a given basename
+ //defined by user in options dialog
+ QSettings settings;
+ QStringList myPathList;
+ QString myPaths = settings.value( "svg/searchPathsForSVG", "" ).toString();
+ if ( !myPaths.isEmpty() )
+ {
+ myPathList = myPaths.split( "|" );
+ }
+ //additional default paths
+ myPathList
+ << mPkgDataPath + QString( "/svg/" )
+ << qgisSettingsDirPath() + QString( "svg/" );
+ return myPathList;
+
}
/*!
@@ -327,13 +340,15 @@
"Active Theme Name : %4\n"
"Active Theme Path : %5\n"
"Default Theme Path : %6\n"
- "User DB Path : %7\n" )
+ "SVG Search Paths : %7\n"
+ "User DB Path : %8\n" )
.arg( mPrefixPath )
.arg( mPluginPath )
.arg( mPkgDataPath )
.arg( themeName() )
.arg( activeThemePath() )
.arg( defaultThemePath() )
+ .arg( svgPaths().join( "\n" ) )
.arg( qgisMasterDbFilePath() );
return myState;
}
Modified: trunk/qgis/src/core/qgsapplication.h
===================================================================
--- trunk/qgis/src/core/qgsapplication.h 2009-10-25 16:39:53 UTC (rev 11843)
+++ trunk/qgis/src/core/qgsapplication.h 2009-10-26 05:36:52 UTC (rev 11844)
@@ -108,8 +108,8 @@
//! @note added in 1.4
static const QStringList svgPaths();
- //! Returns the pathes to svg applications svg directory.
- //! @note deprecated
+ //! Returns the paths to svg applications svg directory.
+ //! @note deprecated since 1.4
static const QString svgPath();
//! Returns the path to the application prefix directory.
Modified: trunk/qgis/src/core/symbology/qgsmarkercatalogue.cpp
===================================================================
--- trunk/qgis/src/core/symbology/qgsmarkercatalogue.cpp 2009-10-25 16:39:53 UTC (rev 11843)
+++ trunk/qgis/src/core/symbology/qgsmarkercatalogue.cpp 2009-10-26 05:36:52 UTC (rev 11844)
@@ -70,16 +70,20 @@
// SVG
QStringList svgPaths = QgsApplication::svgPaths();
+ QgsDebugMsg( QString( "Application SVG Search paths: \n%1" ).arg( svgPaths.join( "\n" ) ) );
for(int i=0; i<svgPaths.size(); i++)
{
// TODO recursive ?
QDir dir( svgPaths[i] );
+
QStringList dl = dir.entryList( QDir::Dirs );
for ( QStringList::iterator it = dl.begin(); it != dl.end(); ++it )
{
+ QgsDebugMsg( QString( "Looking for svgs in %1" ).arg( svgPaths[i] + *it ) );
+
if ( *it == "." || *it == ".." ) continue;
QDir dir2( svgPaths[i] + *it );
Modified: trunk/qgis/src/core/symbology/qgssymbol.cpp
===================================================================
--- trunk/qgis/src/core/symbology/qgssymbol.cpp 2009-10-25 16:39:53 UTC (rev 11843)
+++ trunk/qgis/src/core/symbology/qgssymbol.cpp 2009-10-26 05:36:52 UTC (rev 11844)
@@ -224,38 +224,38 @@
for( int i=0; i<svgPaths.size(); i++)
{
- QgsDebugMsg( "SvgPath: " + svgPaths[i] );
- QFileInfo myInfo( myTempName );
- QString myFileName = myInfo.fileName(); // foo.svg
- QString myLowestDir = myInfo.dir().dirName();
- QString myLocalPath = svgPaths[i] + QDir::separator() +
- myLowestDir + QDir::separator() +
- myFileName;
- QgsDebugMsg( "Alternative svg path: " + myLocalPath );
- if ( QFile( myLocalPath ).exists() )
- {
- name = "svg:" + myLocalPath;
- QgsDebugMsg( "Svg found in alternative path" );
- }
- else if ( myInfo.isRelative() )
- {
- QFileInfo pfi( QgsProject::instance()->fileName() );
- if ( pfi.exists() && QFile( pfi.canonicalPath() + QDir::separator() + myTempName ).exists() )
- {
- name = "svg:" + pfi.canonicalPath() + QDir::separator() + myTempName;
- QgsDebugMsg( "Svg found in alternative path" );
- break;
- }
- else
- {
- QgsDebugMsg( "Svg not found in project path" );
- }
- }
- else
- {
- //couldnt find the file, no happy ending :-(
- QgsDebugMsg( "Computed alternate path but no svg there either" );
- }
+ QgsDebugMsg( "SvgPath: " + svgPaths[i] );
+ QFileInfo myInfo( myTempName );
+ QString myFileName = myInfo.fileName(); // foo.svg
+ QString myLowestDir = myInfo.dir().dirName();
+ QString myLocalPath = svgPaths[i] + QDir::separator() +
+ myLowestDir + QDir::separator() +
+ myFileName;
+ QgsDebugMsg( "Alternative svg path: " + myLocalPath );
+ if ( QFile( myLocalPath ).exists() )
+ {
+ name = "svg:" + myLocalPath;
+ QgsDebugMsg( "Svg found in alternative path" );
+ }
+ else if ( myInfo.isRelative() )
+ {
+ QFileInfo pfi( QgsProject::instance()->fileName() );
+ if ( pfi.exists() && QFile( pfi.canonicalPath() + QDir::separator() + myTempName ).exists() )
+ {
+ name = "svg:" + pfi.canonicalPath() + QDir::separator() + myTempName;
+ QgsDebugMsg( "Svg found in alternative path" );
+ break;
+ }
+ else
+ {
+ QgsDebugMsg( "Svg not found in project path" );
+ }
+ }
+ else
+ {
+ //couldnt find the file, no happy ending :-(
+ QgsDebugMsg( "Computed alternate path but no svg there either" );
+ }
}
}
}
Modified: trunk/qgis/src/ui/qgsoptionsbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsoptionsbase.ui 2009-10-25 16:39:53 UTC (rev 11843)
+++ trunk/qgis/src/ui/qgsoptionsbase.ui 2009-10-26 05:36:52 UTC (rev 11844)
@@ -5,17 +5,15 @@
<rect>
<x>0</x>
<y>0</y>
- <width>654</width>
- <height>546</height>
+ <width>657</width>
+ <height>594</height>
</rect>
</property>
<property name="windowTitle" >
<string>Options</string>
</property>
<property name="windowIcon" >
- <iconset>
- <normaloff/>
- </iconset>
+ <iconset/>
</property>
<property name="sizeGripEnabled" >
<bool>true</bool>
@@ -37,7 +35,7 @@
<item row="0" column="0" >
<widget class="QTabWidget" name="tabWidget" >
<property name="currentIndex" >
- <number>0</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="tabGeneral" >
<attribute name="title" >
@@ -255,27 +253,11 @@
</layout>
</widget>
</item>
- <item row="3" column="0" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Minimum</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>577</width>
- <height>21</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
<widget class="QWidget" name="tabRendering" >
<attribute name="title" >
- <string>&Rendering</string>
+ <string>&Rendering and SVG</string>
</attribute>
<layout class="QGridLayout" >
<item row="0" column="0" >
@@ -370,17 +352,50 @@
</widget>
</item>
<item row="2" column="0" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
+ <widget class="QGroupBox" name="groupBox_2" >
+ <property name="title" >
+ <string>SVG paths</string>
</property>
- <property name="sizeHint" >
- <size>
- <width>614</width>
- <height>111</height>
- </size>
- </property>
- </spacer>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="mSVGLabel" >
+ <property name="text" >
+ <string>Path(s) to search for Scalable Vector Graphic (SVG) symbols</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>31</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="2" >
+ <widget class="QPushButton" name="mBtnAddSVGPath" >
+ <property name="text" >
+ <string>Add</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3" >
+ <widget class="QPushButton" name="mBtnRemoveSVGPath" >
+ <property name="text" >
+ <string>Remove</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="4" >
+ <widget class="QListWidget" name="mListSVGPaths" />
+ </item>
+ </layout>
+ </widget>
</item>
</layout>
</widget>
@@ -650,54 +665,56 @@
<attribute name="title" >
<string>Overlay</string>
</attribute>
- <widget class="QGroupBox" name="mPositionGroupBox" >
- <property name="geometry" >
- <rect>
- <x>10</x>
- <y>10</y>
- <width>801</width>
- <height>111</height>
- </rect>
- </property>
- <property name="title" >
- <string>Position</string>
- </property>
- <widget class="QWidget" name="layoutWidget" >
- <property name="geometry" >
- <rect>
- <x>20</x>
- <y>40</y>
- <width>761</width>
- <height>42</height>
- </rect>
- </property>
- <layout class="QHBoxLayout" >
- <item>
- <widget class="QLabel" name="mAlgorithmLabel" >
- <property name="text" >
- <string>Placement algorithm:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="mOverlayAlgorithmComboBox" />
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>221</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </widget>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QGroupBox" name="mPositionGroupBox" >
+ <property name="title" >
+ <string>Position</string>
+ </property>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="mAlgorithmLabel" >
+ <property name="text" >
+ <string>Placement algorithm:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>mOverlayAlgorithmComboBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QComboBox" name="mOverlayAlgorithmComboBox" />
+ </item>
+ <item row="0" column="2" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>221</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</widget>
<widget class="QWidget" name="tabDigitizing" >
<attribute name="title" >
@@ -767,6 +784,9 @@
<property name="text" >
<string>Default snap mode</string>
</property>
+ <property name="buddy" >
+ <cstring>mDefaultSnapModeComboBox</cstring>
+ </property>
</widget>
</item>
<item row="0" column="1" colspan="3" >
@@ -797,6 +817,9 @@
<property name="text" >
<string>Default snapping tolerance</string>
</property>
+ <property name="buddy" >
+ <cstring>mDefaultSnappingToleranceSpinBox</cstring>
+ </property>
</widget>
</item>
<item row="1" column="2" colspan="2" >
@@ -827,6 +850,9 @@
<property name="text" >
<string>Search radius for vertex edits</string>
</property>
+ <property name="buddy" >
+ <cstring>mSearchRadiusVertexEditSpinBox</cstring>
+ </property>
</widget>
</item>
<item row="2" column="3" >
@@ -907,6 +933,9 @@
<property name="text" >
<string>Marker style</string>
</property>
+ <property name="buddy" >
+ <cstring>mMarkerStyleComboBox</cstring>
+ </property>
</widget>
</item>
<item row="1" column="1" >
@@ -950,6 +979,9 @@
<property name="text" >
<string>Marker size</string>
</property>
+ <property name="buddy" >
+ <cstring>mMarkerSizeSpinBox</cstring>
+ </property>
</widget>
</item>
<item row="2" column="1" >
More information about the QGIS-commit
mailing list