Skip to content

Commit

Permalink
[composer] Refresh view action now also reloads html items and refres…
Browse files Browse the repository at this point in the history
…hes attribute table features.
  • Loading branch information
nyalldawson committed May 1, 2014
1 parent 8eb929a commit 2d7cd38
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/core/composer/qgscomposition.sip
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,12 @@ class QgsComposition : QGraphicsScene
@note added in version 2.2*/
void updateBounds();

/**Forces items in the composition to refresh. For instance, this causes maps to redraw
* and rebuild cached images, html items to reload their source url, and attribute tables
* to refresh their contents.
@note added in version 2.3*/
void refreshItems();

protected:
void init();

Expand Down Expand Up @@ -441,4 +447,7 @@ class QgsComposition : QGraphicsScene
void composerTableAdded( QgsComposerAttributeTable* table );
/**Is emitted when a composer item has been removed from the scene*/
void itemRemoved( QgsComposerItem* );

/**Is emitted when item in the composition must be refreshed*/
void refreshItemsTriggered();
};
1 change: 1 addition & 0 deletions src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ void QgsComposer::on_mActionRefreshView_triggered()
}
}

mComposition->refreshItems();
mComposition->update();
}

Expand Down
5 changes: 5 additions & 0 deletions src/core/composer/qgscomposerattributetable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ QgsComposerAttributeTable::QgsComposerAttributeTable( QgsComposition* compositio
}
}
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) );

if ( mComposition )
{
connect( mComposition, SIGNAL( refreshItemsTriggered() ), this, SLOT( refreshAttributes() ) );
}
}

QgsComposerAttributeTable::~QgsComposerAttributeTable()
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgscomposerhtml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ QgsComposerHtml::QgsComposerHtml( QgsComposition* c, bool createUndoCommands ):
if ( mComposition )
{
QObject::connect( mComposition, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SLOT( handleFrameRemoval( QgsComposerItem* ) ) );
connect( mComposition, SIGNAL( refreshItemsTriggered() ), this, SLOT( loadHtml() ) );
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/core/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ void QgsComposition::updateBounds()
setSceneRect( compositionBounds() );
}

void QgsComposition::refreshItems()
{
emit refreshItemsTriggered();
}

QRectF QgsComposition::compositionBounds() const
{
//start with an empty rectangle
Expand Down
9 changes: 9 additions & 0 deletions src/core/composer/qgscomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
@note added in version 2.2*/
void updateBounds();

/**Forces items in the composition to refresh. For instance, this causes maps to redraw
* and rebuild cached images, html items to reload their source url, and attribute tables
* to refresh their contents.
@note added in version 2.3*/
void refreshItems();

protected:
void init();

Expand Down Expand Up @@ -596,6 +602,9 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
/**Is emitted when a composer item has been removed from the scene*/
void itemRemoved( QgsComposerItem* );

/**Is emitted when item in the composition must be refreshed*/
void refreshItemsTriggered();

/**Is emitted when the composition has an updated status bar message for the composer window*/
void statusMsgChanged( QString message );
};
Expand Down

0 comments on commit 2d7cd38

Please sign in to comment.