Index: src/app/qgssinglesymboldialog.h =================================================================== --- src/app/qgssinglesymboldialog.h (revision 7689) +++ src/app/qgssinglesymboldialog.h (working copy) @@ -58,19 +58,21 @@ void apply( QgsSymbol *sy); /**emits the signal settingsChanged()*/ void resendSettingsChanged(); + /**changes the texture selection button to enabled or + * disabled depending if the texture entry in the combo + */ + void fillStyleChanged( int theIndex ); protected slots: void selectOutlineColor(); void selectFillColor(); - void selectTextureImage(); - + void selectTextureImage(); + void symbolChanged ( QListWidgetItem * current, QListWidgetItem * previous ); private: /** Default constructor is private, do not use this */ QgsSingleSymbolDialog(); + QString mTexturePath; - /** vector of marker names for combo items */ - std::vector mMarkers; - signals: void settingsChanged(); }; Index: src/app/qgsvectorlayerproperties.h =================================================================== --- src/app/qgsvectorlayerproperties.h (revision 7689) +++ src/app/qgsvectorlayerproperties.h (working copy) @@ -63,6 +63,10 @@ void on_pbnQueryBuilder_clicked(); void on_pbnIndex_clicked(); void on_pbnChangeSpatialRefSys_clicked(); + void on_pbnLoadDefaultStyle_clicked(); + void on_pbnSaveDefaultStyle_clicked(); + void on_pbnLoadStyle_clicked(); + void on_pbnSaveStyleAs_clicked(); signals: Index: src/app/qgsvectorlayerproperties.cpp =================================================================== --- src/app/qgsvectorlayerproperties.cpp (revision 7689) +++ src/app/qgsvectorlayerproperties.cpp (working copy) @@ -17,36 +17,41 @@ ***************************************************************************/ /* $Id$ */ -#include "qgsvectorlayerproperties.h" #include "qgsattributeactiondialog.h" #include "qgscontexthelp.h" #include "qgscontinuouscolordialog.h" #include "qgscoordinatetransform.h" #include "qgsgraduatedsymboldialog.h" +#include "qgslabeldialog.h" #include "qgslabel.h" -#include "qgslabeldialog.h" #include "qgslayerprojectionselector.h" #include "qgslogger.h" #include "qgssinglesymboldialog.h" #include "qgsuniquevaluedialog.h" #include "qgsvectordataprovider.h" #include "qgsvectorlayer.h" +#include "qgsvectorlayerproperties.h" +#include "qgsconfig.h" -#include "qgsconfig.h" #ifdef HAVE_POSTGRESQL #include "qgspgquerybuilder.h" #include "../providers/postgres/qgspostgresprovider.h" #endif #include +#include +#include +#include +#include +#include QgsVectorLayerProperties::QgsVectorLayerProperties(QgsVectorLayer * lyr, - QWidget * parent, - Qt::WFlags fl) + QWidget * parent, + Qt::WFlags fl) : QDialog(parent, fl), - layer(lyr), - mRendererDialog(0) + layer(lyr), + mRendererDialog(0) { setupUi(this); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); @@ -61,7 +66,7 @@ layout->addWidget( labelDialog ); labelOptionsFrame->setLayout(layout); connect(labelDialog, SIGNAL(labelSourceSet()), - this, SLOT(setLabelCheckBox())); + this, SLOT(setLabelCheckBox())); // Create the Actions dialog tab QgsVectorDataProvider *dp = dynamic_cast(layer->getDataProvider()); @@ -69,22 +74,22 @@ actionLayout->setMargin(0); QgsFieldMap fields = dp->fields(); actionDialog = new QgsAttributeActionDialog ( layer->actions(), fields, - actionOptionsFrame ); + actionOptionsFrame ); actionLayout->addWidget( actionDialog ); reset(); if(layer->getDataProvider())//enable spatial index button group if supported by provider { - int capabilities=layer->getDataProvider()->capabilities(); - if(!(capabilities&QgsVectorDataProvider::CreateSpatialIndex)) - { - indexGroupBox->setEnabled(false); - } + int capabilities=layer->getDataProvider()->capabilities(); + if(!(capabilities&QgsVectorDataProvider::CreateSpatialIndex)) + { + indexGroupBox->setEnabled(false); + } } leSpatialRefSys->setText(layer->srs().proj4String()); leSpatialRefSys->setCursorPosition(0); - + connect(sliderTransparency, SIGNAL(valueChanged(int)), this, SLOT(sliderTransparency_valueChanged(int))); } // QgsVectorLayerProperties ctor @@ -92,7 +97,7 @@ QgsVectorLayerProperties::~QgsVectorLayerProperties() { disconnect(labelDialog, SIGNAL(labelSourceSet()), - this, SLOT(setLabelCheckBox())); + this, SLOT(setLabelCheckBox())); } void QgsVectorLayerProperties::sliderTransparency_valueChanged(int theValue) { @@ -109,27 +114,27 @@ void QgsVectorLayerProperties::alterLayerDialog(const QString & dialogString) { - widgetStackRenderers->removeWidget(mRendererDialog); - delete mRendererDialog; - mRendererDialog=0; - if(dialogString == tr("Single Symbol")) - { - mRendererDialog = new QgsSingleSymbolDialog(layer); - } - else if(dialogString == tr("Graduated Symbol")) - { - mRendererDialog = new QgsGraduatedSymbolDialog(layer); - } - else if(dialogString == tr("Continuous Color")) - { - mRendererDialog = new QgsContinuousColorDialog(layer); - } - else if(dialogString == tr("Unique Value")) - { - mRendererDialog = new QgsUniqueValueDialog(layer); - } - widgetStackRenderers->addWidget(mRendererDialog); - widgetStackRenderers->setCurrentWidget(mRendererDialog); + widgetStackRenderers->removeWidget(mRendererDialog); + delete mRendererDialog; + mRendererDialog=0; + if(dialogString == tr("Single Symbol")) + { + mRendererDialog = new QgsSingleSymbolDialog(layer); + } + else if(dialogString == tr("Graduated Symbol")) + { + mRendererDialog = new QgsGraduatedSymbolDialog(layer); + } + else if(dialogString == tr("Continuous Color")) + { + mRendererDialog = new QgsContinuousColorDialog(layer); + } + else if(dialogString == tr("Unique Value")) + { + mRendererDialog = new QgsUniqueValueDialog(layer); + } + widgetStackRenderers->addWidget(mRendererDialog); + widgetStackRenderers->setCurrentWidget(mRendererDialog); } void QgsVectorLayerProperties::setLegendType(QString type) @@ -147,8 +152,12 @@ { // populate the general information txtDisplayName->setText(layer->name()); - pbnQueryBuilder->setWhatsThis(tr("This button opens the PostgreSQL query builder and allows you to create a subset of features to display on the map canvas rather than displaying all features in the layer")); - txtSubsetSQL->setWhatsThis(tr("The query used to limit the features in the layer is shown here. This is currently only supported for PostgreSQL layers. To enter or modify the query, click on the Query Builder button")); + pbnQueryBuilder->setWhatsThis(tr("This button opens the PostgreSQL query " + "builder and allows you to create a subset of features to display on " + "the map canvas rather than displaying all features in the layer")); + txtSubsetSQL->setWhatsThis(tr("The query used to limit the features in the " + "layer is shown here. This is currently only supported for PostgreSQL " + "layers. To enter or modify the query, click on the Query Builder button")); //we are dealing with a pg layer here so that we can enable the sql box QgsVectorDataProvider *dp = dynamic_cast(layer->getDataProvider()); @@ -184,15 +193,15 @@ // symbology initialization if(legendtypecombobox->count()==0) + { + legendtypecombobox->insertItem(tr("Single Symbol")); + if(myFields.size()>0) { - legendtypecombobox->insertItem(tr("Single Symbol")); - if(myFields.size()>0) - { - legendtypecombobox->insertItem(tr("Graduated Symbol")); - legendtypecombobox->insertItem(tr("Continuous Color")); - legendtypecombobox->insertItem(tr("Unique Value")); - } + legendtypecombobox->insertItem(tr("Graduated Symbol")); + legendtypecombobox->insertItem(tr("Continuous Color")); + legendtypecombobox->insertItem(tr("Unique Value")); } + } //find out the type of renderer in the vectorlayer, create a dialog with these settings and add it to the form delete mRendererDialog; @@ -200,37 +209,38 @@ QString rtype=layer->renderer()->name(); if(rtype=="Single Symbol") { - mRendererDialog=new QgsSingleSymbolDialog(layer); - legendtypecombobox->setCurrentIndex(0); + mRendererDialog=new QgsSingleSymbolDialog(layer); + legendtypecombobox->setCurrentIndex(0); } else if(rtype=="Graduated Symbol") { - mRendererDialog=new QgsGraduatedSymbolDialog(layer); - legendtypecombobox->setCurrentIndex(1); + mRendererDialog=new QgsGraduatedSymbolDialog(layer); + legendtypecombobox->setCurrentIndex(1); } else if(rtype=="Continuous Color") { - mRendererDialog=new QgsContinuousColorDialog(layer); - legendtypecombobox->setCurrentIndex(2); + mRendererDialog=new QgsContinuousColorDialog(layer); + legendtypecombobox->setCurrentIndex(2); } else if(rtype == "Unique Value") { - mRendererDialog=new QgsUniqueValueDialog(layer); - legendtypecombobox->setCurrentIndex(3); + mRendererDialog=new QgsUniqueValueDialog(layer); + legendtypecombobox->setCurrentIndex(3); } - + if(mRendererDialog) { - widgetStackRenderers->addWidget(mRendererDialog); - widgetStackRenderers->setCurrentWidget(mRendererDialog); + widgetStackRenderers->addWidget(mRendererDialog); + widgetStackRenderers->setCurrentWidget(mRendererDialog); } - - QObject::connect(legendtypecombobox, SIGNAL(activated(const QString &)), this, SLOT(alterLayerDialog(const QString &))); + QObject::connect(legendtypecombobox, SIGNAL(activated(const QString &)), this, + SLOT(alterLayerDialog(const QString &))); + // reset fields in label dialog layer->label()->setFields ( layer->getDataProvider()->fields() ); - + //set the metadata contents teMetadata->setText(getMetadata()); actionDialog->init(); @@ -259,8 +269,6 @@ // Set up sql subset query if applicable // #ifdef HAVE_POSTGRESQL - // Tim commented out the next line because dp is not actually used anywhere.... - //QgsVectorDataProvider *dp = dynamic_cast(layer->getDataProvider()); //see if we are dealing with a pg layer here if(layer->providerType() == "postgres") { @@ -288,32 +296,36 @@ layer->setLayerName(displayName()); - QgsSingleSymbolDialog *sdialog = dynamic_cast < QgsSingleSymbolDialog * >(widgetStackRenderers->currentWidget()); - QgsGraduatedSymbolDialog *gdialog = dynamic_cast < QgsGraduatedSymbolDialog * >(widgetStackRenderers->currentWidget()); - QgsContinuousColorDialog *cdialog = dynamic_cast < QgsContinuousColorDialog * >(widgetStackRenderers->currentWidget()); - QgsUniqueValueDialog* udialog = dynamic_cast< QgsUniqueValueDialog * >(widgetStackRenderers->currentWidget()); + QgsSingleSymbolDialog *sdialog = + dynamic_cast < QgsSingleSymbolDialog * >(widgetStackRenderers->currentWidget()); + QgsGraduatedSymbolDialog *gdialog = + dynamic_cast < QgsGraduatedSymbolDialog * >(widgetStackRenderers->currentWidget()); + QgsContinuousColorDialog *cdialog = + dynamic_cast < QgsContinuousColorDialog * >(widgetStackRenderers->currentWidget()); + QgsUniqueValueDialog* udialog = + dynamic_cast< QgsUniqueValueDialog * >(widgetStackRenderers->currentWidget()); if (sdialog) - { - sdialog->apply(); - } + { + sdialog->apply(); + } else if (gdialog) { - gdialog->apply(); + gdialog->apply(); } else if (cdialog) - { - cdialog->apply(); - } + { + cdialog->apply(); + } else if(udialog) { - udialog->apply(); + udialog->apply(); } layer->setTransparency(static_cast < unsigned int >(255 - sliderTransparency->value())); - + // update symbology emit refreshLegend(layer->getLayerID(), false); - + layer->triggerRepaint(); } @@ -333,7 +345,7 @@ // and postgres connection from the provider QgsDataSourceURI uri(myPGProvider->dataSourceUri()); QgsPgQueryBuilder *pqb = new QgsPgQueryBuilder(&uri, this); - + // Set the sql in the query builder to the same in the prop dialog // (in case the user has already changed it) pqb->setSql(txtSubsetSQL->text()); @@ -355,55 +367,56 @@ void QgsVectorLayerProperties::on_pbnIndex_clicked() { - QgsVectorDataProvider* pr=layer->getDataProvider(); - if(pr) + QgsVectorDataProvider* pr=layer->getDataProvider(); + if(pr) + { + setCursor(Qt::WaitCursor); + bool errval=pr->createSpatialIndex(); + setCursor(Qt::ArrowCursor); + if(errval) { - setCursor(Qt::WaitCursor); - bool errval=pr->createSpatialIndex(); - setCursor(Qt::ArrowCursor); - if(errval) - { - QMessageBox::information(this, tr("Spatial Index"), tr("Creation of spatial index successfull")); - } - else - { - // TODO: Remind the user to use OGR >= 1.2.6 and Shapefile - QMessageBox::information(this, tr("Spatial Index"), tr("Creation of spatial index failed")); - } + QMessageBox::information(this, tr("Spatial Index"), + tr("Creation of spatial index successfull")); } + else + { + // TODO: Remind the user to use OGR >= 1.2.6 and Shapefile + QMessageBox::information(this, tr("Spatial Index"), tr("Creation of spatial index failed")); + } + } } QString QgsVectorLayerProperties::getMetadata() { - QString myMetadataQString = ""; - myMetadataQString += ""; - + QString myMetedata = ""; + myMetedata += "
"; + //------------- - - myMetadataQString += ""; + myMetedata += ""; + // data comment if (!(layer->dataComment().isEmpty())) { - myMetadataQString += ""; + myMetedata += ""; } //storage type - myMetadataQString += ""; + myMetedata += ""; // data source - myMetadataQString += ""; + myMetedata += ""; //geom type @@ -411,48 +424,48 @@ if ( vectorType < 0 || vectorType > QGis::Polygon ) { - QgsDebugMsg( "Invalid vector type" ); + QgsDebugMsg( "Invalid vector type" ); } else { - QString vectorTypeString( QGis::qgisVectorGeometryType[layer->vectorType()] ); + QString vectorTypeString( QGis::qgisVectorGeometryType[layer->vectorType()] ); - myMetadataQString += ""; + myMetedata += ""; } - //feature count - myMetadataQString += ""; + //feature count + myMetedata += ""; //capabilities - myMetadataQString += ""; + myMetedata += ""; //------------- QgsRect myExtent = layer->extent(); - myMetadataQString += ""; + myMetedata += ""; //extents in layer cs TODO...maybe make a little nested table to improve layout... - myMetadataQString += ""; + myMetedata += ""; //extents in project cs @@ -461,40 +474,40 @@ /* // TODO: currently disabled, will revisit later [MD] QgsRect myProjectedExtent = coordinateTransform->transformBoundingBox(layer->extent()); - myMetadataQString += ""; + myMetedata += ""; */ // // Display layer spatial ref system // - myMetadataQString += ""; - myMetadataQString += ""; + myMetedata += ""; + myMetedata += ""; // // Display project (output) spatial ref system // /* // TODO: disabled for now, will revisit later [MD] - myMetadataQString += ""; - myMetadataQString += ""; + myMetedata += ""; + myMetedata += ""; */ } @@ -503,74 +516,74 @@ UNUSED(cse); QgsDebugMsg( cse.what() ); - myMetadataQString += ""; + myMetedata += ""; } - + // // Add the info about each field in the attribute table // - myMetadataQString += ""; - myMetadataQString += ""; + myMetedata += ""; //end of stats container table row + myMetedata += "
"; - myMetadataQString += tr("General:"); - myMetadataQString += "
"; + myMetedata += tr("General:"); + myMetedata += "
"; - myMetadataQString += tr("Layer comment: ") + - layer->dataComment(); - myMetadataQString += "
"; + myMetedata += tr("Layer comment: ") + + layer->dataComment(); + myMetedata += "
"; - myMetadataQString += tr("Storage type of this layer : ") + - layer->storageType(); - myMetadataQString += "
"; + myMetedata += tr("Storage type of this layer : ") + + layer->storageType(); + myMetedata += "
"; - myMetadataQString += tr("Source for this layer : ") + - layer->publicSource(); - myMetadataQString += "
"; + myMetedata += tr("Source for this layer : ") + + layer->publicSource(); + myMetedata += "
"; - myMetadataQString += tr("Geometry type of the features in this layer : ") + - vectorTypeString; - myMetadataQString += "
"; + myMetedata += tr("Geometry type of the features in this layer : ") + + vectorTypeString; + myMetedata += "
"; - myMetadataQString += tr("The number of features in this layer : ") + - QString::number(layer->featureCount()); - myMetadataQString += "
"; + myMetedata += tr("The number of features in this layer : ") + + QString::number(layer->featureCount()); + myMetedata += "
"; - myMetadataQString += tr("Editing capabilities of this layer : ") + - layer->capabilitiesString(); - myMetadataQString += "
"; + myMetedata += tr("Editing capabilities of this layer : ") + + layer->capabilitiesString(); + myMetedata += "
"; - myMetadataQString += tr("Extents:"); - myMetadataQString += "
"; + myMetedata += tr("Extents:"); + myMetedata += "
"; - myMetadataQString += tr("In layer spatial reference system units : ") + - tr("xMin,yMin ") + - QString::number(myExtent.xMin()) + - "," + - QString::number( myExtent.yMin()) + - tr(" : xMax,yMax ") + - QString::number(myExtent.xMax()) + - "," + - QString::number(myExtent.yMax()); - myMetadataQString += "
"; + myMetedata += tr("In layer spatial reference system units : ") + + tr("xMin,yMin ") + + QString::number(myExtent.xMin()) + + "," + + QString::number( myExtent.yMin()) + + tr(" : xMax,yMax ") + + QString::number(myExtent.xMax()) + + "," + + QString::number(myExtent.yMax()); + myMetedata += "
"; - myMetadataQString += tr("In project spatial reference system units : ") + - tr("xMin,yMin ") + - QString::number(myProjectedExtent.xMin()) + - "," + - QString::number( myProjectedExtent.yMin()) + - tr(" : xMax,yMax ") + - QString::number(myProjectedExtent.xMax()) + - "," + - QString::number(myProjectedExtent.yMax()); - myMetadataQString += "
"; + myMetedata += tr("In project spatial reference system units : ") + + tr("xMin,yMin ") + + QString::number(myProjectedExtent.xMin()) + + "," + + QString::number( myProjectedExtent.yMin()) + + tr(" : xMax,yMax ") + + QString::number(myProjectedExtent.xMax()) + + "," + + QString::number(myProjectedExtent.yMax()); + myMetedata += "
"; - myMetadataQString += tr("Layer Spatial Reference System:"); - myMetadataQString += "
"; - myMetadataQString += layer->srs().proj4String().replace(QRegExp("\"")," \""); - myMetadataQString += "
"; + myMetedata += tr("Layer Spatial Reference System:"); + myMetedata += "
"; + myMetedata += layer->srs().proj4String().replace(QRegExp("\"")," \""); + myMetedata += "
"; - myMetadataQString += tr("Project (Output) Spatial Reference System:"); - myMetadataQString += "
"; - myMetadataQString += coordinateTransform->destSRS().proj4String().replace(QRegExp("\"")," \""); - myMetadataQString += "
"; + myMetedata += tr("Project (Output) Spatial Reference System:"); + myMetedata += "
"; + myMetedata += coordinateTransform->destSRS().proj4String().replace(QRegExp("\"")," \""); + myMetedata += "
"; - myMetadataQString += tr("In project spatial reference system units : "); - myMetadataQString += " (Invalid transformation of layer extents) "; - myMetadataQString += "
"; + myMetedata += tr("In project spatial reference system units : "); + myMetedata += " (Invalid transformation of layer extents) "; + myMetedata += "
"; - myMetadataQString += tr("Attribute field info:"); - myMetadataQString += "
"; + myMetedata += "
"; + myMetedata += tr("Attribute field info:"); + myMetedata += "
"; // Start a nested table in this trow - myMetadataQString += ""; - myMetadataQString += ""; - myMetadataQString += ""; - myMetadataQString += ""; - myMetadataQString += ""; - myMetadataQString += ""; - + myMetedata += "
"; - myMetadataQString += "" + tr("Field") + ""; - myMetadataQString += ""; - myMetadataQString += "" + tr("Type") + ""; - myMetadataQString += ""; - myMetadataQString += "" + tr("Length") + ""; - myMetadataQString += ""; - myMetadataQString += "" + tr("Precision") + ""; - myMetadataQString += ""; - myMetadataQString += "" + tr("Comment") + ""; - myMetadataQString += "
"; + myMetedata += ""; + myMetedata += ""; + myMetedata += ""; + myMetedata += ""; + myMetedata += ""; + //get info for each field by looping through them QgsVectorDataProvider *myDataProvider = dynamic_cast(layer->getDataProvider()); const QgsFieldMap& myFields = myDataProvider->fields(); for (QgsFieldMap::const_iterator it = myFields.begin(); it != myFields.end(); ++it) { const QgsField& myField = *it; - - myMetadataQString += ""; - myMetadataQString += ""; - myMetadataQString += ""; - myMetadataQString += ""; - myMetadataQString += ""; + + myMetedata += ""; + myMetedata += ""; + myMetedata += ""; + myMetedata += ""; + myMetedata += ""; } //close field list - myMetadataQString += "
"; + myMetedata += "" + tr("Field") + ""; + myMetedata += ""; + myMetedata += "" + tr("Type") + ""; + myMetedata += ""; + myMetedata += "" + tr("Length") + ""; + myMetedata += ""; + myMetedata += "" + tr("Precision") + ""; + myMetedata += ""; + myMetedata += "" + tr("Comment") + ""; + myMetedata += "
"; - myMetadataQString += myField.name(); - myMetadataQString += ""; - myMetadataQString += myField.typeName(); - myMetadataQString += ""; - myMetadataQString += QString("%1").arg(myField.length()); - myMetadataQString += ""; - myMetadataQString += QString("%1").arg(myField.precision()); - myMetadataQString += ""; - myMetadataQString += QString("%1").arg(myField.comment()); - myMetadataQString += "
"; + myMetedata += myField.name(); + myMetedata += ""; + myMetedata += myField.typeName(); + myMetedata += ""; + myMetedata += QString("%1").arg(myField.length()); + myMetedata += ""; + myMetedata += QString("%1").arg(myField.precision()); + myMetedata += ""; + myMetedata += QString("%1").arg(myField.comment()); + myMetedata += "
"; //end of nested table - myMetadataQString += "
"; //end of nested table + myMetedata += ""; //end of stats container table row // // Close the table // - myMetadataQString += ""; - myMetadataQString += ""; - return myMetadataQString; + myMetedata += ""; + myMetedata += ""; + return myMetedata; } @@ -578,19 +591,170 @@ void QgsVectorLayerProperties::on_pbnChangeSpatialRefSys_clicked() { - QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(this); - mySelector->setSelectedSRSID(layer->srs().srsid()); - if(mySelector->exec()) + QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(this); + mySelector->setSelectedSRSID(layer->srs().srsid()); + if(mySelector->exec()) + { + QgsSpatialRefSys srs(mySelector->getCurrentSRSID(), QgsSpatialRefSys::QGIS_SRSID); + layer->setSrs(srs); + } + else + { + QApplication::restoreOverrideCursor(); + } + delete mySelector; + + leSpatialRefSys->setText(layer->srs().proj4String()); + leSpatialRefSys->setCursorPosition(0); +} + +void QgsVectorLayerProperties::on_pbnLoadDefaultStyle_clicked() +{ + bool defaultLoadedFlag = false; + QString myMessage = layer->loadDefaultStyle( defaultLoadedFlag ); + //reset if the default style was loaded ok only + if ( defaultLoadedFlag ) + { + reset (); + } + QMessageBox::information( this, + tr("Default Style"), + myMessage + ); +} + +void QgsVectorLayerProperties::on_pbnSaveDefaultStyle_clicked() +{ + // a flag passed by reference + bool defaultSavedFlag = false; + // after calling this the above flag will be set true for success + // or false if the save operation failed + QString myMessage = layer->saveDefaultStyle( defaultSavedFlag ); + QMessageBox::information( this, + tr("Default Style"), + myMessage + ); +} + + +void QgsVectorLayerProperties::on_pbnLoadStyle_clicked() +{ + QSettings myQSettings; // where we keep last used filter in persistant state + QString myLastUsedDir = myQSettings.value ( "style/lastStyleDir", "." ).toString(); + + //create a file dialog + std::auto_ptr < QFileDialog > myFileDialog + ( + new QFileDialog ( + this, + QFileDialog::tr ( "Load layer properties from style file (.qml)" ), + myLastUsedDir, + tr ( "QGIS Layer Style File (*.qml)" ) + ) + ); + myFileDialog->setFileMode ( QFileDialog::AnyFile ); + myFileDialog->setAcceptMode ( QFileDialog::AcceptOpen ); + + //prompt the user for a filename + QString myFileName; + if ( myFileDialog->exec() == QDialog::Accepted ) + { + QStringList myFiles = myFileDialog->selectedFiles(); + if ( !myFiles.isEmpty() ) { - QgsSpatialRefSys srs(mySelector->getCurrentSRSID(), QgsSpatialRefSys::QGIS_SRSID); - layer->setSrs(srs); + myFileName = myFiles[0]; } + } + + if ( !myFileName.isEmpty() ) + { + if ( myFileDialog->selectedFilter() == tr ( "QGIS Layer Style File (*.qml)" ) ) + { + //ensure the user never ommitted the extension from the filename + if ( !myFileName.toUpper().endsWith ( ".QML" ) ) + { + myFileName += ".qml"; + } + bool defaultLoadedFlag = false; + QString myMessage = layer->loadNamedStyle( myFileName, defaultLoadedFlag ); + //reset if the default style was loaded ok only + if ( defaultLoadedFlag ) + { + reset (); + } + QMessageBox::information( this, + tr("Default Style"), + myMessage + ); + } else { - QApplication::restoreOverrideCursor(); + QMessageBox::warning ( this, tr ( "QGIS" ), tr ( "Unknown style format: " ) + + myFileDialog->selectedFilter() ); + } - delete mySelector; + myQSettings.setValue ( "style/lastStyleDir", myFileDialog->directory().absolutePath() ); + } +} - leSpatialRefSys->setText(layer->srs().proj4String()); - leSpatialRefSys->setCursorPosition(0); + +void QgsVectorLayerProperties::on_pbnSaveStyleAs_clicked() +{ + + QSettings myQSettings; // where we keep last used filter in persistant state + QString myLastUsedDir = myQSettings.value ( "style/lastStyleDir", "." ).toString(); + + //create a file dialog + std::auto_ptr < QFileDialog > myFileDialog + ( + new QFileDialog ( + this, + QFileDialog::tr ( "Save layer properties as style file (.qml)" ), + myLastUsedDir, + tr ( "QGIS Layer Style File (*.qml)" ) + ) + ); + myFileDialog->setFileMode ( QFileDialog::AnyFile ); + myFileDialog->setAcceptMode ( QFileDialog::AcceptSave ); + + //prompt the user for a filename + QString myOutputFileName; + if ( myFileDialog->exec() == QDialog::Accepted ) + { + QStringList myFiles = myFileDialog->selectedFiles(); + if ( !myFiles.isEmpty() ) + { + myOutputFileName = myFiles[0]; + } + } + + if ( !myOutputFileName.isEmpty() ) + { + if ( myFileDialog->selectedFilter() == tr ( "QGIS Layer Style File (*.qml)" ) ) + { + //ensure the user never ommitted the extension from the filename + if ( !myOutputFileName.toUpper().endsWith ( ".QML" ) ) + { + myOutputFileName += ".qml"; + } + bool defaultLoadedFlag = false; + QString myMessage = layer->saveNamedStyle( myOutputFileName, defaultLoadedFlag ); + //reset if the default style was loaded ok only + if ( defaultLoadedFlag ) + { + reset (); + } + QMessageBox::information( this, + tr("Default Style"), + myMessage + ); + } + else + { + QMessageBox::warning ( this, tr ( "QGIS" ), tr ( "Unknown style format: " ) + + myFileDialog->selectedFilter() ); + + } + myQSettings.setValue ( "style/lastStyleDir", myFileDialog->directory().absolutePath() ); + } } Index: src/app/qgssinglesymboldialog.cpp =================================================================== --- src/app/qgssinglesymboldialog.cpp (revision 7689) +++ src/app/qgssinglesymboldialog.cpp (working copy) @@ -27,6 +27,7 @@ #include #include #include +#include QgsSingleSymbolDialog::QgsSingleSymbolDialog(): QDialog(), mVectorLayer(0) @@ -39,139 +40,132 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer * layer): QDialog(), mVectorLayer(layer) { - setupUi(this); + setupUi(this); #ifdef QGISDEBUG - qWarning("constructor QgsSingleSymbolDialog called WITH a layer"); + qWarning("constructor QgsSingleSymbolDialog called WITH a layer"); #endif - // - //set point symbol combo box - // + // + //set point symbol list + // - // If this layer doesn't have points, break out of the following - // two loops after the first iteration. This gives one point - // symbol in the dialog, etc so that other code can rely on such a - // fact, but avoids the long time required to load all of the - // available symbols when they are not needed. + // If this layer doesn't have points, break out of the following + // two loops after the first iteration. This gives one point + // symbol in the dialog, etc so that other code can rely on such a + // fact, but avoids the long time required to load all of the + // available symbols when they are not needed. - QStringList ml = QgsMarkerCatalogue::instance()->list(); - mMarkers.clear(); + // NOTE BY Tim: I think the note above and the break out in the + // loops can be removed now with changes I have made to use combo + // boxes for line style and fill style...test and remove if poss. - int size = 18; - QPen pen (QColor(0,0,255)); - QBrush brush ( QColor(220,220,220), Qt::SolidPattern ); - - for ( QStringList::iterator it = ml.begin(); it != ml.end(); ++it ) + QPen pen (QColor(0,0,255)); + QBrush brush ( QColor(220,220,220), Qt::SolidPattern ); + int size = 18; + int myCounter = 0; + QStringList ml = QgsMarkerCatalogue::instance()->list(); + for ( QStringList::iterator it = ml.begin(); it != ml.end(); ++it ) + { + QPixmap myPixmap = QPixmap::fromImage(QgsMarkerCatalogue::instance()->imageMarker ( *it, size, pen, brush )); + QListWidgetItem * mypItem = new QListWidgetItem(lstSymbols); + QIcon myIcon; + myIcon.addPixmap ( myPixmap ); + mypItem->setIcon ( myIcon ); + mypItem->setText ( "" ); + //store the symbol offset in the UserData role for later retrieval + mypItem->setData ( Qt::UserRole, *it); + if (layer->vectorType() != QGis::Point) { - mMarkers.push_back ( *it ); - QPixmap pic = QPixmap::fromImage(QgsMarkerCatalogue::instance()->imageMarker ( *it, size, pen, brush )); - mPointSymbolComboBox->insertItem ( pic ); - if (layer->vectorType() != QGis::Point) - { - break; - } + break; } + ++myCounter; + } - // - //set outline / line style - // - pbnLineSolid->setPixmap(QgsSymbologyUtils::char2LinePixmap("SolidLine")); - pbnLineDash->setPixmap(QgsSymbologyUtils::char2LinePixmap("DashLine")); - pbnLineDot->setPixmap(QgsSymbologyUtils::char2LinePixmap("DotLine")); - pbnLineDashDot->setPixmap(QgsSymbologyUtils::char2LinePixmap("DashDotLine")); - pbnLineDashDotDot->setPixmap(QgsSymbologyUtils::char2LinePixmap("DashDotDotLine")); - pbnLineNoPen->setPixmap(QgsSymbologyUtils::char2LinePixmap("NoPen")); + // + //set outline / line style + // + cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("SolidLine")),tr("Solid Line"),"SolidLine"); + cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("DashLine")),tr("Dash Line"),"DashLine"); + cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("DotLine")),tr("Dot Line"),"DotLine"); + cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("DashDotLine")),tr("Dash Dot Line"),"DashDotLine"); + cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("DashDotDotLine")),tr("Dash Dot Dot Line"),"DashDotDotLine"); + cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("NoPen")),tr("No Pen"),"NoPen"); - // - //set pattern button group icons and state - // - solid->setPixmap(QgsSymbologyUtils::char2PatternPixmap("SolidPattern")); - horizontal->setPixmap(QgsSymbologyUtils::char2PatternPixmap("HorPattern")); - vertical->setPixmap(QgsSymbologyUtils::char2PatternPixmap("VerPattern")); - cross->setPixmap(QgsSymbologyUtils::char2PatternPixmap("CrossPattern")); - bdiag->setPixmap(QgsSymbologyUtils::char2PatternPixmap("BDiagPattern")); - fdiag->setPixmap(QgsSymbologyUtils::char2PatternPixmap("FDiagPattern")); - diagcross->setPixmap(QgsSymbologyUtils::char2PatternPixmap("DiagCrossPattern")); - dense1->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense1Pattern")); - dense2->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense2Pattern")); - dense3->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense3Pattern")); - dense4->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense4Pattern")); - dense5->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense5Pattern")); - dense6->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense6Pattern")); - dense7->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense7Pattern")); - nopen->setPixmap(QgsSymbologyUtils::char2PatternPixmap("NoBrush")); - texture->setPixmap(QgsSymbologyUtils::char2PatternPixmap("TexturePattern")); + // + //set pattern icons and state + // + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("SolidPattern")),tr("Solid Pattern"),"SolidPattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("HorPattern")),tr("Hor Pattern"),"HorPattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("VerPattern")),tr("Ver Pattern"),"VerPattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("CrossPattern")),tr("Cross Pattern"),"CrossPattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("BDiagPattern")),tr("BDiag Pattern"),"BDiagPattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("FDiagPattern")),tr("FDiag Pattern"),"FDiagPattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("DiagCrossPattern")),tr("Diag Cross Pattern"),"DiagCrossPattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense1Pattern")),tr("Dense1 Pattern"),"Dense1Pattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense2Pattern")),tr("Dense2 Pattern"),"Dense2Pattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense3Pattern")),tr("Dense3 Pattern"),"Dense3Pattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense4Pattern")),tr("Dense4 Pattern"),"Dense4Pattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense5Pattern")),tr("Dense5 Pattern"),"Dense5Pattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense6Pattern")),tr("Dense6 Pattern"),"Dense6Pattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense7Pattern")),tr("Dense7 Pattern"),"Dense7Pattern"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("NoBrush")),tr("No Brush"),"NoBrush"); + cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("TexturePattern")),tr("Texture Pattern"),"TexturePattern"); + if (mVectorLayer) + { + const QgsSingleSymbolRenderer *renderer=dynamic_cast(mVectorLayer->renderer()); - if (mVectorLayer) + if (renderer) { - const QgsSingleSymbolRenderer *renderer=dynamic_cast(mVectorLayer->renderer()); - - if (renderer) - { - // Set from the existing renderer - set ( renderer->symbol() ); - } - else - { - // Take values from an example instance - QgsSingleSymbolRenderer exampleRenderer = QgsSingleSymbolRenderer( mVectorLayer->vectorType() ); - set ( exampleRenderer.symbol() ); - } - - if (mVectorLayer && mVectorLayer->vectorType() == QGis::Line) - { - btnFillColor->setEnabled(false); - grpPattern->setEnabled(false); - mGroupPoint->setEnabled(false); - } - - if (mVectorLayer && mVectorLayer->vectorType() == QGis::Polygon) { - mGroupPoint->setEnabled(false); - - } - + // Set from the existing renderer + set ( renderer->symbol() ); } else { - qWarning("Warning, layer is a null pointer in QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer)"); + // Take values from an example instance + QgsSingleSymbolRenderer exampleRenderer = QgsSingleSymbolRenderer( mVectorLayer->vectorType() ); + set ( exampleRenderer.symbol() ); } - //do the signal/slot connections - QObject::connect(btnOutlineColor, SIGNAL(clicked()), this, SLOT(selectOutlineColor())); - //QObject::connect(stylebutton, SIGNAL(clicked()), this, SLOT(selectOutlineStyle())); - QObject::connect(btnFillColor, SIGNAL(clicked()), this, SLOT(selectFillColor())); - QObject::connect(outlinewidthspinbox, SIGNAL(valueChanged(int)), this, SLOT(resendSettingsChanged())); - QObject::connect(mLabelEdit, SIGNAL(textChanged(const QString&)), this, SLOT(resendSettingsChanged())); - QObject::connect(mPointSymbolComboBox, SIGNAL(activated(int)), this, SLOT(resendSettingsChanged())); - QObject::connect(mPointSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(resendSettingsChanged())); + if (mVectorLayer && mVectorLayer->vectorType() == QGis::Line) + { + btnFillColor->setEnabled(false); + cboFillStyle->setEnabled(false); + mGroupPoint->setEnabled(false); + mGroupPoint->setVisible(false); + } - //connect fill style and line style buttons - QObject::connect(pbnLineSolid, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(pbnLineDot, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(pbnLineDashDot, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(pbnLineDash, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(pbnLineDashDotDot, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(pbnLineNoPen, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(solid, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(fdiag, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(dense4, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(horizontal, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(bdiag, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(diagcross, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(dense5, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(vertical, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(dense1, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(dense3, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(dense6, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(cross, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(dense2, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(dense7, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(nopen, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(texture, SIGNAL(clicked()), this, SLOT(resendSettingsChanged())); - QObject::connect(textureSelect, SIGNAL(clicked()), this, SLOT(selectTextureImage())); + if (mVectorLayer && mVectorLayer->vectorType() == QGis::Polygon) + { + mGroupPoint->setEnabled(false); + mGroupPoint->setVisible(false); + } + + } + else + { + qWarning("Warning, layer is a null pointer in " + "QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer)"); + } + + //do the signal/slot connections + connect(btnOutlineColor, SIGNAL(clicked()), this, SLOT(selectOutlineColor())); + connect(btnFillColor, SIGNAL(clicked()), this, SLOT(selectFillColor())); + connect(outlinewidthspinbox, SIGNAL(valueChanged(int)), this, SLOT(resendSettingsChanged())); + connect(mLabelEdit, SIGNAL(textChanged(const QString&)), this, SLOT(resendSettingsChanged())); + connect (lstSymbols,SIGNAL(currentItemChanged ( QListWidgetItem * , QListWidgetItem * )), + this, SLOT (symbolChanged (QListWidgetItem * , QListWidgetItem * ))); + connect(mPointSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(resendSettingsChanged())); + connect(cboOutlineStyle, SIGNAL( + currentIndexChanged ( const QString & )), this, SLOT(resendSettingsChanged())); + connect(cboFillStyle, SIGNAL( + currentIndexChanged ( const QString & )), this, SLOT(resendSettingsChanged())); + //need this to deal with when texture fill is selected or deselected + connect(cboFillStyle, SIGNAL( + currentIndexChanged ( int )), this, SLOT(fillStyleChanged(int))); + connect(toolSelectTexture, SIGNAL(clicked()), this, SLOT(selectTextureImage())); } QgsSingleSymbolDialog::~QgsSingleSymbolDialog() @@ -190,7 +184,7 @@ emit settingsChanged(); } - setActiveWindow(); + activateWindow(); } void QgsSingleSymbolDialog::selectFillColor() @@ -202,20 +196,19 @@ emit settingsChanged(); } - setActiveWindow(); + activateWindow(); } //should this method have a different name? void QgsSingleSymbolDialog::selectTextureImage() { QString fileName = QFileDialog::getOpenFileName(this, "Open File", - textureFilePath->text(), - "Images (*.png *.xpm *.jpg)"); //should we allow other types of images? + mTexturePath, + "Images (*.png *.xpm *.jpg)"); //should we allow other types of images? - if(fileName.isNull() == false){ //only process the string if the user clicked OK - textureFilePath->setText(fileName); - texture->setOn(true); //set the fill style to custom texture - texture->setPixmap(QPixmap(fileName)); //Change the button to show the selected image + if(fileName.isNull() == false) + { //only process the string if the user clicked OK + mTexturePath = fileName; resendSettingsChanged(); } } @@ -230,100 +223,32 @@ // // Apply point symbol // - sy->setNamedPointSymbol( mMarkers[mPointSymbolComboBox->currentItem()] ) ; + if ( lstSymbols->currentItem() ) + { + sy->setNamedPointSymbol( lstSymbols->currentItem()->data(Qt::UserRole).toString() ) ; + } sy->setPointSize ( mPointSizeSpinBox->value() ); // // Apply the line style // - if (pbnLineNoPen->isOn()) - (sy->setLineStyle(Qt::NoPen)); - else if (pbnLineDash->isOn()) - (sy->setLineStyle(Qt::DashLine)); - else if (pbnLineDot->isOn()) - (sy->setLineStyle(Qt::DotLine)) ; - else if (pbnLineDashDot->isOn()) - (sy->setLineStyle(Qt::DashDotLine)); - else if (pbnLineDashDotDot->isOn()) - (sy->setLineStyle(Qt::DashDotDotLine)) ; - else - (sy->setLineStyle(Qt::SolidLine)); //default to solid + QString myLineStyle = + cboOutlineStyle->itemData(cboOutlineStyle->currentIndex(),Qt::UserRole).toString(); + sy->setLineStyle(QgsSymbologyUtils::qString2PenStyle(myLineStyle)); - // // Apply the pattern // //Store the file path, and set the brush to TexturePattern. If we have a different button selected, // the below code will override it, but leave the file path alone. - sy->setCustomTexture(textureFilePath->text()); + + sy->setCustomTexture(mTexturePath); - if (solid->isOn()) - { - sy->setFillStyle(Qt::SolidPattern); - } - else if (fdiag->isOn()) - { - sy->setFillStyle(Qt::FDiagPattern); - } - else if (dense4->isOn()) - { - sy->setFillStyle(Qt::Dense4Pattern); - } - else if (horizontal->isOn()) - { - sy->setFillStyle(Qt::HorPattern); - } - else if (dense5->isOn()) - { - sy->setFillStyle(Qt::Dense5Pattern); - } - else if (diagcross->isOn()) - { - sy->setFillStyle(Qt::DiagCrossPattern); - } - else if (dense1->isOn()) - { - sy->setFillStyle(Qt::Dense1Pattern); - } - else if (dense6->isOn()) - { - sy->setFillStyle(Qt::Dense6Pattern); - } - else if (vertical->isOn()) - { - sy->setFillStyle(Qt::VerPattern); - } - else if (dense7->isOn()) - { - sy->setFillStyle(Qt::Dense7Pattern); - } - else if (cross->isOn()) - { - sy->setFillStyle(Qt::CrossPattern); - } - else if (dense2->isOn()) - { - sy->setFillStyle(Qt::Dense2Pattern); - } - else if (bdiag->isOn()) - { - sy->setFillStyle(Qt::BDiagPattern); - } - else if (dense3->isOn()) - { - sy->setFillStyle(Qt::Dense3Pattern); - } - else if (nopen->isOn()) - { - sy->setFillStyle(Qt::NoBrush); - } - else if (texture->isOn()) - { - //we already set the brush to TexturePattern up above, so don't do anything here - } + QString myFillStyle = + cboFillStyle->itemData(cboFillStyle->currentIndex(),Qt::UserRole).toString(); + sy->setFillStyle(QgsSymbologyUtils::qString2BrushStyle(myFillStyle)); - //apply the label sy->setLabel(mLabelEdit->text()); } @@ -343,118 +268,74 @@ mLabelEdit->setText(sy->label()); - // Set point symbol - for ( uint i = 0; i < mMarkers.size(); i++ ) { - if ( mMarkers[i] == sy->pointSymbolName() ) { - mPointSymbolComboBox->setCurrentItem ( i ); - break; - } - } - mPointSizeSpinBox->setValue ( sy->pointSize() ); - - outlinewidthspinbox->setValue(sy->pen().width()); + // Set point symbol + QString mySymbolName = sy->pointSymbolName(); + for ( int i = 0; i < lstSymbols->count(); ++i ) + { + if (lstSymbols->item(i)->data( Qt::UserRole ).toString() == (mySymbolName)) + { + lstSymbols->setCurrentItem ( lstSymbols->item(i) ); + lstSymbols->item(i)->setBackground( QBrush ( Qt::cyan ) ); + break; + } + } + mPointSizeSpinBox->setValue ( sy->pointSize() ); - //set line width 1 as minimum to avoid confusion between line width 0 and no pen line style - // ... but, drawLine is not correct with width > 0 -> until solved set to 0 - outlinewidthspinbox->setMinValue(0); + outlinewidthspinbox->setValue(sy->pen().width()); - btnFillColor->setColor( sy->brush().color() ); + //set line width 1 as minimum to avoid confusion between line width 0 and no pen line style + // ... but, drawLine is not correct with width > 0 -> until solved set to 0 + outlinewidthspinbox->setMinValue(0); - btnOutlineColor->setColor( sy->pen().color() ); + btnFillColor->setColor( sy->brush().color() ); - //stylebutton->setName(QgsSymbologyUtils::penStyle2Char(sy->pen().style())); - //stylebutton->setPixmap(QgsSymbologyUtils::char2LinePixmap(stylebutton->name())); - //load the icons stored in QgsSymbologyUtils.cpp (to avoid redundancy) + btnOutlineColor->setColor( sy->pen().color() ); - QPen myPen = sy->pen(); + //load the icons stored in QgsSymbologyUtils.cpp (to avoid redundancy) - switch ( myPen.style() ) - { - case Qt::NoPen : - pbnLineNoPen->setOn(true); - break; - case Qt::DashLine : - pbnLineDash->setOn(true); - break; - case Qt::DotLine : - pbnLineDot->setOn(true); - break; - case Qt::DashDotLine : - pbnLineDashDot->setOn(true); - break; - case Qt::DashDotDotLine : - pbnLineDashDotDot->setOn(true); - break; - default : - pbnLineSolid->setOn(true); // default to solid - break; - } - - QBrush myBrush = sy->brush(); - - switch ( myBrush.style() ) - { - case Qt::SolidPattern : - solid->setOn(true); - break; - case Qt::HorPattern : - horizontal->setOn(true); - break; - case Qt::VerPattern : - vertical->setOn(true); - break; - case Qt::CrossPattern : - cross->setOn(true); - break; - case Qt::BDiagPattern : - bdiag->setOn(true); - break; - case Qt::FDiagPattern : - fdiag->setOn(true); - break; - case Qt::DiagCrossPattern : - diagcross->setOn(true); - break; - case Qt::Dense1Pattern : - dense1->setOn(true); - break; - case Qt::Dense2Pattern : - dense2->setOn(true); - break; - case Qt::Dense3Pattern : - dense3->setOn(true); - break; - case Qt::Dense4Pattern : - dense4->setOn(true); - break; - case Qt::Dense5Pattern : - dense5->setOn(true); - break; - case Qt::Dense6Pattern : - dense6->setOn(true); - break; - case Qt::Dense7Pattern : - dense7->setOn(true); - break; - case Qt::NoBrush : - nopen->setOn(true); - break; - case Qt::TexturePattern : - texture->setOn(true); - break; - default : - solid->setOn(true); - break; - } - textureFilePath->setText(sy->customTexture()); //get and show the file path, even if we aren't using it. - if(sy->customTexture().size() > 0)//if the file path isn't empty, show the image on the button + // + // Set the line style combo + // + + QPen myPen = sy->pen(); + QString myLineStyle = QgsSymbologyUtils::penStyle2QString(myPen.style()); + for ( int i = 0; i < cboOutlineStyle->count(); ++i ) + { + if (cboOutlineStyle->itemData(i, Qt::UserRole ).toString() == myLineStyle) { - texture->setPixmap(QPixmap(sy->customTexture())); //show the current texture image + cboOutlineStyle->setCurrentIndex( i ); + break; } - else + } + + // + // Set the brush combo + // + + QBrush myBrush = sy->brush(); + QString myFillStyle = QgsSymbologyUtils::brushStyle2QString(myBrush.style()); + for ( int i = 0; i < cboFillStyle->count(); ++i ) + { + if (cboFillStyle->itemData(i, Qt::UserRole ).toString() == myFillStyle) { - texture->setPixmap(QgsSymbologyUtils::char2PatternPixmap("TexturePattern")); //show the default question mark + cboFillStyle->setCurrentIndex( i ); + break; } + } + + //get and show the file path, even if we aren't using it. + mTexturePath = sy->customTexture(); + //if the file path isn't empty, show the image on the button + if(sy->customTexture().size() > 0) + { + //show the current texture image + // texture->setPixmap(QPixmap(sy->customTexture())); + } + else + { + //show the default question mark + //texture->setPixmap(QgsSymbologyUtils::char2PatternPixmap("TexturePattern")); + } } void QgsSingleSymbolDialog::setOutlineColor(QColor& c) @@ -464,19 +345,15 @@ void QgsSingleSymbolDialog::setOutlineStyle(Qt::PenStyle pstyle) { - // XXX use switch() instead - if (pstyle==Qt::NoPen) - (pbnLineNoPen->setOn(true)); - else if (pstyle==Qt::DashLine) - (pbnLineDash->setOn(true)); - else if (pstyle==Qt::DotLine) - (pbnLineDot->setOn(true)); - else if (pstyle==Qt::DashDotLine) - (pbnLineDashDot->setOn(true)); - else if (pstyle==Qt::DashDotDotLine) - (pbnLineDashDotDot->setOn(true)); - else - (pbnLineSolid->setOn(true)); //default to solid + QString myLineStyle = QgsSymbologyUtils::penStyle2QString(pstyle); + for ( int i = 0; i < cboOutlineStyle->count(); ++i ) + { + if (cboOutlineStyle->itemData(i, Qt::UserRole ).toString() == myLineStyle) + { + cboOutlineStyle->setCurrentIndex( i ); + break; + } + } } void QgsSingleSymbolDialog::setFillColor(QColor& c) @@ -487,42 +364,17 @@ void QgsSingleSymbolDialog::setFillStyle(Qt::BrushStyle fstyle) { #ifdef QGISDEBUG - qWarning(("Setting fill style: "+QgsSymbologyUtils::brushStyle2QString(fstyle)).toLocal8Bit().data()); + qWarning(("Setting fill style: "+QgsSymbologyUtils::brushStyle2QString(fstyle)).toLocal8Bit().data()); #endif - - // XXX use switch instead - if (fstyle==Qt::SolidPattern) - (solid->setOn(true)); - else if (fstyle==Qt::HorPattern) - (horizontal->setOn(true)); - else if (fstyle==Qt::VerPattern) - (vertical->setOn(true)); - else if (fstyle==Qt::CrossPattern) - (cross->setOn(true)); - else if (fstyle==Qt::BDiagPattern) - (bdiag->setOn(true)); - else if (fstyle==Qt::FDiagPattern) - (fdiag->setOn(true)); - else if (fstyle==Qt::DiagCrossPattern) - (diagcross->setOn(true)); - else if (fstyle==Qt::Dense1Pattern) - (dense1->setOn(true)); - else if (fstyle==Qt::Dense2Pattern) - (dense2->setOn(true)); - else if (fstyle==Qt::Dense3Pattern) - (dense3->setOn(true)); - else if (fstyle==Qt::Dense4Pattern) - (dense4->setOn(true)); - else if (fstyle==Qt::Dense5Pattern) - (dense5->setOn(true)); - else if (fstyle==Qt::Dense6Pattern) - (dense6->setOn(true)); - else if (fstyle==Qt::Dense7Pattern) - (dense7->setOn(true)); - else if (fstyle==Qt::TexturePattern) - (texture->setOn(true)); - else if (fstyle==Qt::NoBrush) - (nopen->setOn(true)); //default to no brush + QString myFillStyle = QgsSymbologyUtils::brushStyle2QString(fstyle); + for ( int i = 0; i < cboFillStyle->count(); ++i ) + { + if (cboFillStyle->itemData(i, Qt::UserRole ).toString() == myFillStyle) + { + cboFillStyle->setCurrentIndex( i ); + break; + } + } } void QgsSingleSymbolDialog::setOutlineWidth(int width) @@ -537,19 +389,9 @@ Qt::PenStyle QgsSingleSymbolDialog::getOutlineStyle() { - if (pbnLineNoPen->isOn()) - return Qt::NoPen; - else if (pbnLineDash->isOn()) - return Qt::DashLine; - else if (pbnLineDot->isOn()) - return Qt::DotLine ; - else if (pbnLineDashDot->isOn()) - return Qt::DashDotLine; - else if (pbnLineDashDotDot->isOn()) - return Qt::DashDotDotLine ; - else - return Qt::SolidLine; //default to solid - + QString myLineStyle = + cboOutlineStyle->itemData(cboOutlineStyle->currentIndex(),Qt::UserRole).toString(); + return QgsSymbologyUtils::qString2PenStyle(myLineStyle); } int QgsSingleSymbolDialog::getOutlineWidth() @@ -564,69 +406,9 @@ Qt::BrushStyle QgsSingleSymbolDialog::getFillStyle() { - if (solid->isOn()) - { - return Qt::SolidPattern; - } - else if (fdiag->isOn()) - { - return Qt::FDiagPattern; - } - else if (dense4->isOn()) - { - return Qt::Dense4Pattern; - } - else if (horizontal->isOn()) - { - return Qt::HorPattern; - } - else if (dense5->isOn()) - { - return Qt::Dense5Pattern; - } - else if (diagcross->isOn()) - { - return Qt::DiagCrossPattern; - } - else if (dense1->isOn()) - { - return Qt::Dense1Pattern; - } - else if (dense6->isOn()) - { - return Qt::Dense6Pattern; - } - else if (vertical->isOn()) - { - return Qt::VerPattern; - } - else if (dense7->isOn()) - { - return Qt::Dense7Pattern; - } - else if (cross->isOn()) - { - return Qt::CrossPattern; - } - else if (dense2->isOn()) - { - return Qt::Dense2Pattern; - } - else if (bdiag->isOn()) - { - return Qt::BDiagPattern; - } - else if (dense3->isOn()) - { - return Qt::Dense3Pattern; - } - else if (texture->isOn()) - { - return Qt::TexturePattern; - } - //fall back to transparent - return Qt::NoBrush; - + QString myFillStyle = + cboFillStyle->itemData(cboFillStyle->currentIndex(),Qt::UserRole).toString(); + return QgsSymbologyUtils::qString2BrushStyle(myFillStyle); } void QgsSingleSymbolDialog::resendSettingsChanged() @@ -644,4 +426,30 @@ mLabelEdit->setText(label); } +void QgsSingleSymbolDialog::symbolChanged + ( QListWidgetItem * current, QListWidgetItem * previous ) +{ + current->setBackground( QBrush ( Qt::cyan ) ); + if (previous) + { + previous->setBackground( QBrush ( Qt::white ) ); + } + emit settingsChanged(); +} +void QgsSingleSymbolDialog::fillStyleChanged( int theIndex ) +{ + //if the new style is texture we need to enable the texture + //selection button, otherwise disable it + QString myFillStyle = + cboFillStyle->itemData( theIndex ,Qt::UserRole ).toString(); + if ( "TexturePattern" == myFillStyle ) + { + toolSelectTexture->setEnabled( true ); + } + else + { + toolSelectTexture->setEnabled( false ); + } + +} Index: src/core/qgsvectorlayer.cpp =================================================================== --- src/core/qgsvectorlayer.cpp (revision 7689) +++ src/core/qgsvectorlayer.cpp (working copy) @@ -85,7 +85,8 @@ QgsVectorLayer::QgsVectorLayer(QString vectorLayerPath, QString baseName, - QString providerKey) + QString providerKey, + bool loadDefaultStyleFlag ) : QgsMapLayer(VECTOR, baseName, vectorLayerPath), mUpdateThreshold(0), // XXX better default value? mDataProvider(NULL), @@ -105,12 +106,29 @@ } if(mValid) { - setCoordinateSystem(); - - // add single symbol renderer as default - QgsSingleSymbolRenderer *renderer = new QgsSingleSymbolRenderer(vectorType()); - setRenderer(renderer); - + // check if there is a default style / propertysheet defined + // for this layer and if so apply it + // + // + if ( loadDefaultStyleFlag ) + { + bool defaultLoadedFlag = false; + loadDefaultStyle( defaultLoadedFlag ); + if ( !defaultLoadedFlag ) + { + setCoordinateSystem(); + // add single symbol renderer as default + QgsSingleSymbolRenderer *renderer = new QgsSingleSymbolRenderer(vectorType()); + setRenderer(renderer); + } + } + else // Otherwise use some very basic defaults + { + setCoordinateSystem(); + // add single symbol renderer as default + QgsSingleSymbolRenderer *renderer = new QgsSingleSymbolRenderer(vectorType()); + setRenderer(renderer); + } // Get the update threshold from user settings. We // do this only on construction to avoid the penality of // fetching this each time the layer is drawn. If the user @@ -119,7 +137,7 @@ // TODO: load this setting somewhere else [MD] //QSettings settings; //mUpdateThreshold = settings.readNumEntry("Map/updateThreshold", 1000); - + } } // QgsVectorLayer ctor Index: src/core/qgsmaplayer.cpp =================================================================== --- src/core/qgsmaplayer.cpp (revision 7689) +++ src/core/qgsmaplayer.cpp (working copy) @@ -22,7 +22,15 @@ #include #include #include // TODO: get rid of it [MD] +#include +#include +#include +#include +#include +#include +#include + #include "qgslogger.h" #include "qgsmaptopixel.h" #include "qgsrect.h" @@ -399,3 +407,135 @@ return layerName; } + +QString QgsMapLayer::loadDefaultStyle ( bool & theResultFlag ) +{ + + QString myURI = publicSource(); + QFileInfo myFileInfo ( myURI ); + //get the file name for our .qml style file + QString myFileName = myFileInfo.path() + QDir::separator() + + myFileInfo.completeBaseName () + ".qml"; + return loadNamedStyle ( myFileName, theResultFlag ); +} +QString QgsMapLayer::loadNamedStyle ( const QString theURI , bool & theResultFlag ) +{ + theResultFlag = false; + //first check if its a file - we will add support for + //database etc uris later + QFileInfo myFileInfo ( theURI ); + if ( !myFileInfo.isFile() ) + { + return QObject::tr( "Currently only filebased datasets are supported" ); + } + QFile myFile ( theURI ); + if ( myFile.open(QFile::ReadOnly ) ) + { + QDomDocument myDocument ( "qgis" ); + // location of problem associated with errorMsg + int line, column; + QString myErrorMessage; + if ( !myDocument.setContent ( &myFile, &myErrorMessage, &line, &column ) ) + { + myFile.close(); + return myErrorMessage + " at line " + QString::number( line ) + + " column " + QString::number( column ); + } + else //dom parsed in ok + { + myFile.close(); + + // now get the layer node out and pass it over to the layer + // to deserialise... + QDomElement myRoot = myDocument.firstChildElement("qgis"); + if (myRoot.isNull()) + { + myErrorMessage = "Error: qgis element could not be found in " + theURI; + return myErrorMessage; + } + + QDomElement myLayer = myRoot.firstChildElement("maplayer"); + if (myLayer.isNull()) + { + myErrorMessage = "Error: maplayer element could not be found in " + theURI; + return myErrorMessage; + } + + // + // we need to ensure the data source matches the layers + // current datasource not the one specified in the qml + // + QDomElement myDataSource = myLayer.firstChildElement("datasource"); + if (myDataSource.isNull()) + { + myErrorMessage = "Error: datasource element could not be found in " + theURI; + return myErrorMessage; + } + QDomElement myNewDataSource = myDocument.createElement( "datasource" ); + QDomText myDataSourceText = myDocument.createTextNode( source() ); + myNewDataSource.appendChild( myDataSourceText ); + myLayer.replaceChild( myNewDataSource , + myLayer.firstChildElement("datasource") ); + + // + // Now go on to parse the xml (QDomElement inherits QDomNode + // so we can just pass along the element to readXML) + // + theResultFlag = readXML ( myLayer ); + + return QObject::tr( "Loaded default style file from " ) + theURI; + } + } +} +QString QgsMapLayer::saveDefaultStyle ( bool & theResultFlag ) +{ + + QString myURI = publicSource(); + QFileInfo myFileInfo ( myURI ); + //get the file name for our .qml style file + QString myFileName = myFileInfo.path() + QDir::separator() + + myFileInfo.completeBaseName () + ".qml"; + return saveNamedStyle ( myFileName, theResultFlag ); +} +QString QgsMapLayer::saveNamedStyle ( const QString theURI , bool & theResultFlag ) +{ + + QFileInfo myFileInfo ( theURI ); + //now check if we can write to the dir where the layer + //exists... + QFileInfo myDirInfo ( myFileInfo.path() ); //excludes filename + if ( !myDirInfo.isWritable() ) + { + return QObject::tr( "The directory containing your dataset needs to be writeable!" ); + } + //now construct the file name for our .qml style file + QString myFileName = myFileInfo.path() + QDir::separator() + + myFileInfo.completeBaseName () + ".qml"; + + QDomImplementation DOMImplementation; + QDomDocumentType documentType = + DOMImplementation.createDocumentType( + "qgis", "http://mrcc.com/qgis.dtd","SYSTEM" ); + QDomDocument myDocument ( documentType ); + QDomElement myRootNode = myDocument.createElement( "qgis" ); + myRootNode.setAttribute( "version", QString("%1").arg( QGis::qgisVersion ) ); + myDocument.appendChild( myRootNode ); + writeXML( myRootNode, myDocument ); + + + QFile myFile ( myFileName ); + if ( myFile.open(QFile::WriteOnly | QFile::Truncate ) ) + { + QTextStream myFileStream( &myFile ); + // save as utf-8 with 2 spaces for indents + myDocument.save( myFileStream, 2 ); + myFile.close(); + return QObject::tr( "Created default style file as " ) + myFileName; + } + else + { + return QObject::tr( "ERROR: Failed to created default style file as " ) + myFileName + + tr( " Check file permissions and retry." ); + } + +} Index: src/core/qgsvectorlayer.h =================================================================== --- src/core/qgsvectorlayer.h (revision 7689) +++ src/core/qgsvectorlayer.h (working copy) @@ -71,7 +71,8 @@ public: /** Constructor */ - QgsVectorLayer(QString path = 0, QString baseName = 0, QString providerLib = 0); + QgsVectorLayer(QString path = 0, QString baseName = 0, + QString providerLib = 0, bool loadDefaultStyleFlag = true); /** Destructor */ virtual ~QgsVectorLayer(); Index: src/core/symbology/qgssymbol.cpp =================================================================== --- src/core/symbology/qgssymbol.cpp (revision 7689) +++ src/core/symbology/qgssymbol.cpp (working copy) @@ -90,7 +90,7 @@ mType = s.mType; mPen = s.mPen; mBrush = s.mBrush; - mTextureFilePath = s.mTextureFilePath; + mTextureFilePath = s.mTextureFilePath; mPointSymbolName = s.mPointSymbolName; mPointSize = s.mPointSize; mPointSymbolImage = s.mPointSymbolImage; Index: src/core/symbology/qgssymbologyutils.cpp =================================================================== --- src/core/symbology/qgssymbologyutils.cpp (revision 7689) +++ src/core/symbology/qgssymbologyutils.cpp (working copy) @@ -641,205 +641,251 @@ QString QgsSymbologyUtils::penStyle2QString(Qt::PenStyle penstyle) { if (penstyle == Qt::NoPen) - { - return "NoPen"; - } else if (penstyle == Qt::SolidLine) - { - return "SolidLine"; - } else if (penstyle == Qt::DashLine) - { - return "DashLine"; - } else if (penstyle == Qt::DotLine) - { - return "DotLine"; - } else if (penstyle == Qt::DashDotLine) - { - return "DashDotLine"; - } else if (penstyle == Qt::DashDotDotLine) - { - return "DashDotDotLine"; - } else if (penstyle == Qt::MPenStyle) - { - return "MPenStyle"; - } else //return a null string - { - return QString(); - } + { + return "NoPen"; + } + else if (penstyle == Qt::SolidLine) + { + return "SolidLine"; + } + else if (penstyle == Qt::DashLine) + { + return "DashLine"; + } + else if (penstyle == Qt::DotLine) + { + return "DotLine"; + } + else if (penstyle == Qt::DashDotLine) + { + return "DashDotLine"; + } + else if (penstyle == Qt::DashDotDotLine) + { + return "DashDotDotLine"; + } + else if (penstyle == Qt::MPenStyle) + { + return "MPenStyle"; + } + else //return a null string + { + return QString(); + } } Qt::PenStyle QgsSymbologyUtils::qString2PenStyle(QString penString) { if (penString == "NoPen") - { - return Qt::NoPen; - } else if (penString == "SolidLine") - { - return Qt::SolidLine; - } else if (penString == "DashLine") - { - return Qt::DashLine; - } else if (penString == "DotLine") - { - return Qt::DotLine; - } else if (penString == "DashDotLine") - { - return Qt::DashDotLine; - } else if (penString == "DashDotDotLine") - { - return Qt::DashDotDotLine; - } else if (penString == "MPenStyle") - { - return Qt::MPenStyle; - } else - { - return Qt::NoPen; - } + { + return Qt::NoPen; + } + else if (penString == "SolidLine") + { + return Qt::SolidLine; + } + else if (penString == "DashLine") + { + return Qt::DashLine; + } + else if (penString == "DotLine") + { + return Qt::DotLine; + } + else if (penString == "DashDotLine") + { + return Qt::DashDotLine; + } + else if (penString == "DashDotDotLine") + { + return Qt::DashDotDotLine; + } + else if (penString == "MPenStyle") + { + return Qt::MPenStyle; + } + else + { + return Qt::NoPen; + } } QString QgsSymbologyUtils::brushStyle2QString(Qt::BrushStyle brushstyle) { if (brushstyle == Qt::NoBrush) - { - return "NoBrush"; - } else if (brushstyle == Qt::SolidPattern) - { - return "SolidPattern"; - } else if (brushstyle == Qt::Dense1Pattern) - { - return "Dense1Pattern"; - } else if (brushstyle == Qt::Dense2Pattern) - { - return "Dense2Pattern"; - } else if (brushstyle == Qt::Dense3Pattern) - { - return "Dense3Pattern"; - } else if (brushstyle == Qt::Dense4Pattern) - { - return "Dense4Pattern"; - } else if (brushstyle == Qt::Dense5Pattern) - { - return "Dense5Pattern"; - } else if (brushstyle == Qt::Dense6Pattern) - { - return "Dense6Pattern"; - } else if (brushstyle == Qt::Dense7Pattern) - { - return "Dense7Pattern"; - } else if (brushstyle == Qt::HorPattern) - { - return "HorPattern"; - } else if (brushstyle == Qt::VerPattern) - { - return "VerPattern"; - } else if (brushstyle == Qt::CrossPattern) - { - return "CrossPattern"; - } else if (brushstyle == Qt::BDiagPattern) - { - return "BDiagPattern"; - } else if (brushstyle == Qt::FDiagPattern) - { - return "FDiagPattern"; - } else if (brushstyle == Qt::DiagCrossPattern) - { - return "DiagCrossPattern"; - } else if (brushstyle == Qt::TexturePattern) - { - return "CustomPattern"; - } else //return a null string - { - qWarning("Warning, no matching pattern found in QgsSymbologyUtils::brushStyle2QString"); - return " "; - } + { + return "NoBrush"; + } + else if (brushstyle == Qt::SolidPattern) + { + return "SolidPattern"; + } + else if (brushstyle == Qt::Dense1Pattern) + { + return "Dense1Pattern"; + } + else if (brushstyle == Qt::Dense2Pattern) + { + return "Dense2Pattern"; + } + else if (brushstyle == Qt::Dense3Pattern) + { + return "Dense3Pattern"; + } + else if (brushstyle == Qt::Dense4Pattern) + { + return "Dense4Pattern"; + } + else if (brushstyle == Qt::Dense5Pattern) + { + return "Dense5Pattern"; + } + else if (brushstyle == Qt::Dense6Pattern) + { + return "Dense6Pattern"; + } + else if (brushstyle == Qt::Dense7Pattern) + { + return "Dense7Pattern"; + } + else if (brushstyle == Qt::HorPattern) + { + return "HorPattern"; + } + else if (brushstyle == Qt::VerPattern) + { + return "VerPattern"; + } + else if (brushstyle == Qt::CrossPattern) + { + return "CrossPattern"; + } + else if (brushstyle == Qt::BDiagPattern) + { + return "BDiagPattern"; + } + else if (brushstyle == Qt::FDiagPattern) + { + return "FDiagPattern"; + } + else if (brushstyle == Qt::DiagCrossPattern) + { + return "DiagCrossPattern"; + } + else if (brushstyle == Qt::TexturePattern) + { + return "CustomPattern"; + } + else //return a null string + { + qWarning("Warning, no matching pattern found in QgsSymbologyUtils::brushStyle2QString"); + return " "; + } } Qt::BrushStyle QgsSymbologyUtils::qString2BrushStyle(QString brushString) { if (brushString == "NoBrush") - { - return Qt::NoBrush; - } else if (brushString == "SolidPattern") - { - return Qt::SolidPattern; - } else if (brushString == "Dense1Pattern") - { - return Qt::Dense1Pattern; - } else if (brushString == "Dense2Pattern") - { - return Qt::Dense2Pattern; - } else if (brushString == "Dense3Pattern") - { - return Qt::Dense3Pattern; - } else if (brushString == "Dense4Pattern") - { - return Qt::Dense4Pattern; - } else if (brushString == "Dense5Pattern") - { - return Qt::Dense5Pattern; - } else if (brushString == "Dense6Pattern") - { - return Qt::Dense6Pattern; - } else if (brushString == "Dense7Pattern") - { - return Qt::Dense7Pattern; - } else if (brushString == "HorPattern") - { - return Qt::HorPattern; - } else if (brushString == "VerPattern") - { - return Qt::VerPattern; - } else if (brushString == "CrossPattern") - { - return Qt::CrossPattern; - } else if (brushString == "BDiagPattern") - { - return Qt::BDiagPattern; - } else if (brushString == "FDiagPattern") - { - return Qt::FDiagPattern; - } else if (brushString == "DiagCrossPattern") - { - return Qt::DiagCrossPattern; - } else if (brushString == "CustomPattern") - { - return Qt::TexturePattern; - } else //return a null string - { - qWarning("Brush style \"" + brushString + "\" not found in qString2BrushStyle"); - return Qt::NoBrush; - } + { + return Qt::NoBrush; + } + else if (brushString == "SolidPattern") + { + return Qt::SolidPattern; + } + else if (brushString == "Dense1Pattern") + { + return Qt::Dense1Pattern; + } + else if (brushString == "Dense2Pattern") + { + return Qt::Dense2Pattern; + } + else if (brushString == "Dense3Pattern") + { + return Qt::Dense3Pattern; + } + else if (brushString == "Dense4Pattern") + { + return Qt::Dense4Pattern; + } + else if (brushString == "Dense5Pattern") + { + return Qt::Dense5Pattern; + } + else if (brushString == "Dense6Pattern") + { + return Qt::Dense6Pattern; + } + else if (brushString == "Dense7Pattern") + { + return Qt::Dense7Pattern; + } + else if (brushString == "HorPattern") + { + return Qt::HorPattern; + } + else if (brushString == "VerPattern") + { + return Qt::VerPattern; + } + else if (brushString == "CrossPattern") + { + return Qt::CrossPattern; + } + else if (brushString == "BDiagPattern") + { + return Qt::BDiagPattern; + } + else if (brushString == "FDiagPattern") + { + return Qt::FDiagPattern; + } + else if (brushString == "DiagCrossPattern") + { + return Qt::DiagCrossPattern; + } + else if (brushString == "CustomPattern") + { + return Qt::TexturePattern; + } + else //return a null string + { + qWarning("Brush style \"" + brushString + "\" not found in qString2BrushStyle"); + return Qt::NoBrush; + } } QPixmap QgsSymbologyUtils::qString2LinePixmap(QString lineString) { if (lineString == "SolidLine") - { - return QPixmap(solidLineData); - } + { + return QPixmap(solidLineData); + } if (lineString == "DashLine") - { - return QPixmap(dashLineData); - } + { + return QPixmap(dashLineData); + } if (lineString == "DotLine") - { - return QPixmap(dotLineData); - } + { + return QPixmap(dotLineData); + } if (lineString == "DashDotLine") - { - return QPixmap(dashDotLineData); - } + { + return QPixmap(dashDotLineData); + } if (lineString == "DashDotDotLine") - { - return QPixmap(dashDotDotLineData); - } + { + return QPixmap(dashDotDotLineData); + } if(lineString =="NoPen") - { - return QPixmap(noPenLineData); - } + { + return QPixmap(noPenLineData); + } return QPixmap(); // XXX I hope returning a blank one is ok } @@ -847,411 +893,411 @@ QPixmap QgsSymbologyUtils::qString2PatternPixmap(QString patternString) { if (patternString == "SolidPattern") - { - return QPixmap(solidData); + { + return QPixmap(solidData); } else if (patternString == "Dense1Pattern") - { - return QPixmap(dense1Data); + { + return QPixmap(dense1Data); } else if (patternString == "Dense2Pattern") - { - return QPixmap(dense2Data); + { + return QPixmap(dense2Data); } else if (patternString == "Dense3Pattern") - { - return QPixmap(dense3Data); + { + return QPixmap(dense3Data); } else if (patternString == "Dense4Pattern") - { - return QPixmap(dense4Data); + { + return QPixmap(dense4Data); } else if (patternString == "Dense5Pattern") - { - return QPixmap(dense5Data); + { + return QPixmap(dense5Data); } else if (patternString == "Dense6Pattern") - { - return QPixmap(dense6Data); + { + return QPixmap(dense6Data); } else if (patternString == "Dense7Pattern") - { - return QPixmap(dense7Data); + { + return QPixmap(dense7Data); } else if (patternString == "HorPattern") - { - return QPixmap(horizontalData); + { + return QPixmap(horizontalData); } else if (patternString == "VerPattern") - { - return QPixmap(verticalData); + { + return QPixmap(verticalData); } else if (patternString == "CrossPattern") - { - return QPixmap(crossData); + { + return QPixmap(crossData); } else if (patternString == "BDiagPattern") - { - return QPixmap(bdiagData); + { + return QPixmap(bdiagData); } else if (patternString == "FDiagPattern") - { - return QPixmap(fdiagData); + { + return QPixmap(fdiagData); } else if (patternString == "DiagCrossPattern") - { - return QPixmap(diagCrossData); + { + return QPixmap(diagCrossData); } else if (patternString == "TexturePattern") - { - return QPixmap(texturePatternData); + { + return QPixmap(texturePatternData); } else if (patternString == "NoBrush") - { - return QPixmap(nobrush); + { + return QPixmap(nobrush); } else //return a null patternString - { - qWarning("Warning, no matching pattern found in QgsSymbologyUtils::qString2PatternPixmap"); - return QPixmap(); - } + { + qWarning("Warning, no matching pattern found in QgsSymbologyUtils::qString2PatternPixmap"); + return QPixmap(); + } } const char * QgsSymbologyUtils::penStyle2Char(Qt::PenStyle penstyle) { if (penstyle == Qt::NoPen) - { - return "NoPen"; + { + return "NoPen"; } else if (penstyle == Qt::SolidLine) - { - return "SolidLine"; + { + return "SolidLine"; } else if (penstyle == Qt::DashLine) - { - return "DashLine"; + { + return "DashLine"; } else if (penstyle == Qt::DotLine) - { - return "DotLine"; + { + return "DotLine"; } else if (penstyle == Qt::DashDotLine) - { - return "DashDotLine"; + { + return "DashDotLine"; } else if (penstyle == Qt::DashDotDotLine) - { - return "DashDotDotLine"; + { + return "DashDotDotLine"; } else if (penstyle == Qt::MPenStyle) - { - return "MPenStyle"; + { + return "MPenStyle"; } else //return an empty char* - { - return " "; - } + { + return " "; + } } const char *QgsSymbologyUtils::brushStyle2Char(Qt::BrushStyle brushstyle) { if (brushstyle == Qt::NoBrush) - { - return "NoBrush"; + { + return "NoBrush"; } else if (brushstyle == Qt::SolidPattern) - { - return "SolidPattern"; + { + return "SolidPattern"; } else if (brushstyle == Qt::Dense1Pattern) - { - return "Dense1Pattern"; + { + return "Dense1Pattern"; } else if (brushstyle == Qt::Dense2Pattern) - { - return "Dense2Pattern"; + { + return "Dense2Pattern"; } else if (brushstyle == Qt::Dense3Pattern) - { - return "Dense3Pattern"; + { + return "Dense3Pattern"; } else if (brushstyle == Qt::Dense4Pattern) - { - return "Dense4Pattern"; + { + return "Dense4Pattern"; } else if (brushstyle == Qt::Dense5Pattern) - { - return "Dense5Pattern"; + { + return "Dense5Pattern"; } else if (brushstyle == Qt::Dense6Pattern) - { - return "Dense6Pattern"; + { + return "Dense6Pattern"; } else if (brushstyle == Qt::Dense7Pattern) - { - return "Dense7Pattern"; + { + return "Dense7Pattern"; } else if (brushstyle == Qt::HorPattern) - { - return "HorPattern"; + { + return "HorPattern"; } else if (brushstyle == Qt::VerPattern) - { - return "VerPattern"; + { + return "VerPattern"; } else if (brushstyle == Qt::CrossPattern) - { - return "CrossPattern"; + { + return "CrossPattern"; } else if (brushstyle == Qt::BDiagPattern) - { - return "BDiagPattern"; + { + return "BDiagPattern"; } else if (brushstyle == Qt::FDiagPattern) - { - return "FDiagPattern"; + { + return "FDiagPattern"; } else if (brushstyle == Qt::DiagCrossPattern) - { - return "DiagCrossPattern"; + { + return "DiagCrossPattern"; } else if (brushstyle == Qt::TexturePattern) - { - return "CustomPattern"; + { + return "CustomPattern"; } else //return an empty char* - { - return " "; - } + { + return " "; + } } QPixmap QgsSymbologyUtils::char2LinePixmap(const char *c) { if (strcmp(c, "SolidLine") == 0) - { - return QPixmap(solidLineData); - } + { + return QPixmap(solidLineData); + } else if (strcmp(c, "DashLine") == 0) - { - return QPixmap(dashLineData); - } + { + return QPixmap(dashLineData); + } else if (strcmp(c, "DotLine") == 0) - { - return QPixmap(dotLineData); - } + { + return QPixmap(dotLineData); + } else if (strcmp(c, "DashDotLine") == 0) - { - return QPixmap(dashDotLineData); - } + { + return QPixmap(dashDotLineData); + } else if (strcmp(c, "DashDotDotLine") == 0) - { - return QPixmap(dashDotDotLineData); - } + { + return QPixmap(dashDotDotLineData); + } else if (strcmp(c, "NoPen") == 0) - { - return QPixmap(noPenLineData); - } + { + return QPixmap(noPenLineData); + } else - { - qWarning("Warning, no matching style found in QgsSymbologyUtils::char2LinePixmap"); - return QPixmap(); - } + { + qWarning("Warning, no matching style found in QgsSymbologyUtils::char2LinePixmap"); + return QPixmap(); + } } QPixmap QgsSymbologyUtils::char2PatternPixmap(const char *c) { if (strcmp(c, "SolidPattern") == 0) - { - return QPixmap(solidData); + { + return QPixmap(solidData); } else if (strcmp(c, "Dense1Pattern") == 0) - { - return QPixmap(dense1Data); + { + return QPixmap(dense1Data); } else if (strcmp(c, "Dense2Pattern") == 0) - { - return QPixmap(dense2Data); + { + return QPixmap(dense2Data); } else if (strcmp(c, "Dense3Pattern") == 0) - { - return QPixmap(dense3Data); + { + return QPixmap(dense3Data); } else if (strcmp(c, "Dense4Pattern") == 0) - { - return QPixmap(dense4Data); + { + return QPixmap(dense4Data); } else if (strcmp(c, "Dense5Pattern") == 0) - { - return QPixmap(dense5Data); + { + return QPixmap(dense5Data); } else if (strcmp(c, "Dense6Pattern") == 0) - { - return QPixmap(dense6Data); + { + return QPixmap(dense6Data); } else if (strcmp(c, "Dense7Pattern") == 0) - { - return QPixmap(dense7Data); + { + return QPixmap(dense7Data); } else if (strcmp(c, "HorPattern") == 0) - { - return QPixmap(horizontalData); + { + return QPixmap(horizontalData); } else if (strcmp(c, "VerPattern") == 0) - { - return QPixmap(verticalData); + { + return QPixmap(verticalData); } else if (strcmp(c, "CrossPattern") == 0) - { - return QPixmap(crossData); + { + return QPixmap(crossData); } else if (strcmp(c, "BDiagPattern") == 0) - { - return QPixmap(bdiagData); + { + return QPixmap(bdiagData); } else if (strcmp(c, "FDiagPattern") == 0) - { - return QPixmap(fdiagData); + { + return QPixmap(fdiagData); } else if (strcmp(c, "DiagCrossPattern") == 0) - { - return QPixmap(diagCrossData); + { + return QPixmap(diagCrossData); } else if (strcmp(c, "TexturePattern") == 0) - { - return QPixmap(texturePatternData); + { + return QPixmap(texturePatternData); }else if (strcmp(c, "NoBrush") == 0) - { - return QPixmap(nobrush); + { + return QPixmap(nobrush); } else - { - qWarning("Warning, no matching pattern found in QgsSymbologyUtils::char2PatternPixmap"); - return QPixmap(); - } + { + qWarning("Warning, no matching pattern found in QgsSymbologyUtils::char2PatternPixmap"); + return QPixmap(); + } } Qt::PenStyle QgsSymbologyUtils::char2PenStyle(const char *c) { if (strcmp(c, "NoPen") == 0) - { - return Qt::NoPen; + { + return Qt::NoPen; } else if (strcmp(c, "SolidLine") == 0) - { - return Qt::SolidLine; + { + return Qt::SolidLine; } else if (strcmp(c, "DashLine") == 0) - { - return Qt::DashLine; + { + return Qt::DashLine; } else if (strcmp(c, "DotLine") == 0) - { - return Qt::DotLine; + { + return Qt::DotLine; } else if (strcmp(c, "DashDotLine") == 0) - { - return Qt::DashDotLine; + { + return Qt::DashDotLine; } else if (strcmp(c, "DashDotDotLine") == 0) - { - return Qt::DashDotDotLine; + { + return Qt::DashDotDotLine; } else if (strcmp(c, "MPenStyle") == 0) - { - return Qt::MPenStyle; + { + return Qt::MPenStyle; } else - { - qWarning("Warning, no matching pen style found in QgsSymbologyUtils::char2PenStyle"); - return Qt::NoPen; - } + { + qWarning("Warning, no matching pen style found in QgsSymbologyUtils::char2PenStyle"); + return Qt::NoPen; + } } Qt::BrushStyle QgsSymbologyUtils::char2BrushStyle(const char *c) { if (strcmp(c, "SolidPattern") == 0) - { - return Qt::SolidPattern; + { + return Qt::SolidPattern; } else if (strcmp(c, "Dense1Pattern") == 0) - { - return Qt::Dense1Pattern; + { + return Qt::Dense1Pattern; } else if (strcmp(c, "Dense2Pattern") == 0) - { - return Qt::Dense2Pattern; + { + return Qt::Dense2Pattern; } else if (strcmp(c, "Dense3Pattern") == 0) - { - return Qt::Dense3Pattern; + { + return Qt::Dense3Pattern; } else if (strcmp(c, "Dense4Pattern") == 0) - { - return Qt::Dense4Pattern; + { + return Qt::Dense4Pattern; } else if (strcmp(c, "Dense5Pattern") == 0) - { - return Qt::Dense5Pattern; + { + return Qt::Dense5Pattern; } else if (strcmp(c, "Dense6Pattern") == 0) - { - return Qt::Dense6Pattern; + { + return Qt::Dense6Pattern; } else if (strcmp(c, "Dense7Pattern") == 0) - { - return Qt::Dense7Pattern; + { + return Qt::Dense7Pattern; } else if (strcmp(c, "HorPattern") == 0) - { - return Qt::HorPattern; + { + return Qt::HorPattern; } else if (strcmp(c, "VerPattern") == 0) - { - return Qt::VerPattern; + { + return Qt::VerPattern; } else if (strcmp(c, "CrossPattern") == 0) - { - return Qt::CrossPattern; + { + return Qt::CrossPattern; } else if (strcmp(c, "BDiagPattern") == 0) - { - return Qt::BDiagPattern; + { + return Qt::BDiagPattern; } else if (strcmp(c, "FDiagPattern") == 0) - { - return Qt::FDiagPattern; + { + return Qt::FDiagPattern; } else if (strcmp(c, "DiagCrossPattern") == 0) - { - return Qt::DiagCrossPattern; + { + return Qt::DiagCrossPattern; } else if (strcmp(c, "CustomPattern") == 0) - { - return Qt::TexturePattern; + { + return Qt::TexturePattern; } else if (strcmp(c, "NoBrush") == 0) - { - return Qt::NoBrush; + { + return Qt::NoBrush; }else //return a null string - { - qWarning("Warning, no matching brush style found in QgsSymbologyUtils::char2BrushStyle"); - return Qt::NoBrush; - } + { + qWarning("Warning, no matching brush style found in QgsSymbologyUtils::char2BrushStyle"); + return Qt::NoBrush; + } } QPixmap QgsSymbologyUtils::penStyle2Pixmap(Qt::PenStyle penstyle) { switch (penstyle) - { - case (Qt::SolidLine): - return QPixmap(solidLineData); - break; - case (Qt::DashLine): - return QPixmap(dashLineData); - break; - case (Qt::DotLine): - return QPixmap(dotLineData); - break; - case (Qt::DashDotLine): - return QPixmap(dashDotLineData); - break; - case (Qt::DashDotDotLine): - return QPixmap(dashDotDotLineData); - break; - case (Qt::NoPen): - return QPixmap(noPenLineData); - break; - default: - qWarning("Warning, no matching pen style found in QgsSymbologyUtils::penStyle2Pixmap"); - return QPixmap(); - } + { + case (Qt::SolidLine): + return QPixmap(solidLineData); + break; + case (Qt::DashLine): + return QPixmap(dashLineData); + break; + case (Qt::DotLine): + return QPixmap(dotLineData); + break; + case (Qt::DashDotLine): + return QPixmap(dashDotLineData); + break; + case (Qt::DashDotDotLine): + return QPixmap(dashDotDotLineData); + break; + case (Qt::NoPen): + return QPixmap(noPenLineData); + break; + default: + qWarning("Warning, no matching pen style found in QgsSymbologyUtils::penStyle2Pixmap"); + return QPixmap(); + } } QPixmap QgsSymbologyUtils::brushStyle2Pixmap(Qt::BrushStyle brushstyle) { switch (brushstyle) - { - case (Qt::SolidPattern): - return QPixmap(solidData); - break; - case (Qt::Dense1Pattern): - return QPixmap(dense1Data); - break; - case (Qt::Dense2Pattern): - return QPixmap(dense2Data); - break; - case (Qt::Dense3Pattern): - return QPixmap(dense3Data); - break; - case (Qt::Dense4Pattern): - return QPixmap(dense4Data); - break; - case (Qt::Dense5Pattern): - return QPixmap(dense5Data); - break; - case (Qt::Dense6Pattern): - return QPixmap(dense6Data); - break; - case (Qt::Dense7Pattern): - return QPixmap(dense7Data); - break; - case (Qt::HorPattern): - return QPixmap(horizontalData); - break; - case (Qt::VerPattern): - return QPixmap(verticalData); - break; - case (Qt::CrossPattern): - return QPixmap(crossData); - break; - case (Qt::BDiagPattern): - return QPixmap(bdiagData); - break; - case (Qt::FDiagPattern): - return QPixmap(fdiagData); - break; - case (Qt::DiagCrossPattern): - return QPixmap(diagCrossData); - break; - case (Qt::TexturePattern) : - return QPixmap(texturePatternData); - break; - case (Qt::NoBrush): - return QPixmap(nobrush); - default: - qWarning("Warning, no matching pattern found in QgsSymbologyUtils::brushStyle2Pixmap"); - } + { + case (Qt::SolidPattern): + return QPixmap(solidData); + break; + case (Qt::Dense1Pattern): + return QPixmap(dense1Data); + break; + case (Qt::Dense2Pattern): + return QPixmap(dense2Data); + break; + case (Qt::Dense3Pattern): + return QPixmap(dense3Data); + break; + case (Qt::Dense4Pattern): + return QPixmap(dense4Data); + break; + case (Qt::Dense5Pattern): + return QPixmap(dense5Data); + break; + case (Qt::Dense6Pattern): + return QPixmap(dense6Data); + break; + case (Qt::Dense7Pattern): + return QPixmap(dense7Data); + break; + case (Qt::HorPattern): + return QPixmap(horizontalData); + break; + case (Qt::VerPattern): + return QPixmap(verticalData); + break; + case (Qt::CrossPattern): + return QPixmap(crossData); + break; + case (Qt::BDiagPattern): + return QPixmap(bdiagData); + break; + case (Qt::FDiagPattern): + return QPixmap(fdiagData); + break; + case (Qt::DiagCrossPattern): + return QPixmap(diagCrossData); + break; + case (Qt::TexturePattern) : + return QPixmap(texturePatternData); + break; + case (Qt::NoBrush): + return QPixmap(nobrush); + default: + qWarning("Warning, no matching pattern found in QgsSymbologyUtils::brushStyle2Pixmap"); + } return QPixmap(); // XXX I hope returning a blank one is ok } Index: src/core/symbology/qgssymbologyutils.h =================================================================== --- src/core/symbology/qgssymbologyutils.h (revision 7689) +++ src/core/symbology/qgssymbologyutils.h (working copy) @@ -27,20 +27,20 @@ /**Namespace containing static methods which are useful for the symbology widgets*/ namespace QgsSymbologyUtils { - QPixmap CORE_EXPORT qString2LinePixmap(QString string); - QPixmap CORE_EXPORT char2LinePixmap(const char* c); - QPixmap CORE_EXPORT qString2PatternPixmap(QString string); - QPixmap CORE_EXPORT char2PatternPixmap(const char* c); - QString CORE_EXPORT penStyle2QString(Qt::PenStyle penstyle); - const char CORE_EXPORT * penStyle2Char(Qt::PenStyle penstyle); - QPixmap CORE_EXPORT penStyle2Pixmap(Qt::PenStyle penstyle); - Qt::PenStyle CORE_EXPORT qString2PenStyle(QString string); - Qt::PenStyle CORE_EXPORT char2PenStyle(const char* c); - QString CORE_EXPORT brushStyle2QString(Qt::BrushStyle brushstyle); - const char CORE_EXPORT * brushStyle2Char(Qt::BrushStyle brushstyle); - QPixmap CORE_EXPORT brushStyle2Pixmap(Qt::BrushStyle brushstyle); - Qt::BrushStyle CORE_EXPORT qString2BrushStyle(QString string); - Qt::BrushStyle CORE_EXPORT char2BrushStyle(const char* c); + QPixmap CORE_EXPORT qString2LinePixmap(QString string); + QPixmap CORE_EXPORT char2LinePixmap(const char* c); + QPixmap CORE_EXPORT qString2PatternPixmap(QString string); + QPixmap CORE_EXPORT char2PatternPixmap(const char* c); + QString CORE_EXPORT penStyle2QString(Qt::PenStyle penstyle); + const char CORE_EXPORT * penStyle2Char(Qt::PenStyle penstyle); + QPixmap CORE_EXPORT penStyle2Pixmap(Qt::PenStyle penstyle); + Qt::PenStyle CORE_EXPORT qString2PenStyle(QString string); + Qt::PenStyle CORE_EXPORT char2PenStyle(const char* c); + QString CORE_EXPORT brushStyle2QString(Qt::BrushStyle brushstyle); + const char CORE_EXPORT * brushStyle2Char(Qt::BrushStyle brushstyle); + QPixmap CORE_EXPORT brushStyle2Pixmap(Qt::BrushStyle brushstyle); + Qt::BrushStyle CORE_EXPORT qString2BrushStyle(QString string); + Qt::BrushStyle CORE_EXPORT char2BrushStyle(const char* c); } #endif Index: src/core/qgsmaplayer.h =================================================================== --- src/core/qgsmaplayer.h (revision 7689) +++ src/core/qgsmaplayer.h (working copy) @@ -198,7 +198,57 @@ /** A convenience function to capitalise the layer name */ static QString capitaliseLayerName(const QString name); + + /** Retrieve the default style for this layer if one + * exists (either as a .qml file on disk or as a + * record in the users style table in their personal qgis.db) + * @param a reference to a flag that will be set to false if + * we did not manage to load the default style. + * @return a QString with any status messages + * @see also loadNamedStyle (); + */ + virtual QString loadDefaultStyle ( bool & theResultFlag ); + /** Retrieve a named style for this layer if one + * exists (either as a .qml file on disk or as a + * record in the users style table in their personal qgis.db) + * @param QString theURI - the file name or other URI for the + * style file. First an attempt will be made to see if this + * is a file and load that, if that fails the qgis.db styles + * table will be consulted to see if there is a style who's + * key matches the URI. + * @param a reference to a flag that will be set to false if + * we did not manage to load the default style. + * @return a QString with any status messages + * @see also loadDefaultStyle (); + */ + virtual QString loadNamedStyle ( const QString theURI , bool & theResultFlag ); + + /** Save the properties of this layer as the default style + * (either as a .qml file on disk or as a + * record in the users style table in their personal qgis.db) + * @param a reference to a flag that will be set to false if + * we did not manage to save the default style. + * @return a QString with any status messages + * @see also loadNamedStyle () and saveNamedStyle() + */ + virtual QString saveDefaultStyle ( bool & theResultFlag ); + + /** Save the properties of this layer as a named style + * (either as a .qml file on disk or as a + * record in the users style table in their personal qgis.db) + * @param QString theURI - the file name or other URI for the + * style file. First an attempt will be made to see if this + * is a file and save to that, if that fails the qgis.db styles + * table will be used to create a style entry who's + * key matches the URI. + * @param a reference to a flag that will be set to false if + * we did not manage to save the default style. + * @return a QString with any status messages + * @see also saveDefaultStyle (); + */ + virtual QString saveNamedStyle ( const QString theURI , bool & theResultFlag ); + public slots: /** Event handler for when a coordinate transform fails due to bad vertex error */ Index: src/ui/qgsvectorlayerpropertiesbase.ui =================================================================== --- src/ui/qgsvectorlayerpropertiesbase.ui (revision 7689) +++ src/ui/qgsvectorlayerpropertiesbase.ui (working copy) @@ -5,7 +5,7 @@ 0 0 - 469 + 508 600 @@ -26,21 +26,11 @@ - 9 + 11 6 - - - - Qt::Horizontal - - - QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok - - - @@ -55,7 +45,7 @@ - 9 + 11 6 @@ -64,8 +54,8 @@ - 7 - 7 + 0 + 0 0 0 @@ -137,7 +127,7 @@ - 9 + 11 6 @@ -188,7 +178,7 @@ - 8 + 11 6 @@ -249,7 +239,7 @@ - 8 + 11 6 @@ -297,7 +287,7 @@ - 8 + 11 6 @@ -326,7 +316,7 @@ - 9 + 11 6 @@ -378,7 +368,7 @@ - 9 + 11 6 @@ -398,7 +388,7 @@ - 9 + 11 6 @@ -407,8 +397,8 @@ - 7 - 7 + 0 + 0 0 0 @@ -425,7 +415,7 @@ - 7 + 0 0 0 0 @@ -444,7 +434,7 @@ - 9 + 11 6 @@ -453,8 +443,8 @@ - 7 - 7 + 0 + 0 0 0 @@ -471,6 +461,54 @@ + + + + 11 + + + 6 + + + + + Restore Default Style + + + + + + + Save As Default + + + + + + + Load Style ... + + + + + + + Save Style ... + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + Index: src/ui/qgssinglesymboldialogbase.ui =================================================================== --- src/ui/qgssinglesymboldialogbase.ui (revision 7689) +++ src/ui/qgssinglesymboldialogbase.ui (working copy) @@ -5,14 +5,14 @@ 0 0 - 413 - 497 + 395 + 506 - 3 - 5 + 0 + 0 0 0 @@ -22,7 +22,7 @@ - 9 + 11 6 @@ -30,7 +30,7 @@ - 0 + 11 6 @@ -44,7 +44,7 @@ - Label: + Label mLabelEdit @@ -65,17 +65,44 @@ + + + 0 + 0 + 0 + 0 + + - Point + Point Symbol - 9 + 11 6 - + + + + QAbstractItemView::DragDrop + + + false + + + QListView::IconMode + + + true + + + false + + + + Qt::Horizontal @@ -85,37 +112,13 @@ - 78 + 251 35 - - - - - 7 - 7 - 0 - 0 - - - - - 0 - 0 - - - - - 32767 - 40 - - - - - + Size @@ -125,7 +128,7 @@ - + 1000 @@ -141,721 +144,169 @@ - - - - - 5 - 1 - 0 - 0 - - - - Symbol - - - mPointSymbolComboBox - - - - - + + + + + 0 + 0 + 0 + 0 + + - Fill Patterns: + Style Options - 4 + 11 - 4 + 6 - - - - - 60 - 30 - - + + - + Outline style - - - 50 - 20 - + + btnOutlineColor - - true - - - true - - - - - - 60 - 30 - + + + + Qt::Horizontal - - - - + - 50 + 161 20 - - true - - - true - - + - - - - - 60 - 30 - - - - - - - - 50 - 20 - - - - true - - - true - - - - - - - - 60 - 30 - - - - - - - - 50 - 20 - - - - true - - - true - - - - - - - - 60 - 30 - - - - - - - - 50 - 20 - - - - true - - - true - - - - - - - - 60 - 30 - - - - - - - - 50 - 20 - - - - true - - - true - - - - + - 1 - 1 + 0 + 0 0 0 - - - 0 - 0 - - - - - 60 - 30 - - - - - - - - 50 - 20 - - - - true - - - true - - - - - - 5 - 5 - 0 - 0 - - - - - 60 - 30 - - + + - + Outline color - - - 50 - 20 - + + btnOutlineColor - - true - - - true - - - - - - 60 - 30 - + + + + Qt::Horizontal - - + + QSizePolicy::Expanding - + - 50 - 20 + 116 + 16 - - true - - - true - - + - - - - - 60 - 30 - - - - - - - - 50 - 20 - - - - true - - - true - - - - + - 5 - 5 + 0 + 0 0 0 - 0 + 100 0 - - - 60 - 30 - - - - - 50 - 20 - - - - true - - - true - - - - - - 5 - 5 - 0 - 0 - - - - - 60 - 30 - - + + - + Outline width: - - - 50 - 20 - + + outlinewidthspinbox - - true - - - true - - - - - - 5 - 5 - 0 - 0 - + + + + Qt::Horizontal - - - 0 - 0 - + + QSizePolicy::Expanding - + - 60 - 30 + 201 + 16 - - No Fill - - - - - - - 50 - 20 - - - - true - - - true - - + - - + + - 5 - 5 + 0 + 0 0 0 - 60 - 30 + 99999 + 32767 - - + + 0 - - - 50 - 20 - - - - true - - - true - - - - - - 5 - 5 - 0 - 0 - - - - - 60 - 30 - - - - - - - - 50 - 20 - - - - true - - - true - - - - - - - - - - - 60 - 30 - - - - Browse: - - - - - - - 5 - 5 - 0 - 0 - - - - - 60 - 30 - - + - + Fill color: - - - 50 - 20 - + + btnFillColor - - true - - - true - - - - - - - - Outline Style: - - - - 8 - - - 6 - - - - - - 50 - 30 - - - - - - - - 60 - 26 - - - - true - - - true - - - - - - - - 50 - 30 - - - - - - - - 60 - 26 - - - - true - - - true - - - - - - - - 50 - 30 - - - - - - - - 60 - 26 - - - - true - - - true - - - - - - - - 50 - 30 - - - - - - - - 60 - 26 - - - - true - - - true - - - - - - - - 50 - 30 - - - - - - - - 60 - 26 - - - - true - - - true - - - - - - - - 50 - 30 - - - - - - - - 60 - 26 - - - - true - - - true - - - - - - - - - - - - - - 8 - - - 6 - - + Qt::Horizontal @@ -865,45 +316,22 @@ - 201 + 138 16 - - + + - 4 + 0 0 0 0 - - - 100 - 32767 - - - - 0 - - - - - - - Outline Width: - - - outlinewidthspinbox - - - - - 100 @@ -915,74 +343,65 @@ - - - - - 100 - 0 - - + + - + Fill style - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 138 - 16 - - - - - - - - Fill Color: - btnFillColor - - - - Outline color: - - - btnOutlineColor - - - - + Qt::Horizontal - - QSizePolicy::Expanding - - 116 - 16 + 40 + 20 + + + + 11 + + + 6 + + + + + + + + ... + + + + + + + + + Qt::Vertical + + + + 20 + 21 + + + + @@ -996,32 +415,10 @@ mLabelEdit - mPointSymbolComboBox mPointSizeSpinBox - pbnLineSolid - pbnLineDot - pbnLineDashDot - pbnLineDash - pbnLineDashDotDot - pbnLineNoPen btnOutlineColor outlinewidthspinbox btnFillColor - solid - fdiag - dense4 - horizontal - bdiag - diagcross - dense5 - vertical - dense1 - dense3 - dense6 - cross - dense2 - dense7 - nopen