30 #include <QItemDelegate>
42 return mModel->
item( index.
row() )->icon().actualSize(
QSize( 512, 512 ) );
50 void QgsSizeScaleWidget::setFromSymbol()
61 for (
int i = 0; i < scaleMethodComboBox->count(); i++ )
63 if ( scaleMethodComboBox->itemData( i ).toInt() == int( expr.type() ) )
65 scaleMethodComboBox->setCurrentIndex( i );
70 mExpressionWidget->setField( expr.baseExpression() );
72 minValueSpinBox->setValue( expr.minValue() );
73 maxValueSpinBox->setValue( expr.maxValue() );
74 minSizeSpinBox->setValue( expr.minSize() );
75 maxSizeSpinBox->setValue( expr.maxSize() );
76 nullSizeSpinBox->setValue( expr.nullSize() );
100 treeView->setModel( &mPreviewList );
101 treeView->setItemDelegate(
new ItemDelegate( &mPreviewList ) );
102 treeView->setHeaderHidden(
true );
103 treeView->expandAll();
105 QAction* computeFromLayer =
new QAction(
tr(
"Compute from layer" ),
this );
106 connect( computeFromLayer, SIGNAL( triggered() ),
this, SLOT( computeFromLayerTriggered() ) );
110 computeValuesButton->setMenu( menu );
111 connect( computeValuesButton, SIGNAL( clicked() ), computeValuesButton, SLOT( showMenu() ) );
116 mExpressionWidget->setLayer( mLayer );
123 minSizeSpinBox->setShowClearButton(
false );
124 maxSizeSpinBox->setShowClearButton(
false );
125 minValueSpinBox->setShowClearButton(
false );
126 maxValueSpinBox->setShowClearButton(
false );
127 nullSizeSpinBox->setShowClearButton(
false );
132 connect( minSizeSpinBox, SIGNAL( valueChanged(
double ) ),
this, SLOT( updatePreview() ) );
133 connect( maxSizeSpinBox, SIGNAL( valueChanged(
double ) ),
this, SLOT( updatePreview() ) );
134 connect( minValueSpinBox, SIGNAL( valueChanged(
double ) ),
this, SLOT( updatePreview() ) );
135 connect( maxValueSpinBox, SIGNAL( valueChanged(
double ) ),
this, SLOT( updatePreview() ) );
136 connect( nullSizeSpinBox, SIGNAL( valueChanged(
double ) ),
this, SLOT( updatePreview() ) );
138 connect( mExpressionWidget, SIGNAL( fieldChanged(
QString ) ),
this, SLOT( computeFromLayerTriggered() ) );
139 connect( scaleMethodComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT( updatePreview() ) );
156 mExpressionWidget->currentField(),
157 minValueSpinBox->value(),
158 maxValueSpinBox->value(),
159 minSizeSpinBox->value(),
160 maxSizeSpinBox->value(),
161 nullSizeSpinBox->value() );
164 void QgsSizeScaleWidget::updatePreview()
166 if ( !mSymbol || !mLayer )
172 treeView->setIconSize(
QSize( 512, 512 ) );
173 mPreviewList.
clear();
175 for (
int i = 0; i < breaks.
length(); i++ )
180 symbol->setSize( expr->size( breaks[i] ) );
182 const QSize sz( node.minimumIconSize() );
183 node.setIconSize( sz );
185 widthMax = qMax( sz.width(), widthMax );
191 for (
int i = 0; i < breaks.
length(); i++ )
194 QPixmap enlarged( widthMax, img.height() );
196 enlarged.
fill( Qt::transparent );
198 p.drawPixmap(
QPoint(( widthMax - img.width() ) / 2, 0 ), img );
204 void QgsSizeScaleWidget::computeFromLayerTriggered()
209 QgsExpression expression( mExpressionWidget->currentField() );
222 double min = DBL_MAX;
223 double max = -DBL_MAX;
225 while ( fit.nextFeature( f ) )
228 const double value = expression.evaluate( f ).toDouble( &ok );
231 max = qMax( max, value );
232 min = qMin( min, value );
235 minValueSpinBox->setValue( min );
236 maxValueSpinBox->setValue( max );
Class for parsing and evaluation of expressions (formerly called "search strings").
Wrapper for iterator of features from vector data provider or vector layer.
void setIcon(const QIcon &icon)
A container class for data source field mapping or expression.
static QList< double > prettyBreaks(double minimum, double maximum, int classes)
Computes a sequence of about 'classes' equally spaced round values which cover the range of values fr...
void fill(const QColor &color)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
Class storing parameters of a scale expression, which is a subclass of QgsExpression for expressions ...
QgsDataDefined dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
QString expressionString() const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QString tr(const char *sourceText, const char *disambiguation, int n)
QPixmap pixmap(const QSize &size, Mode mode, State state) const
ItemDelegate(QStandardItemModel *model)
QString number(int n, int base)
This class wraps a request for features to a vector layer (or directly its vector data provider)...
virtual QgsSymbolV2 * clone() const override
QSize actualSize(const QSize &size, Mode mode, State state) const
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &index) const override
This class tracks map layers that are currently loaded and provides a means to fetch a pointer to a m...
QStandardItem * item(int row, int column) const
void addChildNode(QgsLayerTreeNode *node)
Append an existing node. The node must not have a parent yet. The node will be owned by this group...
Implementation of legend node interface for displaying preview of vector symbols and their labels and...
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
Geometry is not required. It may still be returned if e.g. required for a filter condition.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
void appendRow(const QList< QStandardItem * > &items)
Layer tree node points to a map layer.