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 Q_FOREACH (
const QItemSelectionRange &range, sel )
212 QgsDebugMsg( QStringLiteral(
"RANGE: r %1 - %2" ).arg( range.top() ).arg( range.bottom() ) );
213 if ( range.isValid() )
214 mModel->
removeRows( range.top(), range.bottom() - range.top() + 1, range.parent() );
217 viewRules->selectionModel()->clear();
223 Q_UNUSED( previous );
224 btnEditRule->setEnabled( current.isValid() );
233 #include <QDialogButtonBox> 234 #include <QInputDialog> 235 #include <QClipboard> 239 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
241 if ( indexlist.isEmpty() )
247 else if ( type == 1 )
255 Q_FOREACH (
const QModelIndex &index, indexlist )
256 viewRules->expand( index );
294 Q_FOREACH (
const QModelIndex &index, indexList )
299 if ( !initialRule->
symbol() )
301 QMessageBox::warning(
this, tr(
"Scale Refinement" ), tr(
"Parent rule %1 must have a symbol for this operation." ).arg( initialRule->
label() ) );
306 QString txt = QInputDialog::getText(
this,
307 tr(
"Scale Refinement" ),
308 tr(
"Please enter scale denominators at which will split the rule, separate them by commas (e.g. 1000,5000):" ) );
314 Q_FOREACH (
const QString &item, txt.split(
',' ) )
316 int scale = item.toInt( &ok );
318 scales.append( scale );
320 QMessageBox::information(
this, tr(
"Scale Refinement" ), QString( tr(
"\"%1\" is not valid scale denominator, ignoring it." ) ).arg( item ) );
323 Q_FOREACH (
const QModelIndex &index, indexList )
334 QList<QgsSymbol *> symbolList;
341 QItemSelection sel = viewRules->selectionModel()->selection();
342 Q_FOREACH (
const QItemSelectionRange &range, sel )
344 QModelIndex parent = range.parent();
347 for (
int row = range.top(); row <= range.bottom(); row++ )
349 symbolList.append( children.at( row )->symbol() );
359 QItemSelection sel = viewRules->selectionModel()->selection();
360 Q_FOREACH (
const QItemSelectionRange &range, sel )
362 QModelIndex parent = range.parent();
365 for (
int row = range.top(); row <= range.bottom(); row++ )
367 rl.append( children.at( row )->clone() );
392 if ( event->key() == Qt::Key_C &&
event->modifiers() == Qt::ControlModifier )
398 else if ( event->key() == Qt::Key_V &&
event->modifiers() == Qt::ControlModifier )
400 QgsRuleBasedRenderer::RuleList::const_iterator rIt =
mCopyBuffer.constBegin();
440 QString path =
"/Windows/RuleBasedTree/sectionWidth/" + QString::number( section );
447 QString path = QStringLiteral(
"/Windows/RuleBasedTree/sectionWidth/" );
448 QHeaderView *head = viewRules->header();
449 head->resizeSection( 0, settings.
value( path + QString::number( 0 ), 150 ).toInt() );
450 head->resizeSection( 1, settings.
value( path + QString::number( 1 ), 150 ).toInt() );
451 head->resizeSection( 2, settings.
value( path + QString::number( 2 ), 80 ).toInt() );
452 head->resizeSection( 3, settings.
value( path + QString::number( 3 ), 80 ).toInt() );
453 head->resizeSection( 4, settings.
value( path + QString::number( 4 ), 50 ).toInt() );
454 head->resizeSection( 5, settings.
value( path + QString::number( 5 ), 50 ).toInt() );
459 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
460 QgsDebugMsg( QStringLiteral(
"%1" ).arg( indexlist.count() ) );
462 if ( indexlist.isEmpty() )
466 QApplication::clipboard()->setMimeData( mime );
471 const QMimeData *mime = QApplication::clipboard()->mimeData();
472 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
474 if ( indexlist.isEmpty() )
477 index = indexlist.first();
478 mModel->
dropMimeData( mime, Qt::CopyAction, index.row(), index.column(), index.parent() );
481 void QgsRuleBasedRendererWidget::refineRuleCategoriesAccepted(
QgsPanelWidget *panel )
487 QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
488 Q_FOREACH (
const QModelIndex &index, indexList )
497 void QgsRuleBasedRendererWidget::refineRuleRangesAccepted(
QgsPanelWidget *panel )
502 QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
503 Q_FOREACH (
const QModelIndex &index, indexList )
512 void QgsRuleBasedRendererWidget::ruleWidgetPanelAccepted(
QgsPanelWidget *panel )
521 QModelIndex index = viewRules->selectionModel()->currentIndex();
526 void QgsRuleBasedRendererWidget::liveUpdateRuleFromPanel()
528 ruleWidgetPanelAccepted( qobject_cast<QgsPanelWidget *>( sender() ) );
538 QHash<QgsRuleBasedRenderer::Rule *, QgsRuleBasedRendererCount> countMap;
544 countMap[rule].count = 0;
545 countMap[rule].duplicateCount = 0;
569 QProgressDialog p( tr(
"Calculating feature count." ), tr(
"Abort" ), 0, nFeatures );
570 p.setWindowModality( Qt::WindowModal );
571 int featuresCounted = 0;
581 countMap[rule].count++;
582 if ( featureRuleList.size() > 1 )
584 countMap[rule].duplicateCount++;
588 if ( duplicateRule == rule )
continue;
589 countMap[rule].duplicateCountMap[duplicateRule] += 1;
593 if ( featuresCounted % 50 == 0 )
595 if ( featuresCounted > nFeatures )
599 p.setValue( featuresCounted );
600 if ( p.wasCanceled() )
606 p.setValue( nFeatures );
613 QgsDebugMsg( QStringLiteral(
"rule: %1 count %2" ).arg( rule->
label() ).arg( countMap[rule].count ) );
622 bool enabled = !viewRules->selectionModel()->selectedIndexes().isEmpty();
623 btnRefineRule->setEnabled( enabled );
624 btnRemoveRule->setEnabled( enabled );
636 layout()->setMargin( 0 );
637 layout()->setContentsMargins( 0, 0, 0, 0 );
649 groupScale->setChecked(
true );
650 mScaleRangeWidget->setScaleRange( std::max( rule->
minimumScale(), 0.0 ),
657 groupSymbol->setChecked(
true );
662 groupSymbol->setChecked(
false );
667 mSymbolSelector->setContext(
mContext );
671 QVBoxLayout *l =
new QVBoxLayout;
672 l->addWidget( mSymbolSelector );
673 groupSymbol->setLayout( l );
683 connect( mFilterRadio, &QRadioButton::toggled,
this, [ = ](
bool toggled ) { filterFrame->setEnabled( toggled ) ; } );
684 connect( mElseRadio, &QRadioButton::toggled,
this, [ = ](
bool toggled ) {
if ( toggled ) editFilter->setText( QStringLiteral(
"ELSE" ) );} );
694 setWindowModality( Qt::WindowModal );
697 QVBoxLayout *layout =
new QVBoxLayout(
this );
699 layout->addWidget( scrollArea );
701 buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
704 scrollArea->setWidget( mPropsWidget );
705 layout->addWidget( buttonBox );
706 this->setWindowTitle(
"Edit Rule" );
709 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
710 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsRendererRulePropsDialog::showHelp );
713 restoreGeometry( settings.
value( QStringLiteral(
"Windows/QgsRendererRulePropsDialog/geometry" ) ).toByteArray() );
719 settings.
setValue( QStringLiteral(
"Windows/QgsRendererRulePropsDialog/geometry" ),
saveGeometry() );
734 mPropsWidget->
apply();
738 void QgsRendererRulePropsDialog::showHelp()
740 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html#rule-based-rendering" ) );
757 editFilter->setText( dlg.expressionText() );
762 if ( !mFilterRadio->isChecked() )
766 if ( filter.hasParserError() )
768 QMessageBox::critical(
this, tr(
"Test Filter" ), tr(
"Filter expression parsing error:\n" ) + filter.parserErrorString() );
780 if ( !filter.prepare( &context ) )
782 QMessageBox::critical(
this, tr(
"Test Filter" ), filter.evalErrorString() );
786 QApplication::setOverrideCursor( Qt::WaitCursor );
791 .setExpressionContext( context );
802 QApplication::restoreOverrideCursor();
804 QMessageBox::information(
this, tr(
"Test Filter" ), tr(
"Filter returned %n feature(s)",
"number of filtered features", count ) );
809 QString filter = mElseRadio->isChecked() ? QStringLiteral(
"ELSE" ) : editFilter->text();
810 mRule->setFilterExpression( filter );
811 mRule->setLabel( editLabel->text() );
812 mRule->setDescription( editDescription->text() );
814 mRule->setMinimumScale( groupScale->isChecked() ? mScaleRangeWidget->minimumScale() : 0 );
815 mRule->setMaximumScale( groupScale->isChecked() ? mScaleRangeWidget->maximumScale() : 0 );
816 mRule->setSymbol( groupSymbol->isChecked() ? mSymbol->clone() : nullptr );
822 mSymbolSelector->setDockMode( dockMode );
837 : QAbstractItemModel( parent )
844 if ( !index.isValid() )
845 return Qt::ItemIsDropEnabled;
848 Qt::ItemFlag drop = ( index.column() == 0 ? Qt::ItemIsDropEnabled : Qt::NoItemFlags );
850 Qt::ItemFlag checkable = ( index.column() == 0 ? Qt::ItemIsUserCheckable : Qt::NoItemFlags );
852 return Qt::ItemIsEnabled | Qt::ItemIsSelectable |
853 Qt::ItemIsEditable | checkable |
854 Qt::ItemIsDragEnabled | drop;
859 if ( !index.isValid() )
864 if ( role == Qt::DisplayRole || role == Qt::ToolTipRole )
866 switch ( index.column() )
869 return rule->
label();
892 if ( role == Qt::DisplayRole )
900 QString tip = QStringLiteral(
"<p style='margin:0px;'><ul>" );
902 for (
auto it = duplicateMap.constBegin(); it != duplicateMap.constEnd(); ++it )
904 QString label = it.key()->label().replace(
'&', QLatin1String(
"&" ) ).replace(
'>', QLatin1String(
">" ) ).replace(
'<', QLatin1String(
"<" ) );
905 tip += tr(
"<li><nobr>%1 features also in rule %2</nobr></li>" ).arg( it.value() ).arg( label );
907 tip += QLatin1String(
"</ul>" );
921 else if ( role == Qt::DecorationRole && index.column() == 0 && rule->
symbol() )
926 else if ( role == Qt::TextAlignmentRole )
928 return ( index.column() == 2 || index.column() == 3 ) ? Qt::AlignRight : Qt::AlignLeft;
930 else if ( role == Qt::FontRole && index.column() == 1 )
935 italicFont.setItalic(
true );
940 else if ( role == Qt::EditRole )
942 switch ( index.column() )
945 return rule->
label();
956 else if ( role == Qt::CheckStateRole )
958 if ( index.column() != 0 )
960 return rule->
active() ? Qt::Checked : Qt::Unchecked;
968 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < 7 )
971 lst << tr(
"Label" ) << tr(
"Rule" ) << tr(
"Min. scale" ) << tr(
"Max. scale" ) << tr(
"Count" ) << tr(
"Duplicate count" );
974 else if ( orientation == Qt::Horizontal && role == Qt::ToolTipRole )
978 return tr(
"Number of features in this rule." );
980 else if ( section == 5 )
982 return tr(
"Number of features in this rule which are also present in other rule(s)." );
991 if ( parent.column() > 0 )
996 return parentRule->
children().count();
1006 if ( hasIndex( row, column, parent ) )
1010 return createIndex( row, column, childRule );
1012 return QModelIndex();
1017 if ( !index.isValid() )
1018 return QModelIndex();
1024 return QModelIndex();
1027 int row = parentRule->
parent()->
children().indexOf( parentRule );
1029 return createIndex( row, 0, parentRule );
1034 if ( !index.isValid() )
1039 if ( role == Qt::CheckStateRole )
1041 rule->
setActive( value.toInt() == Qt::Checked );
1042 emit dataChanged( index, index );
1046 if ( role != Qt::EditRole )
1049 switch ( index.column() )
1052 rule->
setLabel( value.toString() );
1067 emit dataChanged( index, index );
1073 return Qt::MoveAction;
1079 types << QStringLiteral(
"application/vnd.text.list" );
1085 QMimeData *
mimeData =
new QMimeData();
1086 QByteArray encodedData;
1088 QDataStream stream( &encodedData, QIODevice::WriteOnly );
1090 Q_FOREACH (
const QModelIndex &
index, indexes )
1093 if ( !index.isValid() || index.column() != 0 )
1102 QDomElement rootElem = doc.createElement( QStringLiteral(
"rule_mime" ) );
1103 rootElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"renderer" ) );
1104 QDomElement rulesElem = rule->
save( doc, symbols );
1105 rootElem.appendChild( rulesElem );
1107 rootElem.appendChild( symbolsElem );
1108 doc.appendChild( rootElem );
1112 stream << doc.toString( -1 );
1115 mimeData->setData( QStringLiteral(
"application/vnd.text.list" ), encodedData );
1124 if ( ruleElem.hasAttribute( QStringLiteral(
"description" ) ) )
1125 ruleElem.setAttribute( QStringLiteral(
"label" ), ruleElem.attribute( QStringLiteral(
"description" ) ) );
1128 QDomElement childRuleElem = ruleElem.firstChildElement( QStringLiteral(
"rule" ) );
1129 while ( !childRuleElem.isNull() )
1132 childRuleElem = childRuleElem.nextSiblingElement( QStringLiteral(
"rule" ) );
1138 Qt::DropAction action,
int row,
int column,
const QModelIndex &
parent )
1142 if ( action == Qt::IgnoreAction )
1145 if ( !data->hasFormat( QStringLiteral(
"application/vnd.text.list" ) ) )
1148 if ( parent.column() > 0 )
1151 QByteArray encodedData = data->data( QStringLiteral(
"application/vnd.text.list" ) );
1152 QDataStream stream( &encodedData, QIODevice::ReadOnly );
1161 while ( !stream.atEnd() )
1167 if ( !doc.setContent( text ) )
1169 QDomElement rootElem = doc.documentElement();
1170 if ( rootElem.tagName() != QLatin1String(
"rule_mime" ) )
1172 if ( rootElem.attribute( QStringLiteral(
"type" ) ) == QLatin1String(
"labeling" ) )
1173 rootElem.appendChild( doc.createElement( QStringLiteral(
"symbols" ) ) );
1174 QDomElement symbolsElem = rootElem.firstChildElement( QStringLiteral(
"symbols" ) );
1175 if ( symbolsElem.isNull() )
1178 QDomElement ruleElem = rootElem.firstChildElement( QStringLiteral(
"rule" ) );
1179 if ( rootElem.attribute( QStringLiteral(
"type" ) ) == QLatin1String(
"labeling" ) )
1192 if ( index.isValid() )
1193 return static_cast<QgsRuleBasedRenderer::Rule *>( index.internalPointer() );
1201 if ( row < 0 || row >= parentRule->
children().count() )
1204 QgsDebugMsg( QStringLiteral(
"Called: row %1 count %2 parent ~~%3~~" ).arg( row ).arg( count ).arg( parentRule->
dump() ) );
1206 beginRemoveRows( parent, row, row + count - 1 );
1208 for (
int i = 0; i < count; i++ )
1210 if ( row < parentRule->children().count() )
1218 QgsDebugMsg( QStringLiteral(
"trying to remove invalid index - this should not happen!" ) );
1230 beginInsertRows( parent, before, before );
1232 QgsDebugMsg( QStringLiteral(
"insert before %1 rule: %2" ).arg( before ).arg( newrule->
dump() ) );
1242 emit dataChanged(
index( row, 0, parent ),
1248 emit dataChanged(
index( 0, 0, idx ),
1251 for (
int i = 0; i <
rowCount( idx ); i++ )
1260 if ( !index.isValid() )
1263 beginRemoveRows( index.parent(), index.row(), index.row() );
1266 rule->parent()->removeChild( rule );
1274 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.
void insertRule(const QModelIndex &parent, int before, QgsRuleBasedRenderer::Rule *newrule)
Tree model for the rules:
QgsRuleBasedRenderer::Rule * clone() const
clone this rule, return new instance
bool dependsOnScale() const
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:
bool active() const
Returns if this rule is active.
const QgsRuleBasedRenderer::RuleList & children()
Returns all children rules of this rule.
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.
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.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setForceOrderingEnabled(bool enabled)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
int columnCount(const QModelIndex &=QModelIndex()) const override
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
double maximumScale() const
Returns the maximum map scale (i.e.
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 QIcon symbolPreviewIcon(QgsSymbol *symbol, QSize size, int padding=0)
Returns an icon preview for a color ramp.
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.
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()
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
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 ...
QString filterExpression() const
A filter that will check if this rule applies.
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
static QString toString(double scale)
Helper function to convert a scale double to scale string.
double minimumScale() const
Returns the minimum map scale (i.e.
Qt::ItemFlags flags(const QModelIndex &index) const override
bool isElse() const
Check if this rule is an ELSE rule.
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 ...
void setActive(bool state)
Sets if this rule is active.
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()
QgsRuleBasedRenderer::RuleList descendants() const
Returns all children, grand-children, grand-grand-children, grand-gra...
QString description() const
A human readable description for this rule.
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
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
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)
QDomElement save(QDomDocument &doc, QgsSymbolMap &symbolMap) const
QgsRuleBasedRenderer::Rule * ruleForIndex(const QModelIndex &index) const
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.
QgsRuleBasedRenderer::Rule * parent()
The parent rule.