Skip to content
Permalink
Browse files

Flag project as dirty when attribute table configuration changes

  • Loading branch information
m-kuhn committed Jun 2, 2016
1 parent 662bf43 commit 60dce16e9eb5e6de13de702e5202ded5b68da89d
@@ -228,6 +228,11 @@ void QgsAttributeTableConfig::setColumnHidden( int column, bool hidden )
mColumns[ column ].hidden = hidden;
}

bool QgsAttributeTableConfig::operator!=( const QgsAttributeTableConfig& other ) const
{
return mSortExpression != other.mSortExpression || mColumns != other.mColumns || mActionWidgetStyle != other.mActionWidgetStyle;
}

void QgsAttributeTableConfig::writeXml( QDomNode& node ) const
{
QDomDocument doc( node.ownerDocument() );
@@ -263,3 +268,8 @@ void QgsAttributeTableConfig::writeXml( QDomNode& node ) const

node.appendChild( configElement );
}

bool QgsAttributeTableConfig::ColumnConfig::operator== ( const ColumnConfig& other ) const
{
return type == other.type && name == other.name && hidden == other.hidden;
}
@@ -52,6 +52,8 @@ class CORE_EXPORT QgsAttributeTableConfig
, width( -1 )
{}

bool operator== ( const ColumnConfig& other ) const;

Type type; //!< The type of this column.
QString name; //!< The name of the attribute if this column represents a field
bool hidden; //!< Flag that controls if the column is hidden
@@ -165,6 +167,11 @@ class CORE_EXPORT QgsAttributeTableConfig
*/
void setColumnHidden( int column, bool hidden );

/**
* Compare this configuration to other.
*/
bool operator!= ( const QgsAttributeTableConfig& other ) const;

private:
QVector<ColumnConfig> mColumns;
ActionWidgetStyle mActionWidgetStyle;
@@ -672,6 +672,12 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
void legendChanged();

/**
* Emitted whenever the configuration is changed. The project listens to this signal
* to be marked as dirty.
*/
void configChanged();

protected:
/** Set the extent */
virtual void setExtent( const QgsRectangle &rect );
@@ -1050,6 +1050,8 @@ void QgsProject::onMapLayersAdded( const QList<QgsMapLayer*>& layers )
}
vlayer->dataProvider()->setProviderProperty( QgsVectorDataProvider::EvaluateDefaultValues, evaluateDefaultValues() );
}

connect( layer, SIGNAL( configChanged() ), this, SLOT( setDirty() ) );
}
}

@@ -116,13 +116,6 @@ class CORE_EXPORT QgsProject : public QObject
*/
Q_DECL_DEPRECATED inline void dirty( bool b ) { setDirty( b ); }

/**
* Flag the project as dirty (modified). If this flag is set, the user will
* be asked to save changes to the project before closing the current project.
*
* @note added in 2.4
*/
void setDirty( bool b );
//@}


@@ -470,6 +463,17 @@ class CORE_EXPORT QgsProject : public QObject
//! Emitted when the list of layer which are excluded from map identification changes
void nonIdentifiableLayersChanged( QStringList nonIdentifiableLayers );

public slots:

/**
* Flag the project as dirty (modified). If this flag is set, the user will
* be asked to save changes to the project before closing the current project.
*
* @note added in 2.4
* @note promoted to public slot in 2.16
*/
void setDirty( bool b = true );

private slots:
void onMapLayersAdded( const QList<QgsMapLayer*>& layers );
void cleanTransactionGroups( bool force = false );
@@ -3752,7 +3752,11 @@ QgsAttributeTableConfig QgsVectorLayer::attributeTableConfig() const

void QgsVectorLayer::setAttributeTableConfig( const QgsAttributeTableConfig& attributeTableConfig )
{
mAttributeTableConfig = attributeTableConfig;
if ( mAttributeTableConfig != attributeTableConfig )
{
mAttributeTableConfig = attributeTableConfig;
emit configChanged();
}
}

void QgsVectorLayer::setDiagramLayerSettings( const QgsDiagramLayerSettings& s )

0 comments on commit 60dce16

Please sign in to comment.
You can’t perform that action at this time.