Skip to content

Commit 576102b

Browse files
committed
reapply some cleanup to 'styles_to_db'
1 parent a905b55 commit 576102b

File tree

8 files changed

+560
-509
lines changed

8 files changed

+560
-509
lines changed

doc/TRANSLATORS

Lines changed: 21 additions & 21 deletions
Large diffs are not rendered by default.

i18n/qgis_de.ts

Lines changed: 177 additions & 129 deletions
Large diffs are not rendered by default.

src/app/qgsvectorlayerproperties.cpp

Lines changed: 190 additions & 189 deletions
Large diffs are not rendered by default.

src/core/qgsvectorlayer.cpp

Lines changed: 130 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <QString>
3333
#include <QDomNode>
3434
#include <QVector>
35-
#include <QMessageBox>
3635

3736
#include "qgsvectorlayer.h"
3837

@@ -74,39 +73,40 @@
7473
#include "qgsdiagramrendererv2.h"
7574
#include "qgsstylev2.h"
7675
#include "qgssymbologyv2conversion.h"
76+
#include "qgspallabeling.h"
7777

7878
#ifdef TESTPROVIDERLIB
7979
#include <dlfcn.h>
8080
#endif
8181

8282
typedef bool saveStyle_t(
83-
const QString& uri,
84-
const QString& qmlStyle,
85-
const QString& sldStyle,
86-
const QString& styleName,
87-
const QString& styleDescription,
88-
const QString& uiFileContent,
89-
bool useAsDefault,
90-
QString& errCause
83+
const QString& uri,
84+
const QString& qmlStyle,
85+
const QString& sldStyle,
86+
const QString& styleName,
87+
const QString& styleDescription,
88+
const QString& uiFileContent,
89+
bool useAsDefault,
90+
QString& errCause
9191
);
9292

9393
typedef QString loadStyle_t(
94-
const QString& uri,
95-
QString& errCause
94+
const QString& uri,
95+
QString& errCause
9696
);
9797

9898
typedef int listStyles_t(
99-
const QString& uri,
100-
QVector<QString> &ids,
101-
QVector<QString> &names,
102-
QVector<QString> &descriptions,
103-
QString& errCause
99+
const QString& uri,
100+
QStringList &ids,
101+
QStringList &names,
102+
QStringList &descriptions,
103+
QString& errCause
104104
);
105105

106106
typedef QString getStyleById_t(
107-
const QString& uri,
108-
QString styleID,
109-
QString& errCause
107+
const QString& uri,
108+
QString styleID,
109+
QString& errCause
110110
);
111111

112112

@@ -3731,151 +3731,152 @@ QDomElement QgsAttributeEditorField::toDomElement( QDomDocument& doc ) const
37313731
return elem;
37323732
}
37333733

3734-
int QgsVectorLayer::listStylesInDatabase( QVector<QString> &ids, QVector<QString> &names, QVector<QString> &descriptions, QString &msgError )
3734+
int QgsVectorLayer::listStylesInDatabase( QStringList &ids, QStringList &names, QStringList &descriptions, QString &msgError )
37353735
{
3736-
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
3737-
QLibrary *myLib = pReg->providerLibrary( mProviderKey );
3738-
if ( !myLib )
3739-
{
3740-
msgError = QObject::tr( "Unable to load %1 provider" ).arg( mProviderKey );
3741-
return -1;
3742-
}
3743-
listStyles_t* listStylesExternalMethod = ( listStyles_t * ) cast_to_fptr(myLib->resolve("listStyles"));
3736+
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
3737+
QLibrary *myLib = pReg->providerLibrary( mProviderKey );
3738+
if ( !myLib )
3739+
{
3740+
msgError = QObject::tr( "Unable to load %1 provider" ).arg( mProviderKey );
3741+
return -1;
3742+
}
3743+
listStyles_t* listStylesExternalMethod = ( listStyles_t * ) cast_to_fptr( myLib->resolve( "listStyles" ) );
37443744

3745-
if ( !listStylesExternalMethod )
3746-
{
3747-
delete myLib;
3748-
msgError = QObject::tr( "Provider %1 has no listStyles method" ).arg( mProviderKey );
3749-
return -1;
3750-
}
3745+
if ( !listStylesExternalMethod )
3746+
{
3747+
delete myLib;
3748+
msgError = QObject::tr( "Provider %1 has no %2 method" ).arg( mProviderKey ).arg( "listStyles" );
3749+
return -1;
3750+
}
37513751

3752-
return listStylesExternalMethod(mDataSource, ids, names, descriptions, msgError);
3752+
return listStylesExternalMethod( mDataSource, ids, names, descriptions, msgError );
37533753
}
37543754

