diff --git a/python/core/auto_generated/mesh/qgsmeshlayer.sip.in b/python/core/auto_generated/mesh/qgsmeshlayer.sip.in index 2150d82f4bf..91997f9ba16 100644 --- a/python/core/auto_generated/mesh/qgsmeshlayer.sip.in +++ b/python/core/auto_generated/mesh/qgsmeshlayer.sip.in @@ -110,9 +110,9 @@ QgsMeshLayer cannot be copied. virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) /Factory/; virtual bool readSymbology( const QDomNode &node, QString &errorMessage, - QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ); + QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, - const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const; + const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const; virtual QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const; virtual QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const; diff --git a/python/core/auto_generated/qgsmaplayer.sip.in b/python/core/auto_generated/qgsmaplayer.sip.in index 69a6f477694..add32343157 100644 --- a/python/core/auto_generated/qgsmaplayer.sip.in +++ b/python/core/auto_generated/qgsmaplayer.sip.in @@ -89,7 +89,7 @@ This is the base class for all map layer types (vector, raster). AttributeTable, Rendering, CustomProperties, - AllCategories + AllStyleCategories }; typedef QFlags StyleCategories; @@ -824,7 +824,7 @@ Retrieve a named style for this layer from a sqlite database. %End virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg /Out/, - QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ); + QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); %Docstring Import the properties of this layer from a QDomDocument @@ -838,13 +838,14 @@ Import the properties of this layer from a QDomDocument .. versionadded:: 2.8 %End - virtual void exportNamedStyle( QDomDocument &doc, QString &errorMsg /Out/, QgsReadWriteContext &context, - QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const; + virtual void exportNamedStyle( QDomDocument &doc, QString &errorMsg /Out/, const QgsReadWriteContext &context = QgsReadWriteContext(), + QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const; %Docstring Export the properties of this layer as named style in a QDomDocument :param doc: the target QDomDocument :param errorMsg: this QString will be initialized on error +:param context: read write context :param categories: the style categories to export during the execution of writeSymbology %End @@ -923,25 +924,27 @@ Attempts to style the layer using the formatting from an SLD type file. virtual bool readSymbology( const QDomNode &node, QString &errorMessage, - QgsReadWriteContext &context, StyleCategories categories = AllCategories ) = 0; + QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) = 0; %Docstring Read the symbology for the current layer from the DOM node supplied. :param node: node that will contain the symbology definition for this layer. :param errorMessage: reference to string that will be updated with any error messages :param context: reading context (used for transform from relative to absolute paths) +:param categories: the style categories to be read :return: true in case of success. %End virtual bool readStyle( const QDomNode &node, QString &errorMessage, - QgsReadWriteContext &context, StyleCategories categories = AllCategories ); + QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ); %Docstring Read the style for the current layer from the DOM node supplied. :param node: node that will contain the style definition for this layer. :param errorMessage: reference to string that will be updated with any error messages :param context: reading context (used for transform from relative to absolute paths) +:param categories: the style categories to be read :return: true in case of success. @@ -953,7 +956,7 @@ Read the style for the current layer from the DOM node supplied. %End virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, - StyleCategories categories = AllCategories ) const = 0; + StyleCategories categories = AllStyleCategories ) const = 0; %Docstring Write the style for the layer into the docment provided. @@ -961,6 +964,7 @@ Write the style for the layer into the docment provided. :param doc: the document that will have the QDomNode added. :param errorMessage: reference to string that will be updated with any error messages :param context: writing context (used for transform from absolute to relative paths) +:param categories: the style categories to be written .. note:: @@ -970,7 +974,7 @@ Write the style for the layer into the docment provided. %End virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, - StyleCategories categories = AllCategories ) const; + StyleCategories categories = AllStyleCategories ) const; %Docstring Write just the symbology information for the layer into the document @@ -978,6 +982,7 @@ Write just the symbology information for the layer into the document :param doc: the document that will have the QDomNode added. :param errorMessage: reference to string that will be updated with any error messages :param context: writing context (used for transform from absolute to relative paths) +:param categories: the style categories to be written :return: true in case of success. @@ -1546,7 +1551,7 @@ Write style manager's configuration (if exists). To be called by subclasses. void writeCommonStyle( QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, - StyleCategories categories = AllCategories ) const; + StyleCategories categories = AllStyleCategories ) const; %Docstring Write style data common to all layer types @@ -1554,7 +1559,7 @@ Write style data common to all layer types %End void readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context, - StyleCategories categories = AllCategories ); + StyleCategories categories = AllStyleCategories ); %Docstring Read style data common to all layer types diff --git a/python/core/auto_generated/qgsvectorlayer.sip.in b/python/core/auto_generated/qgsvectorlayer.sip.in index 16a7cfd2457..8d5d146719e 100644 --- a/python/core/auto_generated/qgsvectorlayer.sip.in +++ b/python/core/auto_generated/qgsvectorlayer.sip.in @@ -871,7 +871,7 @@ Returns the current auxiliary layer. virtual bool readSymbology( const QDomNode &layerNode, QString &errorMessage, - QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ); + QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); %Docstring Read the symbology for the current layer from the Dom node supplied. @@ -883,7 +883,7 @@ Read the symbology for the current layer from the Dom node supplied. %End virtual bool readStyle( const QDomNode &node, QString &errorMessage, - QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ); + QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); %Docstring Read the style for the current layer from the Dom node supplied. @@ -895,7 +895,7 @@ Read the style for the current layer from the Dom node supplied. %End virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, - const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const; + const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const; %Docstring Write the symbology for the layer into the docment provided. @@ -908,7 +908,7 @@ Write the symbology for the layer into the docment provided. %End virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, - const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const; + const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const; %Docstring Write just the style information for the layer into the document diff --git a/python/core/auto_generated/raster/qgsrasterlayer.sip.in b/python/core/auto_generated/raster/qgsrasterlayer.sip.in index d4935874f18..f62f9a742a9 100644 --- a/python/core/auto_generated/raster/qgsrasterlayer.sip.in +++ b/python/core/auto_generated/raster/qgsrasterlayer.sip.in @@ -348,16 +348,16 @@ Draws a preview of the rasterlayer into a QImage void showStatusMessage( const QString &message ); protected: - virtual bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ); + virtual bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); - virtual bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ); + virtual bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); virtual bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ); virtual bool writeSymbology( QDomNode &, QDomDocument &doc, QString &errorMessage, - const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const; + const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const; virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, - const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const; + const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const; virtual bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const; virtual QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const; diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index edd84be279e..3a75e185ce7 100755 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -138,6 +138,7 @@ SET(QGIS_APP_SRCS qgssvgannotationdialog.cpp qgsundowidget.cpp qgsvectorlayerlegendwidget.cpp + qgsvectorlayerloadsavestyledialog.cpp qgsvectorlayerproperties.cpp qgsmapthemes.cpp qgshandlebadlayers.cpp @@ -377,6 +378,7 @@ SET (QGIS_APP_MOC_HDRS qgstextannotationdialog.h qgsundowidget.h qgsvectorlayerlegendwidget.h + qgsvectorlayerloadsavestyledialog.h qgsvectorlayerproperties.h qgsmapthemes.h qgshandlebadlayers.h diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index e37d16e3a03..8e8b421d8c1 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -834,7 +834,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow * \param sourceLayer The layer where the style will be taken from (defaults to the active layer on the legend) * \param categories The style categories to copy */ - void copyStyle( QgsMapLayer *sourceLayer = nullptr, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ); + void copyStyle( QgsMapLayer *sourceLayer = nullptr, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); //! pastes style on the clipboard to the active layer /** @@ -842,7 +842,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow * \param categories The style categories to copy */ void pasteStyle( QgsMapLayer *destinationLayer = nullptr, - QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ); + QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); //! copies group or layer on the clipboard void copyLayer(); //! pastes group or layer from the clipboard to layer tree diff --git a/src/app/qgsapplayertreeviewmenuprovider.cpp b/src/app/qgsapplayertreeviewmenuprovider.cpp index db281fe45a1..d054cb863b5 100644 --- a/src/app/qgsapplayertreeviewmenuprovider.cpp +++ b/src/app/qgsapplayertreeviewmenuprovider.cpp @@ -321,7 +321,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() QMenu *copyStyleMenu = menuStyleManager->addMenu( tr( "Copy Style" ) ); copyStyleMenu->setToolTipsVisible( true ); QList categories = qgsEnumMap().keys(); - categories.move( categories.indexOf( QgsMapLayer::AllCategories ), 0 ); // move All categories to top + categories.move( categories.indexOf( QgsMapLayer::AllStyleCategories ), 0 ); // move All categories to top for ( QgsMapLayer::StyleCategory category : categories ) { QgsMapLayer::ReadableStyleCategory readableCategory = QgsMapLayer::readableStyleCategory( category ); @@ -329,7 +329,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() copyAction->setToolTip( readableCategory.toolTip() ); connect( copyAction, &QAction::triggered, this, [ = ]() {app->copyStyle( layer, category );} ); copyStyleMenu->addAction( copyAction ); - if ( category == QgsMapLayer::AllCategories ) + if ( category == QgsMapLayer::AllStyleCategories ) copyStyleMenu->addSeparator(); } } @@ -345,7 +345,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() QMenu *copyStyleMenu = menuStyleManager->addMenu( tr( "Paste Style" ) ); copyStyleMenu->setToolTipsVisible( true ); QList categories = qgsEnumMap().keys(); - categories.move( categories.indexOf( QgsMapLayer::AllCategories ), 0 ); // move All categories to top + categories.move( categories.indexOf( QgsMapLayer::AllStyleCategories ), 0 ); // move All categories to top for ( QgsMapLayer::StyleCategory category : categories ) { QgsMapLayer::ReadableStyleCategory readableCategory = QgsMapLayer::readableStyleCategory( category ); @@ -353,7 +353,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() copyAction->setToolTip( readableCategory.toolTip() ); connect( copyAction, &QAction::triggered, this, [ = ]() {app->pasteStyle( layer, category );} ); copyStyleMenu->addAction( copyAction ); - if ( category == QgsMapLayer::AllCategories ) + if ( category == QgsMapLayer::AllStyleCategories ) copyStyleMenu->addSeparator(); } } diff --git a/src/app/qgsvectorlayerloadsavestyledialog.cpp b/src/app/qgsvectorlayerloadsavestyledialog.cpp new file mode 100644 index 00000000000..c3597437389 --- /dev/null +++ b/src/app/qgsvectorlayerloadsavestyledialog.cpp @@ -0,0 +1,96 @@ +/*************************************************************************** + qgsvectorlayerloadsavestyledialog.h + -------------------------------------- + Date : September 2018 + Copyright : (C) 2018 by Denis Rouzaud + Email : denis@opengis.ch + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include + +#include "qgsvectorlayerloadsavestyledialog.h" +#include "qgsvectorlayer.h" +#include "qgssettings.h" +#include "qgisapp.h" +#include "qgshelp.h" + +QgsVectorLayerLoadSaveStyleDialog::QgsVectorLayerLoadSaveStyleDialog( QgsVectorLayer *layer, Mode mode, QWidget *parent ) + : QDialog( parent ) + , mLayer( layer ) + , mMode( mode ) +{ + setupUi( this ); + + QString providerName = mLayer->providerType(); + if ( providerName == QLatin1String( "ogr" ) ) + { + providerName = mLayer->dataProvider()->storageType(); + if ( providerName == QLatin1String( "GPKG" ) ) + providerName = QStringLiteral( "GeoPackage" ); + } + + //QStringLiteral( "style/lastStyleDir" ) + + QgsSettings settings; + QgsMapLayer::StyleCategories lastStyleCategories = settings.flagValue( QStringLiteral( "style/lastStyleCategories" ), QgsMapLayer::AllStyleCategories ); + + + switch ( mMode ) + { + case Save: + mModeLabel->setText( tr( "Save" ) ); + mStyleTypeComboBox->addItem( tr( "from file" ), GenericFile ); + if ( mLayer->dataProvider()->isSaveAndLoadStyleToDatabaseSupported() ) + mStyleTypeComboBox->addItem( tr( "from database (%1)" ).arg( providerName ), DB ); + break; + case Load: + mModeLabel->setText( tr( "Load" ) ); + mStyleTypeComboBox->addItem( tr( "as QGIS QML style file" ), QML ); + mStyleTypeComboBox->addItem( tr( "as SLD style file" ), SLD ); + if ( mLayer->dataProvider()->isSaveAndLoadStyleToDatabaseSupported() ) + mStyleTypeComboBox->addItem( tr( "in database (%1)" ).arg( providerName ), DB ); + break; + } + + connect( mStyleTypeComboBox, qgis::overload::of( &QComboBox::currentIndexChanged ), this, [ = ]( int idx ) {mFileWidget->setVisible( mStyleTypeComboBox->itemData( idx ) != DB );} ); + + for ( QgsMapLayer::StyleCategory category : qgsEnumMap().keys() ) + { + if ( category == QgsMapLayer::AllStyleCategories ) + continue; + + QgsMapLayer::ReadableStyleCategory readableCategory = QgsMapLayer::readableStyleCategory( category ); + + QListWidgetItem *item = new QListWidgetItem( readableCategory.icon(), readableCategory.name(), mStyleCategoriesListWidget ); + item->setFlags( item->flags() | Qt::ItemIsUserCheckable ); + item->setCheckState( lastStyleCategories.testFlag( category ) ? Qt::Checked : Qt::Unchecked ); + item->setData( Qt::UserRole, category ); + } +} + +void QgsVectorLayerLoadSaveStyleDialog::accept() +{ + bool ok = true; + QgsMapLayer::StyleCategories lastStyleCategories; + for ( int row = 0; row < mStyleCategoriesListWidget->count(); ++row ) + { + QListWidgetItem *item = mStyleCategoriesListWidget->item( row ); + if ( item->checkState() == Qt::Checked ) + lastStyleCategories |= static_cast( item->data( Qt::UserRole ).toInt() ); + } + + if ( ok ) + { + QgsSettings settings; + settings.setFlagValue( QStringLiteral( "style/lastStyleCategories" ), lastStyleCategories ); + close(); + } +} diff --git a/src/app/qgsvectorlayerloadsavestyledialog.h b/src/app/qgsvectorlayerloadsavestyledialog.h new file mode 100644 index 00000000000..531c077855d --- /dev/null +++ b/src/app/qgsvectorlayerloadsavestyledialog.h @@ -0,0 +1,55 @@ +/*************************************************************************** + qgsvectorlayerloadsavestyledialog.h + -------------------------------------- + Date : September 2018 + Copyright : (C) 2018 by Denis Rouzaud + Email : denis@opengis.ch + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSVECTORLAYERLOADSAVESTYLEDIALOG_H +#define QGSVECTORLAYERLOADSAVESTYLEDIALOG_H + +#include +#include "ui_qgsvectorlayerloadsavestyledialog.h" + +class QgsVectorLayer; + + +class QgsVectorLayerLoadSaveStyleDialog : public QDialog, private Ui::QgsVectorLayerLoadSaveStyleDialog +{ + Q_OBJECT + + public: + enum Mode + { + Save, + Load + }; + + enum StyleType + { + GenericFile, + QML, + SLD, + DB, + }; + + explicit QgsVectorLayerLoadSaveStyleDialog( QgsVectorLayer *layer, Mode mode, QWidget *parent = nullptr ); + ~QgsVectorLayerLoadSaveStyleDialog() = default; + + public slots: + void accept(); + + private: + QgsVectorLayer *mLayer; + Mode mMode; +}; + +#endif // QGSVECTORLAYERLOADSAVESTYLE_H diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index 0b387030985..7acae4a6f25 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -63,6 +63,7 @@ #include "qgslabelinggui.h" #include "qgssymbollayer.h" #include "qgsgeometryfixes.h" +#include "qgsvectorlayerloadsavestyledialog.h" #include "layertree/qgslayertreelayer.h" #include "qgslayertree.h" @@ -117,8 +118,8 @@ QgsVectorLayerProperties::QgsVectorLayerProperties( mBtnStyle = new QPushButton( tr( "Style" ), this ); QMenu *menuStyle = new QMenu( this ); - mActionLoadStyle = menuStyle->addAction( tr( "Load Style" ), this, SLOT( loadStyle_clicked() ) ); - mActionSaveStyleAs = menuStyle->addAction( tr( "Save Style" ), this, SLOT( saveStyleAs_clicked() ) ); + mActionLoadStyle = menuStyle->addAction( tr( "Load Style" ), this, &QgsVectorLayerProperties::loadStyle_clicked ); + menuStyle->addAction( tr( "Save Style" ), this, &QgsVectorLayerProperties::saveStyleAs ); menuStyle->addSeparator(); menuStyle->addAction( tr( "Save as Default" ), this, SLOT( saveDefaultStyle_clicked() ) ); menuStyle->addAction( tr( "Restore Default" ), this, SLOT( loadDefaultStyle_clicked() ) ); @@ -186,11 +187,6 @@ QgsVectorLayerProperties::QgsVectorLayerProperties( mActionDialog->layout()->setMargin( 0 ); actionLayout->addWidget( mActionDialog ); - // Create the menu for the save style button to choose the output format - mSaveAsMenu = new QMenu( this ); - mSaveAsMenu->addAction( tr( "QGIS Layer Style File…" ) ); - mSaveAsMenu->addAction( tr( "SLD File…" ) ); - //Only if the provider support loading & saving styles to db add new choices if ( mLayer->dataProvider()->isSaveAndLoadStyleToDatabaseSupported() ) { @@ -203,21 +199,8 @@ QgsVectorLayerProperties::QgsVectorLayerProperties( connect( mLoadStyleMenu, &QMenu::triggered, this, &QgsVectorLayerProperties::loadStyleMenuTriggered ); - - //for saving - QString providerName = mLayer->providerType(); - if ( providerName == QLatin1String( "ogr" ) ) - { - providerName = mLayer->dataProvider()->storageType(); - if ( providerName == QLatin1String( "GPKG" ) ) - providerName = QStringLiteral( "GeoPackage" ); - } - mSaveAsMenu->addAction( tr( "Save in Database (%1)" ).arg( providerName ) ); } - connect( mSaveAsMenu, &QMenu::triggered, - this, &QgsVectorLayerProperties::saveStyleAsMenuTriggered ); - mSourceFieldsPropertiesDialog = new QgsSourceFieldsProperties( mLayer, mSourceFieldsFrame ); mSourceFieldsPropertiesDialog->layout()->setMargin( 0 ); mSourceFieldsFrame->setLayout( new QVBoxLayout( mSourceFieldsFrame ) ); @@ -992,8 +975,8 @@ void QgsVectorLayerProperties::saveDefaultStyle_clicked() void QgsVectorLayerProperties::loadStyle_clicked() { - QgsSettings myQSettings; // where we keep last used filter in persistent state - QString myLastUsedDir = myQSettings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString(); + QgsSettings settings; // where we keep last used filter in persistent state + QString myLastUsedDir = settings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString(); QString myFileName = QFileDialog::getOpenFileName( this, tr( "Load Layer Properties from Style File" ), myLastUsedDir, tr( "QGIS Layer Style File" ) + " (*.qml);;" + tr( "SLD File" ) + " (*.sld)" ); @@ -1029,17 +1012,12 @@ void QgsVectorLayerProperties::loadStyle_clicked() QFileInfo myFI( myFileName ); QString myPath = myFI.path(); - myQSettings.setValue( QStringLiteral( "style/lastStyleDir" ), myPath ); + settings.setValue( QStringLiteral( "style/lastStyleDir" ), myPath ); activateWindow(); // set focus back to properties dialog } -void QgsVectorLayerProperties::saveStyleAs_clicked() -{ - saveStyleAs( QML ); -} - void QgsVectorLayerProperties::loadMetadata() { QgsSettings myQSettings; // where we keep last used filter in persistent state @@ -1142,116 +1120,109 @@ void QgsVectorLayerProperties::loadDefaultMetadata() } } -void QgsVectorLayerProperties::saveStyleAsMenuTriggered( QAction *action ) + +void QgsVectorLayerProperties::saveStyleAs() { - QMenu *menu = qobject_cast( sender() ); - if ( !menu ) - return; + QgsVectorLayerLoadSaveStyleDialog dlg( mLayer, QgsVectorLayerLoadSaveStyleDialog::Save ); + dlg.exec(); - int index = mSaveAsMenu->actions().indexOf( action ); - if ( index < 0 ) - return; + /* + QgsSettings myQSettings; // where we keep last used filter in persistent state + QString myLastUsedDir = myQSettings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString(); - saveStyleAs( static_cast< StyleType >( index ) ); -} - -void QgsVectorLayerProperties::saveStyleAs( StyleType styleType ) -{ - QgsSettings myQSettings; // where we keep last used filter in persistent state - QString myLastUsedDir = myQSettings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString(); - - if ( styleType == DB ) - { - QString infoWindowTitle = QObject::tr( "Save style to DB (%1)" ).arg( mLayer->providerType() ); - QString msgError; - - QgsSaveStyleToDbDialog askToUser; - //Ask the user for a name and a description about the style - if ( askToUser.exec() == QDialog::Accepted ) + if ( styleType == DB ) { - QString styleName = askToUser.getName(); - QString styleDesc = askToUser.getDescription(); - QString uiFileContent = askToUser.getUIFileContent(); - bool isDefault = askToUser.isDefault(); + QString infoWindowTitle = QObject::tr( "Save style to DB (%1)" ).arg( mLayer->providerType() ); + QString msgError; - apply(); - - mLayer->saveStyleToDatabase( styleName, styleDesc, isDefault, uiFileContent, msgError ); - - if ( !msgError.isNull() ) + QgsSaveStyleToDbDialog askToUser; + //Ask the user for a name and a description about the style + if ( askToUser.exec() == QDialog::Accepted ) { - QgisApp::instance()->messageBar()->pushMessage( infoWindowTitle, msgError, Qgis::Warning, QgisApp::instance()->messageTimeout() ); + QString styleName = askToUser.getName(); + QString styleDesc = askToUser.getDescription(); + QString uiFileContent = askToUser.getUIFileContent(); + bool isDefault = askToUser.isDefault(); + + apply(); + + mLayer->saveStyleToDatabase( styleName, styleDesc, isDefault, uiFileContent, msgError ); + + if ( !msgError.isNull() ) + { + QgisApp::instance()->messageBar()->pushMessage( infoWindowTitle, msgError, Qgis::Warning, QgisApp::instance()->messageTimeout() ); + } + else + { + QgisApp::instance()->messageBar()->pushMessage( infoWindowTitle, tr( "Style saved" ), Qgis::Info, QgisApp::instance()->messageTimeout() ); + } + } else { - QgisApp::instance()->messageBar()->pushMessage( infoWindowTitle, tr( "Style saved" ), Qgis::Info, QgisApp::instance()->messageTimeout() ); + return; + } + } + else + { + + QString format, extension; + if ( styleType == SLD ) + { + format = tr( "SLD File" ) + " (*.sld)"; + extension = QStringLiteral( ".sld" ); + } + else + { + format = tr( "QGIS Layer Style File" ) + " (*.qml)"; + extension = QgsMapLayer::extensionPropertyType( QgsMapLayer::Style ); } - } - else - { - return; - } - } - else - { + QString myOutputFileName = QFileDialog::getSaveFileName( this, tr( "Save Layer Properties as Style File" ), + myLastUsedDir, format ); + if ( myOutputFileName.isNull() ) //dialog canceled + { + return; + } - QString format, extension; - if ( styleType == SLD ) - { - format = tr( "SLD File" ) + " (*.sld)"; - extension = QStringLiteral( ".sld" ); - } - else - { - format = tr( "QGIS Layer Style File" ) + " (*.qml)"; - extension = QgsMapLayer::extensionPropertyType( QgsMapLayer::Style ); - } + apply(); // make sure the style to save is uptodate - QString myOutputFileName = QFileDialog::getSaveFileName( this, tr( "Save Layer Properties as Style File" ), - myLastUsedDir, format ); - if ( myOutputFileName.isNull() ) //dialog canceled - { - return; - } + QString myMessage; + bool defaultLoadedFlag = false; - apply(); // make sure the style to save is uptodate + //ensure the user never omitted the extension from the file name + if ( !myOutputFileName.endsWith( extension, Qt::CaseInsensitive ) ) + { + myOutputFileName += extension; + } - QString myMessage; - bool defaultLoadedFlag = false; + if ( styleType == SLD ) + { + // convert to SLD + myMessage = mLayer->saveSldStyle( myOutputFileName, defaultLoadedFlag ); + } + else + { + myMessage = mLayer->saveNamedStyle( myOutputFileName, defaultLoadedFlag ); + } - //ensure the user never omitted the extension from the file name - if ( !myOutputFileName.endsWith( extension, Qt::CaseInsensitive ) ) - { - myOutputFileName += extension; - } + //reset if the default style was loaded OK only + if ( defaultLoadedFlag ) + { + syncToLayer(); + } + else + { + //let the user know what went wrong + QMessageBox::information( this, tr( "Save Style" ), myMessage ); + } - if ( styleType == SLD ) - { - // convert to SLD - myMessage = mLayer->saveSldStyle( myOutputFileName, defaultLoadedFlag ); + QFileInfo myFI( myOutputFileName ); + QString myPath = myFI.path(); + // Persist last used dir + myQSettings.setValue( QStringLiteral( "style/lastStyleDir" ), myPath ); } - else - { - myMessage = mLayer->saveNamedStyle( myOutputFileName, defaultLoadedFlag ); - } - - //reset if the default style was loaded OK only - if ( defaultLoadedFlag ) - { - syncToLayer(); - } - else - { - //let the user know what went wrong - QMessageBox::information( this, tr( "Save Style" ), myMessage ); - } - - QFileInfo myFI( myOutputFileName ); - QString myPath = myFI.path(); - // Persist last used dir - myQSettings.setValue( QStringLiteral( "style/lastStyleDir" ), myPath ); - } + */ } void QgsVectorLayerProperties::loadStyleMenuTriggered( QAction *action ) @@ -1596,11 +1567,6 @@ void QgsVectorLayerProperties::updateSymbologyPage() connect( mRendererDialog, &QgsRendererPropertiesDialog::showPanel, this, &QgsVectorLayerProperties::openPanel ); connect( mRendererDialog, &QgsRendererPropertiesDialog::layerVariablesChanged, this, &QgsVectorLayerProperties::updateVariableEditor ); connect( mRendererDialog, &QgsRendererPropertiesDialog::widgetChanged, this, [ = ] { updateAuxiliaryStoragePage(); } ); - - // display the menu to choose the output format (fix #5136) - mActionSaveStyleAs->setText( tr( "Save Style" ) ); - mActionSaveStyleAs->setMenu( mSaveAsMenu ); - disconnect( mActionSaveStyleAs, &QAction::triggered, this, &QgsVectorLayerProperties::saveStyleAs_clicked ); } else { diff --git a/src/app/qgsvectorlayerproperties.h b/src/app/qgsvectorlayerproperties.h index 0762ba75fb0..42b0f84c5c9 100644 --- a/src/app/qgsvectorlayerproperties.h +++ b/src/app/qgsvectorlayerproperties.h @@ -116,7 +116,6 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private void loadDefaultStyle_clicked(); void saveDefaultStyle_clicked(); void loadStyle_clicked(); - void saveStyleAs_clicked(); void loadMetadata(); void saveMetadataAs(); void saveDefaultMetadata(); @@ -144,7 +143,7 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private void toggleEditing(); //! Save the style based on selected format from the menu - void saveStyleAsMenuTriggered( QAction * ); + void saveStyleAs(); //! Called when is possible to choice if load the style from filesystem or from db void loadStyleMenuTriggered( QAction * ); @@ -178,8 +177,6 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private Metadata, }; - void saveStyleAs( StyleType styleType ); - //! When provider supports, it will list all the styles relative the layer in a dialog void showListOfStylesFromDatabase(); @@ -198,7 +195,6 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private QAction *mActionLoadMetadata = nullptr; QAction *mActionSaveMetadataAs = nullptr; - QMenu *mSaveAsMenu = nullptr; QMenu *mLoadStyleMenu = nullptr; QAction *mActionLoadStyle = nullptr; diff --git a/src/core/mesh/qgsmeshlayer.h b/src/core/mesh/qgsmeshlayer.h index f5e2c633b80..5fe471ebe12 100644 --- a/src/core/mesh/qgsmeshlayer.h +++ b/src/core/mesh/qgsmeshlayer.h @@ -126,9 +126,9 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer QgsRectangle extent() const override; QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY; bool readSymbology( const QDomNode &node, QString &errorMessage, - QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override; + QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) override; bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, - const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override; + const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const override; QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override; QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const override; bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override; diff --git a/src/core/qgsmaplayer.cpp b/src/core/qgsmaplayer.cpp index f0bf88cf9db..1ee521cd198 100644 --- a/src/core/qgsmaplayer.cpp +++ b/src/core/qgsmaplayer.cpp @@ -111,7 +111,7 @@ QgsMapLayer::ReadableStyleCategory QgsMapLayer::readableStyleCategory( QgsMapLay case CustomProperties : return ReadableStyleCategory( tr( "Custom Properties" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionOptions.svg" ) ) ); - case AllCategories : + case AllStyleCategories : return ReadableStyleCategory( tr( "All Categories" ) ); } } @@ -1138,7 +1138,7 @@ void QgsMapLayer::exportNamedMetadata( QDomDocument &doc, QString &errorMsg ) co doc = myDocument; } -void QgsMapLayer::exportNamedStyle( QDomDocument &doc, QString &errorMsg, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const +void QgsMapLayer::exportNamedStyle( QDomDocument &doc, QString &errorMsg, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const { QDomImplementation DomImplementation; QDomDocumentType documentType = DomImplementation.createDocumentType( QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); diff --git a/src/core/qgsmaplayer.h b/src/core/qgsmaplayer.h index f4b6f1c25b7..1da3d23e073 100644 --- a/src/core/qgsmaplayer.h +++ b/src/core/qgsmaplayer.h @@ -37,13 +37,13 @@ #include "qgsmaplayerdependency.h" #include "qgslayermetadata.h" #include "qgsmaplayerstyle.h" +#include "qgsreadwritecontext.h" class QgsAbstract3DRenderer; class QgsDataProvider; class QgsMapLayerLegend; class QgsMapLayerRenderer; class QgsMapLayerStyleManager; -class QgsReadWriteContext; class QgsProject; class QDomDocument; @@ -153,8 +153,8 @@ class CORE_EXPORT QgsMapLayer : public QObject AttributeTable = 1 << 9, //!< Attribute table settings: choice and order of columns, conditional styling Rendering = 1 << 10, //!< Rendering: scale visibility, simplify method, opacity CustomProperties = 1 << 11, //!< Custom properties (by plugins for instance) - AllCategories = LayerConfiguration | Symbology | Labeling | Fields | Forms | Actions | - MapTips | Diagrams | AttributeTable | Rendering | CustomProperties, + AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions | + MapTips | Diagrams | AttributeTable | Rendering | CustomProperties, }; Q_ENUM( StyleCategory ) Q_DECLARE_FLAGS( StyleCategories, StyleCategory ) @@ -793,17 +793,18 @@ class CORE_EXPORT QgsMapLayer : public QObject * \since QGIS 2.8 */ virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg SIP_OUT, - QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ); + QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); /** * Export the properties of this layer as named style in a QDomDocument * \param doc the target QDomDocument * \param errorMsg this QString will be initialized on error + * \param context read write context * \param categories the style categories to export * during the execution of writeSymbology */ - virtual void exportNamedStyle( QDomDocument &doc, QString &errorMsg SIP_OUT, QgsReadWriteContext &context, - QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const; + virtual void exportNamedStyle( QDomDocument &doc, QString &errorMsg SIP_OUT, const QgsReadWriteContext &context = QgsReadWriteContext(), + QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const; /** @@ -871,22 +872,24 @@ class CORE_EXPORT QgsMapLayer : public QObject * \param node node that will contain the symbology definition for this layer. * \param errorMessage reference to string that will be updated with any error messages * \param context reading context (used for transform from relative to absolute paths) + * \param categories the style categories to be read * \returns true in case of success. */ virtual bool readSymbology( const QDomNode &node, QString &errorMessage, - QgsReadWriteContext &context, StyleCategories categories = AllCategories ) = 0; + QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) = 0; /** * Read the style for the current layer from the DOM node supplied. * \param node node that will contain the style definition for this layer. * \param errorMessage reference to string that will be updated with any error messages * \param context reading context (used for transform from relative to absolute paths) + * \param categories the style categories to be read * \returns true in case of success. * \note To be implemented in subclasses. Default implementation does nothing and returns false. * \since QGIS 2.16 */ virtual bool readStyle( const QDomNode &node, QString &errorMessage, - QgsReadWriteContext &context, StyleCategories categories = AllCategories ); + QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ); /** * Write the style for the layer into the docment provided. @@ -894,11 +897,12 @@ class CORE_EXPORT QgsMapLayer : public QObject * \param doc the document that will have the QDomNode added. * \param errorMessage reference to string that will be updated with any error messages * \param context writing context (used for transform from absolute to relative paths) + * \param categories the style categories to be written * \note There is a confusion of terms with the GUI. This method actually writes what is called a style in the application. * \returns true in case of success. */ virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, - StyleCategories categories = AllCategories ) const = 0; + StyleCategories categories = AllStyleCategories ) const = 0; /** * Write just the symbology information for the layer into the document @@ -906,13 +910,14 @@ class CORE_EXPORT QgsMapLayer : public QObject * \param doc the document that will have the QDomNode added. * \param errorMessage reference to string that will be updated with any error messages * \param context writing context (used for transform from absolute to relative paths) + * \param categories the style categories to be written * \returns true in case of success. * \note To be implemented in subclasses. Default implementation does nothing and returns false. * \note There is a confusion of terms with the GUI. This method actually writes what is known as the symbology in the application. * \since QGIS 2.16 */ virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, - StyleCategories categories = AllCategories ) const; + StyleCategories categories = AllStyleCategories ) const; //! Returns pointer to layer's undo stack QUndoStack *undoStack(); @@ -1359,14 +1364,14 @@ class CORE_EXPORT QgsMapLayer : public QObject */ void writeCommonStyle( QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, - StyleCategories categories = AllCategories ) const; + StyleCategories categories = AllStyleCategories ) const; /** * Read style data common to all layer types * \since QGIS 3.0 */ void readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context, - StyleCategories categories = AllCategories ); + StyleCategories categories = AllStyleCategories ); #ifndef SIP_RUN #if 0 diff --git a/src/core/qgsvectorlayer.h b/src/core/qgsvectorlayer.h index 402095bc075..eef0bdfc962 100644 --- a/src/core/qgsvectorlayer.h +++ b/src/core/qgsvectorlayer.h @@ -881,7 +881,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte * \returns true in case of success. */ bool readSymbology( const QDomNode &layerNode, QString &errorMessage, - QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override; + QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) override; /** * Read the style for the current layer from the Dom node supplied. @@ -891,7 +891,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte * \returns true in case of success. */ bool readStyle( const QDomNode &node, QString &errorMessage, - QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override; + QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) override; /** * Write the symbology for the layer into the docment provided. @@ -902,7 +902,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte * \returns true in case of success. */ bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, - const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override; + const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const override; /** * Write just the style information for the layer into the document @@ -913,7 +913,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte * \returns true in case of success. */ bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, - const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override; + const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const override; /** * Writes the symbology of the layer into the document provided in SLD 1.1 format diff --git a/src/core/raster/qgsrasterlayer.h b/src/core/raster/qgsrasterlayer.h index 822b397bb97..6205041ee50 100644 --- a/src/core/raster/qgsrasterlayer.h +++ b/src/core/raster/qgsrasterlayer.h @@ -404,13 +404,13 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer void showStatusMessage( const QString &message ); protected: - bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override; - bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) override; + bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) override; + bool readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) override; bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override; bool writeSymbology( QDomNode &, QDomDocument &doc, QString &errorMessage, - const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override; + const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const override; bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, - const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllCategories ) const override; + const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const override; bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override; QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const override; QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const override; diff --git a/src/ui/qgsvectorlayerloadsavestyledialog.ui b/src/ui/qgsvectorlayerloadsavestyledialog.ui new file mode 100644 index 00000000000..a3f2a0d8134 --- /dev/null +++ b/src/ui/qgsvectorlayerloadsavestyledialog.ui @@ -0,0 +1,144 @@ + + + QgsVectorLayerLoadSaveStyleDialog + + + + 0 + 0 + 733 + 775 + + + + Dialog + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + TextLabel + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + File + + + + + + + + + + + + + Categories + + + + + + + + + + + QgsFileWidget + QWidget +
qgsfilewidget.h
+ 1 +
+
+ + + + buttonBox + accepted() + QgsVectorLayerLoadSaveStyleDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + QgsVectorLayerLoadSaveStyleDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/tests/src/core/testqgsmaplayer.cpp b/tests/src/core/testqgsmaplayer.cpp index 1f2e6af101b..b5bc96acf90 100644 --- a/tests/src/core/testqgsmaplayer.cpp +++ b/tests/src/core/testqgsmaplayer.cpp @@ -290,10 +290,10 @@ void TestQgsMapLayer::layerRefListUtils() void TestQgsMapLayer::styleCategories() { // control that AllStyleCategories is actually complete - QgsMapLayer::StyleCategories allStyleCategories = QgsMapLayer::AllCategories; + QgsMapLayer::StyleCategories allStyleCategories = QgsMapLayer::AllStyleCategories; for ( QgsMapLayer::StyleCategory category : qgsEnumMap().keys() ) { - if ( category == QgsMapLayer::AllCategories ) + if ( category == QgsMapLayer::AllStyleCategories ) continue; QVERIFY( allStyleCategories.testFlag( category ) );