fix edit widget deprecation warnings and sync sip bindings

This commit is contained in:
Juergen E. Fischer 2014-05-24 03:52:19 +02:00
parent d1da612300
commit 0903684314
5 changed files with 133 additions and 35 deletions

View File

@ -118,9 +118,12 @@ class QgsVectorLayer : QgsMapLayer
{ {
GeneratedLayout, GeneratedLayout,
TabLayout, TabLayout,
UiFileLayout, UiFileLayout
}; };
/**
* @deprecated Use the editorWidgetV2() system instead
*/
enum EditType enum EditType
{ {
LineEdit, LineEdit,
@ -758,16 +761,38 @@ class QgsVectorLayer : QgsMapLayer
* *
* @return The id for the editor widget or a NULL string if not applicable * @return The id for the editor widget or a NULL string if not applicable
*/ */
const QString editorWidgetV2( int fieldIdx ); const QString editorWidgetV2( int fieldIdx ) const;
/**
* Get the id for the editor widget used to represent the field at the given index
*
* @param fieldName The name of the field
*
* @return The id for the editor widget or a NULL string if not applicable
*
* @note python method name editorWidgetV2ByName
*/
const QString editorWidgetV2( const QString& fieldName ) const /PyName=editorWidgetV2ByName/;
/** /**
* Get the configuration for the editor widget used to represent the field at the given index * Get the configuration for the editor widget used to represent the field at the given index
* *
* @param fieldIdx The index of the field * @param fieldIdx The index of the field
* *
* @return The id for the editor widget or a NULL string if not configured * @return The configuration for the editor widget or an empty config if the field does not exist
*/ */
const QgsEditorWidgetConfig editorWidgetV2Config( int fieldIdx ); const QgsEditorWidgetConfig editorWidgetV2Config( int fieldIdx ) const;
/**
* Get the configuration for the editor widget used to represent the field at the given index
*
* @param fieldName The name of the field
*
* @return The configuration for the editor widget or an empty config if the field does not exist
*
* @note python method name is editorWidgetV2ConfigByName
*/
const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const /PyName=editorWidgetV2ConfigByName/;
/** /**
* Returns a list of tabs holding groups and fields * Returns a list of tabs holding groups and fields
@ -841,11 +866,19 @@ class QgsVectorLayer : QgsMapLayer
*/ */
bool rollBack( bool deleteBuffer = true ); bool rollBack( bool deleteBuffer = true );
/**get edit type*/ /**
EditType editType( int idx ); * Get edit type
*
* @deprecated Use @see{editorWidgetV2} instead
*/
EditType editType( int idx ) /Deprecated/;
/**set edit type*/ /**
void setEditType( int idx, EditType edit ); * Get edit type
*
* @deprecated Use @see{setEditorWidgetV2} instead
*/
void setEditType( int idx, EditType edit ) /Deprecated/;
/** get the active layout for the attribute editor for this layer (added in 1.9) */ /** get the active layout for the attribute editor for this layer (added in 1.9) */
EditorLayout editorLayout(); EditorLayout editorLayout();
@ -853,12 +886,28 @@ class QgsVectorLayer : QgsMapLayer
/** set the active layout for the attribute editor for this layer (added in 1.9) */ /** set the active layout for the attribute editor for this layer (added in 1.9) */
void setEditorLayout( EditorLayout editorLayout ); void setEditorLayout( EditorLayout editorLayout );
/**
* Set the editor widget type for a field
*
* @param attrIdx Index of the field
* @param widgetType Type id of the editor widget to use
*/
void setEditorWidgetV2( int attrIdx, const QString& widgetType ); void setEditorWidgetV2( int attrIdx, const QString& widgetType );
/**
* Set the editor widget config for a field
*
* @param attrIdx Index of the field
* @param config The config to set for this field
*/
void setEditorWidgetV2Config( int attrIdx, const QMap<QString, QVariant>& config ); void setEditorWidgetV2Config( int attrIdx, const QMap<QString, QVariant>& config );
/** set string representing 'true' for a checkbox (added in 1.4) */ /**
void setCheckedState( int idx, QString checked, QString notChecked ); * Set string representing 'true' for a checkbox (added in 1.4)
*
* @deprecated Use @see{setEditorWidgetV2Config} instead
*/
void setCheckedState( int idx, QString checked, QString notChecked ) /Deprecated/;
/** get edit form (added in 1.4) */ /** get edit form (added in 1.4) */
QString editForm(); QString editForm();
@ -886,16 +935,25 @@ class QgsVectorLayer : QgsMapLayer
/** set python function for edit form initialization (added in 1.4) */ /** set python function for edit form initialization (added in 1.4) */
void setEditFormInit( QString function ); void setEditFormInit( QString function );
/**access value map*/ /**
QMap<QString, QVariant> valueMap( int idx ); * Access value map
* @deprecated Use @see{editorWidgetV2Config} instead
*/
QMap<QString, QVariant> valueMap( int idx ) /Deprecated/;
/**access range */ /**
* Access range widget config data
*
* @deprecated Use @see{editorWidgetV2Config} instead
*/
RangeData range( int idx ) /Deprecated/; RangeData range( int idx ) /Deprecated/;
/**access relations /**
* Access value relation widget data
*
* @note added in 1.8 * @note added in 1.8
**/ */
ValueRelationData valueRelation( int idx ) /Deprecated/; ValueRelationData valueRelation( int idx );
/** /**
* Get relations, where the foreign key is on this layer * Get relations, where the foreign key is on this layer
@ -905,13 +963,21 @@ class QgsVectorLayer : QgsMapLayer
*/ */
QList<QgsRelation> referencingRelations( int idx ); QList<QgsRelation> referencingRelations( int idx );
/**access date format /**
* Access date format
*
* @note added in 1.9 * @note added in 1.9
*
* @deprecated Use @see{setEditorWdigetV2Config} instead
*/ */
QString dateFormat( int idx ) /Deprecated/; QString dateFormat( int idx ) /Deprecated/;
/**access widget size for photo and webview widget /**
* Access widget size for photo and webview widget
*
* @note added in 1.9 * @note added in 1.9
*
* @deprecated Use @see{setEditorWdigetV2Config} instead
*/ */
QSize widgetSize( int idx ) /Deprecated/; QSize widgetSize( int idx ) /Deprecated/;
@ -1110,6 +1176,9 @@ class QgsVectorLayer : QgsMapLayer
/** This signal is emitted when modifications has been done on layer */ /** This signal is emitted when modifications has been done on layer */
void layerModified(); void layerModified();
/** Is emitted, when layer is checked for modifications. Use for last-minute additions */
void beforeModifiedCheck() const;
/** Is emitted, when editing on this layer has started*/ /** Is emitted, when editing on this layer has started*/
void editingStarted(); void editingStarted();
@ -1179,6 +1248,27 @@ class QgsVectorLayer : QgsMapLayer
/** Signal emitted when setLayerTransparency() is called */ /** Signal emitted when setLayerTransparency() is called */
void layerTransparencyChanged( int layerTransparency ); void layerTransparencyChanged( int layerTransparency );
/**
* Signal emitted when a new edit command has been started
*
* @param text Description for this edit command
*/
void editCommandStarted( const QString& text );
/**
* Signal emitted, when an edit command successfully ended
* @note This does not mean it is also committed, only that it is written
* to the edit buffer. See {@link beforeCommitChanges()}
*/
void editCommandEnded();
/**
* Signal emitted, whan an edit command is destroyed
* @note This is not a rollback, it is only related to the current edit command.
* See {@link beforeRollBack()}
*/
void editCommandDestroyed();
protected: protected:
/** Set the extent */ /** Set the extent */
void setExtent( const QgsRectangle &rect ); void setExtent( const QgsRectangle &rect );

View File

@ -90,8 +90,8 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
int col = 0; int col = 0;
for ( int idx = 0; idx < fields.count(); ++idx ) for ( int idx = 0; idx < fields.count(); ++idx )
{ {
if ( mVectorLayer->editType( idx ) == QgsVectorLayer::Hidden || if ( mVectorLayer->editorWidgetV2( idx ) == "Hidden" ||
mVectorLayer->editType( idx ) == QgsVectorLayer::Immutable ) mVectorLayer->editorWidgetV2( idx ) == "Immutable" )
continue; continue;
mTableWidget->setColumnCount( col + 1 ); mTableWidget->setColumnCount( col + 1 );

View File

@ -1120,6 +1120,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
* @param fieldName The name of the field * @param fieldName The name of the field
* *
* @return The id for the editor widget or a NULL string if not applicable * @return The id for the editor widget or a NULL string if not applicable
*
* @note python method name editorWidgetV2ByName
*/ */
const QString editorWidgetV2( const QString& fieldName ) const; const QString editorWidgetV2( const QString& fieldName ) const;
@ -1138,6 +1140,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
* @param fieldName The name of the field * @param fieldName The name of the field
* *
* @return The configuration for the editor widget or an empty config if the field does not exist * @return The configuration for the editor widget or an empty config if the field does not exist
*
* @note python method name is editorWidgetV2ConfigByName
*/ */
const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const; const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const;
@ -1252,7 +1256,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** /**
* Set string representing 'true' for a checkbox (added in 1.4) * Set string representing 'true' for a checkbox (added in 1.4)
* *
* @deprecated Use @see{setEditorWdigetV2Config} instead * @deprecated Use @see{setEditorWidgetV2Config} instead
*/ */
Q_DECL_DEPRECATED void setCheckedState( int idx, QString checked, QString notChecked ); Q_DECL_DEPRECATED void setCheckedState( int idx, QString checked, QString notChecked );
@ -1284,14 +1288,14 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** /**
* Access value map * Access value map
* @deprecated Use @see{editorWdigetV2Config} instead * @deprecated Use @see{editorWidgetV2Config} instead
*/ */
Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap( int idx ); Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap( int idx );
/** /**
* Access range widget config data * Access range widget config data
* *
* @deprecated Use @see{editorWdigetV2Config} instead * @deprecated Use @see{editorWidgetV2Config} instead
*/ */
Q_DECL_DEPRECATED RangeData range( int idx ); Q_DECL_DEPRECATED RangeData range( int idx );

View File

@ -469,8 +469,7 @@ void QgsServerProjectParser::addLayerProjectSettings( QDomElement& layerElem, QD
attributeElem.setAttribute( "typeName", field.typeName() ); attributeElem.setAttribute( "typeName", field.typeName() );
//edit type to text //edit type to text
QgsVectorLayer::EditType typeEnum = vLayer->editType( idx ); attributeElem.setAttribute( "editType", vLayer->editorWidgetV2( idx ) );
attributeElem.setAttribute( "editType", editTypeString( typeEnum ) );
attributeElem.setAttribute( "comment", field.comment() ); attributeElem.setAttribute( "comment", field.comment() );
attributeElem.setAttribute( "length", field.length() ); attributeElem.setAttribute( "length", field.length() );
attributeElem.setAttribute( "precision", field.precision() ); attributeElem.setAttribute( "precision", field.precision() );

View File

@ -2903,12 +2903,12 @@ QString QgsWMSServer::replaceValueMapAndRelation( QgsVectorLayer* vl, int idx, c
return attributeVal; return attributeVal;
} }
QgsVectorLayer::EditType type = vl->editType( idx ); QString type = vl->editorWidgetV2( idx );
if ( type == QgsVectorLayer::ValueMap ) if ( type == "ValueMap" )
{ {
QMap<QString, QVariant> valueMap = vl->valueMap( idx ); QgsEditorWidgetConfig cfg( vl->editorWidgetV2Config( idx ) );
QMap<QString, QVariant>::const_iterator vmapIt = valueMap.constBegin(); QMap<QString, QVariant>::const_iterator vmapIt = cfg.constBegin();
for ( ; vmapIt != valueMap.constEnd(); ++vmapIt ) for ( ; vmapIt != cfg.constEnd(); ++vmapIt )
{ {
if ( vmapIt.value().toString() == attributeVal ) if ( vmapIt.value().toString() == attributeVal )
{ {
@ -2916,17 +2916,17 @@ QString QgsWMSServer::replaceValueMapAndRelation( QgsVectorLayer* vl, int idx, c
} }
} }
} }
else if ( type == QgsVectorLayer::ValueRelation ) else if ( type == "ValueRelation" )
{ {
QgsVectorLayer::ValueRelationData vrdata = vl->valueRelation( idx ); QgsEditorWidgetConfig cfg( vl->editorWidgetV2Config( idx ) );
QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( vrdata.mLayer ) ); QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( cfg.value( "Layer" ).toString() ) );
if ( !layer ) if ( !layer )
{ {
return attributeVal; return attributeVal;
} }
QString outputString; QString outputString;
if ( vrdata.mAllowMulti ) if ( cfg.value( "AllowMulti" ).toBool() )
{ {
QString valueString = attributeVal; QString valueString = attributeVal;
QStringList valueList = valueString.remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( "," ); QStringList valueList = valueString.remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( "," );
@ -2936,7 +2936,12 @@ QString QgsWMSServer::replaceValueMapAndRelation( QgsVectorLayer* vl, int idx, c
{ {
outputString += ";"; outputString += ";";
} }
outputString += relationValue( valueList.at( i ), layer, vrdata.mKey, vrdata.mValue ); outputString += relationValue(
valueList.at( i ),
layer,
cfg.value( "Key" ).toString(),
cfg.value( "Value" ).toString()
);
} }
} }
return outputString; return outputString;