3755-
QString QgsVectorLayer::getStyleFromDatabase(QString styleId, QString &msgError)
3755+
QString QgsVectorLayer::getStyleFromDatabase( QString styleId, QString &msgError )
37563756
{
3757-
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
3758-
QLibrary *myLib = pReg->providerLibrary( mProviderKey );
3759-
if ( !myLib )
3760-
{
3761-
msgError = QObject::tr( "Unable to load %1 provider" ).arg( mProviderKey );
3762-
return QObject::tr( "" );
3763-
}
3764-
getStyleById_t* getStyleByIdMethod = ( getStyleById_t * ) cast_to_fptr(myLib->resolve("getStyleById"));
3757+
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
3758+
QLibrary *myLib = pReg->providerLibrary( mProviderKey );
3759+
if ( !myLib )
3760+
{
3761+
msgError = QObject::tr( "Unable to load %1 provider" ).arg( mProviderKey );
3762+
return QObject::tr( "" );
3763+
}
3764+
getStyleById_t* getStyleByIdMethod = ( getStyleById_t * ) cast_to_fptr( myLib->resolve( "getStyleById" ) );
37653765

3766-
if ( !getStyleByIdMethod )
3767-
{
3768-
delete myLib;
3769-
msgError = QObject::tr( "Provider %1 has no getStyleById method" ).arg( mProviderKey );
3770-
return QObject::tr( "" );
3771-
}
3766+
if ( !getStyleByIdMethod )
3767+
{
3768+
delete myLib;
3769+
msgError = QObject::tr( "Provider %1 has no %2 method" ).arg( mProviderKey ).arg( "getStyleById" );
3770+
return QObject::tr( "" );
3771+
}
37723772

3773-
return getStyleByIdMethod( mDataSource, styleId, msgError );
3773+
return getStyleByIdMethod( mDataSource, styleId, msgError );
37743774
}
37753775

37763776

