17#include "moc_qgsrulebasedrendererwidget.cpp"
36#include <QProgressDialog>
37#include <QTreeWidgetItem>
44#ifdef ENABLE_MODELTEST
56 , mContextMenu( new QMenu( this ) )
72 mRenderer = std::make_unique<QgsRuleBasedRenderer>( symbol );
78 this->layout()->setContentsMargins( 0, 0, 0, 0 );
81#ifdef ENABLE_MODELTEST
82 new ModelTest(
mModel,
this );
84 viewRules->setModel(
mModel );
87 mDeleteAction->setShortcut( QKeySequence( QKeySequence::Delete ) );
93 mRefineMenu =
new QMenu( tr(
"Refine Current Rule" ), btnRefineRule );
106 connect( viewRules, &QWidget::customContextMenuRequested,
this, &QgsRuleBasedRendererWidget::showContextMenu );
167 QModelIndex currentIndex = viewRules->selectionModel()->currentIndex();
168 mModel->
insertRule( currentIndex.parent(), currentIndex.row() + 1, newrule );
169 QModelIndex newindex =
mModel->
index( currentIndex.row() + 1, 0, currentIndex.parent() );
170 viewRules->selectionModel()->setCurrentIndex( newindex, QItemSelectionModel::ClearAndSelect );
178 viewRules->selectionModel()->setCurrentIndex( newindex, QItemSelectionModel::ClearAndSelect );
185 QItemSelectionModel *sel = viewRules->selectionModel();
186 QModelIndex idx = sel->currentIndex();
187 if ( !idx.isValid() )
194 editRule( viewRules->selectionModel()->currentIndex() );
199 if ( !index.isValid() )
226 QItemSelection sel = viewRules->selectionModel()->selection();
227 QgsDebugMsgLevel( QStringLiteral(
"REMOVE RULES!!! ranges: %1" ).arg( sel.count() ), 2 );
228 const auto constSel = sel;
229 for (
const QItemSelectionRange &range : constSel )
231 QgsDebugMsgLevel( QStringLiteral(
"RANGE: r %1 - %2" ).arg( range.top() ).arg( range.bottom() ), 2 );
232 if ( range.isValid() )
233 mModel->
removeRows( range.top(), range.bottom() - range.top() + 1, range.parent() );
236 viewRules->selectionModel()->clear();
243 btnEditRule->setEnabled( current.isValid() );
252#include <QDialogButtonBox>
253#include <QInputDialog>
258 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
260 if ( indexlist.isEmpty() )
266 else if ( type == 1 )
274 const auto constIndexlist = indexlist;
275 for (
const QModelIndex &index : constIndexlist )
276 viewRules->expand( index );
314 for (
const QModelIndex &index : indexList )
319 if ( !initialRule->
symbol() )
321 QMessageBox::warning(
this, tr(
"Scale Refinement" ), tr(
"Parent rule %1 must have a symbol for this operation." ).arg( initialRule->
label() ) );
326 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):" ) );
332 const auto constSplit = txt.split(
',' );
333 for (
const QString &item : constSplit )
335 int scale = item.toInt( &ok );
337 scales.append( scale );
339 QMessageBox::information(
this, tr(
"Scale Refinement" ), tr(
"\"%1\" is not valid scale denominator, ignoring it." ).arg( item ) );
342 for (
const QModelIndex &index : indexList )
361 mRenderer->setLegendSymbolItem( legendSymbol.ruleKey(), sym->
clone() );
370 QList<QgsSymbol *> symbolList;
377 QItemSelection sel = viewRules->selectionModel()->selection();
378 const auto constSel = sel;
379 for (
const QItemSelectionRange &range : constSel )
381 QModelIndex parent = range.parent();
384 for (
int row = range.top(); row <= range.bottom(); row++ )
386 symbolList.append( children.at( row )->symbol() );
396 QItemSelection sel = viewRules->selectionModel()->selection();
397 const auto constSel = sel;
398 for (
const QItemSelectionRange &range : constSel )
400 QModelIndex parent = range.parent();
403 for (
int row = range.top(); row <= range.bottom(); row++ )
405 rl.append( children.at( row )->clone() );
430 if ( event->key() == Qt::Key_C && event->modifiers() == Qt::ControlModifier )
436 else if ( event->key() == Qt::Key_V && event->modifiers() == Qt::ControlModifier )
438 QgsRuleBasedRenderer::RuleList::const_iterator rIt =
mCopyBuffer.constBegin();
480 QString path =
"/Windows/RuleBasedTree/sectionWidth/" + QString::number( section );
487 QString path = QStringLiteral(
"/Windows/RuleBasedTree/sectionWidth/" );
488 QHeaderView *head = viewRules->header();
489 head->resizeSection( 0, settings.
value( path + QString::number( 0 ), 150 ).toInt() );
490 head->resizeSection( 1, settings.
value( path + QString::number( 1 ), 150 ).toInt() );
491 head->resizeSection( 2, settings.
value( path + QString::number( 2 ), 80 ).toInt() );
492 head->resizeSection( 3, settings.
value( path + QString::number( 3 ), 80 ).toInt() );
493 head->resizeSection( 4, settings.
value( path + QString::number( 4 ), 50 ).toInt() );
494 head->resizeSection( 5, settings.
value( path + QString::number( 5 ), 50 ).toInt() );
499 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
502 if ( indexlist.isEmpty() )
506 QApplication::clipboard()->setMimeData( mime );
511 const QMimeData *mime = QApplication::clipboard()->mimeData();
512 QModelIndexList indexlist = viewRules->selectionModel()->selectedRows();
514 if ( indexlist.isEmpty() )
517 index = indexlist.first();
518 mModel->
dropMimeData( mime, Qt::CopyAction, index.row(), index.column(), index.parent() );
527 const QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
528 for (
const QModelIndex &index : indexList )
532 if ( !rule->symbol() || rule->symbol()->type() != tempSymbol->type() )
541void QgsRuleBasedRendererWidget::refineRuleCategoriesAccepted(
QgsPanelWidget *panel )
547 QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
548 const auto constIndexList = indexList;
549 for (
const QModelIndex &index : constIndexList )
558void QgsRuleBasedRendererWidget::refineRuleRangesAccepted(
QgsPanelWidget *panel )
563 QModelIndexList indexList = viewRules->selectionModel()->selectedRows();
564 const auto constIndexList = indexList;
565 for (
const QModelIndex &index : constIndexList )
574void QgsRuleBasedRendererWidget::ruleWidgetPanelAccepted(
QgsPanelWidget *panel )
583 QModelIndex index = viewRules->selectionModel()->currentIndex();
588void QgsRuleBasedRendererWidget::liveUpdateRuleFromPanel()
590 ruleWidgetPanelAccepted( qobject_cast<QgsPanelWidget *>( sender() ) );
593void QgsRuleBasedRendererWidget::showContextMenu( QPoint )
599 const QList<QAction *> actions =
contextMenu->actions();
600 for ( QAction *act : actions )
617 QHash<QgsRuleBasedRenderer::Rule *, QgsRuleBasedRendererCount> countMap;
621 const auto constRuleList = ruleList;
624 countMap[rule].count = 0;
625 countMap[rule].duplicateCount = 0;
650 QProgressDialog p( tr(
"Calculating feature count." ), tr(
"Abort" ), 0, 100 );
651 p.setWindowModality( Qt::WindowModal );
652 long long featuresCounted = 0;
660 const auto constFeatureRuleList = featureRuleList;
663 countMap[rule].count++;
664 if ( featureRuleList.size() > 1 )
666 countMap[rule].duplicateCount++;
668 const auto constFeatureRuleList = featureRuleList;
671 if ( duplicateRule == rule )
673 countMap[rule].duplicateCountMap[duplicateRule] += 1;
677 if ( featuresCounted % 50 == 0 )
679 if ( featuresCounted > nFeatures )
683 p.setValue(
static_cast<double>( featuresCounted ) / nFeatures * 100.0 );
684 if ( p.wasCanceled() )
690 p.setValue( nFeatures );
695 const auto constKeys = countMap.keys();
698 QgsDebugMsgLevel( QStringLiteral(
"rule: %1 count %2" ).arg( rule->label() ).arg( countMap[rule].count ), 2 );
707 bool enabled = !viewRules->selectionModel()->selectedIndexes().isEmpty();
708 btnRefineRule->setEnabled( enabled );
709 btnRemoveRule->setEnabled( enabled );
718 , mContext( context )
721 layout()->setContentsMargins( 0, 0, 0, 0 );
733 groupScale->setChecked(
true );
740 groupSymbol->setChecked(
true );
745 groupSymbol->setChecked(
false );
754 QVBoxLayout *l =
new QVBoxLayout;
756 groupSymbol->setLayout( l );
766 connect( mFilterRadio, &QRadioButton::toggled,
this, [=](
bool toggled ) { filterFrame->setEnabled( toggled ); } );
767 connect( mElseRadio, &QRadioButton::toggled,
this, [=](
bool toggled ) {
if ( toggled ) editFilter->setText( QStringLiteral(
"ELSE" ) ); } );
776 setWindowModality( Qt::WindowModal );
779 QVBoxLayout *layout =
new QVBoxLayout(
this );
781 scrollArea->setFrameShape( QFrame::NoFrame );
782 layout->addWidget( scrollArea );
784 buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
787 scrollArea->setWidget( mPropsWidget );
788 layout->addWidget( buttonBox );
789 this->setWindowTitle(
"Edit Rule" );
793 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
794 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsRendererRulePropsDialog::showHelp );
809 mPropsWidget->
apply();
813void QgsRendererRulePropsDialog::showHelp()
815 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html#rule-based-rendering" ) );
838 if ( !mFilterRadio->isChecked() )
844 QMessageBox::critical(
this, tr(
"Test Filter" ), tr(
"Filter expression parsing error:\n" ) + filter.
parserErrorString() );
857 if ( !filter.
prepare( &context ) )
859 QMessageBox::critical(
this, tr(
"Test Filter" ), filter.
evalErrorString() );
863 QApplication::setOverrideCursor( Qt::WaitCursor );
876 QApplication::restoreOverrideCursor();
878 QMessageBox::information(
this, tr(
"Test Filter" ), tr(
"Filter returned %n feature(s)",
"number of filtered features", count ) );
883 QString filter = mElseRadio->isChecked() ? QStringLiteral(
"ELSE" ) : editFilter->text();
911 : QAbstractItemModel( parent )
919 if ( !
index.isValid() )
920 return Qt::ItemIsDropEnabled;
923 Qt::ItemFlag drop = (
index.column() == 0 ? Qt::ItemIsDropEnabled : Qt::NoItemFlags );
925 Qt::ItemFlag checkable = (
index.column() == 0 ? Qt::ItemIsUserCheckable : Qt::NoItemFlags );
927 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | checkable | Qt::ItemIsDragEnabled | drop;
932 if ( !
index.isValid() )
937 if ( role == Qt::DisplayRole || role == Qt::ToolTipRole )
939 switch (
index.column() )
942 return rule->
label();
965 if ( role == Qt::DisplayRole )
973 QString tip = QStringLiteral(
"<p style='margin:0px;'><ul>" );
975 for (
auto it = duplicateMap.constBegin(); it != duplicateMap.constEnd(); ++it )
977 QString label = it.key()->label().replace(
'&', QLatin1String(
"&" ) ).replace(
'>', QLatin1String(
">" ) ).replace(
'<', QLatin1String(
"<" ) );
978 tip += tr(
"<li><nobr>%1 features also in rule %2</nobr></li>" ).arg( it.value() ).arg( label );
980 tip += QLatin1String(
"</ul>" );
994 else if ( role == Qt::DecorationRole &&
index.column() == 0 && rule->
symbol() )
999 else if ( role == Qt::TextAlignmentRole )
1001 return (
index.column() == 2 ||
index.column() == 3 ) ?
static_cast<Qt::Alignment::Int
>( Qt::AlignRight ) :
static_cast<Qt::Alignment::Int
>( Qt::AlignLeft );
1003 else if ( role == Qt::FontRole &&
index.column() == 1 )
1008 italicFont.setItalic(
true );
1013 else if ( role == Qt::EditRole )
1015 switch (
index.column() )
1018 return rule->
label();
1029 else if ( role == Qt::CheckStateRole )
1031 if (
index.column() != 0 )
1033 return rule->
active() ? Qt::Checked : Qt::Unchecked;
1041 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < 7 )
1044 lst << tr(
"Label" ) << tr(
"Rule" ) << tr(
"Min. Scale" ) << tr(
"Max. Scale" ) << tr(
"Count" ) << tr(
"Duplicate Count" );
1045 return lst[section];
1047 else if ( orientation == Qt::Horizontal && role == Qt::ToolTipRole )
1051 return tr(
"Number of features in this rule." );
1053 else if ( section == 5 )
1055 return tr(
"Number of features in this rule which are also present in other rule(s)." );
1064 if (
parent.column() > 0 )
1069 return parentRule->
children().count();
1079 if ( hasIndex( row, column,
parent ) )
1083 return createIndex( row, column, childRule );
1085 return QModelIndex();
1090 if ( !
index.isValid() )
1091 return QModelIndex();
1097 return QModelIndex();
1100 int row = parentRule->
parent()->
children().indexOf( parentRule );
1102 return createIndex( row, 0, parentRule );
1107 if ( !
index.isValid() )
1112 if ( role == Qt::CheckStateRole )
1114 rule->
setActive( value.toInt() == Qt::Checked );
1119 if ( role != Qt::EditRole )
1122 switch (
index.column() )
1125 rule->
setLabel( value.toString() );
1146 return Qt::MoveAction;
1152 types << QStringLiteral(
"application/vnd.text.list" );
1158 QMimeData *
mimeData =
new QMimeData();
1159 QByteArray encodedData;
1161 QDataStream stream( &encodedData, QIODevice::WriteOnly );
1163 const auto constIndexes = indexes;
1164 for (
const QModelIndex &
index : constIndexes )
1167 if ( !
index.isValid() ||
index.column() != 0 )
1176 QDomElement rootElem = doc.createElement( QStringLiteral(
"rule_mime" ) );
1177 rootElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"renderer" ) );
1178 QDomElement rulesElem = rule->
save( doc, symbols );
1179 rootElem.appendChild( rulesElem );
1181 rootElem.appendChild( symbolsElem );
1182 doc.appendChild( rootElem );
1186 stream << doc.toString( -1 );
1189 mimeData->setData( QStringLiteral(
"application/vnd.text.list" ), encodedData );
1198 if ( ruleElem.hasAttribute( QStringLiteral(
"description" ) ) )
1199 ruleElem.setAttribute( QStringLiteral(
"label" ), ruleElem.attribute( QStringLiteral(
"description" ) ) );
1202 QDomElement childRuleElem = ruleElem.firstChildElement( QStringLiteral(
"rule" ) );
1203 while ( !childRuleElem.isNull() )
1206 childRuleElem = childRuleElem.nextSiblingElement( QStringLiteral(
"rule" ) );
1215 if ( action == Qt::IgnoreAction )
1218 if ( !
data->hasFormat( QStringLiteral(
"application/vnd.text.list" ) ) )
1221 if (
parent.column() > 0 )
1224 QByteArray encodedData =
data->data( QStringLiteral(
"application/vnd.text.list" ) );
1225 QDataStream stream( &encodedData, QIODevice::ReadOnly );
1234 while ( !stream.atEnd() )
1240 if ( !doc.setContent( text ) )
1242 QDomElement rootElem = doc.documentElement();
1243 if ( rootElem.tagName() != QLatin1String(
"rule_mime" ) )
1245 if ( rootElem.attribute( QStringLiteral(
"type" ) ) == QLatin1String(
"labeling" ) )
1246 rootElem.appendChild( doc.createElement( QStringLiteral(
"symbols" ) ) );
1247 QDomElement symbolsElem = rootElem.firstChildElement( QStringLiteral(
"symbols" ) );
1248 if ( symbolsElem.isNull() )
1251 QDomElement ruleElem = rootElem.firstChildElement( QStringLiteral(
"rule" ) );
1252 if ( rootElem.attribute( QStringLiteral(
"type" ) ) == QLatin1String(
"labeling" ) )
1265 if (
index.isValid() )
1274 if ( row < 0 || row >= parentRule->
children().count() )
1277 QgsDebugMsgLevel( QStringLiteral(
"Called: row %1 count %2 parent ~~%3~~" ).arg( row ).arg( count ).arg( parentRule->
dump() ), 2 );
1279 beginRemoveRows(
parent, row, row + count - 1 );
1281 for (
int i = 0; i < count; i++ )
1283 if ( row < parentRule->children().count() )
1291 QgsDebugError( QStringLiteral(
"trying to remove invalid index - this should not happen!" ) );
1303 beginInsertRows(
parent, before, before );
1305 QgsDebugMsgLevel( QStringLiteral(
"insert before %1 rule: %2" ).arg( before ).arg( newrule->
dump() ), 2 );
1322 for (
int i = 0; i <
rowCount( idx ); i++ )
1331 if ( !
index.isValid() )
1352 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.
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.
Class for 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.
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
This class 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...
A vector feature renderer which uses numeric attributes to classify features into different ranges.
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.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
The class is used as a container of context for various read/write operations on other 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.
QgsRuleBasedRenderer::Rule * rule()
QgsRendererRulePropsDialog(QgsRuleBasedRenderer::Rule *rule, QgsVectorLayer *layer, QgsStyle *style, QWidget *parent=nullptr, const QgsSymbolWidgetContext &context=QgsSymbolWidgetContext())
Constructor for QgsRendererRulePropsDialog.
Tree model for the 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()
This class keeps data about a rules for 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
void setDescription(const QString &description)
Set a human readable description for this rule.
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.
QString description() const
A human readable description for this rule.
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.
static QgsRuleBasedRenderer::Rule * create(QDomElement &ruleElem, QgsSymbolMap &symbolMap, bool reuseId=true)
Create a rule from an XML definition.
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
QgsRuleBasedRenderer::Rule * rootRule()
static QString toString(double scale)
Helper function to convert a scale double to scale string.
Stores properties relating to a screen.
This class is a composition of two QSettings instances:
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.
static 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,...
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer.
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
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 data sets.
long long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
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