Skip to content

Commit

Permalink
Fix random sort order of symbols in Symbol Export dialog
Browse files Browse the repository at this point in the history
Fixes #20572

(cherry picked from commit 987310f)
  • Loading branch information
nyalldawson committed Jun 19, 2020
1 parent 99ccdeb commit 394e4d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/gui/symbology/qgsstyleexportimportdialog.cpp
Expand Up @@ -66,6 +66,7 @@ QgsStyleExportImportDialog::QgsStyleExportImportDialog( QgsStyle *style, QWidget
mGroupSelectionDlg = nullptr;
mTempFile = nullptr;

QgsStyle *dialogStyle = nullptr;
if ( mDialogMode == Import )
{
setWindowTitle( tr( "Import Item(s)" ) );
Expand All @@ -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
{
Expand All @@ -115,13 +115,16 @@ QgsStyleExportImportDialog::QgsStyleExportImportDialog( QgsStyle *style, QWidget

buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Export" ) );

mModel = new QgsStyleModel( mStyle, this );
dialogStyle = mStyle;
}

double iconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 10;
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,
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology/qgsstyleexportimportdialog.h
Expand Up @@ -30,7 +30,7 @@
class QgsStyle;
class QgsStyleGroupSelectionDialog;
class QgsTemporaryCursorOverride;
class QgsStyleModel;
class QgsStyleProxyModel;
class QTemporaryFile;

/**
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 394e4d5

Please sign in to comment.