3777-
void QgsVectorLayer::saveStyleToDatabase(QString name, QString description,
3778-
bool useAsDefault, QString uiFileContent, QString &msgError){
3777+
void QgsVectorLayer::saveStyleToDatabase( QString name, QString description,
3778+
bool useAsDefault, QString uiFileContent, QString &msgError )
3779+
{
37793780

3780-
QString sldStyle, qmlStyle;
3781-
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
3782-
QLibrary *myLib = pReg->providerLibrary( mProviderKey );
3783-
if ( !myLib )
3784-
{
3785-
msgError = QObject::tr( "Unable to load %1 provider" ).arg( mProviderKey );
3786-
return;
3787-
}
3788-
saveStyle_t* saveStyleExternalMethod = ( saveStyle_t * ) cast_to_fptr(myLib->resolve("saveStyle"));
3781+
QString sldStyle, qmlStyle;
3782+
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
3783+
QLibrary *myLib = pReg->providerLibrary( mProviderKey );
3784+
if ( !myLib )
3785+
{
3786+
msgError = QObject::tr( "Unable to load %1 provider" ).arg( mProviderKey );
3787+
return;
3788+
}
3789+
saveStyle_t* saveStyleExternalMethod = ( saveStyle_t * ) cast_to_fptr( myLib->resolve( "saveStyle" ) );
37893790

3790-
if ( !saveStyleExternalMethod )
3791-
{
3792-
delete myLib;
3793-
msgError = QObject::tr( "Provider %1 has no saveStyle method" ).arg( mProviderKey );
3794-
return;
3795-
}
3791+
if ( !saveStyleExternalMethod )
3792+
{
3793+
delete myLib;
3794+
msgError = QObject::tr( "Provider %1 has no %2 method" ).arg( mProviderKey ).arg( "saveStyle" );
3795+
return;
3796+
}
37963797

3797-
QDomDocument qmlDocument, sldDocument;
3798-
this->exportNamedStyle(qmlDocument, msgError);
3799-
if( !msgError.isNull() )
3800-
{
3801-
return;
3802-
}
3803-
qmlStyle = qmlDocument.toString();
3798+
QDomDocument qmlDocument, sldDocument;
3799+
this->exportNamedStyle( qmlDocument, msgError );
3800+
if ( !msgError.isNull() )
3801+
{
3802+
return;
3803+
}
3804+
qmlStyle = qmlDocument.toString();
38043805

3805-
this->exportSldStyle(sldDocument, msgError);
3806-
if( !msgError.isNull() )
3807-
{
3808-
return;
3809-
}
3810-
sldStyle = sldDocument.toString();
3806+
this->exportSldStyle( sldDocument, msgError );
3807+
if ( !msgError.isNull() )
3808+
{
3809+
return;
3810+
}
3811+
sldStyle = sldDocument.toString();
38113812

3812-
saveStyleExternalMethod( mDataSource, qmlStyle, sldStyle, name,
3813-
description, uiFileContent, useAsDefault, msgError );
3813+
saveStyleExternalMethod( mDataSource, qmlStyle, sldStyle, name,
3814+
description, uiFileContent, useAsDefault, msgError );
38143815
}
38153816

38163817

38173818

38183819
QString QgsVectorLayer::loadNamedStyle( const QString theURI, bool &theResultFlag )
38193820
{
3820-
return loadNamedStyle( theURI, theResultFlag, false );
3821+
return loadNamedStyle( theURI, theResultFlag, false );
38213822
}
38223823

38233824
QString QgsVectorLayer::loadNamedStyle( const QString theURI, bool &theResultFlag , bool loadFromLocalDB )
38243825
{
3825-
QgsDataSourceURI dsUri( theURI );
3826-
if ( !loadFromLocalDB && !dsUri.database().isEmpty() )
3826+
QgsDataSourceURI dsUri( theURI );
3827+
if ( !loadFromLocalDB && !dsUri.database().isEmpty() )
3828+
{
3829+
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
3830+
QLibrary *myLib = pReg->providerLibrary( mProviderKey );
3831+
if ( myLib )
38273832
{
3828-
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
3829-
QLibrary *myLib = pReg->providerLibrary( mProviderKey );
3830-
if ( myLib )
3833+
loadStyle_t* loadStyleExternalMethod = ( loadStyle_t * ) cast_to_fptr( myLib->resolve( "loadStyle" ) );
3834+
if ( loadStyleExternalMethod )
3835+
{
3836+
QString qml, errorMsg;
3837+
qml = loadStyleExternalMethod( mDataSource, errorMsg );
3838+
if ( !qml.isEmpty() )
38313839
{
3832-
loadStyle_t* loadStyleExternalMethod = ( loadStyle_t * ) cast_to_fptr( myLib->resolve( "loadStyle" ) );
3833-
if ( loadStyleExternalMethod )
3834-
{
3835-
QString qml, errorMsg;
3836-
qml = loadStyleExternalMethod( mDataSource, errorMsg );
3837-
if( !qml.isEmpty() )
3838-
{
3839-
theResultFlag = this->applyNamedStyle( qml, errorMsg );
3840-
}
3841-
}
3840+
theResultFlag = this->applyNamedStyle( qml, errorMsg );
38423841
}
3843-
3844-
}
3845-
if( !theResultFlag )
3846-
{
3847-
return QgsMapLayer::loadNamedStyle( theURI, theResultFlag );
3842+
}
38483843
}
3849-
return QObject::tr( "Loaded from Provider" );
3844+
3845+
}
3846+
if ( !theResultFlag )
3847+
{
3848+
return QgsMapLayer::loadNamedStyle( theURI, theResultFlag );
3849+
}
3850+
return QObject::tr( "Loaded from Provider" );
38503851
}
38513852

3852-
bool QgsVectorLayer::applyNamedStyle(QString namedStyle, QString errorMsg )
3853+
bool QgsVectorLayer::applyNamedStyle( QString namedStyle, QString errorMsg )
38533854
{
3854-
QDomDocument myDocument( "qgis" );
3855-
myDocument.setContent( namedStyle );
3855+
QDomDocument myDocument( "qgis" );
3856+
myDocument.setContent( namedStyle );
38563857

3857-
QDomElement myRoot = myDocument.firstChildElement( "qgis" );
3858+
QDomElement myRoot = myDocument.firstChildElement( "qgis" );
38583859

3859-
if( myRoot.isNull() )
3860-
{
3861-
errorMsg = tr( "Error: qgis element could not be found" );
3862-
return false;
3863-
}
3864-
toggleScaleBasedVisibility( myRoot.attribute( "hasScaleBasedVisibilityFlag" ).toInt() == 1 );
3865-
setMinimumScale( myRoot.attribute( "minimumScale" ).toFloat() );
3866-
setMaximumScale( myRoot.attribute( "maximumScale" ).toFloat() );
3860+
if ( myRoot.isNull() )
3861+
{
3862+
errorMsg = tr( "Error: qgis element could not be found" );
3863+
return false;
3864+
}
3865+
toggleScaleBasedVisibility( myRoot.attribute( "hasScaleBasedVisibilityFlag" ).toInt() == 1 );
3866+
setMinimumScale( myRoot.attribute( "minimumScale" ).toFloat() );
3867+
setMaximumScale( myRoot.attribute( "maximumScale" ).toFloat() );
38673868

3868-
#if 0
3869-
//read transparency level
3870-
QDomNode transparencyNode = myRoot.namedItem( "transparencyLevelInt" );
3871-
if ( ! transparencyNode.isNull() )
3872-
{
3873-
// set transparency level only if it's in project
3874-
// (otherwise it sets the layer transparent)
3875-
QDomElement myElement = transparencyNode.toElement();
3876-
setTransparency( myElement.text().toInt() );
3877-
}
3878-
#endif
3869+
#if 0
3870+
//read transparency level
3871+
QDomNode transparencyNode = myRoot.namedItem( "transparencyLevelInt" );
3872+
if ( ! transparencyNode.isNull() )
3873+
{
3874+
// set transparency level only if it's in project
3875+
// (otherwise it sets the layer transparent)
3876+
QDomElement myElement = transparencyNode.toElement();
3877+
setTransparency( myElement.text().toInt() );
3878+
}
3879+
#endif
38793880

3880-
return readSymbology( myRoot, errorMsg );
3881+
return readSymbology( myRoot, errorMsg );
38813882
}

src/core/qgsvectorlayer.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <QSet>
2323
#include <QList>
2424
#include <QStringList>
25-
#include <QVector>
2625

2726
#include "qgis.h"
2827
#include "qgsmaplayer.h"
@@ -707,14 +706,14 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
707706

708707
/**
709708
* Lists all the style in db split into related to the layer and not related to
710-
* @param ids the QVector in which will be stored the style db ids
711-
* @param names the QVector in which will be stored the style names
712-
* @param descriptions the QVector in which will be stored the style descriptions
709+
* @param ids the list in which will be stored the style db ids
710+
* @param names the list in which will be stored the style names
711+
* @param descriptions the list in which will be stored the style descriptions
713712
* @param msgError
714713
* @return the number of styles related to current layer
715714
*/
716-
virtual int listStylesInDatabase( QVector<QString> &ids, QVector<QString> &names,
717-
QVector<QString> &descriptions, QString &msgError );
715+
virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
716+
QStringList &descriptions, QString &msgError );
718717

