Skip to content
Permalink
Browse files

Show preview icons in rule based labeling list of rules and vector tile

labeling list of rules

Makes it MUCH easier to identify specific rules in the list, and matches
appearance with the rule based renderer/vector tile renderer list appearances.
  • Loading branch information
nyalldawson committed Sep 14, 2020
1 parent 7cd51dc commit d214e637fc41668ee4d11844c34c144b200949e6
@@ -31,6 +31,7 @@
#include <QClipboard>
#include <QMessageBox>

const double ICON_PADDING_FACTOR = 0.16;

static QList<QgsExpressionContextScope *> _globalProjectAtlasMapLayerScopes( QgsMapCanvas *mapCanvas, const QgsMapLayer *layer )
{
@@ -291,8 +292,8 @@ QVariant QgsRuleBasedLabelingModel::data( const QModelIndex &index, int role ) c
}
else if ( role == Qt::DecorationRole && index.column() == 0 && rule->settings() )
{
// TODO return QgsSymbolLayerUtils::symbolPreviewIcon( rule->symbol(), QSize( 16, 16 ) );
return QVariant();
const int iconSize = QgsGuiUtils::scaleIconSize( 16 );
return QgsPalLayerSettings::labelSettingsPreviewPixmap( *rule->settings(), QSize( iconSize, iconSize ), QString(), static_cast< int >( iconSize * ICON_PADDING_FACTOR ) );
}
else if ( role == Qt::TextAlignmentRole )
{
@@ -26,6 +26,7 @@

///@cond PRIVATE

const double ICON_PADDING_FACTOR = 0.16;

QgsVectorTileBasicLabelingListModel::QgsVectorTileBasicLabelingListModel( QgsVectorTileBasicLabeling *l, QObject *parent )
: QAbstractListModel( parent )
@@ -96,6 +97,16 @@ QVariant QgsVectorTileBasicLabelingListModel::data( const QModelIndex &index, in
return style.isEnabled() ? Qt::Checked : Qt::Unchecked;
}

case Qt::DecorationRole:
{
if ( index.column() == 0 )
{
const int iconSize = QgsGuiUtils::scaleIconSize( 16 );
return QgsPalLayerSettings::labelSettingsPreviewPixmap( style.labelSettings(), QSize( iconSize, iconSize ), QString(), static_cast< int >( iconSize * ICON_PADDING_FACTOR ) );
}
break;
}

case MinZoom:
return style.minZoomLevel();

0 comments on commit d214e63

Please sign in to comment.
You can’t perform that action at this time.