40 #include <QMessageBox> 41 #include <QStandardItemModel> 42 #include <QStandardItem> 50 QgsGraduatedSymbolRendererModel::QgsGraduatedSymbolRendererModel( QObject *parent ) : QAbstractItemModel( parent )
51 , mMimeFormat( QStringLiteral(
"application/x-qgsgraduatedsymbolrendererv2model" ) )
59 if ( mRenderer->
ranges().size() )
61 beginRemoveRows( QModelIndex(), 0, mRenderer->
ranges().size() - 1 );
72 if ( renderer->
ranges().size() )
74 beginInsertRows( QModelIndex(), 0, renderer->
ranges().size() - 1 );
85 void QgsGraduatedSymbolRendererModel::addClass(
QgsSymbol *symbol )
87 if ( !mRenderer )
return;
88 int idx = mRenderer->
ranges().size();
89 beginInsertRows( QModelIndex(), idx, idx );
94 void QgsGraduatedSymbolRendererModel::addClass(
const QgsRendererRange &range )
100 int idx = mRenderer->
ranges().size();
101 beginInsertRows( QModelIndex(), idx, idx );
106 QgsRendererRange QgsGraduatedSymbolRendererModel::rendererRange(
const QModelIndex &index )
108 if ( !index.isValid() || !mRenderer || mRenderer->
ranges().size() <= index.row() )
113 return mRenderer->
ranges().value( index.row() );
116 Qt::ItemFlags QgsGraduatedSymbolRendererModel::flags(
const QModelIndex &index )
const 118 if ( !index.isValid() )
120 return Qt::ItemIsDropEnabled;
123 Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable;
125 if ( index.column() == 2 )
127 flags |= Qt::ItemIsEditable;
133 Qt::DropActions QgsGraduatedSymbolRendererModel::supportedDropActions()
const 135 return Qt::MoveAction;
138 QVariant QgsGraduatedSymbolRendererModel::data(
const QModelIndex &index,
int role )
const 140 if ( !index.isValid() || !mRenderer )
return QVariant();
144 if ( role == Qt::CheckStateRole && index.column() == 0 )
146 return range.
renderState() ? Qt::Checked : Qt::Unchecked;
148 else if ( role == Qt::DisplayRole || role == Qt::ToolTipRole )
150 switch ( index.column() )
155 if ( decimalPlaces < 0 ) decimalPlaces = 0;
156 return QLocale().toString( range.
lowerValue(),
'f', decimalPlaces ) +
" - " + QLocale().toString( range.
upperValue(),
'f', decimalPlaces );
159 return range.
label();
164 else if ( role == Qt::DecorationRole && index.column() == 0 && range.
symbol() )
169 else if ( role == Qt::TextAlignmentRole )
171 return ( index.column() == 0 ) ? Qt::AlignHCenter : Qt::AlignLeft;
173 else if ( role == Qt::EditRole )
175 switch ( index.column() )
179 return range.
label();
188 bool QgsGraduatedSymbolRendererModel::setData(
const QModelIndex &index,
const QVariant &value,
int role )
190 if ( !index.isValid() )
193 if ( index.column() == 0 && role == Qt::CheckStateRole )
196 emit dataChanged( index, index );
200 if ( role != Qt::EditRole )
203 switch ( index.column() )
214 emit dataChanged( index, index );
218 QVariant QgsGraduatedSymbolRendererModel::headerData(
int section, Qt::Orientation orientation,
int role )
const 220 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < 3 )
223 lst << tr(
"Symbol" ) << tr(
"Values" ) << tr(
"Legend" );
224 return lst.value( section );
229 int QgsGraduatedSymbolRendererModel::rowCount(
const QModelIndex &parent )
const 231 if ( parent.isValid() || !mRenderer )
235 return mRenderer->
ranges().size();
238 int QgsGraduatedSymbolRendererModel::columnCount(
const QModelIndex &index )
const 244 QModelIndex QgsGraduatedSymbolRendererModel::index(
int row,
int column,
const QModelIndex &parent )
const 246 if ( hasIndex( row, column, parent ) )
248 return createIndex( row, column );
250 return QModelIndex();
253 QModelIndex QgsGraduatedSymbolRendererModel::parent(
const QModelIndex &index )
const 256 return QModelIndex();
259 QStringList QgsGraduatedSymbolRendererModel::mimeTypes()
const 262 types << mMimeFormat;
266 QMimeData *QgsGraduatedSymbolRendererModel::mimeData(
const QModelIndexList &indexes )
const 268 QMimeData *mimeData =
new QMimeData();
269 QByteArray encodedData;
271 QDataStream stream( &encodedData, QIODevice::WriteOnly );
274 Q_FOREACH (
const QModelIndex &index, indexes )
276 if ( !index.isValid() || index.column() != 0 )
279 stream << index.row();
281 mimeData->setData( mMimeFormat, encodedData );
285 bool QgsGraduatedSymbolRendererModel::dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
289 if ( action != Qt::MoveAction )
return true;
291 if ( !data->hasFormat( mMimeFormat ) )
return false;
293 QByteArray encodedData = data->data( mMimeFormat );
294 QDataStream stream( &encodedData, QIODevice::ReadOnly );
297 while ( !stream.atEnd() )
304 int to = parent.row();
307 if ( to == -1 ) to = mRenderer->
ranges().size();
308 for (
int i = rows.size() - 1; i >= 0; i-- )
310 QgsDebugMsg( QStringLiteral(
"move %1 to %2" ).arg( rows[i] ).arg( to ) );
313 if ( rows[i] < t ) t--;
316 for (
int j = 0; j < i; j++ )
318 if ( to < rows[j] && rows[i] > rows[j] ) rows[j] += 1;
321 if ( rows[i] < to ) to--;
323 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->
ranges().size(), 0 ) );
328 void QgsGraduatedSymbolRendererModel::deleteRows( QList<int> rows )
330 for (
int i = rows.size() - 1; i >= 0; i-- )
332 beginRemoveRows( QModelIndex(), rows[i], rows[i] );
338 void QgsGraduatedSymbolRendererModel::removeAllRows()
340 beginRemoveRows( QModelIndex(), 0, mRenderer->
ranges().size() - 1 );
345 void QgsGraduatedSymbolRendererModel::sort(
int column, Qt::SortOrder order )
355 else if ( column == 2 )
360 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->
ranges().size(), 0 ) );
363 void QgsGraduatedSymbolRendererModel::updateSymbology(
bool resetModel )
371 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->
ranges().size(), 0 ) );
375 void QgsGraduatedSymbolRendererModel::updateLabels()
377 emit dataChanged( createIndex( 0, 2 ), createIndex( mRenderer->
ranges().size(), 2 ) );
381 QgsGraduatedSymbolRendererViewStyle::QgsGraduatedSymbolRendererViewStyle( QWidget *parent )
385 void QgsGraduatedSymbolRendererViewStyle::drawPrimitive( PrimitiveElement element,
const QStyleOption *option, QPainter *painter,
const QWidget *widget )
const 387 if ( element == QStyle::PE_IndicatorItemViewItemDrop && !option->rect.isNull() )
389 QStyleOption opt( *option );
390 opt.rect.setLeft( 0 );
392 opt.rect.setHeight( 0 );
393 if ( widget ) opt.rect.setRight( widget->width() );
394 QProxyStyle::drawPrimitive( element, &opt, painter, widget );
397 QProxyStyle::drawPrimitive( element, option, painter, widget );
416 if ( mContext.mapCanvas() )
449 mRenderer = qgis::make_unique< QgsGraduatedSymbolRenderer >( QString(),
QgsRangeList() );
461 connect( methodComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsGraduatedSymbolRendererWidget::methodComboBox_currentIndexChanged );
462 this->layout()->setContentsMargins( 0, 0, 0, 0 );
464 mModel =
new QgsGraduatedSymbolRendererModel(
this );
467 mExpressionWidget->setLayer(
mLayer );
475 btnColorRamp->setShowRandomColorRamp(
true );
478 QString defaultColorRamp =
QgsProject::instance()->
readEntry( QStringLiteral(
"DefaultStyles" ), QStringLiteral(
"/ColorRamp" ), QString() );
479 if ( !defaultColorRamp.isEmpty() )
481 btnColorRamp->setColorRampFromName( defaultColorRamp );
486 btnColorRamp->setColorRamp( ramp );
491 viewGraduated->setStyle(
new QgsGraduatedSymbolRendererViewStyle( viewGraduated ) );
495 methodComboBox->blockSignals(
true );
496 methodComboBox->addItem( QStringLiteral(
"Color" ) );
499 methodComboBox->addItem( QStringLiteral(
"Size" ) );
500 minSizeSpinBox->setValue( 1 );
501 maxSizeSpinBox->setValue( 8 );
505 methodComboBox->addItem( QStringLiteral(
"Size" ) );
506 minSizeSpinBox->setValue( .1 );
507 maxSizeSpinBox->setValue( 2 );
509 methodComboBox->blockSignals(
false );
530 mGroupBoxSymmetric->setCollapsed(
true );
533 QMenu *advMenu =
new QMenu(
this );
535 advMenu->addAction( tr(
"Symbol Levels…" ),
this, SLOT(
showSymbolLevels() ) );
538 QAction *actionDdsLegend = advMenu->addAction( tr(
"Data-defined Size Legend…" ) );
540 connect( actionDdsLegend, &QAction::triggered,
this, &QgsGraduatedSymbolRendererWidget::dataDefinedSizeLegend );
543 btnAdvanced->setMenu( advMenu );
545 mHistogramWidget->setLayer(
mLayer );
546 mHistogramWidget->setRenderer( mRenderer.get() );
550 mExpressionWidget->registerExpressionContextGenerator(
this );
553 void QgsGraduatedSymbolRendererWidget::mSizeUnitWidget_changed()
555 if ( !mGraduatedSymbol )
return;
556 mGraduatedSymbol->setOutputUnit( mSizeUnitWidget->unit() );
557 mGraduatedSymbol->setMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
559 mRenderer->updateSymbols( mGraduatedSymbol.get() );
570 return mRenderer.get();
619 spinSymmetryPointForOtherMethods->setShowClearButton(
false );
622 if ( cboGraduatedMode->findData( mRenderer->mode() ) >= 0 )
624 cboGraduatedMode->setCurrentIndex( cboGraduatedMode->findData( mRenderer->mode() ) );
634 mGroupBoxSymmetric->setVisible(
true );
635 cbxAstride->setVisible(
true );
636 cboSymmetryPointForPretty->setVisible(
false );
637 spinSymmetryPointForOtherMethods->setVisible(
true );
638 spinSymmetryPointForOtherMethods->setValue( mRenderer->symmetryPoint() );
644 mGroupBoxSymmetric->setVisible(
true );
645 cbxAstride->setVisible(
true );
646 spinSymmetryPointForOtherMethods->setVisible(
false );
647 cboSymmetryPointForPretty->setVisible(
true );
648 cboSymmetryPointForPretty->clear();
649 cboSymmetryPointForPretty->addItems( mRenderer->listForCboPrettyBreaks() );
651 cboSymmetryPointForPretty->setCurrentText( QString::number( mRenderer->symmetryPoint(),
'f', 2 ) );
659 mGroupBoxSymmetric->setVisible(
false );
660 cbxAstride->setVisible(
false );
661 cboSymmetryPointForPretty->setVisible(
false );
662 spinSymmetryPointForOtherMethods->setVisible(
false );
663 spinSymmetryPointForOtherMethods->setValue( mRenderer->symmetryPoint() );
668 if ( mRenderer->useSymmetricMode() )
670 mGroupBoxSymmetric->setChecked(
true );
671 spinSymmetryPointForOtherMethods->setEnabled(
true );
672 cbxAstride->setEnabled(
true );
673 cboSymmetryPointForPretty->setEnabled(
true );
677 mGroupBoxSymmetric->setChecked(
false );
678 spinSymmetryPointForOtherMethods->setEnabled(
false );
679 cbxAstride->setEnabled(
false );
680 cboSymmetryPointForPretty->setEnabled(
false );
683 if ( mRenderer->astride() )
684 cbxAstride->setChecked(
true );
686 cbxAstride->setChecked(
false );
689 int nclasses = mRenderer->ranges().count();
690 if ( nclasses && updateCount )
691 spinGraduatedClasses->setValue( mRenderer->ranges().count() );
694 QString attrName = mRenderer->classAttribute();
695 mExpressionWidget->setField( attrName );
696 mHistogramWidget->setSourceFieldExp( attrName );
699 if ( mRenderer->sourceSymbol() )
701 mGraduatedSymbol.reset( mRenderer->sourceSymbol()->clone() );
705 mModel->setRenderer( mRenderer.get() );
706 viewGraduated->setModel( mModel );
708 if ( mGraduatedSymbol )
710 mSizeUnitWidget->blockSignals(
true );
711 mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() );
712 mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() );
713 mSizeUnitWidget->blockSignals(
false );
717 methodComboBox->blockSignals(
true );
720 methodComboBox->setCurrentIndex( 0 );
721 if ( mRenderer->sourceColorRamp() )
723 btnColorRamp->setColorRamp( mRenderer->sourceColorRamp() );
728 methodComboBox->setCurrentIndex( 1 );
729 if ( !mRenderer->ranges().isEmpty() )
731 minSizeSpinBox->setValue( mRenderer->minSymbolSize() );
732 maxSizeSpinBox->setValue( mRenderer->maxSymbolSize() );
735 toggleMethodWidgets( methodComboBox->currentIndex() );
736 methodComboBox->blockSignals(
false );
739 txtLegendFormat->setText( labelFormat.
format() );
740 spinPrecision->setValue( labelFormat.
precision() );
743 viewGraduated->resizeColumnToContents( 0 );
744 viewGraduated->resizeColumnToContents( 1 );
745 viewGraduated->resizeColumnToContents( 2 );
747 mHistogramWidget->refresh();
755 mRenderer->setClassAttribute( field );
758 void QgsGraduatedSymbolRendererWidget::methodComboBox_currentIndexChanged(
int idx )
760 toggleMethodWidgets( idx );
768 QMessageBox::critical(
this, tr(
"Select Method" ), tr(
"No color ramp defined." ) );
771 mRenderer->setSourceColorRamp( ramp );
776 lblColorRamp->setVisible(
false );
777 btnColorRamp->setVisible(
false );
778 lblSize->setVisible(
true );
779 minSizeSpinBox->setVisible(
true );
780 lblSize->setVisible(
true );
781 maxSizeSpinBox->setVisible(
true );
782 mSizeUnitWidget->setVisible(
true );
789 void QgsGraduatedSymbolRendererWidget::toggleMethodWidgets(
int idx )
793 lblColorRamp->setVisible(
true );
794 btnColorRamp->setVisible(
true );
795 lblSize->setVisible(
false );
796 minSizeSpinBox->setVisible(
false );
797 lblSizeTo->setVisible(
false );
798 maxSizeSpinBox->setVisible(
false );
799 mSizeUnitWidget->setVisible(
false );
803 lblColorRamp->setVisible(
false );
804 btnColorRamp->setVisible(
false );
805 lblSize->setVisible(
true );
806 minSizeSpinBox->setVisible(
true );
807 lblSizeTo->setVisible(
true );
808 maxSizeSpinBox->setVisible(
true );
809 mSizeUnitWidget->setVisible(
true );
818 mModel->updateSymbology( reset );
822 void QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector(
QgsPanelWidget *container )
831 void QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget()
841 mSizeUnitWidget->blockSignals(
true );
842 mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() );
843 mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() );
844 mSizeUnitWidget->blockSignals(
false );
846 QItemSelectionModel *m = viewGraduated->selectionModel();
847 QModelIndexList selectedIndexes = m->selectedRows( 1 );
848 if ( m && !selectedIndexes.isEmpty() )
850 Q_FOREACH (
const QModelIndex &idx, selectedIndexes )
854 int rangeIdx = idx.row();
855 QgsSymbol *newRangeSymbol = mGraduatedSymbol->clone();
856 if ( selectedIndexes.count() > 1 )
859 newRangeSymbol->
setColor( mRenderer->ranges().at( rangeIdx ).symbol()->color() );
861 mRenderer->updateRangeSymbol( rangeIdx, newRangeSymbol );
867 mRenderer->updateSymbols( mGraduatedSymbol.get() );
877 QString attrName = mExpressionWidget->currentField();
878 int nclasses = spinGraduatedClasses->value();
880 std::unique_ptr<QgsColorRamp> ramp( btnColorRamp->colorRamp() );
883 QMessageBox::critical(
this, tr(
"Apply Classification" ), tr(
"No color ramp defined." ) );
888 bool useSymmetricMode =
false;
889 bool astride =
false;
894 spinSymmetryPointForOtherMethods->setMinimum( minimum );
895 spinSymmetryPointForOtherMethods->setMaximum( maximum );
896 spinSymmetryPointForOtherMethods->setDecimals( spinPrecision->value() );
898 double symmetryPoint = spinSymmetryPointForOtherMethods->value();
908 if ( spinSymmetryPointForOtherMethods->value() < ( minimum + ( maximum - minimum ) / 100. ) || spinSymmetryPointForOtherMethods->value() > ( maximum - ( maximum - minimum ) / 100. ) )
909 spinSymmetryPointForOtherMethods->setValue( minimum + ( maximum - minimum ) / 2. );
911 if ( mGroupBoxSymmetric->isChecked() )
913 useSymmetricMode =
true;
914 symmetryPoint = spinSymmetryPointForOtherMethods->value();
915 astride = cbxAstride->isChecked();
931 if ( spinSymmetryPointForOtherMethods->value() < ( minimum + ( maximum - minimum ) / 100. ) || spinSymmetryPointForOtherMethods->value() > ( maximum - ( maximum - minimum ) / 100. ) )
932 spinSymmetryPointForOtherMethods->setValue( minimum + ( maximum - minimum ) / 2. );
934 if ( mGroupBoxSymmetric->isChecked() )
936 useSymmetricMode =
true;
937 symmetryPoint = spinSymmetryPointForOtherMethods->value();
938 astride = cbxAstride->isChecked();
946 if ( mGroupBoxSymmetric->isChecked() )
948 useSymmetricMode =
true;
949 astride = cbxAstride->isChecked();
950 symmetryPoint = cboSymmetryPointForPretty->currentText().toDouble();
968 if ( QMessageBox::Cancel == QMessageBox::question(
this, tr(
"Apply Classification" ), tr(
"Natural break classification (Jenks) is O(n2) complexity, your classification may take a long time.\nPress cancel to abort breaks calculation or OK to continue." ), QMessageBox::Cancel, QMessageBox::Ok ) )
972 mRenderer->setClassAttribute( attrName );
973 mRenderer->setMode( mode );
974 mRenderer->setUseSymmetricMode( useSymmetricMode );
975 mRenderer->setSymmetryPoint( symmetryPoint );
976 mRenderer->setAstride( astride );
978 if ( methodComboBox->currentIndex() == 0 )
982 QMessageBox::critical(
this, tr(
"Apply Classification" ), tr(
"No color ramp defined." ) );
985 mRenderer->setSourceColorRamp( ramp.release() );
989 mRenderer->setSourceColorRamp(
nullptr );
992 QApplication::setOverrideCursor( Qt::WaitCursor );
994 mRenderer->updateClasses(
mLayer, mode, nclasses, useSymmetricMode, symmetryPoint, astride );
996 if ( methodComboBox->currentIndex() == 1 )
997 mRenderer->setSymbolSizes( minSizeSpinBox->value(), maxSizeSpinBox->value() );
999 mRenderer->calculateLabelPrecision();
1000 QApplication::restoreOverrideCursor();
1008 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
1012 mRenderer->updateColorRamp( ramp.release() );
1013 mRenderer->updateSymbols( mGraduatedSymbol.get() );
1019 mRenderer->setSymbolSizes( minSizeSpinBox->value(), maxSizeSpinBox->value() );
1020 mRenderer->updateSymbols( mGraduatedSymbol.get() );
1027 std::unique_ptr< QgsSymbol > newSymbol( mGraduatedSymbol->clone() );
1041 if ( !dlg.exec() || !newSymbol )
1046 mGraduatedSymbol = std::move( newSymbol );
1054 if ( !mGraduatedSymbol )
1058 btnChangeGraduatedSymbol->setIcon( icon );
1062 int QgsRendererPropertiesDialog::currentRangeRow()
1064 QModelIndex idx = viewGraduated->selectionModel()->currentIndex();
1065 if ( !idx.isValid() )
1074 QModelIndexList selectedRows = viewGraduated->selectionModel()->selectedRows();
1076 Q_FOREACH (
const QModelIndex &r, selectedRows )
1080 rows.append( r.row() );
1089 QModelIndexList selectedRows = viewGraduated->selectionModel()->selectedRows();
1090 QModelIndexList::const_iterator sIt = selectedRows.constBegin();
1092 for ( ; sIt != selectedRows.constEnd(); ++sIt )
1094 selectedRanges.append( mModel->rendererRange( *sIt ) );
1101 if ( idx.isValid() && idx.column() == 0 )
1103 if ( idx.isValid() && idx.column() == 1 )
1109 if ( !idx.isValid() )
1112 mRowSelected = idx.row();
1122 std::unique_ptr< QgsSymbol > newSymbol( range.
symbol()->
clone() );
1124 if ( panel && panel->dockMode() )
1139 if ( !dlg.exec() || !newSymbol )
1144 mGraduatedSymbol = std::move( newSymbol );
1156 int decimalPlaces = mRenderer->labelFormat().precision() + 2;
1157 if ( decimalPlaces < 0 ) decimalPlaces = 0;
1161 if ( dialog.exec() == QDialog::Accepted )
1170 mRenderer->updateRangeUpperValue( rangeIdx, upperValue );
1171 mRenderer->updateRangeLowerValue( rangeIdx, lowerValue );
1174 if ( cbxLinkBoundaries->isChecked() )
1178 mRenderer->updateRangeUpperValue( rangeIdx - 1, lowerValue );
1181 if ( rangeIdx < mRenderer->ranges().size() - 1 )
1183 mRenderer->updateRangeLowerValue( rangeIdx + 1, upperValue );
1187 mHistogramWidget->refresh();
1193 mModel->addClass( mGraduatedSymbol.get() );
1194 mHistogramWidget->refresh();
1200 mModel->deleteRows( classIndexes );
1201 mHistogramWidget->refresh();
1206 mModel->removeAllRows();
1207 mHistogramWidget->refresh();
1213 bool ordered =
true;
1214 for (
int i = 1; i < ranges.size(); ++i )
1216 if ( ranges[i] < ranges[i - 1] )
1233 int result = QMessageBox::warning(
1235 tr(
"Link Class Boundaries" ),
1236 tr(
"Rows will be reordered before linking boundaries. Continue?" ),
1237 QMessageBox::Ok | QMessageBox::Cancel );
1238 if ( result != QMessageBox::Ok )
1240 cbxLinkBoundaries->setChecked(
false );
1243 mRenderer->sortByValue();
1247 for (
int i = 1; i < mRenderer->ranges().size(); ++i )
1249 mRenderer->updateRangeLowerValue( i, mRenderer->ranges()[i - 1].upperValue() );
1257 if ( item->column() == 2 )
1259 QString label = item->text();
1260 int idx = item->row();
1261 mRenderer->updateRangeLabel( idx, label );
1268 txtLegendFormat->text(),
1269 spinPrecision->value(),
1270 cbxTrimTrailingZeroes->isChecked() );
1271 mRenderer->setLabelFormat( labelFormat,
true );
1272 mModel->updateLabels();
1280 QItemSelectionModel *m = viewGraduated->selectionModel();
1281 QModelIndexList selectedIndexes = m->selectedRows( 1 );
1282 if ( m && !selectedIndexes.isEmpty() )
1285 QModelIndexList::const_iterator indexIt = selectedIndexes.constBegin();
1286 for ( ; indexIt != selectedIndexes.constEnd(); ++indexIt )
1288 QStringList list = m->model()->data( *indexIt ).toString().split(
' ' );
1289 if ( list.size() < 3 )
1305 selectedSymbols.append( s );
1314 int decimalPlaces = mRenderer->labelFormat().precision() + 2;
1315 if ( decimalPlaces < 0 )
1317 double precision = 1.0 / std::pow( 10, decimalPlaces );
1319 for ( QgsRangeList::const_iterator it = ranges.begin(); it != ranges.end(); ++it )
1323 return it->symbol();
1333 mModel->updateSymbology();
1335 mHistogramWidget->refresh();
1346 viewGraduated->selectionModel()->clear();
1349 cbxLinkBoundaries->setChecked(
false );
1366 if ( event->key() == Qt::Key_C &&
event->modifiers() == Qt::ControlModifier )
1368 mCopyBuffer.clear();
1371 else if ( event->key() == Qt::Key_V &&
event->modifiers() == Qt::ControlModifier )
1373 QgsRangeList::const_iterator rIt = mCopyBuffer.constBegin();
1374 for ( ; rIt != mCopyBuffer.constEnd(); ++rIt )
1376 mModel->addClass( *rIt );
1382 void QgsGraduatedSymbolRendererWidget::dataDefinedSizeLegend()
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
const QgsRendererRangeLabelFormat & labelFormat() const
Returns the label format used to generate default classification labels.
static QgsGraduatedSymbolRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
creates a QgsGraduatedSymbolRenderer from an existing renderer.
QString readEntry(const QString &scope, const QString &key, const QString &def=QString(), bool *ok=nullptr) const
Abstract base class for all rendered symbols.
QList< QgsRendererRange > QgsRangeList
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
double qgsPermissiveToDouble(QString string, bool &ok)
Converts a string to a double in a permissive way, e.g., allowing for incorrect numbers of digits bet...
Abstract base class for color ramps.
static QIcon symbolPreviewIcon(const QgsSymbol *symbol, QSize size, int padding=0)
Returns an icon preview for a color ramp.
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.
A QProxyStyle subclass which correctly sets the base style to match the QGIS application style...
void setLowerValue(const QString &val)
void addClass(QgsSymbol *symbol)
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
A marker symbol type, for rendering Point and MultiPoint geometries.
The QgsMapSettings class contains configuration for rendering of the map.
void sortByValue(Qt::SortOrder order=Qt::AscendingOrder)
double lowerValue() const
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.
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
points (e.g., for font sizes)
QgsSymbol * symbol() const
QVariant minimumValue(int index) const FINAL
Returns the minimum value for an attribute column or an invalid variant in case of error...
Single scope for storing variables and functions for use within a QgsExpressionContext.
void moveClass(int from, int to)
Moves the category at index position from to index position to.
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...
void sortByLabel(Qt::SortOrder order=Qt::AscendingOrder)
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.
void setUpperValue(const QString &val)
double upperValue() const
bool updateRangeRenderState(int rangeIndex, bool render)
QString lowerValue() const
bool updateRangeLabel(int rangeIndex, const QString &label)
QString upperValue() const
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
QVariant maximumValue(int index) const FINAL
Returns the maximum value for an attribute column or an invalid variant in case of error...
Represents a vector layer which manages a vector based data sets.
const QgsRangeList & ranges() const
void deleteClass(int idx)
void setColor(const QColor &color)
Sets the color for the symbol.