Skip to content

Commit 8c899d8

Browse files
committed
Make style model refresh icons when svg cache fetches a remote image
1 parent 57f89c9 commit 8c899d8

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/core/symbology/qgsstylemodel.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "qgsstylemodel.h"
1717
#include "qgsstyle.h"
1818
#include "qgssymbollayerutils.h"
19+
#include "qgsapplication.h"
20+
#include "qgssvgcache.h"
1921
#include <QIcon>
2022

2123
const double ICON_PADDING_FACTOR = 0.16;
@@ -38,6 +40,13 @@ QgsStyleModel::QgsStyleModel( QgsStyle *style, QObject *parent )
3840
connect( mStyle, &QgsStyle::rampRenamed, this, &QgsStyleModel::onRampRename );
3941

4042
connect( mStyle, &QgsStyle::entityTagsChanged, this, &QgsStyleModel::onTagsChanged );
43+
44+
// when a remote svg has been fetched, update the model's decorations.
45+
// this is required if a symbol utilizes remote svgs, and the current icons
46+
// have been generated using the temporary "downloading" svg. In this case
47+
// we require the preview to be regenerated to use the correct fetched
48+
// svg
49+
connect( QgsApplication::svgCache(), &QgsSvgCache::remoteSvgFetched, this, &QgsStyleModel::rebuildSymbolIcons );
4150
}
4251

4352
QVariant QgsStyleModel::data( const QModelIndex &index, int role ) const
@@ -403,6 +412,12 @@ void QgsStyleModel::onTagsChanged( int entity, const QString &name, const QStrin
403412
emit dataChanged( i, i );
404413
}
405414

415+
void QgsStyleModel::rebuildSymbolIcons()
416+
{
417+
mSymbolIconCache.clear();
418+
emit dataChanged( index( 0, 0 ), index( mSymbolNames.count() - 1, 0 ), QVector<int>() << Qt::DecorationRole );
419+
}
420+
406421
//
407422
// QgsStyleProxyModel
408423
//

src/core/symbology/qgsstylemodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class CORE_EXPORT QgsStyleModel: public QAbstractItemModel
9696
void onRampChanged( const QString &name );
9797
void onRampRename( const QString &oldName, const QString &newName );
9898
void onTagsChanged( int entity, const QString &name, const QStringList &tags );
99+
void rebuildSymbolIcons();
99100

100101
private:
101102

src/gui/symbology/qgssymbolslistwidget.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "qgssettings.h"
3030
#include "qgsnewauxiliarylayerdialog.h"
3131
#include "qgsauxiliarystorage.h"
32-
#include "qgssvgcache.h"
3332
#include "qgsstylemodel.h"
3433

3534
#include <QAction>
@@ -210,13 +209,6 @@ QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbol *symbol, QgsStyle *style,
210209
connect( btnSaveSymbol, &QPushButton::clicked, this, &QgsSymbolsListWidget::saveSymbol );
211210

212211
connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsSymbolsListWidget::opacityChanged );
213-
214-
// when a remote svg has been fetched, update the widget's previews
215-
// this is required if the symbol utilizes remote svgs, and the current previews
216-
// have been generated using the temporary "downloading" svg. In this case
217-
// we require the preview to be regenerated to use the correct fetched
218-
// svg
219-
connect( QgsApplication::svgCache(), &QgsSvgCache::remoteSvgFetched, this, &QgsSymbolsListWidget::updateModelFilters );
220212
}
221213

222214
QgsSymbolsListWidget::~QgsSymbolsListWidget()

0 commit comments

Comments
 (0)