From c8ffe9a1d1698e3b6879154a9a955058ad4edfcc Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Sat, 23 May 2020 11:36:29 +1000 Subject: [PATCH] Fix random sort order of symbols in Symbol Export dialog Fixes #20572 --- src/gui/symbology/qgsstyleexportimportdialog.cpp | 9 ++++++--- src/gui/symbology/qgsstyleexportimportdialog.h | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/symbology/qgsstyleexportimportdialog.cpp b/src/gui/symbology/qgsstyleexportimportdialog.cpp index 8c18e05afbe9..31e013af8693 100644 --- a/src/gui/symbology/qgsstyleexportimportdialog.cpp +++ b/src/gui/symbology/qgsstyleexportimportdialog.cpp @@ -66,6 +66,7 @@ QgsStyleExportImportDialog::QgsStyleExportImportDialog( QgsStyle *style, QWidget mGroupSelectionDlg = nullptr; mTempFile = nullptr; + QgsStyle *dialogStyle = nullptr; if ( mDialogMode == Import ) { setWindowTitle( tr( "Import Item(s)" ) ); @@ -91,8 +92,7 @@ QgsStyleExportImportDialog::QgsStyleExportImportDialog( QgsStyle *style, QWidget label->setText( tr( "Select items to import" ) ); buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Import" ) ); - mModel = new QgsStyleModel( mTempStyle.get(), this ); - listItems->setModel( mModel ); + dialogStyle = mTempStyle.get(); } else { @@ -115,7 +115,7 @@ QgsStyleExportImportDialog::QgsStyleExportImportDialog( QgsStyle *style, QWidget buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Export" ) ); - mModel = new QgsStyleModel( mStyle, this ); + dialogStyle = mStyle; } #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) @@ -125,7 +125,10 @@ QgsStyleExportImportDialog::QgsStyleExportImportDialog( QgsStyle *style, QWidget #endif listItems->setIconSize( QSize( static_cast< int >( iconSize ), static_cast< int >( iconSize * 0.9 ) ) ); // ~100, 90 on low dpi + mModel = new QgsStyleProxyModel( dialogStyle, this ); + mModel->addDesiredIconSize( listItems->iconSize() ); + listItems->setModel( mModel ); connect( listItems->selectionModel(), &QItemSelectionModel::selectionChanged, diff --git a/src/gui/symbology/qgsstyleexportimportdialog.h b/src/gui/symbology/qgsstyleexportimportdialog.h index a69125b11bab..bbb14dfd5daf 100644 --- a/src/gui/symbology/qgsstyleexportimportdialog.h +++ b/src/gui/symbology/qgsstyleexportimportdialog.h @@ -30,7 +30,7 @@ class QgsStyle; class QgsStyleGroupSelectionDialog; class QgsTemporaryCursorOverride; -class QgsStyleModel; +class QgsStyleProxyModel; class QTemporaryFile; /** @@ -148,7 +148,7 @@ class GUI_EXPORT QgsStyleExportImportDialog : public QDialog, private Ui::QgsSty QString mFileName; Mode mDialogMode; - QgsStyleModel *mModel = nullptr; + QgsStyleProxyModel *mModel = nullptr; QgsStyle *mStyle = nullptr; std::unique_ptr< QgsStyle > mTempStyle;