Skip to content

Commit

Permalink
remove join returns true in case of success
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Feb 1, 2016
1 parent cae49d7 commit e453c15
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
5 changes: 3 additions & 2 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -446,8 +446,9 @@ class QgsVectorLayer : QgsMapLayer
@note since 2.6 returns bool indicating whether the join can be added */
bool addJoin( const QgsVectorJoinInfo& joinInfo );

/** Removes a vector layer join */
void removeJoin( const QString& joinLayerId );
/** Removes a vector layer join
@returns true if join was found and successfully removed */
bool removeJoin( const QString& joinLayerId );

const QList<QgsVectorJoinInfo> vectorJoins() const;

Expand Down
5 changes: 3 additions & 2 deletions python/core/qgsvectorlayerjoinbuffer.sip
Expand Up @@ -12,8 +12,9 @@ class QgsVectorLayerJoinBuffer : QObject
@return (since 2.6) whether the join was successfully added */
bool addJoin( const QgsVectorJoinInfo& joinInfo );

/** Removes a vector layer join*/
void removeJoin( const QString& joinLayerId );
/** Removes a vector layer join
@returns true if join was found and successfully removed */
bool removeJoin( const QString& joinLayerId );

/** Updates field map with joined attributes
@param fields map to append joined attributes
Expand Down
8 changes: 6 additions & 2 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -2764,10 +2764,14 @@ void QgsVectorLayer::checkJoinLayerRemove( const QString& theLayerId )
removeJoin( theLayerId );
}

void QgsVectorLayer::removeJoin( const QString& joinLayerId )
bool QgsVectorLayer::removeJoin( const QString& joinLayerId )
{
bool res = false;
if ( mJoinBuffer )
mJoinBuffer->removeJoin( joinLayerId );
{
res = mJoinBuffer->removeJoin( joinLayerId );
}
return res;
}

const QList< QgsVectorJoinInfo > QgsVectorLayer::vectorJoins() const
Expand Down
5 changes: 3 additions & 2 deletions src/core/qgsvectorlayer.h
Expand Up @@ -554,8 +554,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
@note since 2.6 returns bool indicating whether the join can be added */
bool addJoin( const QgsVectorJoinInfo& joinInfo );

/** Removes a vector layer join */
void removeJoin( const QString& joinLayerId );
/** Removes a vector layer join
@returns true if join was found and successfully removed */
bool removeJoin( const QString& joinLayerId );

const QList<QgsVectorJoinInfo> vectorJoins() const;

Expand Down
7 changes: 6 additions & 1 deletion src/core/qgsvectorlayerjoinbuffer.cpp
Expand Up @@ -94,20 +94,25 @@ bool QgsVectorLayerJoinBuffer::addJoin( const QgsVectorJoinInfo& joinInfo )
}


void QgsVectorLayerJoinBuffer::removeJoin( const QString& joinLayerId )
bool QgsVectorLayerJoinBuffer::removeJoin( const QString& joinLayerId )
{
bool res = false;
for ( int i = 0; i < mVectorJoins.size(); ++i )
{
if ( mVectorJoins.at( i ).joinLayerId == joinLayerId )
{
mVectorJoins.removeAt( i );
res = true;
}
}

if ( QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( joinLayerId ) ) )
{
disconnect( vl, SIGNAL( updatedFields() ), this, SLOT( joinedLayerUpdatedFields() ) );
}

emit joinedFieldsChanged();
return res;
}

void QgsVectorLayerJoinBuffer::cacheJoinLayer( QgsVectorJoinInfo& joinInfo )
Expand Down
5 changes: 3 additions & 2 deletions src/core/qgsvectorlayerjoinbuffer.h
Expand Up @@ -41,8 +41,9 @@ class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject
@return (since 2.6) whether the join was successfully added */
bool addJoin( const QgsVectorJoinInfo& joinInfo );

/** Removes a vector layer join*/
void removeJoin( const QString& joinLayerId );
/** Removes a vector layer join
@returns true if join was found and successfully removed */
bool removeJoin( const QString& joinLayerId );

/** Updates field map with joined attributes
@param fields map to append joined attributes
Expand Down

0 comments on commit e453c15

Please sign in to comment.