37 #include <QProgressDialog> 38 #include <QTreeWidgetItem> 39 #include <QVBoxLayout> 40 #include <QMessageBox> 43 #ifdef ENABLE_MODELTEST 44 #include "modeltest.h" 50 return new QgsRuleBasedRendererWidget( layer, style, renderer );
55 , mContextMenu( new QMenu( this ) )
75 this->layout()->setContentsMargins( 0, 0, 0, 0 );
78 #ifdef ENABLE_MODELTEST 79 new ModelTest(
mModel,
this );
81 viewRules->setModel(
mModel );
84 mDeleteAction->setShortcut( QKeySequence( QKeySequence::Delete ) );
90 mRefineMenu =
new QMenu( tr(
"Refine Current Rule" ), btnRefineRule );
103 connect( viewRules, &QWidget::customContextMenuRequested,
this, &QgsRuleBasedRendererWidget::showContextMenu );
155 QModelIndex currentIndex = viewRules->selectionModel()->currentIndex();
156 mModel->
insertRule( currentIndex.parent(), currentIndex.row() + 1, newrule );
157 QModelIndex newindex =
mModel->
index( currentIndex.row() + 1, 0, currentIndex.parent() );
158 viewRules->selectionModel()->setCurrentIndex( newindex, QItemSelectionModel::ClearAndSelect );
166 viewRules->selectionModel()->setCurrentIndex( newindex, QItemSelectionModel::ClearAndSelect );
173 QItemSelectionModel *sel = viewRules->selectionModel();
174 QModelIndex idx = sel->currentIndex();
175 if ( !idx.isValid() )
182 editRule( viewRules->selectionModel()->currentIndex() );
187 if ( !index.isValid() )
195 QgsRendererRulePropsWidget *widget =
new QgsRendererRulePropsWidget( rule,
mLayer,
mStyle,
this,
mContext );
196 widget->setPanelTitle( tr(
"Edit Rule" ) );
214 QItemSelection sel = viewRules->selectionModel()->selection();
215 QgsDebugMsg( QStringLiteral(
"REMOVE RULES!!! ranges: %1" ).arg( sel.count() ) );
216 const auto constSel = sel;
217 for (
const QItemSelectionRange &range : constSel )
219 QgsDebugMsg( QStringLiteral(
"RANGE: r %1 - %2" ).arg( range.top() ).arg( range.bottom() ) );
220 if ( range.isValid() )
221 mModel->
removeRows( range.top(), range.bottom() - range.top() + 1, range.parent() );
224 viewRules->selectionModel()->clear();
231 btnEditRule->setEnabled( current.isValid() );
240 #include <QDialogButtonBox> 241 #include <QInputDialog> 242 #include <QClipboard> 246 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
248 if ( indexlist.isEmpty() )
254 else if ( type == 1 )
262 const auto constIndexlist = indexlist;
263 for (
const QModelIndex &index : constIndexlist )
264 viewRules->expand( index );
284 QgsCategorizedSymbolRendererWidget *w =
new QgsCategorizedSymbolRendererWidget(
mLayer,
mStyle,
nullptr );
285 w->setPanelTitle( tr(
"Add Categories to Rules" ) );
293 QgsGraduatedSymbolRendererWidget *w =
new QgsGraduatedSymbolRendererWidget(
mLayer,
mStyle,
nullptr );
294 w->setPanelTitle( tr(
"Add Ranges to Rules" ) );
302 for (
const QModelIndex &index : indexList )
307 if ( !initialRule->
symbol() )
309 QMessageBox::warning(
this, tr(
"Scale Refinement" ), tr(
"Parent rule %1 must have a symbol for this operation." ).arg( initialRule->
label() ) );
314 QString txt = QInputDialog::getText(
this,
315 tr(
"Scale Refinement" ),
316 tr(
"Please enter scale denominators at which will split the rule, separate them by commas (e.g. 1000,5000):" ) );
322 const auto constSplit = txt.split(
',' );
323 for (
const QString &item : constSplit )
325 int scale = item.toInt( &ok );
327 scales.append( scale );
329 QMessageBox::information(
this, tr(
"Scale Refinement" ), QString( tr(
"\"%1\" is not valid scale denominator, ignoring it." ) ).arg( item ) );
332 for (
const QModelIndex &index : indexList )
343 QList<QgsSymbol *> symbolList;
350 QItemSelection sel = viewRules->selectionModel()->selection();
351 const auto constSel = sel;
352 for (
const QItemSelectionRange &range : constSel )
354 QModelIndex parent = range.parent();
357 for (
int row = range.top(); row <= range.bottom(); row++ )
359 symbolList.append( children.at( row )->symbol() );
369 QItemSelection sel = viewRules->selectionModel()->selection();
370 const auto constSel = sel;
371 for (
const QItemSelectionRange &range : constSel )
373 QModelIndex parent = range.parent();
376 for (
int row = range.top(); row <= range.bottom(); row++ )
378 rl.append( children.at( row )->clone() );
403 if ( event->key() == Qt::Key_C &&
event->modifiers() == Qt::ControlModifier )
409 else if ( event->key() == Qt::Key_V &&
event->modifiers() == Qt::ControlModifier )
411 QgsRuleBasedRenderer::RuleList::const_iterator rIt =
mCopyBuffer.constBegin();
451 QString path =
"/Windows/RuleBasedTree/sectionWidth/" + QString::number( section );
458 QString path = QStringLiteral(
"/Windows/RuleBasedTree/sectionWidth/" );
459 QHeaderView *head = viewRules->header();
460 head->resizeSection( 0, settings.
value( path + QString::number( 0 ), 150 ).toInt() );
461 head->resizeSection( 1, settings.
value( path + QString::number( 1 ), 150 ).toInt() );
462 head->resizeSection( 2, settings.
value( path + QString::number( 2 ), 80 ).toInt() );
463 head->resizeSection( 3, settings.
value( path + QString::number( 3 ), 80 ).toInt() );
464 head->resizeSection( 4, settings.
value( path + QString::number( 4 ), 50 ).toInt() );
465 head->resizeSection( 5, settings.
value( path + QString::number( 5 ), 50 ).toInt() );
470 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
471 QgsDebugMsg( QStringLiteral(
"%1" ).arg( indexlist.count() ) );
473 if ( indexlist.isEmpty() )
477 QApplication::clipboard()->setMimeData( mime );
482 const QMimeData *mime = QApplication::clipboard()->mimeData();
483 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
485 if ( indexlist.isEmpty() )
488 index = indexlist.first();
489 mModel->
dropMimeData( mime, Qt::CopyAction, index.row(), index.column(), index.parent() );
498 const QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
499 for (
const QModelIndex &index : indexList )
503 if ( !rule->symbol() || rule->symbol()->type() != tempSymbol->type() )
512 void QgsRuleBasedRendererWidget::refineRuleCategoriesAccepted(
QgsPanelWidget *panel )
514 QgsCategorizedSymbolRendererWidget *w = qobject_cast<QgsCategorizedSymbolRendererWidget *>( panel );
518 QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
519 const auto constIndexList = indexList;
520 for (
const QModelIndex &index : constIndexList )
529 void QgsRuleBasedRendererWidget::refineRuleRangesAccepted(
QgsPanelWidget *panel )
531 QgsGraduatedSymbolRendererWidget *w = qobject_cast<QgsGraduatedSymbolRendererWidget *>( panel );
534 QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
535 const auto constIndexList = indexList;
536 for (
const QModelIndex &index : constIndexList )
545 void QgsRuleBasedRendererWidget::ruleWidgetPanelAccepted(
QgsPanelWidget *panel )
547 QgsRendererRulePropsWidget *widget = qobject_cast<QgsRendererRulePropsWidget *>( panel );
554 QModelIndex index = viewRules->selectionModel()->currentIndex();
559 void QgsRuleBasedRendererWidget::liveUpdateRuleFromPanel()
561 ruleWidgetPanelAccepted( qobject_cast<QgsPanelWidget *>( sender() ) );
564 void QgsRuleBasedRendererWidget::showContextMenu( QPoint )
570 const QList< QAction * > actions =
contextMenu->actions();
571 for ( QAction *act : actions )
588 QHash<QgsRuleBasedRenderer::Rule *, QgsRuleBasedRendererCount> countMap;
592 const auto constRuleList = ruleList;
595 countMap[rule].count = 0;
596 countMap[rule].duplicateCount = 0;
621 QProgressDialog p( tr(
"Calculating feature count." ), tr(
"Abort" ), 0, nFeatures );
622 p.setWindowModality( Qt::WindowModal );
623 int featuresCounted = 0;
631 const auto constFeatureRuleList = featureRuleList;
634 countMap[rule].count++;
635 if ( featureRuleList.size() > 1 )
637 countMap[rule].duplicateCount++;
639 const auto constFeatureRuleList = featureRuleList;
642 if ( duplicateRule == rule )
continue;
643 countMap[rule].duplicateCountMap[duplicateRule] += 1;
647 if ( featuresCounted % 50 == 0 )
649 if ( featuresCounted > nFeatures )
653 p.setValue( featuresCounted );
654 if ( p.wasCanceled() )
660 p.setValue( nFeatures );
665 const auto constKeys = countMap.keys();
668 QgsDebugMsg( QStringLiteral(
"rule: %1 count %2" ).arg( rule->label() ).arg( countMap[rule].count ) );
677 bool enabled = !viewRules->selectionModel()->selectedIndexes().isEmpty();
678 btnRefineRule->setEnabled( enabled );
679 btnRemoveRule->setEnabled( enabled );
691 layout()->setMargin( 0 );
692 layout()->setContentsMargins( 0, 0, 0, 0 );
704 groupScale->setChecked(
true );
705 mScaleRangeWidget->setScaleRange( std::max( rule->
minimumScale(), 0.0 ),
712 groupSymbol->setChecked(
true );
717 groupSymbol->setChecked(
false );
722 mSymbolSelector->setContext(
mContext );
726 QVBoxLayout *l =
new QVBoxLayout;
727 l->addWidget( mSymbolSelector );
728 groupSymbol->setLayout( l );
738 connect( mFilterRadio, &QRadioButton::toggled,
this, [ = ](
bool toggled ) { filterFrame->setEnabled( toggled ) ; } );
739 connect( mElseRadio, &QRadioButton::toggled,
this, [ = ](
bool toggled ) {
if ( toggled ) editFilter->setText( QStringLiteral(
"ELSE" ) );} );
749 setWindowModality( Qt::WindowModal );
752 QVBoxLayout *layout =
new QVBoxLayout(
this );
754 layout->addWidget( scrollArea );
756 buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
757 mPropsWidget =
new QgsRendererRulePropsWidget( rule, layer, style,
this, context );
759 scrollArea->setWidget( mPropsWidget );
760 layout->addWidget( buttonBox );
761 this->setWindowTitle(
"Edit Rule" );
765 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
766 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsRendererRulePropsDialog::showHelp );
771 mPropsWidget->testFilter();
776 mPropsWidget->buildExpression();
781 mPropsWidget->apply();
785 void QgsRendererRulePropsDialog::showHelp()
787 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html#rule-based-rendering" ) );
796 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
805 editFilter->setText( dlg.expressionText() );
810 if ( !mFilterRadio->isChecked() )
814 if ( filter.hasParserError() )
816 QMessageBox::critical(
this, tr(
"Test Filter" ), tr(
"Filter expression parsing error:\n" ) + filter.parserErrorString() );
823 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
829 if ( !filter.prepare( &context ) )
831 QMessageBox::critical(
this, tr(
"Test Filter" ), filter.evalErrorString() );
835 QApplication::setOverrideCursor( Qt::WaitCursor );
840 .setExpressionContext( context );
851 QApplication::restoreOverrideCursor();
853 QMessageBox::information(
this, tr(
"Test Filter" ), tr(
"Filter returned %n feature(s)",
"number of filtered features", count ) );
858 QString filter = mElseRadio->isChecked() ? QStringLiteral(
"ELSE" ) : editFilter->text();
859 mRule->setFilterExpression( filter );
860 mRule->setLabel( editLabel->text() );
861 mRule->setDescription( editDescription->text() );
863 mRule->setMinimumScale( groupScale->isChecked() ? mScaleRangeWidget->minimumScale() : 0 );
864 mRule->setMaximumScale( groupScale->isChecked() ? mScaleRangeWidget->maximumScale() : 0 );
865 mRule->setSymbol( groupSymbol->isChecked() ? mSymbol->clone() : nullptr );
871 mSymbolSelector->setDockMode( dockMode );
886 : QAbstractItemModel( parent )
893 if ( !index.isValid() )
894 return Qt::ItemIsDropEnabled;
897 Qt::ItemFlag drop = ( index.column() == 0 ? Qt::ItemIsDropEnabled : Qt::NoItemFlags );
899 Qt::ItemFlag checkable = ( index.column() == 0 ? Qt::ItemIsUserCheckable : Qt::NoItemFlags );
901 return Qt::ItemIsEnabled | Qt::ItemIsSelectable |
902 Qt::ItemIsEditable | checkable |
903 Qt::ItemIsDragEnabled | drop;
908 if ( !index.isValid() )
913 if ( role == Qt::DisplayRole || role == Qt::ToolTipRole )
915 switch ( index.column() )
918 return rule->
label();
941 if ( role == Qt::DisplayRole )
949 QString tip = QStringLiteral(
"<p style='margin:0px;'><ul>" );
951 for (
auto it = duplicateMap.constBegin(); it != duplicateMap.constEnd(); ++it )
953 QString label = it.key()->label().replace(
'&', QLatin1String(
"&" ) ).replace(
'>', QLatin1String(
">" ) ).replace(
'<', QLatin1String(
"<" ) );
954 tip += tr(
"<li><nobr>%1 features also in rule %2</nobr></li>" ).arg( it.value() ).arg( label );
956 tip += QLatin1String(
"</ul>" );
970 else if ( role == Qt::DecorationRole && index.column() == 0 && rule->
symbol() )
975 else if ( role == Qt::TextAlignmentRole )
977 return ( index.column() == 2 || index.column() == 3 ) ? Qt::AlignRight : Qt::AlignLeft;
979 else if ( role == Qt::FontRole && index.column() == 1 )
984 italicFont.setItalic(
true );
989 else if ( role == Qt::EditRole )
991 switch ( index.column() )
994 return rule->
label();
1005 else if ( role == Qt::CheckStateRole )
1007 if ( index.column() != 0 )
1009 return rule->
active() ? Qt::Checked : Qt::Unchecked;
1017 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < 7 )
1020 lst << tr(
"Label" ) << tr(
"Rule" ) << tr(
"Min. scale" ) << tr(
"Max. scale" ) << tr(
"Count" ) << tr(
"Duplicate count" );
1021 return lst[section];
1023 else if ( orientation == Qt::Horizontal && role == Qt::ToolTipRole )
1027 return tr(
"Number of features in this rule." );
1029 else if ( section == 5 )
1031 return tr(
"Number of features in this rule which are also present in other rule(s)." );
1040 if ( parent.column() > 0 )
1045 return parentRule->
children().count();
1055 if ( hasIndex( row, column, parent ) )
1059 return createIndex( row, column, childRule );
1061 return QModelIndex();
1066 if ( !index.isValid() )
1067 return QModelIndex();
1073 return QModelIndex();
1076 int row = parentRule->
parent()->
children().indexOf( parentRule );
1078 return createIndex( row, 0, parentRule );
1083 if ( !index.isValid() )
1088 if ( role == Qt::CheckStateRole )
1090 rule->
setActive( value.toInt() == Qt::Checked );
1091 emit dataChanged( index, index );
1095 if ( role != Qt::EditRole )
1098 switch ( index.column() )
1101 rule->
setLabel( value.toString() );
1116 emit dataChanged( index, index );
1122 return Qt::MoveAction;
1128 types << QStringLiteral(
"application/vnd.text.list" );
1134 QMimeData *
mimeData =
new QMimeData();
1135 QByteArray encodedData;
1137 QDataStream stream( &encodedData, QIODevice::WriteOnly );
1139 const auto constIndexes = indexes;
1140 for (
const QModelIndex &
index : constIndexes )
1143 if ( !
index.isValid() ||
index.column() != 0 )
1152 QDomElement rootElem = doc.createElement( QStringLiteral(
"rule_mime" ) );
1153 rootElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"renderer" ) );
1154 QDomElement rulesElem = rule->
save( doc, symbols );
1155 rootElem.appendChild( rulesElem );
1157 rootElem.appendChild( symbolsElem );
1158 doc.appendChild( rootElem );
1162 stream << doc.toString( -1 );
1165 mimeData->setData( QStringLiteral(
"application/vnd.text.list" ), encodedData );
1174 if ( ruleElem.hasAttribute( QStringLiteral(
"description" ) ) )
1175 ruleElem.setAttribute( QStringLiteral(
"label" ), ruleElem.attribute( QStringLiteral(
"description" ) ) );
1178 QDomElement childRuleElem = ruleElem.firstChildElement( QStringLiteral(
"rule" ) );
1179 while ( !childRuleElem.isNull() )
1182 childRuleElem = childRuleElem.nextSiblingElement( QStringLiteral(
"rule" ) );
1188 Qt::DropAction action,
int row,
int column,
const QModelIndex &
parent )
1192 if ( action == Qt::IgnoreAction )
1195 if ( !data->hasFormat( QStringLiteral(
"application/vnd.text.list" ) ) )
1198 if ( parent.column() > 0 )
1201 QByteArray encodedData = data->data( QStringLiteral(
"application/vnd.text.list" ) );
1202 QDataStream stream( &encodedData, QIODevice::ReadOnly );
1211 while ( !stream.atEnd() )
1217 if ( !doc.setContent( text ) )
1219 QDomElement rootElem = doc.documentElement();
1220 if ( rootElem.tagName() != QLatin1String(
"rule_mime" ) )
1222 if ( rootElem.attribute( QStringLiteral(
"type" ) ) == QLatin1String(
"labeling" ) )
1223 rootElem.appendChild( doc.createElement( QStringLiteral(
"symbols" ) ) );
1224 QDomElement symbolsElem = rootElem.firstChildElement( QStringLiteral(
"symbols" ) );
1225 if ( symbolsElem.isNull() )
1228 QDomElement ruleElem = rootElem.firstChildElement( QStringLiteral(
"rule" ) );
1229 if ( rootElem.attribute( QStringLiteral(
"type" ) ) == QLatin1String(
"labeling" ) )
1242 if ( index.isValid() )
1243 return static_cast<QgsRuleBasedRenderer::Rule *>( index.internalPointer() );
1251 if ( row < 0 || row >= parentRule->
children().count() )
1254 QgsDebugMsg( QStringLiteral(
"Called: row %1 count %2 parent ~~%3~~" ).arg( row ).arg( count ).arg( parentRule->
dump() ) );
1256 beginRemoveRows( parent, row, row + count - 1 );
1258 for (
int i = 0; i < count; i++ )
1260 if ( row < parentRule->children().count() )
1268 QgsDebugMsg( QStringLiteral(
"trying to remove invalid index - this should not happen!" ) );
1280 beginInsertRows( parent, before, before );
1282 QgsDebugMsg( QStringLiteral(
"insert before %1 rule: %2" ).arg( before ).arg( newrule->
dump() ) );
1292 emit dataChanged(
index( row, 0, parent ),
1298 emit dataChanged(
index( 0, 0, idx ),
1301 for (
int i = 0; i <
rowCount( idx ); i++ )
1310 if ( !index.isValid() )
1313 beginRemoveRows( index.parent(), index.row(), index.row() );
1316 rule->parent()->removeChild( rule );
1325 emit dataChanged( index, index );
1331 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.
static QgsSymbol * symbolFromMimeData(const QMimeData *data)
Attempts to parse mime data as a symbol.
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 setSymbol(const QModelIndex &index, QgsSymbol *symbol)
Sets the symbol for the rule at the specified index.
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...
static QgsGui * instance()
Returns a pointer to the singleton instance.
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.
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.
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 setSymbol(QgsSymbol *sym)
Sets a new symbol (or nullptr). Deletes old symbol.
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)
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 enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
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.