719718
/**
720719
* Will return the named style corresponding to style id provided
@@ -735,7 +734,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
735734
*/
736735
virtual QString loadNamedStyle( const QString theURI, bool &theResultFlag );
737736

738-
virtual bool applyNamedStyle(QString namedStyle , QString errorMsg);
737+
virtual bool applyNamedStyle( QString namedStyle , QString errorMsg );
739738

740739
/** convert a saved attribute editor element into a AttributeEditor structure as it's used internally.
741740
* @param elem the DOM element
@@ -1281,15 +1280,15 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
12811280
signals:
12821281

12831282
/**
1284-
* This signal is emited when selection was changed
1283+
* This signal is emitted when selection was changed
12851284
*
12861285
* @param selected Newly selected feature ids
12871286
* @param deselected Ids of all features which have previously been selected but are not any more
12881287
* @param clearAndSelect In case this is set to true, the old selection was dismissed and the new selection corresponds to selected
12891288
*/
12901289
void selectionChanged( const QgsFeatureIds selected, const QgsFeatureIds deselected, const bool clearAndSelect );
12911290

1292-
/** This signal is emited when selection was changed */
1291+
/** This signal is emitted when selection was changed */
12931292
void selectionChanged();
12941293

12951294
/** This signal is emitted when modifications has been done on layer */
@@ -1298,7 +1297,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
12981297
/** Is emitted, when editing on this layer has started*/
12991298
void editingStarted();
13001299

1301-
/** Is emitted, when edited changes succesfully have been written to the data provider */
1300+
/** Is emitted, when edited changes successfully have been written to the data provider */
13021301
void editingStopped();
13031302

13041303
/** Is emitted, before changes are commited to the data provider */

0 commit comments

Comments
 (0)