45 #include <QMessageBox> 46 #include <QStandardItemModel> 47 #include <QStandardItem> 50 #include <QFileDialog> 54 QgsCategorizedSymbolRendererModel::QgsCategorizedSymbolRendererModel( QObject *parent ) : QAbstractItemModel( parent )
55 , mMimeFormat( QStringLiteral(
"application/x-qgscategorizedsymbolrendererv2model" ) )
63 beginRemoveRows( QModelIndex(), 0, std::max( mRenderer->categories().size() - 1, 0 ) );
72 beginInsertRows( QModelIndex(), 0, renderer->
categories().size() - 1 );
80 if ( !mRenderer )
return;
81 int idx = mRenderer->categories().size();
82 beginInsertRows( QModelIndex(), idx, idx );
83 mRenderer->addCategory( cat );
94 int row = index.row();
95 if ( row >= catList.size() )
99 return catList.at( row );
103 Qt::ItemFlags QgsCategorizedSymbolRendererModel::flags(
const QModelIndex &index )
const 105 if ( !index.isValid() || !mRenderer )
107 return Qt::ItemIsDropEnabled;
110 Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable;
111 if ( index.column() == 1 )
114 if ( category.
value().type() != QVariant::List )
116 flags |= Qt::ItemIsEditable;
119 else if ( index.column() == 2 )
121 flags |= Qt::ItemIsEditable;
126 Qt::DropActions QgsCategorizedSymbolRendererModel::supportedDropActions()
const 128 return Qt::MoveAction;
131 QVariant QgsCategorizedSymbolRendererModel::data(
const QModelIndex &index,
int role )
const 133 if ( !index.isValid() || !mRenderer )
140 case Qt::CheckStateRole:
142 if ( index.column() == 0 )
144 return category.
renderState() ? Qt::Checked : Qt::Unchecked;
149 case Qt::DisplayRole:
150 case Qt::ToolTipRole:
152 switch ( index.column() )
156 if ( category.
value().type() == QVariant::List )
159 const QVariantList list = category.
value().toList();
160 res.reserve( list.size() );
161 for (
const QVariant &v : list )
164 if ( role == Qt::DisplayRole )
165 return res.join(
';' );
167 return res.join(
'\n' );
169 else if ( !category.
value().isValid() || category.
value().isNull() || category.
value().toString().isEmpty() )
171 return tr(
"all other values" );
175 return category.
value().toString();
179 return category.
label();
186 if ( index.column() == 1 && category.
value().type() != QVariant::List && ( !category.
value().isValid() || category.
value().isNull() || category.
value().toString().isEmpty() ) )
189 italicFont.setItalic(
true );
195 case Qt::DecorationRole:
197 if ( index.column() == 0 && category.
symbol() )
205 case Qt::ForegroundRole:
207 QBrush brush( qApp->palette().color( QPalette::Text ), Qt::SolidPattern );
208 if ( index.column() == 1 && ( category.
value().type() == QVariant::List
209 || !category.
value().isValid() || category.
value().isNull() || category.
value().toString().isEmpty() ) )
211 QColor fadedTextColor = brush.color();
212 fadedTextColor.setAlpha( 128 );
213 brush.setColor( fadedTextColor );
218 case Qt::TextAlignmentRole:
220 return ( index.column() == 0 ) ? Qt::AlignHCenter : Qt::AlignLeft;
225 switch ( index.column() )
229 if ( category.
value().type() == QVariant::List )
232 const QVariantList list = category.
value().toList();
233 res.reserve( list.size() );
234 for (
const QVariant &v : list )
237 return res.join(
';' );
241 return category.
value();
246 return category.
label();
255 bool QgsCategorizedSymbolRendererModel::setData(
const QModelIndex &index,
const QVariant &value,
int role )
257 if ( !index.isValid() )
260 if ( index.column() == 0 && role == Qt::CheckStateRole )
262 mRenderer->updateCategoryRenderState( index.row(), value == Qt::Checked );
263 emit dataChanged( index, index );
267 if ( role != Qt::EditRole )
270 switch ( index.column() )
276 switch ( mRenderer->categories().value( index.row() ).value().type() )
281 case QVariant::Double:
282 val = value.toDouble();
286 const QStringList parts = value.toString().split(
';' );
288 list.reserve( parts.count() );
289 for (
const QString &p : parts )
292 if ( list.count() == 1 )
299 val = value.toString();
302 mRenderer->updateCategoryValue( index.row(), val );
306 mRenderer->updateCategoryLabel( index.row(), value.toString() );
312 emit dataChanged( index, index );
316 QVariant QgsCategorizedSymbolRendererModel::headerData(
int section, Qt::Orientation orientation,
int role )
const 318 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < 3 )
321 lst << tr(
"Symbol" ) << tr(
"Value" ) << tr(
"Legend" );
322 return lst.value( section );
327 int QgsCategorizedSymbolRendererModel::rowCount(
const QModelIndex &parent )
const 329 if ( parent.isValid() || !mRenderer )
333 return mRenderer->categories().size();
336 int QgsCategorizedSymbolRendererModel::columnCount(
const QModelIndex &index )
const 342 QModelIndex QgsCategorizedSymbolRendererModel::index(
int row,
int column,
const QModelIndex &parent )
const 344 if ( hasIndex( row, column, parent ) )
346 return createIndex( row, column );
348 return QModelIndex();
351 QModelIndex QgsCategorizedSymbolRendererModel::parent(
const QModelIndex &index )
const 354 return QModelIndex();
357 QStringList QgsCategorizedSymbolRendererModel::mimeTypes()
const 360 types << mMimeFormat;
364 QMimeData *QgsCategorizedSymbolRendererModel::mimeData(
const QModelIndexList &indexes )
const 366 QMimeData *mimeData =
new QMimeData();
367 QByteArray encodedData;
369 QDataStream stream( &encodedData, QIODevice::WriteOnly );
372 const auto constIndexes = indexes;
373 for (
const QModelIndex &index : constIndexes )
375 if ( !index.isValid() || index.column() != 0 )
378 stream << index.row();
380 mimeData->setData( mMimeFormat, encodedData );
384 bool QgsCategorizedSymbolRendererModel::dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
388 if ( action != Qt::MoveAction )
return true;
390 if ( !data->hasFormat( mMimeFormat ) )
return false;
392 QByteArray encodedData = data->data( mMimeFormat );
393 QDataStream stream( &encodedData, QIODevice::ReadOnly );
396 while ( !stream.atEnd() )
403 int to = parent.row();
406 if ( to == -1 ) to = mRenderer->categories().size();
407 for (
int i = rows.size() - 1; i >= 0; i-- )
409 QgsDebugMsg( QStringLiteral(
"move %1 to %2" ).arg( rows[i] ).arg( to ) );
412 if ( rows[i] < t ) t--;
413 mRenderer->moveCategory( rows[i], t );
415 for (
int j = 0; j < i; j++ )
417 if ( to < rows[j] && rows[i] > rows[j] ) rows[j] += 1;
420 if ( rows[i] < to ) to--;
422 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->categories().size(), 0 ) );
427 void QgsCategorizedSymbolRendererModel::deleteRows( QList<int> rows )
429 std::sort( rows.begin(), rows.end() );
430 for (
int i = rows.size() - 1; i >= 0; i-- )
432 beginRemoveRows( QModelIndex(), rows[i], rows[i] );
433 mRenderer->deleteCategory( rows[i] );
438 void QgsCategorizedSymbolRendererModel::removeAllRows()
440 beginRemoveRows( QModelIndex(), 0, mRenderer->categories().size() - 1 );
441 mRenderer->deleteAllCategories();
445 void QgsCategorizedSymbolRendererModel::sort(
int column, Qt::SortOrder order )
453 mRenderer->sortByValue( order );
455 else if ( column == 2 )
457 mRenderer->sortByLabel( order );
459 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->categories().size(), 0 ) );
462 void QgsCategorizedSymbolRendererModel::updateSymbology()
464 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->categories().size(), 0 ) );
468 QgsCategorizedSymbolRendererViewStyle::QgsCategorizedSymbolRendererViewStyle( QWidget *parent )
472 void QgsCategorizedSymbolRendererViewStyle::drawPrimitive( PrimitiveElement element,
const QStyleOption *option, QPainter *painter,
const QWidget *widget )
const 474 if ( element == QStyle::PE_IndicatorItemViewItemDrop && !option->rect.isNull() )
476 QStyleOption opt( *option );
477 opt.rect.setLeft( 0 );
479 opt.rect.setHeight( 0 );
480 if ( widget ) opt.rect.setRight( widget->width() );
481 QProxyStyle::drawPrimitive( element, &opt, painter, widget );
484 QProxyStyle::drawPrimitive( element, option, painter, widget );
497 , mContextMenu( new QMenu( this ) )
511 QString attrName =
mRenderer->classAttribute();
512 mOldClassificationAttribute = attrName;
516 this->layout()->setContentsMargins( 0, 0, 0, 0 );
518 mExpressionWidget->setLayer(
mLayer );
521 btnColorRamp->setShowRandomColorRamp(
true );
524 QString defaultColorRamp =
QgsProject::instance()->
readEntry( QStringLiteral(
"DefaultStyles" ), QStringLiteral(
"/ColorRamp" ), QString() );
525 if ( !defaultColorRamp.isEmpty() )
527 btnColorRamp->setColorRampFromName( defaultColorRamp );
531 btnColorRamp->setRandomColorRamp();
536 mModel =
new QgsCategorizedSymbolRendererModel(
this );
542 viewCategories->setModel(
mModel );
543 viewCategories->resizeColumnToContents( 0 );
544 viewCategories->resizeColumnToContents( 1 );
545 viewCategories->resizeColumnToContents( 2 );
547 viewCategories->setStyle(
new QgsCategorizedSymbolRendererViewStyle( viewCategories ) );
555 connect( viewCategories, &QTreeView::customContextMenuRequested,
this, &QgsCategorizedSymbolRendererWidget::showContextMenu );
566 QMenu *advMenu =
new QMenu;
570 advMenu->addAction( tr(
"Symbol Levels…" ),
this, SLOT(
showSymbolLevels() ) );
573 QAction *actionDdsLegend = advMenu->addAction( tr(
"Data-defined Size Legend…" ) );
575 connect( actionDdsLegend, &QAction::triggered,
this, &QgsCategorizedSymbolRendererWidget::dataDefinedSizeLegend );
578 btnAdvanced->setMenu( advMenu );
580 mExpressionWidget->registerExpressionContextGenerator(
this );
582 mMergeCategoriesAction =
new QAction( tr(
"Merge Categories" ),
this );
583 connect( mMergeCategoriesAction, &QAction::triggered,
this, &QgsCategorizedSymbolRendererWidget::mergeSelectedCategories );
584 mUnmergeCategoriesAction =
new QAction( tr(
"Unmerge Categories" ),
this );
585 connect( mUnmergeCategoriesAction, &QAction::triggered,
this, &QgsCategorizedSymbolRendererWidget::unmergeSelectedCategories );
604 QString attrName =
mRenderer->classAttribute();
605 mExpressionWidget->setField( attrName );
617 btnColorRamp->setColorRamp(
mRenderer->sourceColorRamp() );
630 if ( !selectedCats.isEmpty() )
641 const auto constSelectedCats = selectedCats;
642 for (
int idx : constSelectedCats )
648 mRenderer->updateCategorySymbol( idx, newCatSymbol );
672 if ( !dlg.exec() || !newSymbol )
689 btnChangeCategorizedSymbol->setIcon( icon );
704 if ( idx.isValid() && idx.column() == 0 )
712 std::unique_ptr< QgsSymbol > symbol;
737 if ( !dlg.exec() || !symbol )
750 QString attrName = mExpressionWidget->currentField();
752 QList<QVariant> uniqueValues;
763 expression->
prepare( &context );
769 QVariant value = expression->
evaluate( &context );
770 if ( uniqueValues.contains( value ) )
772 uniqueValues << value;
781 if ( uniqueValues.size() >= 1000 )
783 int res = QMessageBox::warning(
nullptr, tr(
"Classify Categories" ),
784 tr(
"High number of classes. Classification would yield %1 entries which might not be expected. Continue?" ).arg( uniqueValues.size() ),
785 QMessageBox::Ok | QMessageBox::Cancel,
786 QMessageBox::Cancel );
787 if ( res == QMessageBox::Cancel )
794 DlgAddCategories dlg(
mStyle, createDefaultSymbol(), unique_vals,
this );
800 bool deleteExisting =
false;
802 if ( !mOldClassificationAttribute.isEmpty() &&
803 attrName != mOldClassificationAttribute &&
806 int res = QMessageBox::question(
this,
807 tr(
"Delete Classification" ),
808 tr(
"The classification field was changed from '%1' to '%2'.\n" 809 "Should the existing classes be deleted before classification?" )
810 .arg( mOldClassificationAttribute, attrName ),
811 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel );
812 if ( res == QMessageBox::Cancel )
817 deleteExisting = ( res == QMessageBox::Yes );
821 bool keepExistingColors =
false;
822 if ( !deleteExisting )
825 keepExistingColors = !prevCats.isEmpty();
826 for (
int i = 0; i < cats.size(); ++i )
828 bool contains =
false;
829 QVariant value = cats.at( i ).value();
830 for (
int j = 0; j < prevCats.size() && !contains; ++j )
832 const QVariant prevCatValue = prevCats.at( j ).value();
833 if ( prevCatValue.type() == QVariant::List )
835 const QVariantList list = prevCatValue.toList();
836 for (
const QVariant &v : list )
847 if ( prevCats.at( j ).value() == value )
857 prevCats.append( cats.at( i ) );
862 mOldClassificationAttribute = attrName;
879 std::unique_ptr< QgsCategorizedSymbolRenderer > r = qgis::make_unique< QgsCategorizedSymbolRenderer >( attrName, cats );
881 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
883 r->setSourceColorRamp( ramp->clone() );
887 mModel->setRenderer( r.get() );
890 if ( ! keepExistingColors && ramp )
897 if ( !btnColorRamp->isNull() )
899 mRenderer->updateColorRamp( btnColorRamp->colorRamp() );
901 mModel->updateSymbology();
906 QModelIndex idx = viewCategories->selectionModel()->currentIndex();
907 if ( !idx.isValid() )
915 QModelIndexList selectedRows = viewCategories->selectionModel()->selectedRows();
917 const auto constSelectedRows = selectedRows;
918 for (
const QModelIndex &r : constSelectedRows )
922 rows.append( r.row() );
931 mModel->deleteRows( categoryIndexes );
946 mModel->addCategory( cat );
954 QItemSelectionModel *m = viewCategories->selectionModel();
955 QModelIndexList selectedIndexes = m->selectedRows( 1 );
957 if ( m && !selectedIndexes.isEmpty() )
960 QModelIndexList::const_iterator indexIt = selectedIndexes.constBegin();
961 for ( ; indexIt != selectedIndexes.constEnd(); ++indexIt )
963 int row = ( *indexIt ).row();
967 selectedSymbols.append( s );
978 QItemSelectionModel *m = viewCategories->selectionModel();
979 QModelIndexList selectedIndexes = m->selectedRows( 1 );
981 if ( m && !selectedIndexes.isEmpty() )
983 QModelIndexList::const_iterator indexIt = selectedIndexes.constBegin();
984 for ( ; indexIt != selectedIndexes.constEnd(); ++indexIt )
986 cl.append(
mModel->category( *indexIt ) );
1005 viewCategories->selectionModel()->clear();
1013 QMessageBox::information(
this, tr(
"Matched Symbols" ),
1014 tr(
"Matched %1 categories to symbols." ).arg( matched ) );
1018 QMessageBox::warning(
this, tr(
"Matched Symbols" ),
1019 tr(
"No categories could be matched to symbols in library." ) );
1032 QVariantList unmatchedCategories;
1033 QStringList unmatchedSymbols;
1034 const int matched =
mRenderer->matchToSymbols( style, type, unmatchedCategories, unmatchedSymbols );
1036 mModel->updateSymbology();
1043 QString openFileDir = settings.
value( QStringLiteral(
"UI/lastMatchToSymbolsDir" ), QDir::homePath() ).toString();
1045 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Match to Symbols from File" ), openFileDir,
1046 tr(
"XML files (*.xml *.XML)" ) );
1047 if ( fileName.isEmpty() )
1052 QFileInfo openFileInfo( fileName );
1053 settings.
setValue( QStringLiteral(
"UI/lastMatchToSymbolsDir" ), openFileInfo.absolutePath() );
1056 if ( !importedStyle.
importXml( fileName ) )
1058 QMessageBox::warning(
this, tr(
"Match to Symbols from File" ),
1059 tr(
"An error occurred while reading file:\n%1" ).arg( importedStyle.
errorString() ) );
1066 QMessageBox::information(
this, tr(
"Match to Symbols from File" ),
1067 tr(
"Matched %1 categories to symbols from file." ).arg( matched ) );
1071 QMessageBox::warning(
this, tr(
"Match to Symbols from File" ),
1072 tr(
"No categories could be matched to symbols in file." ) );
1076 void QgsCategorizedSymbolRendererWidget::cleanUpSymbolSelector(
QgsPanelWidget *container )
1085 void QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget()
1096 QItemSelectionModel *m = viewCategories->selectionModel();
1097 QModelIndexList i = m->selectedRows();
1099 if ( m && !i.isEmpty() )
1103 if ( !selectedCats.isEmpty() )
1105 const auto constSelectedCats = selectedCats;
1106 for (
int idx : constSelectedCats )
1109 if ( selectedCats.count() > 1 )
1114 mRenderer->updateCategorySymbol( idx, newCatSymbol );
1134 if ( event->key() == Qt::Key_C &&
event->modifiers() == Qt::ControlModifier )
1136 mCopyBuffer.clear();
1139 else if ( event->key() == Qt::Key_V &&
event->modifiers() == Qt::ControlModifier )
1141 QgsCategoryList::const_iterator rIt = mCopyBuffer.constBegin();
1142 for ( ; rIt != mCopyBuffer.constEnd(); ++rIt )
1144 mModel->addCategory( *rIt );
1179 void QgsCategorizedSymbolRendererWidget::dataDefinedSizeLegend()
1194 void QgsCategorizedSymbolRendererWidget::mergeSelectedCategories()
1199 QList< int > categoryIndexes;
1202 for (
int i : selectedCategoryIndexes )
1204 QVariant v = categories.at( i ).value();
1206 if ( !v.isValid() || v ==
"" )
1211 categoryIndexes.append( i );
1214 if ( categoryIndexes.count() < 2 )
1218 QVariantList values;
1219 values.reserve( categoryIndexes.count() );
1220 labels.reserve( categoryIndexes.count() );
1221 for (
int i : categoryIndexes )
1223 QVariant v = categories.at( i ).value();
1225 if ( v.type() == QVariant::List )
1227 values.append( v.toList() );
1232 labels << categories.at( i ).label();
1236 mRenderer->updateCategoryLabel( categoryIndexes.at( 0 ), labels.join(
',' ) );
1237 mRenderer->updateCategoryValue( categoryIndexes.at( 0 ), values );
1239 categoryIndexes.pop_front();
1240 mModel->deleteRows( categoryIndexes );
1245 void QgsCategorizedSymbolRendererWidget::unmergeSelectedCategories()
1248 if ( categoryIndexes.isEmpty() )
1252 for (
int i : categoryIndexes )
1254 const QVariant v = categories.at( i ).value();
1255 if ( v.type() != QVariant::List )
1258 const QVariantList list = v.toList();
1259 for (
int j = 1; j < list.count(); ++j )
1261 mModel->addCategory(
QgsRendererCategory( list.at( j ), categories.at( i ).symbol()->clone(), list.at( j ).toString(), categories.at( i ).renderState() ) );
1263 mRenderer->updateCategoryValue( i, list.at( 0 ) );
1264 mRenderer->updateCategoryLabel( i, list.at( 0 ).toString() );
1270 void QgsCategorizedSymbolRendererWidget::showContextMenu( QPoint )
1272 mContextMenu->clear();
1273 const QList< QAction * > actions =
contextMenu->actions();
1274 for ( QAction *act : actions )
1276 mContextMenu->addAction( act );
1279 mContextMenu->addSeparator();
1281 if ( viewCategories->selectionModel()->selectedRows().count() > 1 )
1283 mContextMenu->addAction( mMergeCategoriesAction );
1285 if ( viewCategories->selectionModel()->selectedRows().count() == 1 )
1289 const QVariant v = categories.at( categoryIndexes.at( 0 ) ).value();
1290 if ( v.type() == QVariant::List )
1291 mContextMenu->addAction( mUnmergeCategoriesAction );
1293 else if ( viewCategories->selectionModel()->selectedRows().count() > 1 )
1295 mContextMenu->addAction( mUnmergeCategoriesAction );
1298 mContextMenu->exec( QCursor::pos() );
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QString label() const
Returns the label for this category, which is used to represent the category within legends and the l...
Class for parsing and evaluation of expressions (formerly called "search strings").
Wrapper for iterator of features from vector data provider or vector layer.
Represents an individual category (class) from a QgsCategorizedSymbolRenderer.
QString readEntry(const QString &scope, const QString &key, const QString &def=QString(), bool *ok=nullptr) const
Abstract base class for all rendered symbols.
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.
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.
QgsSymbol * symbol() const
Returns the symbol which will be used to render this category.
static QIcon symbolPreviewIcon(const QgsSymbol *symbol, QSize size, int padding=0)
Returns an icon preview for a color ramp.
QVariant evaluate()
Evaluate the feature and return the result.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
A QProxyStyle subclass which correctly sets the base style to match the QGIS application style...
A marker symbol type, for rendering Point and MultiPoint geometries.
static QgsStyle * defaultStyle()
Returns default application-wide style.
The QgsMapSettings class contains configuration for rendering of the map.
QList< QgsRendererCategory > QgsCategoryList
SymbolType
Type of the symbol.
static QgsCategoryList createCategories(const QVariantList &values, const QgsSymbol *symbol, QgsVectorLayer *layer=nullptr, const QString &fieldName=QString())
Create categories for a list of values.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
QgsFields fields() const FINAL
Returns the list of fields of this layer.
bool importXml(const QString &filename)
Imports the symbols and colorramps into the default style database from the given XML file...
const QgsCategoryList & categories() const
Returns a list of all categories recognized by the renderer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Single scope for storing variables and functions for use within a QgsExpressionContext.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
bool renderState() const
Returns true if the category is currently enabled and should be rendered.
QVariant value() const
Returns the value corresponding to this category.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
static QgsExpressionContextScope * atlasScope(QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
QgsExpressionContextScope & expressionContextScope()
Returns a reference to the expression context scope for the map canvas.
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
static QgsProject * instance()
Returns the QgsProject singleton instance.
static QgsCategorizedSymbolRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
creates a QgsCategorizedSymbolRenderer from an existing renderer.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
QString errorString()
Returns last error from load/save operation.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
bool nextFeature(QgsFeature &f)
Represents a vector layer which manages a vector based data sets.
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...
void setColor(const QColor &color)
Sets the color for the symbol.