38#include <QProgressDialog>
41#include <QTreeWidgetItem>
44#include "moc_qgsrulebasedrendererwidget.cpp"
46using namespace Qt::StringLiterals;
48#ifdef ENABLE_MODELTEST
76 mRenderer = std::make_unique<QgsRuleBasedRenderer>( symbol );
82 this->layout()->setContentsMargins( 0, 0, 0, 0 );
85#ifdef ENABLE_MODELTEST
86 new ModelTest(
mModel,
this );
88 viewRules->setModel(
mModel );
91 mDeleteAction->setShortcut( QKeySequence( QKeySequence::Delete ) );
97 mRefineMenu =
new QMenu( tr(
"Refine Current Rule" ), btnRefineRule );
110 connect( viewRules, &QWidget::customContextMenuRequested,
this, &QgsRuleBasedRendererWidget::showContextMenu );
135 connect(
mContextMenu, &QMenu::aboutToShow,
this, [
this] {
171 QModelIndex currentIndex = viewRules->selectionModel()->currentIndex();
172 mModel->insertRule( currentIndex.parent(), currentIndex.row() + 1, newrule );
173 QModelIndex newindex =
mModel->index( currentIndex.row() + 1, 0, currentIndex.parent() );
174 viewRules->selectionModel()->setCurrentIndex( newindex, QItemSelectionModel::ClearAndSelect );
179 int rows =
mModel->rowCount();
180 mModel->insertRule( QModelIndex(), rows, newrule );
181 QModelIndex newindex =
mModel->index( rows, 0 );
182 viewRules->selectionModel()->setCurrentIndex( newindex, QItemSelectionModel::ClearAndSelect );
189 QItemSelectionModel *sel = viewRules->selectionModel();
190 QModelIndex idx = sel->currentIndex();
191 if ( !idx.isValid() )
193 return mModel->ruleForIndex( idx );
198 editRule( viewRules->selectionModel()->currentIndex() );
203 if ( !index.isValid() )
222 mModel->updateRule( index.parent(), index.row() );
223 mModel->clearFeatureCounts();
230 QItemSelection sel = viewRules->selectionModel()->selection();
232 const auto constSel = sel;
233 for (
const QItemSelectionRange &range : constSel )
235 QgsDebugMsgLevel( u
"RANGE: r %1 - %2"_s.arg( range.top() ).arg( range.bottom() ), 2 );
236 if ( range.isValid() )
237 mModel->removeRows( range.top(), range.bottom() - range.top() + 1, range.parent() );
240 viewRules->selectionModel()->clear();
241 mModel->clearFeatureCounts();
247 btnEditRule->setEnabled( current.isValid() );
256#include <QDialogButtonBox>
257#include <QInputDialog>
262 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
264 if ( indexlist.isEmpty() )
270 else if ( type == 1 )
278 const auto constIndexlist = indexlist;
279 for (
const QModelIndex &index : constIndexlist )
280 viewRules->expand( index );
318 for (
const QModelIndex &index : indexList )
323 if ( !initialRule->
symbol() )
325 QMessageBox::warning(
this, tr(
"Scale Refinement" ), tr(
"Parent rule %1 must have a symbol for this operation." ).arg( initialRule->
label() ) );
330 QString txt = QInputDialog::getText(
this, tr(
"Scale Refinement" ), tr(
"Please enter scale denominators at which will split the rule, separate them by commas (e.g. 1000,5000):" ) );
336 const auto constSplit = txt.split(
',' );
337 for (
const QString &item : constSplit )
339 int scale = item.toInt( &ok );
341 scales.append( scale );
343 QMessageBox::information(
this, tr(
"Scale Refinement" ), tr(
"\"%1\" is not valid scale denominator, ignoring it." ).arg( item ) );
346 for (
const QModelIndex &index : indexList )
349 mModel->willAddRules( index, scales.count() + 1 );
352 mModel->finishedAddingRules();
365 mRenderer->setLegendSymbolItem( legendSymbol.ruleKey(), sym->
clone() );
374 QList<QgsSymbol *> symbolList;
381 QItemSelection sel = viewRules->selectionModel()->selection();
382 const auto constSel = sel;
383 for (
const QItemSelectionRange &range : constSel )
385 QModelIndex parent = range.parent();
388 for (
int row = range.top(); row <= range.bottom(); row++ )
390 symbolList.append( children.at( row )->symbol() );
400 QItemSelection sel = viewRules->selectionModel()->selection();
401 const auto constSel = sel;
402 for (
const QItemSelectionRange &range : constSel )
404 QModelIndex parent = range.parent();
407 for (
int row = range.top(); row <= range.bottom(); row++ )
409 rl.append( children.at( row )->clone() );
434 if ( event->key() == Qt::Key_C && event->modifiers() == Qt::ControlModifier )
440 else if ( event->key() == Qt::Key_V && event->modifiers() == Qt::ControlModifier )
442 QgsRuleBasedRenderer::RuleList::const_iterator rIt =
mCopyBuffer.constBegin();
445 int rows =
mModel->rowCount();
446 mModel->insertRule( QModelIndex(), rows, ( *rIt )->clone() );
484 QString path =
"/Windows/RuleBasedTree/sectionWidth/" + QString::number( section );
491 QString path = u
"/Windows/RuleBasedTree/sectionWidth/"_s;
492 QHeaderView *head = viewRules->header();
493 head->resizeSection( 0, settings.
value( path + QString::number( 0 ), 150 ).toInt() );
494 head->resizeSection( 1, settings.
value( path + QString::number( 1 ), 150 ).toInt() );
495 head->resizeSection( 2, settings.
value( path + QString::number( 2 ), 80 ).toInt() );
496 head->resizeSection( 3, settings.
value( path + QString::number( 3 ), 80 ).toInt() );
497 head->resizeSection( 4, settings.
value( path + QString::number( 4 ), 50 ).toInt() );
498 head->resizeSection( 5, settings.
value( path + QString::number( 5 ), 50 ).toInt() );
503 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
506 if ( indexlist.isEmpty() )
509 QMimeData *mime =
mModel->mimeData( indexlist );
510 QApplication::clipboard()->setMimeData( mime );
515 const QMimeData *mime = QApplication::clipboard()->mimeData();
519 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
521 if ( indexlist.isEmpty() )
524 index = indexlist.first();
525 mModel->dropMimeData( mime, Qt::CopyAction, index.row(), index.column(), index.parent() );
534 const QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
535 for (
const QModelIndex &index : indexList )
539 if ( !rule->symbol() || rule->symbol()->type() != tempSymbol->type() )
542 mModel->setSymbol( index, tempSymbol->clone() );
548void QgsRuleBasedRendererWidget::refineRuleCategoriesAccepted(
QgsPanelWidget *panel )
554 QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
555 const auto constIndexList = indexList;
556 for (
const QModelIndex &index : constIndexList )
562 mModel->finishedAddingRules();
565void QgsRuleBasedRendererWidget::refineRuleRangesAccepted(
QgsPanelWidget *panel )
567 QgsGraduatedSymbolRendererWidget *w = qobject_cast<QgsGraduatedSymbolRendererWidget *>( panel );
569 QgsGraduatedSymbolRenderer *r =
static_cast<QgsGraduatedSymbolRenderer *
>( w->
renderer() );
570 QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
571 const auto constIndexList = indexList;
572 for (
const QModelIndex &index : constIndexList )
574 QgsRuleBasedRenderer::Rule *initialRule =
mModel->ruleForIndex( index );
578 mModel->finishedAddingRules();
581void QgsRuleBasedRendererWidget::ruleWidgetPanelAccepted(
QgsPanelWidget *panel )
583 QgsRendererRulePropsWidget *widget = qobject_cast<QgsRendererRulePropsWidget *>( panel );
590 QModelIndex index = viewRules->selectionModel()->currentIndex();
591 mModel->updateRule( index.parent(), index.row() );
592 mModel->clearFeatureCounts();
595void QgsRuleBasedRendererWidget::liveUpdateRuleFromPanel()
597 ruleWidgetPanelAccepted( qobject_cast<QgsPanelWidget *>( sender() ) );
600void QgsRuleBasedRendererWidget::showContextMenu( QPoint )
606 const QList<QAction *> actions =
contextMenu->actions();
607 for ( QAction *act : actions )
624 QHash<QgsRuleBasedRenderer::Rule *, QgsRuleBasedRendererCount> countMap;
628 const auto constRuleList = ruleList;
631 countMap[rule].count = 0;
632 countMap[rule].duplicateCount = 0;
641 const auto constAdditionalExpressionContextScopes =
mContext.additionalExpressionContextScopes();
656 long long nFeatures =
mLayer->featureCount();
657 QProgressDialog p( tr(
"Calculating feature count." ), tr(
"Abort" ), 0, 100 );
658 p.setWindowModality( Qt::WindowModal );
659 long long featuresCounted = 0;
667 const auto constFeatureRuleList = featureRuleList;
670 countMap[rule].count++;
671 if ( featureRuleList.size() > 1 )
673 countMap[rule].duplicateCount++;
675 const auto constFeatureRuleList = featureRuleList;
678 if ( duplicateRule == rule )
680 countMap[rule].duplicateCountMap[duplicateRule] += 1;
684 if ( featuresCounted % 50 == 0 )
686 if ( featuresCounted > nFeatures )
690 p.setValue(
static_cast<double>( featuresCounted ) / nFeatures * 100.0 );
691 if ( p.wasCanceled() )
697 p.setValue( nFeatures );
702 const auto constKeys = countMap.keys();
705 QgsDebugMsgLevel( u
"rule: %1 count %2"_s.arg( rule->label() ).arg( countMap[rule].count ), 2 );
709 mModel->setFeatureCounts( countMap );
714 bool enabled = !viewRules->selectionModel()->selectedIndexes().isEmpty();
715 btnRefineRule->setEnabled( enabled );
716 btnRemoveRule->setEnabled( enabled );
728 layout()->setContentsMargins( 0, 0, 0, 0 );
730 mElseRadio->setChecked(
mRule->isElse() );
731 mFilterRadio->setChecked( !
mRule->isElse() );
732 editFilter->setText(
mRule->filterExpression() );
733 editFilter->setToolTip(
mRule->filterExpression() );
734 editLabel->setText(
mRule->label() );
735 editDescription->setText(
mRule->description() );
736 editDescription->setToolTip(
mRule->description() );
738 if (
mRule->dependsOnScale() )
740 groupScale->setChecked(
true );
741 mScaleRangeWidget->setScaleRange( std::max(
rule->minimumScale(), 0.0 ), std::max(
rule->maximumScale(), 0.0 ) );
743 mScaleRangeWidget->setMapCanvas(
mContext.mapCanvas() );
745 if (
mRule->symbol() )
747 groupSymbol->setChecked(
true );
752 groupSymbol->setChecked(
false );
761 QVBoxLayout *l =
new QVBoxLayout;
763 groupSymbol->setLayout( l );
773 connect( mFilterRadio, &QRadioButton::toggled,
this, [
this](
bool toggled ) { filterFrame->setEnabled( toggled ); } );
774 connect( mElseRadio, &QRadioButton::toggled,
this, [
this](
bool toggled ) {
if ( toggled ) editFilter->setText( u
"ELSE"_s ); } );
783 setWindowModality( Qt::WindowModal );
786 QVBoxLayout *layout =
new QVBoxLayout(
this );
788 scrollArea->setFrameShape( QFrame::NoFrame );
789 layout->addWidget( scrollArea );
791 buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
794 scrollArea->setWidget( mPropsWidget );
795 layout->addWidget( buttonBox );
796 this->setWindowTitle(
"Edit Rule" );
800 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
801 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsRendererRulePropsDialog::showHelp );
806 mPropsWidget->testFilter();
811 mPropsWidget->buildExpression();
816 mPropsWidget->apply();
820void QgsRendererRulePropsDialog::showHelp()
822 QgsHelp::openHelp( u
"working_with_vector/vector_properties.html#rule-based-rendering"_s );
831 const auto constAdditionalExpressionContextScopes =
mContext.additionalExpressionContextScopes();
845 if ( !mFilterRadio->isChecked() )
851 QMessageBox::critical(
this, tr(
"Test Filter" ), tr(
"Filter expression parsing error:\n" ) + filter.
parserErrorString() );
858 const auto constAdditionalExpressionContextScopes =
mContext.additionalExpressionContextScopes();
864 if ( !filter.
prepare( &context ) )
866 QMessageBox::critical(
this, tr(
"Test Filter" ), filter.
evalErrorString() );
870 QApplication::setOverrideCursor( Qt::WaitCursor );
883 QApplication::restoreOverrideCursor();
885 QMessageBox::information(
this, tr(
"Test Filter" ), tr(
"Filter returned %n feature(s)",
"number of filtered features", count ) );
890 QString filter = mElseRadio->isChecked() ? u
"ELSE"_s : editFilter->text();
891 mRule->setFilterExpression( filter );
892 mRule->setLabel( editLabel->text() );
893 mRule->setDescription( editDescription->text() );
895 mRule->setMinimumScale( groupScale->isChecked() ? mScaleRangeWidget->minimumScale() : 0 );
896 mRule->setMaximumScale( groupScale->isChecked() ? mScaleRangeWidget->maximumScale() : 0 );
897 mRule->setSymbol( groupSymbol->isChecked() ?
mSymbol->clone() :
nullptr );
918 : QAbstractItemModel(
parent )
926 if ( !
index.isValid() )
927 return Qt::ItemIsDropEnabled;
930 Qt::ItemFlag drop = (
index.column() == 0 ? Qt::ItemIsDropEnabled : Qt::NoItemFlags );
932 Qt::ItemFlag checkable = (
index.column() == 0 ? Qt::ItemIsUserCheckable : Qt::NoItemFlags );
934 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | checkable | Qt::ItemIsDragEnabled | drop;
939 if ( !
index.isValid() )
944 if ( role == Qt::DisplayRole || role == Qt::ToolTipRole )
946 switch (
index.column() )
949 return rule->
label();
972 if ( role == Qt::DisplayRole )
980 QString tip = u
"<p style='margin:0px;'><ul>"_s;
982 for (
auto it = duplicateMap.constBegin(); it != duplicateMap.constEnd(); ++it )
984 QString label = it.key()->label().replace(
'&',
"&"_L1 ).replace(
'>',
">"_L1 ).replace(
'<',
"<"_L1 );
985 tip += tr(
"<li><nobr>%1 features also in rule %2</nobr></li>" ).arg( it.value() ).arg( label );
1001 else if ( role == Qt::DecorationRole &&
index.column() == 0 && rule->
symbol() )
1006 else if ( role == Qt::TextAlignmentRole )
1008 return (
index.column() == 2 ||
index.column() == 3 ) ?
static_cast<Qt::Alignment::Int
>( Qt::AlignRight ) :
static_cast<Qt::Alignment::Int
>( Qt::AlignLeft );
1010 else if ( role == Qt::FontRole &&
index.column() == 1 )
1015 italicFont.setItalic(
true );
1020 else if ( role == Qt::EditRole )
1022 switch (
index.column() )
1025 return rule->
label();
1036 else if ( role == Qt::CheckStateRole )
1038 if (
index.column() != 0 )
1040 return rule->
active() ? Qt::Checked : Qt::Unchecked;
1048 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < 7 )
1051 lst << tr(
"Label" ) << tr(
"Rule" ) << tr(
"Min. Scale" ) << tr(
"Max. Scale" ) << tr(
"Count" ) << tr(
"Duplicate Count" );
1052 return lst[section];
1054 else if ( orientation == Qt::Horizontal && role == Qt::ToolTipRole )
1058 return tr(
"Number of features in this rule." );
1060 else if ( section == 5 )
1062 return tr(
"Number of features in this rule which are also present in other rule(s)." );
1071 if (
parent.column() > 0 )
1076 return parentRule->
children().count();
1086 if ( hasIndex( row, column,
parent ) )
1090 return createIndex( row, column, childRule );
1092 return QModelIndex();
1097 if ( !
index.isValid() )
1098 return QModelIndex();
1103 if ( parentRule ==
mR->rootRule() )
1104 return QModelIndex();
1107 int row = parentRule->
parent()->
children().indexOf( parentRule );
1109 return createIndex( row, 0, parentRule );
1114 if ( !
index.isValid() )
1119 if ( role == Qt::CheckStateRole )
1121 rule->
setActive( value.toInt() == Qt::Checked );
1126 if ( role != Qt::EditRole )
1129 switch (
index.column() )
1132 rule->
setLabel( value.toString() );
1153 return Qt::MoveAction;
1159 types << u
"application/vnd.text.list"_s;
1165 QMimeData *
mimeData =
new QMimeData();
1166 QByteArray encodedData;
1168 QDataStream stream( &encodedData, QIODevice::WriteOnly );
1170 const auto constIndexes = indexes;
1171 for (
const QModelIndex &
index : constIndexes )
1174 if ( !
index.isValid() ||
index.column() != 0 )
1183 QDomElement rootElem = doc.createElement( u
"rule_mime"_s );
1184 rootElem.setAttribute( u
"type"_s, u
"renderer"_s );
1185 QDomElement rulesElem = rule->
save( doc, symbols );
1186 rootElem.appendChild( rulesElem );
1188 rootElem.appendChild( symbolsElem );
1189 doc.appendChild( rootElem );
1193 stream << doc.toString( -1 );
1196 mimeData->setData( u
"application/vnd.text.list"_s, encodedData );
1205 if ( ruleElem.hasAttribute( u
"description"_s ) )
1206 ruleElem.setAttribute( u
"label"_s, ruleElem.attribute( u
"description"_s ) );
1209 QDomElement childRuleElem = ruleElem.firstChildElement( u
"rule"_s );
1210 while ( !childRuleElem.isNull() )
1213 childRuleElem = childRuleElem.nextSiblingElement( u
"rule"_s );
1222 if ( action == Qt::IgnoreAction )
1225 if ( !
data->hasFormat( u
"application/vnd.text.list"_s ) )
1228 if (
parent.column() > 0 )
1231 QByteArray encodedData =
data->data( u
"application/vnd.text.list"_s );
1232 QDataStream stream( &encodedData, QIODevice::ReadOnly );
1241 while ( !stream.atEnd() )
1247 if ( !doc.setContent( text ) )
1249 QDomElement rootElem = doc.documentElement();
1250 if ( rootElem.tagName() !=
"rule_mime"_L1 )
1252 if ( rootElem.attribute( u
"type"_s ) ==
"labeling"_L1 )
1253 rootElem.appendChild( doc.createElement( u
"symbols"_s ) );
1254 QDomElement symbolsElem = rootElem.firstChildElement( u
"symbols"_s );
1255 if ( symbolsElem.isNull() )
1258 QDomElement ruleElem = rootElem.firstChildElement( u
"rule"_s );
1259 if ( rootElem.attribute( u
"type"_s ) ==
"labeling"_L1 )
1272 if (
index.isValid() )
1274 return mR->rootRule();
1281 if ( row < 0 || row >= parentRule->
children().count() )
1284 QgsDebugMsgLevel( u
"Called: row %1 count %2 parent ~~%3~~"_s.arg( row ).arg( count ).arg( parentRule->
dump() ), 2 );
1286 beginRemoveRows(
parent, row, row + count - 1 );
1288 for (
int i = 0; i < count; i++ )
1290 if ( row < parentRule->children().count() )
1298 QgsDebugError( u
"trying to remove invalid index - this should not happen!"_s );
1310 beginInsertRows(
parent, before, before );
1329 for (
int i = 0; i <
rowCount( idx ); i++ )
1338 if ( !
index.isValid() )
1359 beginInsertRows(
parent, row, row + count - 1 );
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
A feature renderer which represents features using a list of renderer categories.
const QgsCategoryList & categories() const
Returns a list of all categories recognized by the renderer.
A generic dialog for building expression strings.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Handles parsing and evaluation of expressions (formerly called "search strings").
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
QString evalErrorString() const
Returns evaluation error.
QString parserErrorString() const
Returns parser error.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
Abstract base class for all 2D vector feature renderers.
Wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFlags(Qgis::FeatureRequestFlags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
const QgsRangeList & ranges() const
Returns a list of all ranges used in the classification.
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.
Stores information about one class/rule of a vector layer renderer in a unified way that can be used ...
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
void setRendererScale(double scale)
Sets the renderer map scale.
A dialog for editing the details of a rule based renderer rule.
QgsRuleBasedRenderer::Rule * rule()
QgsRendererRulePropsDialog(QgsRuleBasedRenderer::Rule *rule, QgsVectorLayer *layer, QgsStyle *style, QWidget *parent=nullptr, const QgsSymbolWidgetContext &context=QgsSymbolWidgetContext())
Constructor for QgsRendererRulePropsDialog.
Tree model for a rule-based renderer's rules.
QgsRuleBasedRenderer::Rule * ruleForIndex(const QModelIndex &index) const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QPointer< QScreen > mScreen
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
void updateRule(const QModelIndex &parent, int row)
void willAddRules(const QModelIndex &parent, int count)
Qt::ItemFlags flags(const QModelIndex &index) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void setSymbol(const QModelIndex &index, QgsSymbol *symbol)
Sets the symbol for the rule at the specified index.
void clearFeatureCounts()
QStringList mimeTypes() const override
void removeRule(const QModelIndex &index)
int columnCount(const QModelIndex &=QModelIndex()) const override
Qt::DropActions supportedDropActions() const override
QgsRuleBasedRendererModel(QgsRuleBasedRenderer *renderer, QObject *parent, QScreen *screen=nullptr)
Constructor for QgsRuleBasedRendererModel, for the specified renderer.
void setFeatureCounts(const QHash< QgsRuleBasedRenderer::Rule *, QgsRuleBasedRendererCount > &countMap)
QgsRuleBasedRenderer * mR
QModelIndex parent(const QModelIndex &index) const override
QHash< QgsRuleBasedRenderer::Rule *, QgsRuleBasedRendererCount > mFeatureCountMap
QMimeData * mimeData(const QModelIndexList &indexes) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void insertRule(const QModelIndex &parent, int before, QgsRuleBasedRenderer::Rule *newrule)
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
void finishedAddingRules()
Represents an individual rule for a rule-based renderer.
void setSymbol(QgsSymbol *sym)
Sets a new symbol (or nullptr). Deletes old symbol.
void removeChild(QgsRuleBasedRenderer::Rule *rule)
delete child rule
void insertChild(int i, QgsRuleBasedRenderer::Rule *rule)
add child rule, take ownership, sets this as parent
static QgsRuleBasedRenderer::Rule * create(QDomElement &ruleElem, QgsSymbolMap &symbolMap, bool reuseId=true, const QgsReadWriteContext &context=QgsReadWriteContext())
Create a rule from an XML definition.
bool dependsOnScale() const
const QgsRuleBasedRenderer::RuleList & children() const
Returns all children rules of this rule.
double maximumScale() const
Returns the maximum map scale (i.e.
QgsRuleBasedRenderer::Rule * parent()
The parent rule.
bool isElse() const
Check if this rule is an ELSE rule.
QgsRuleBasedRenderer::Rule * clone() const
clone this rule, return new instance
void removeChildAt(int i)
delete child rule
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
void setActive(bool state)
Sets if this rule is active.
QDomElement save(QDomDocument &doc, QgsSymbolMap &symbolMap) const
double minimumScale() const
Returns the minimum map scale (i.e.
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
void setFilterExpression(const QString &filterExp)
Set the expression used to check if a given feature shall be rendered with this rule.
void setLabel(const QString &label)
QString dump(int indent=0) const
Dump for debug purpose.
QString filterExpression() const
A filter that will check if this rule applies.
bool active() const
Returns if this rule is active.
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
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
static QgsRuleBasedRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer, QgsVectorLayer *layer=nullptr)
Creates a new QgsRuleBasedRenderer from an existing renderer.
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...
QList< QgsRuleBasedRenderer::Rule * > RuleList
static QString toString(double scale, QgsScaleComboBox::RatioMode mode=QgsScaleComboBox::RatioMode::ForceUnitNumerator)
Helper function to convert a scale double to scale string.
Stores properties relating to a screen.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
A database of saved style entities, including symbols, color ramps, text formats and others.
static std::unique_ptr< QgsSymbol > symbolFromMimeData(const QMimeData *data)
Attempts to parse mime data as a symbol.
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 ...
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.
static QIcon symbolPreviewIcon(const QgsSymbol *symbol, QSize size, int padding=0, QgsLegendPatchShape *shape=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
Returns an icon preview for a color ramp.
A dialog which allows the user to modify the rendering order of symbol layers.
QgsLegendSymbolList symbolLevels() const
Returns the current legend symbols with rendering passes set, as defined in the widget.
bool usingLevels() const
Returns whether the level ordering is enabled.
void setForceOrderingEnabled(bool enabled)
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Abstract base class for all rendered symbols.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
static QgsSymbol * defaultSymbol(Qgis::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Represents a vector layer which manages a vector based dataset.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QMap< QString, QgsSymbol * > QgsSymbolMap