37 #include <QProgressDialog> 38 #include <QTreeWidgetItem> 39 #include <QVBoxLayout> 40 #include <QMessageBox> 42 #ifdef ENABLE_MODELTEST 43 #include "modeltest.h" 73 this->layout()->setContentsMargins( 0, 0, 0, 0 );
76 #ifdef ENABLE_MODELTEST 77 new ModelTest(
mModel,
this );
79 viewRules->setModel(
mModel );
82 mDeleteAction->setShortcut( QKeySequence( QKeySequence::Delete ) );
88 mRefineMenu =
new QMenu( tr(
"Refine Current Rule" ), btnRefineRule );
149 QModelIndex currentIndex = viewRules->selectionModel()->currentIndex();
150 mModel->
insertRule( currentIndex.parent(), currentIndex.row() + 1, newrule );
151 QModelIndex newindex =
mModel->
index( currentIndex.row() + 1, 0, currentIndex.parent() );
152 viewRules->selectionModel()->setCurrentIndex( newindex, QItemSelectionModel::ClearAndSelect );
160 viewRules->selectionModel()->setCurrentIndex( newindex, QItemSelectionModel::ClearAndSelect );
167 QItemSelectionModel *sel = viewRules->selectionModel();
168 QModelIndex idx = sel->currentIndex();
169 if ( !idx.isValid() )
176 editRule( viewRules->selectionModel()->currentIndex() );
181 if ( !index.isValid() )
208 QItemSelection sel = viewRules->selectionModel()->selection();
209 QgsDebugMsg( QStringLiteral(
"REMOVE RULES!!! ranges: %1" ).arg( sel.count() ) );
210 const auto constSel = sel;
211 for (
const QItemSelectionRange &range : constSel )
213 QgsDebugMsg( QStringLiteral(
"RANGE: r %1 - %2" ).arg( range.top() ).arg( range.bottom() ) );
214 if ( range.isValid() )
215 mModel->
removeRows( range.top(), range.bottom() - range.top() + 1, range.parent() );
218 viewRules->selectionModel()->clear();
225 btnEditRule->setEnabled( current.isValid() );
234 #include <QDialogButtonBox> 235 #include <QInputDialog> 236 #include <QClipboard> 240 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
242 if ( indexlist.isEmpty() )
248 else if ( type == 1 )
256 const auto constIndexlist = indexlist;
257 for (
const QModelIndex &index : constIndexlist )
258 viewRules->expand( index );
296 for (
const QModelIndex &index : indexList )
301 if ( !initialRule->
symbol() )
303 QMessageBox::warning(
this, tr(
"Scale Refinement" ), tr(
"Parent rule %1 must have a symbol for this operation." ).arg( initialRule->
label() ) );
308 QString txt = QInputDialog::getText(
this,
309 tr(
"Scale Refinement" ),
310 tr(
"Please enter scale denominators at which will split the rule, separate them by commas (e.g. 1000,5000):" ) );
316 const auto constSplit = txt.split(
',' );
317 for (
const QString &item : constSplit )
319 int scale = item.toInt( &ok );
321 scales.append( scale );
323 QMessageBox::information(
this, tr(
"Scale Refinement" ), QString( tr(
"\"%1\" is not valid scale denominator, ignoring it." ) ).arg( item ) );
326 for (
const QModelIndex &index : indexList )
337 QList<QgsSymbol *> symbolList;
344 QItemSelection sel = viewRules->selectionModel()->selection();
345 const auto constSel = sel;
346 for (
const QItemSelectionRange &range : constSel )
348 QModelIndex parent = range.parent();
351 for (
int row = range.top(); row <= range.bottom(); row++ )
353 symbolList.append( children.at( row )->symbol() );
363 QItemSelection sel = viewRules->selectionModel()->selection();
364 const auto constSel = sel;
365 for (
const QItemSelectionRange &range : constSel )
367 QModelIndex parent = range.parent();
370 for (
int row = range.top(); row <= range.bottom(); row++ )
372 rl.append( children.at( row )->clone() );
397 if ( event->key() == Qt::Key_C &&
event->modifiers() == Qt::ControlModifier )
403 else if ( event->key() == Qt::Key_V &&
event->modifiers() == Qt::ControlModifier )
405 QgsRuleBasedRenderer::RuleList::const_iterator rIt =
mCopyBuffer.constBegin();
445 QString path =
"/Windows/RuleBasedTree/sectionWidth/" + QString::number( section );
452 QString path = QStringLiteral(
"/Windows/RuleBasedTree/sectionWidth/" );
453 QHeaderView *head = viewRules->header();
454 head->resizeSection( 0, settings.
value( path + QString::number( 0 ), 150 ).toInt() );
455 head->resizeSection( 1, settings.
value( path + QString::number( 1 ), 150 ).toInt() );
456 head->resizeSection( 2, settings.
value( path + QString::number( 2 ), 80 ).toInt() );
457 head->resizeSection( 3, settings.
value( path + QString::number( 3 ), 80 ).toInt() );
458 head->resizeSection( 4, settings.
value( path + QString::number( 4 ), 50 ).toInt() );
459 head->resizeSection( 5, settings.
value( path + QString::number( 5 ), 50 ).toInt() );
464 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
465 QgsDebugMsg( QStringLiteral(
"%1" ).arg( indexlist.count() ) );
467 if ( indexlist.isEmpty() )
471 QApplication::clipboard()->setMimeData( mime );
476 const QMimeData *mime = QApplication::clipboard()->mimeData();
477 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
479 if ( indexlist.isEmpty() )
482 index = indexlist.first();
483 mModel->
dropMimeData( mime, Qt::CopyAction, index.row(), index.column(), index.parent() );
486 void QgsRuleBasedRendererWidget::refineRuleCategoriesAccepted(
QgsPanelWidget *panel )
492 QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
493 const auto constIndexList = indexList;
494 for (
const QModelIndex &index : constIndexList )
503 void QgsRuleBasedRendererWidget::refineRuleRangesAccepted(
QgsPanelWidget *panel )
508 QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
509 const auto constIndexList = indexList;
510 for (
const QModelIndex &index : constIndexList )
519 void QgsRuleBasedRendererWidget::ruleWidgetPanelAccepted(
QgsPanelWidget *panel )
528 QModelIndex index = viewRules->selectionModel()->currentIndex();
533 void QgsRuleBasedRendererWidget::liveUpdateRuleFromPanel()
535 ruleWidgetPanelAccepted( qobject_cast<QgsPanelWidget *>( sender() ) );
545 QHash<QgsRuleBasedRenderer::Rule *, QgsRuleBasedRendererCount> countMap;
549 const auto constRuleList = ruleList;
552 countMap[rule].count = 0;
553 countMap[rule].duplicateCount = 0;
578 QProgressDialog p( tr(
"Calculating feature count." ), tr(
"Abort" ), 0, nFeatures );
579 p.setWindowModality( Qt::WindowModal );
580 int featuresCounted = 0;
588 const auto constFeatureRuleList = featureRuleList;
591 countMap[rule].count++;
592 if ( featureRuleList.size() > 1 )
594 countMap[rule].duplicateCount++;
596 const auto constFeatureRuleList = featureRuleList;
599 if ( duplicateRule == rule )
continue;
600 countMap[rule].duplicateCountMap[duplicateRule] += 1;
604 if ( featuresCounted % 50 == 0 )
606 if ( featuresCounted > nFeatures )
610 p.setValue( featuresCounted );
611 if ( p.wasCanceled() )
617 p.setValue( nFeatures );
622 const auto constKeys = countMap.keys();
625 QgsDebugMsg( QStringLiteral(
"rule: %1 count %2" ).arg( rule->label() ).arg( countMap[rule].count ) );
634 bool enabled = !viewRules->selectionModel()->selectedIndexes().isEmpty();
635 btnRefineRule->setEnabled( enabled );
636 btnRemoveRule->setEnabled( enabled );
648 layout()->setMargin( 0 );
649 layout()->setContentsMargins( 0, 0, 0, 0 );
661 groupScale->setChecked(
true );
662 mScaleRangeWidget->setScaleRange( std::max( rule->
minimumScale(), 0.0 ),
669 groupSymbol->setChecked(
true );
674 groupSymbol->setChecked(
false );
679 mSymbolSelector->setContext(
mContext );
683 QVBoxLayout *l =
new QVBoxLayout;
684 l->addWidget( mSymbolSelector );
685 groupSymbol->setLayout( l );
695 connect( mFilterRadio, &QRadioButton::toggled,
this, [ = ](
bool toggled ) { filterFrame->setEnabled( toggled ) ; } );
696 connect( mElseRadio, &QRadioButton::toggled,
this, [ = ](
bool toggled ) {
if ( toggled ) editFilter->setText( QStringLiteral(
"ELSE" ) );} );
706 setWindowModality( Qt::WindowModal );
709 QVBoxLayout *layout =
new QVBoxLayout(
this );
711 layout->addWidget( scrollArea );
713 buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
716 scrollArea->setWidget( mPropsWidget );
717 layout->addWidget( buttonBox );
718 this->setWindowTitle(
"Edit Rule" );
721 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
722 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsRendererRulePropsDialog::showHelp );
725 restoreGeometry( settings.
value( QStringLiteral(
"Windows/QgsRendererRulePropsDialog/geometry" ) ).toByteArray() );
731 settings.
setValue( QStringLiteral(
"Windows/QgsRendererRulePropsDialog/geometry" ),
saveGeometry() );
746 mPropsWidget->
apply();
750 void QgsRendererRulePropsDialog::showHelp()
752 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html#rule-based-rendering" ) );
761 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
770 editFilter->setText( dlg.expressionText() );
775 if ( !mFilterRadio->isChecked() )
779 if ( filter.hasParserError() )
781 QMessageBox::critical(
this, tr(
"Test Filter" ), tr(
"Filter expression parsing error:\n" ) + filter.parserErrorString() );
788 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
794 if ( !filter.prepare( &context ) )
796 QMessageBox::critical(
this, tr(
"Test Filter" ), filter.evalErrorString() );
800 QApplication::setOverrideCursor( Qt::WaitCursor );
805 .setExpressionContext( context );
816 QApplication::restoreOverrideCursor();
818 QMessageBox::information(
this, tr(
"Test Filter" ), tr(
"Filter returned %n feature(s)",
"number of filtered features", count ) );
823 QString filter = mElseRadio->isChecked() ? QStringLiteral(
"ELSE" ) : editFilter->text();
824 mRule->setFilterExpression( filter );
825 mRule->setLabel( editLabel->text() );
826 mRule->setDescription( editDescription->text() );
828 mRule->setMinimumScale( groupScale->isChecked() ? mScaleRangeWidget->minimumScale() : 0 );
829 mRule->setMaximumScale( groupScale->isChecked() ? mScaleRangeWidget->maximumScale() : 0 );
830 mRule->setSymbol( groupSymbol->isChecked() ? mSymbol->clone() : nullptr );
836 mSymbolSelector->setDockMode( dockMode );
851 : QAbstractItemModel( parent )
858 if ( !index.isValid() )
859 return Qt::ItemIsDropEnabled;
862 Qt::ItemFlag drop = ( index.column() == 0 ? Qt::ItemIsDropEnabled : Qt::NoItemFlags );
864 Qt::ItemFlag checkable = ( index.column() == 0 ? Qt::ItemIsUserCheckable : Qt::NoItemFlags );
866 return Qt::ItemIsEnabled | Qt::ItemIsSelectable |
867 Qt::ItemIsEditable | checkable |
868 Qt::ItemIsDragEnabled | drop;
873 if ( !index.isValid() )
878 if ( role == Qt::DisplayRole || role == Qt::ToolTipRole )
880 switch ( index.column() )
883 return rule->
label();
906 if ( role == Qt::DisplayRole )
914 QString tip = QStringLiteral(
"<p style='margin:0px;'><ul>" );
916 for (
auto it = duplicateMap.constBegin(); it != duplicateMap.constEnd(); ++it )
918 QString label = it.key()->label().replace(
'&', QLatin1String(
"&" ) ).replace(
'>', QLatin1String(
">" ) ).replace(
'<', QLatin1String(
"<" ) );
919 tip += tr(
"<li><nobr>%1 features also in rule %2</nobr></li>" ).arg( it.value() ).arg( label );
921 tip += QLatin1String(
"</ul>" );
935 else if ( role == Qt::DecorationRole && index.column() == 0 && rule->
symbol() )
940 else if ( role == Qt::TextAlignmentRole )
942 return ( index.column() == 2 || index.column() == 3 ) ? Qt::AlignRight : Qt::AlignLeft;
944 else if ( role == Qt::FontRole && index.column() == 1 )
949 italicFont.setItalic(
true );
954 else if ( role == Qt::EditRole )
956 switch ( index.column() )
959 return rule->
label();
970 else if ( role == Qt::CheckStateRole )
972 if ( index.column() != 0 )
974 return rule->
active() ? Qt::Checked : Qt::Unchecked;
982 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < 7 )
985 lst << tr(
"Label" ) << tr(
"Rule" ) << tr(
"Min. scale" ) << tr(
"Max. scale" ) << tr(
"Count" ) << tr(
"Duplicate count" );
988 else if ( orientation == Qt::Horizontal && role == Qt::ToolTipRole )
992 return tr(
"Number of features in this rule." );
994 else if ( section == 5 )
996 return tr(
"Number of features in this rule which are also present in other rule(s)." );
1005 if ( parent.column() > 0 )
1010 return parentRule->
children().count();
1020 if ( hasIndex( row, column, parent ) )
1024 return createIndex( row, column, childRule );
1026 return QModelIndex();
1031 if ( !index.isValid() )
1032 return QModelIndex();
1038 return QModelIndex();
1041 int row = parentRule->
parent()->
children().indexOf( parentRule );
1043 return createIndex( row, 0, parentRule );
1048 if ( !index.isValid() )
1053 if ( role == Qt::CheckStateRole )
1055 rule->
setActive( value.toInt() == Qt::Checked );
1056 emit dataChanged( index, index );
1060 if ( role != Qt::EditRole )
1063 switch ( index.column() )
1066 rule->
setLabel( value.toString() );
1081 emit dataChanged( index, index );
1087 return Qt::MoveAction;
1093 types << QStringLiteral(
"application/vnd.text.list" );
1099 QMimeData *
mimeData =
new QMimeData();
1100 QByteArray encodedData;
1102 QDataStream stream( &encodedData, QIODevice::WriteOnly );
1104 const auto constIndexes = indexes;
1105 for (
const QModelIndex &
index : constIndexes )
1108 if ( !
index.isValid() ||
index.column() != 0 )
1117 QDomElement rootElem = doc.createElement( QStringLiteral(
"rule_mime" ) );
1118 rootElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"renderer" ) );
1119 QDomElement rulesElem = rule->
save( doc, symbols );
1120 rootElem.appendChild( rulesElem );
1122 rootElem.appendChild( symbolsElem );
1123 doc.appendChild( rootElem );
1127 stream << doc.toString( -1 );
1130 mimeData->setData( QStringLiteral(
"application/vnd.text.list" ), encodedData );
1139 if ( ruleElem.hasAttribute( QStringLiteral(
"description" ) ) )
1140 ruleElem.setAttribute( QStringLiteral(
"label" ), ruleElem.attribute( QStringLiteral(
"description" ) ) );
1143 QDomElement childRuleElem = ruleElem.firstChildElement( QStringLiteral(
"rule" ) );
1144 while ( !childRuleElem.isNull() )
1147 childRuleElem = childRuleElem.nextSiblingElement( QStringLiteral(
"rule" ) );
1153 Qt::DropAction action,
int row,
int column,
const QModelIndex &
parent )
1157 if ( action == Qt::IgnoreAction )
1160 if ( !data->hasFormat( QStringLiteral(
"application/vnd.text.list" ) ) )
1163 if ( parent.column() > 0 )
1166 QByteArray encodedData = data->data( QStringLiteral(
"application/vnd.text.list" ) );
1167 QDataStream stream( &encodedData, QIODevice::ReadOnly );
1176 while ( !stream.atEnd() )
1182 if ( !doc.setContent( text ) )
1184 QDomElement rootElem = doc.documentElement();
1185 if ( rootElem.tagName() != QLatin1String(
"rule_mime" ) )
1187 if ( rootElem.attribute( QStringLiteral(
"type" ) ) == QLatin1String(
"labeling" ) )
1188 rootElem.appendChild( doc.createElement( QStringLiteral(
"symbols" ) ) );
1189 QDomElement symbolsElem = rootElem.firstChildElement( QStringLiteral(
"symbols" ) );
1190 if ( symbolsElem.isNull() )
1193 QDomElement ruleElem = rootElem.firstChildElement( QStringLiteral(
"rule" ) );
1194 if ( rootElem.attribute( QStringLiteral(
"type" ) ) == QLatin1String(
"labeling" ) )
1207 if ( index.isValid() )
1208 return static_cast<QgsRuleBasedRenderer::Rule *>( index.internalPointer() );
1216 if ( row < 0 || row >= parentRule->
children().count() )
1219 QgsDebugMsg( QStringLiteral(
"Called: row %1 count %2 parent ~~%3~~" ).arg( row ).arg( count ).arg( parentRule->
dump() ) );
1221 beginRemoveRows( parent, row, row + count - 1 );
1223 for (
int i = 0; i < count; i++ )
1225 if ( row < parentRule->children().count() )
1233 QgsDebugMsg( QStringLiteral(
"trying to remove invalid index - this should not happen!" ) );
1245 beginInsertRows( parent, before, before );
1247 QgsDebugMsg( QStringLiteral(
"insert before %1 rule: %2" ).arg( before ).arg( newrule->
dump() ) );
1257 emit dataChanged(
index( row, 0, parent ),
1263 emit dataChanged(
index( 0, 0, idx ),
1266 for (
int i = 0; i <
rowCount( idx ); i++ )
1275 if ( !index.isValid() )
1278 beginRemoveRows( index.parent(), index.row(), index.row() );
1281 rule->parent()->removeChild( rule );
1289 beginInsertRows( parent, row, row + count - 1 );
Class for parsing and evaluation of expressions (formerly called "search strings").
The class is used as a container of context for various read/write operations on other objects...
Wrapper for iterator of features from vector data provider or vector layer.
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
QDomElement save(QDomDocument &doc, QgsSymbolMap &symbolMap) const
void insertRule(const QModelIndex &parent, int before, QgsRuleBasedRenderer::Rule *newrule)
Tree model for the rules:
QgsRuleBasedRenderer::RuleList descendants() const
Returns all children, grand-children, grand-grand-children, grand-gra...
Abstract base class for all rendered symbols.
QMimeData * mimeData(const QModelIndexList &indexes) const override
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
This class is a composition of two QSettings instances:
const QgsRuleBasedRenderer::RuleList & children()
Returns all children rules of this rule.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
This class keeps data about a rules for rule-based renderer.
void setRendererScale(double scale)
Sets the renderer map scale.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
static QIcon symbolPreviewIcon(const QgsSymbol *symbol, QSize size, int padding=0)
Returns an icon preview for a color ramp.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
void updateRule(const QModelIndex &parent, int row)
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
bool dependsOnScale() const
void setForceOrderingEnabled(bool enabled)
double maximumScale() const
Returns the maximum map scale (i.e.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
int columnCount(const QModelIndex &=QModelIndex()) const override
QString description() const
A human readable description for this rule.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
bool isElse() const
Check if this rule is an ELSE rule.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
bool active() const
Returns if this rule is active.
void saveGeometry(QWidget *widget, const QString &keyName)
Save the wigget geometry into settings.
QList< QgsRuleBasedRenderer::Rule * > RuleList
QString dump(int indent=0) const
Dump for debug purpose.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
bool restoreGeometry(QWidget *widget, const QString &keyName)
Restore the wigget geometry from settings.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
static QDomElement saveSymbols(QgsSymbolMap &symbols, const QString &tagName, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a collection of symbols to XML with specified tagName for the top-level element.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
QgsRuleBasedRenderer::RuleList rulesForFeature(const QgsFeature &feature, QgsRenderContext *context=nullptr, bool onlyActive=true)
Returns the list of rules used to render the feature in a specific context.
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
This class wraps a request for features to a vector layer (or directly its vector data provider)...
When drawing a vector layer with rule-based renderer, it goes through the rules and draws features wi...
QgsRuleBasedRenderer::Rule * rootRule()
double minimumScale() const
Returns the minimum map scale (i.e.
void insertChild(int i, QgsRuleBasedRenderer::Rule *rule)
add child rule, take ownership, sets this as parent
Single scope for storing variables and functions for use within a QgsExpressionContext.
QHash< QgsRuleBasedRenderer::Rule *, QgsRuleBasedRendererCount > mFeatureCountMap
QModelIndex parent(const QModelIndex &index) const override
static QgsSymbolMap loadSymbols(QDomElement &element, const QgsReadWriteContext &context)
Reads a collection of symbols from XML and returns them in a map. Caller is responsible for deleting ...
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
void willAddRules(const QModelIndex &parent, int count)
QgsRuleBasedRendererModel(QgsRuleBasedRenderer *renderer, QObject *parent)
Constructor for QgsRuleBasedRendererModel, for the specified renderer.
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
A dialog which allows the user to modify the rendering order of symbol layers.
void setFeatureCounts(const QHash< QgsRuleBasedRenderer::Rule *, QgsRuleBasedRendererCount > &countMap)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QgsRuleBasedRenderer::Rule * ruleForIndex(const QModelIndex &index) const
static QString toString(double scale)
Helper function to convert a scale double to scale string.
Qt::ItemFlags flags(const QModelIndex &index) const override
QgsExpressionContext & expressionContext()
Gets the expression context.
static void refineRuleRanges(QgsRuleBasedRenderer::Rule *initialRule, QgsGraduatedSymbolRenderer *r)
take a rule and create a list of new rules based on the ranges from graduated symbol renderer ...
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
void setActive(bool state)
Sets if this rule is active.
QgsRuleBasedRenderer::Rule * clone() const
clone this rule, return new instance
Contains information about the context of a rendering operation.
void clearFeatureCounts()
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
void setLabel(const QString &label)
~QgsRendererRulePropsDialog() override
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
static QgsRuleBasedRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
creates a QgsRuleBasedRenderer from an existing renderer.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QMap< QString, QgsSymbol *> QgsSymbolMap
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
void finishedAddingRules()
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
static void refineRuleCategories(QgsRuleBasedRenderer::Rule *initialRule, QgsCategorizedSymbolRenderer *r)
take a rule and create a list of new rules based on the categories from categorized symbol renderer ...
QgsRuleBasedRenderer * mR
QString filter(const QgsFields &fields=QgsFields()) override
If a renderer does not require all the features this method may be overridden and return an expressio...
void setFilterExpression(const QString &filterExp)
Set the expression used to check if a given feature shall be rendered with this rule.
bool nextFeature(QgsFeature &f)
static void refineRuleScales(QgsRuleBasedRenderer::Rule *initialRule, QList< int > scales)
take a rule and create a list of new rules with intervals of scales given by the passed scale denomin...
void removeChildAt(int i)
delete child rule
QString filterExpression() const
A filter that will check if this rule applies.
static QgsRuleBasedRenderer::Rule * create(QDomElement &ruleElem, QgsSymbolMap &symbolMap)
Create a rule from an XML definition.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
Qt::DropActions supportedDropActions() const override
Represents a vector layer which manages a vector based data sets.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
A generic dialog for building expression strings.
void removeRule(const QModelIndex &index)
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QgsRendererRulePropsDialog(QgsRuleBasedRenderer::Rule *rule, QgsVectorLayer *layer, QgsStyle *style, QWidget *parent=nullptr, const QgsSymbolWidgetContext &context=QgsSymbolWidgetContext())
Constructor for QgsRendererRulePropsDialog.
QStringList mimeTypes() const override
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...
QgsRuleBasedRenderer::Rule * parent()
The parent rule.