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 Q_FOREACH (
const QModelIndex &index, indexes )
374 if ( !index.isValid() || index.column() != 0 )
377 stream << index.row();
379 mimeData->setData( mMimeFormat, encodedData );
383 bool QgsCategorizedSymbolRendererModel::dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
387 if ( action != Qt::MoveAction )
return true;
389 if ( !data->hasFormat( mMimeFormat ) )
return false;
391 QByteArray encodedData = data->data( mMimeFormat );
392 QDataStream stream( &encodedData, QIODevice::ReadOnly );
395 while ( !stream.atEnd() )
402 int to = parent.row();
405 if ( to == -1 ) to = mRenderer->categories().size();
406 for (
int i = rows.size() - 1; i >= 0; i-- )
408 QgsDebugMsg( QStringLiteral(
"move %1 to %2" ).arg( rows[i] ).arg( to ) );
411 if ( rows[i] < t ) t--;
412 mRenderer->moveCategory( rows[i], t );
414 for (
int j = 0; j < i; j++ )
416 if ( to < rows[j] && rows[i] > rows[j] ) rows[j] += 1;
419 if ( rows[i] < to ) to--;
421 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->categories().size(), 0 ) );
426 void QgsCategorizedSymbolRendererModel::deleteRows( QList<int> rows )
428 std::sort( rows.begin(), rows.end() );
429 for (
int i = rows.size() - 1; i >= 0; i-- )
431 beginRemoveRows( QModelIndex(), rows[i], rows[i] );
432 mRenderer->deleteCategory( rows[i] );
437 void QgsCategorizedSymbolRendererModel::removeAllRows()
439 beginRemoveRows( QModelIndex(), 0, mRenderer->categories().size() - 1 );
440 mRenderer->deleteAllCategories();
444 void QgsCategorizedSymbolRendererModel::sort(
int column, Qt::SortOrder order )
452 mRenderer->sortByValue( order );
454 else if ( column == 2 )
456 mRenderer->sortByLabel( order );
458 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->categories().size(), 0 ) );
461 void QgsCategorizedSymbolRendererModel::updateSymbology()
463 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->categories().size(), 0 ) );
467 QgsCategorizedSymbolRendererViewStyle::QgsCategorizedSymbolRendererViewStyle( QWidget *parent )
471 void QgsCategorizedSymbolRendererViewStyle::drawPrimitive( PrimitiveElement element,
const QStyleOption *option, QPainter *painter,
const QWidget *widget )
const 473 if ( element == QStyle::PE_IndicatorItemViewItemDrop && !option->rect.isNull() )
475 QStyleOption opt( *option );
476 opt.rect.setLeft( 0 );
478 opt.rect.setHeight( 0 );
479 if ( widget ) opt.rect.setRight( widget->width() );
480 QProxyStyle::drawPrimitive( element, &opt, painter, widget );
483 QProxyStyle::drawPrimitive( element, option, painter, widget );
496 , mContextMenu( new QMenu( this ) )
510 QString attrName =
mRenderer->classAttribute();
511 mOldClassificationAttribute = attrName;
515 this->layout()->setContentsMargins( 0, 0, 0, 0 );
517 mExpressionWidget->setLayer(
mLayer );
520 btnColorRamp->setShowRandomColorRamp(
true );
523 QString defaultColorRamp =
QgsProject::instance()->
readEntry( QStringLiteral(
"DefaultStyles" ), QStringLiteral(
"/ColorRamp" ), QString() );
524 if ( !defaultColorRamp.isEmpty() )
526 btnColorRamp->setColorRampFromName( defaultColorRamp );
530 btnColorRamp->setRandomColorRamp();
535 mModel =
new QgsCategorizedSymbolRendererModel(
this );
541 viewCategories->setModel(
mModel );
542 viewCategories->resizeColumnToContents( 0 );
543 viewCategories->resizeColumnToContents( 1 );
544 viewCategories->resizeColumnToContents( 2 );
546 viewCategories->setStyle(
new QgsCategorizedSymbolRendererViewStyle( viewCategories ) );
554 connect( viewCategories, &QTreeView::customContextMenuRequested,
this, &QgsCategorizedSymbolRendererWidget::showContextMenu );
565 QMenu *advMenu =
new QMenu;
569 advMenu->addAction( tr(
"Symbol Levels…" ),
this, SLOT(
showSymbolLevels() ) );
572 QAction *actionDdsLegend = advMenu->addAction( tr(
"Data-defined Size Legend…" ) );
574 connect( actionDdsLegend, &QAction::triggered,
this, &QgsCategorizedSymbolRendererWidget::dataDefinedSizeLegend );
577 btnAdvanced->setMenu( advMenu );
579 mExpressionWidget->registerExpressionContextGenerator(
this );
581 mMergeCategoriesAction =
new QAction( tr(
"Merge Categories" ),
this );
582 connect( mMergeCategoriesAction, &QAction::triggered,
this, &QgsCategorizedSymbolRendererWidget::mergeSelectedCategories );
583 mUnmergeCategoriesAction =
new QAction( tr(
"Unmerge Categories" ),
this );
584 connect( mUnmergeCategoriesAction, &QAction::triggered,
this, &QgsCategorizedSymbolRendererWidget::unmergeSelectedCategories );
603 QString attrName =
mRenderer->classAttribute();
604 mExpressionWidget->setField( attrName );
616 btnColorRamp->setColorRamp(
mRenderer->sourceColorRamp() );
629 if ( !selectedCats.isEmpty() )
640 Q_FOREACH (
int idx, selectedCats )
646 mRenderer->updateCategorySymbol( idx, newCatSymbol );
670 if ( !dlg.exec() || !newSymbol )
687 btnChangeCategorizedSymbol->setIcon( icon );
702 if ( idx.isValid() && idx.column() == 0 )
710 std::unique_ptr< QgsSymbol > symbol;
735 if ( !dlg.exec() || !symbol )
748 QString attrName = mExpressionWidget->currentField();
750 QList<QVariant> uniqueValues;
761 expression->
prepare( &context );
767 QVariant value = expression->
evaluate( &context );
768 if ( uniqueValues.contains( value ) )
770 uniqueValues << value;
779 if ( uniqueValues.size() >= 1000 )
781 int res = QMessageBox::warning(
nullptr, tr(
"Classify Categories" ),
782 tr(
"High number of classes. Classification would yield %1 entries which might not be expected. Continue?" ).arg( uniqueValues.size() ),
783 QMessageBox::Ok | QMessageBox::Cancel,
784 QMessageBox::Cancel );
785 if ( res == QMessageBox::Cancel )
792 DlgAddCategories dlg(
mStyle, createDefaultSymbol(), unique_vals,
this );
798 bool deleteExisting =
false;
800 if ( !mOldClassificationAttribute.isEmpty() &&
801 attrName != mOldClassificationAttribute &&
804 int res = QMessageBox::question(
this,
805 tr(
"Delete Classification" ),
806 tr(
"The classification field was changed from '%1' to '%2'.\n" 807 "Should the existing classes be deleted before classification?" )
808 .arg( mOldClassificationAttribute, attrName ),
809 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel );
810 if ( res == QMessageBox::Cancel )
815 deleteExisting = ( res == QMessageBox::Yes );
819 bool keepExistingColors =
false;
820 if ( !deleteExisting )
823 keepExistingColors = !prevCats.isEmpty();
824 for (
int i = 0; i < cats.size(); ++i )
826 bool contains =
false;
827 QVariant value = cats.at( i ).value();
828 for (
int j = 0; j < prevCats.size() && !contains; ++j )
830 const QVariant prevCatValue = prevCats.at( j ).value();
831 if ( prevCatValue.type() == QVariant::List )
833 const QVariantList list = prevCatValue.toList();
834 for (
const QVariant &v : list )
845 if ( prevCats.at( j ).value() == value )
855 prevCats.append( cats.at( i ) );
860 mOldClassificationAttribute = attrName;
877 std::unique_ptr< QgsCategorizedSymbolRenderer > r = qgis::make_unique< QgsCategorizedSymbolRenderer >( attrName, cats );
879 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
881 r->setSourceColorRamp( ramp->clone() );
885 mModel->setRenderer( r.get() );
888 if ( ! keepExistingColors && ramp )
895 if ( !btnColorRamp->isNull() )
897 mRenderer->updateColorRamp( btnColorRamp->colorRamp() );
899 mModel->updateSymbology();
904 QModelIndex idx = viewCategories->selectionModel()->currentIndex();
905 if ( !idx.isValid() )
913 QModelIndexList selectedRows = viewCategories->selectionModel()->selectedRows();
915 Q_FOREACH (
const QModelIndex &r, selectedRows )
919 rows.append( r.row() );
928 mModel->deleteRows( categoryIndexes );
943 mModel->addCategory( cat );
951 QItemSelectionModel *m = viewCategories->selectionModel();
952 QModelIndexList selectedIndexes = m->selectedRows( 1 );
954 if ( m && !selectedIndexes.isEmpty() )
957 QModelIndexList::const_iterator indexIt = selectedIndexes.constBegin();
958 for ( ; indexIt != selectedIndexes.constEnd(); ++indexIt )
960 int row = ( *indexIt ).row();
964 selectedSymbols.append( s );
975 QItemSelectionModel *m = viewCategories->selectionModel();
976 QModelIndexList selectedIndexes = m->selectedRows( 1 );
978 if ( m && !selectedIndexes.isEmpty() )
980 QModelIndexList::const_iterator indexIt = selectedIndexes.constBegin();
981 for ( ; indexIt != selectedIndexes.constEnd(); ++indexIt )
983 cl.append(
mModel->category( *indexIt ) );
1002 viewCategories->selectionModel()->clear();
1010 QMessageBox::information(
this, tr(
"Matched Symbols" ),
1011 tr(
"Matched %1 categories to symbols." ).arg( matched ) );
1015 QMessageBox::warning(
this, tr(
"Matched Symbols" ),
1016 tr(
"No categories could be matched to symbols in library." ) );
1029 QVariantList unmatchedCategories;
1030 QStringList unmatchedSymbols;
1031 const int matched =
mRenderer->matchToSymbols( style, type, unmatchedCategories, unmatchedSymbols );
1033 mModel->updateSymbology();
1040 QString openFileDir = settings.
value( QStringLiteral(
"UI/lastMatchToSymbolsDir" ), QDir::homePath() ).toString();
1042 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Match to Symbols from File" ), openFileDir,
1043 tr(
"XML files (*.xml *.XML)" ) );
1044 if ( fileName.isEmpty() )
1049 QFileInfo openFileInfo( fileName );
1050 settings.
setValue( QStringLiteral(
"UI/lastMatchToSymbolsDir" ), openFileInfo.absolutePath() );
1053 if ( !importedStyle.
importXml( fileName ) )
1055 QMessageBox::warning(
this, tr(
"Match to Symbols from File" ),
1056 tr(
"An error occurred while reading file:\n%1" ).arg( importedStyle.
errorString() ) );
1063 QMessageBox::information(
this, tr(
"Match to Symbols from File" ),
1064 tr(
"Matched %1 categories to symbols from file." ).arg( matched ) );
1068 QMessageBox::warning(
this, tr(
"Match to Symbols from File" ),
1069 tr(
"No categories could be matched to symbols in file." ) );
1073 void QgsCategorizedSymbolRendererWidget::cleanUpSymbolSelector(
QgsPanelWidget *container )
1082 void QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget()
1093 QItemSelectionModel *m = viewCategories->selectionModel();
1094 QModelIndexList i = m->selectedRows();
1096 if ( m && !i.isEmpty() )
1100 if ( !selectedCats.isEmpty() )
1102 Q_FOREACH (
int idx, selectedCats )
1105 if ( selectedCats.count() > 1 )
1110 mRenderer->updateCategorySymbol( idx, newCatSymbol );
1130 if ( event->key() == Qt::Key_C &&
event->modifiers() == Qt::ControlModifier )
1132 mCopyBuffer.clear();
1135 else if ( event->key() == Qt::Key_V &&
event->modifiers() == Qt::ControlModifier )
1137 QgsCategoryList::const_iterator rIt = mCopyBuffer.constBegin();
1138 for ( ; rIt != mCopyBuffer.constEnd(); ++rIt )
1140 mModel->addCategory( *rIt );
1174 void QgsCategorizedSymbolRendererWidget::dataDefinedSizeLegend()
1189 void QgsCategorizedSymbolRendererWidget::mergeSelectedCategories()
1194 QList< int > categoryIndexes;
1197 for (
int i : selectedCategoryIndexes )
1199 QVariant v = categories.at( i ).value();
1201 if ( !v.isValid() || v ==
"" )
1206 categoryIndexes.append( i );
1209 if ( categoryIndexes.count() < 2 )
1213 QVariantList values;
1214 values.reserve( categoryIndexes.count() );
1215 labels.reserve( categoryIndexes.count() );
1216 for (
int i : categoryIndexes )
1218 QVariant v = categories.at( i ).value();
1220 if ( v.type() == QVariant::List )
1222 values.append( v.toList() );
1227 labels << categories.at( i ).label();
1231 mRenderer->updateCategoryLabel( categoryIndexes.at( 0 ), labels.join(
',' ) );
1232 mRenderer->updateCategoryValue( categoryIndexes.at( 0 ), values );
1234 categoryIndexes.pop_front();
1235 mModel->deleteRows( categoryIndexes );
1240 void QgsCategorizedSymbolRendererWidget::unmergeSelectedCategories()
1243 if ( categoryIndexes.isEmpty() )
1247 for (
int i : categoryIndexes )
1249 const QVariant v = categories.at( i ).value();
1250 if ( v.type() != QVariant::List )
1253 const QVariantList list = v.toList();
1254 for (
int j = 1; j < list.count(); ++j )
1256 mModel->addCategory(
QgsRendererCategory( list.at( j ), categories.at( i ).symbol()->clone(), list.at( j ).toString(), categories.at( i ).renderState() ) );
1258 mRenderer->updateCategoryValue( i, list.at( 0 ) );
1259 mRenderer->updateCategoryLabel( i, list.at( 0 ).toString() );
1265 void QgsCategorizedSymbolRendererWidget::showContextMenu( QPoint )
1267 mContextMenu->clear();
1268 const QList< QAction * > actions =
contextMenu->actions();
1269 for ( QAction *act : actions )
1271 mContextMenu->addAction( act );
1274 mContextMenu->addSeparator();
1276 if ( viewCategories->selectionModel()->selectedRows().count() > 1 )
1278 mContextMenu->addAction( mMergeCategoriesAction );
1280 if ( viewCategories->selectionModel()->selectedRows().count() == 1 )
1284 const QVariant v = categories.at( categoryIndexes.at( 0 ) ).value();
1285 if ( v.type() == QVariant::List )
1286 mContextMenu->addAction( mUnmergeCategoriesAction );
1288 else if ( viewCategories->selectionModel()->selectedRows().count() > 1 )
1290 mContextMenu->addAction( mUnmergeCategoriesAction );
1293 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.
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
Query 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.