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().isEmpty() )
61 beginRemoveRows( QModelIndex(), 0, mRenderer->
ranges().size() - 1 );
72 if ( !renderer->
ranges().isEmpty() )
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 const auto constIndexes = indexes;
275 for (
const QModelIndex &index : constIndexes )
277 if ( !index.isValid() || index.column() != 0 )
280 stream << index.row();
282 mimeData->setData( mMimeFormat, encodedData );
286 bool QgsGraduatedSymbolRendererModel::dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
290 if ( action != Qt::MoveAction )
return true;
292 if ( !data->hasFormat( mMimeFormat ) )
return false;
294 QByteArray encodedData = data->data( mMimeFormat );
295 QDataStream stream( &encodedData, QIODevice::ReadOnly );
298 while ( !stream.atEnd() )
305 int to = parent.row();
308 if ( to == -1 ) to = mRenderer->
ranges().size();
309 for (
int i = rows.size() - 1; i >= 0; i-- )
311 QgsDebugMsg( QStringLiteral(
"move %1 to %2" ).arg( rows[i] ).arg( to ) );
314 if ( rows[i] < t ) t--;
317 for (
int j = 0; j < i; j++ )
319 if ( to < rows[j] && rows[i] > rows[j] ) rows[j] += 1;
322 if ( rows[i] < to ) to--;
324 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->
ranges().size(), 0 ) );
329 void QgsGraduatedSymbolRendererModel::deleteRows( QList<int> rows )
331 for (
int i = rows.size() - 1; i >= 0; i-- )
333 beginRemoveRows( QModelIndex(), rows[i], rows[i] );
339 void QgsGraduatedSymbolRendererModel::removeAllRows()
341 beginRemoveRows( QModelIndex(), 0, mRenderer->
ranges().size() - 1 );
346 void QgsGraduatedSymbolRendererModel::sort(
int column, Qt::SortOrder order )
356 else if ( column == 2 )
361 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->
ranges().size(), 0 ) );
364 void QgsGraduatedSymbolRendererModel::updateSymbology(
bool resetModel )
372 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->
ranges().size(), 0 ) );
376 void QgsGraduatedSymbolRendererModel::updateLabels()
378 emit dataChanged( createIndex( 0, 2 ), createIndex( mRenderer->
ranges().size(), 2 ) );
382 QgsGraduatedSymbolRendererViewStyle::QgsGraduatedSymbolRendererViewStyle( QWidget *parent )
386 void QgsGraduatedSymbolRendererViewStyle::drawPrimitive( PrimitiveElement element,
const QStyleOption *option, QPainter *painter,
const QWidget *widget )
const 388 if ( element == QStyle::PE_IndicatorItemViewItemDrop && !option->rect.isNull() )
390 QStyleOption opt( *option );
391 opt.rect.setLeft( 0 );
393 opt.rect.setHeight( 0 );
394 if ( widget ) opt.rect.setRight( widget->width() );
395 QProxyStyle::drawPrimitive( element, &opt, painter, widget );
398 QProxyStyle::drawPrimitive( element, option, painter, widget );
417 if ( mContext.mapCanvas() )
431 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
451 mRenderer = qgis::make_unique< QgsGraduatedSymbolRenderer >( QString(),
QgsRangeList() );
463 connect( methodComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsGraduatedSymbolRendererWidget::methodComboBox_currentIndexChanged );
464 this->layout()->setContentsMargins( 0, 0, 0, 0 );
466 mModel =
new QgsGraduatedSymbolRendererModel(
this );
469 mExpressionWidget->setLayer(
mLayer );
477 btnColorRamp->setShowRandomColorRamp(
true );
480 QString defaultColorRamp =
QgsProject::instance()->
readEntry( QStringLiteral(
"DefaultStyles" ), QStringLiteral(
"/ColorRamp" ), QString() );
481 if ( !defaultColorRamp.isEmpty() )
483 btnColorRamp->setColorRampFromName( defaultColorRamp );
488 btnColorRamp->setColorRamp( ramp );
493 viewGraduated->setStyle(
new QgsGraduatedSymbolRendererViewStyle( viewGraduated ) );
497 methodComboBox->blockSignals(
true );
498 methodComboBox->addItem( QStringLiteral(
"Color" ) );
501 methodComboBox->addItem( QStringLiteral(
"Size" ) );
502 minSizeSpinBox->setValue( 1 );
503 maxSizeSpinBox->setValue( 8 );
507 methodComboBox->addItem( QStringLiteral(
"Size" ) );
508 minSizeSpinBox->setValue( .1 );
509 maxSizeSpinBox->setValue( 2 );
511 methodComboBox->blockSignals(
false );
532 mGroupBoxSymmetric->setCollapsed(
true );
535 QMenu *advMenu =
new QMenu(
this );
537 advMenu->addAction( tr(
"Symbol Levels…" ),
this, SLOT(
showSymbolLevels() ) );
540 QAction *actionDdsLegend = advMenu->addAction( tr(
"Data-defined Size Legend…" ) );
542 connect( actionDdsLegend, &QAction::triggered,
this, &QgsGraduatedSymbolRendererWidget::dataDefinedSizeLegend );
545 btnAdvanced->setMenu( advMenu );
547 mHistogramWidget->setLayer(
mLayer );
548 mHistogramWidget->setRenderer( mRenderer.get() );
552 mExpressionWidget->registerExpressionContextGenerator(
this );
555 void QgsGraduatedSymbolRendererWidget::mSizeUnitWidget_changed()
557 if ( !mGraduatedSymbol )
return;
558 mGraduatedSymbol->setOutputUnit( mSizeUnitWidget->unit() );
559 mGraduatedSymbol->setMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
561 mRenderer->updateSymbols( mGraduatedSymbol.get() );
572 return mRenderer.get();
621 spinSymmetryPointForOtherMethods->setShowClearButton(
false );
624 if ( cboGraduatedMode->findData( mRenderer->mode() ) >= 0 )
626 cboGraduatedMode->setCurrentIndex( cboGraduatedMode->findData( mRenderer->mode() ) );
636 mGroupBoxSymmetric->setVisible(
true );
637 cbxAstride->setVisible(
true );
638 cboSymmetryPointForPretty->setVisible(
false );
639 spinSymmetryPointForOtherMethods->setVisible(
true );
640 spinSymmetryPointForOtherMethods->setValue( mRenderer->symmetryPoint() );
646 mGroupBoxSymmetric->setVisible(
true );
647 cbxAstride->setVisible(
true );
648 spinSymmetryPointForOtherMethods->setVisible(
false );
649 cboSymmetryPointForPretty->setVisible(
true );
650 cboSymmetryPointForPretty->clear();
651 cboSymmetryPointForPretty->addItems( mRenderer->listForCboPrettyBreaks() );
653 cboSymmetryPointForPretty->setCurrentText( QString::number( mRenderer->symmetryPoint(),
'f', 2 ) );
661 mGroupBoxSymmetric->setVisible(
false );
662 cbxAstride->setVisible(
false );
663 cboSymmetryPointForPretty->setVisible(
false );
664 spinSymmetryPointForOtherMethods->setVisible(
false );
665 spinSymmetryPointForOtherMethods->setValue( mRenderer->symmetryPoint() );
670 if ( mRenderer->useSymmetricMode() )
672 mGroupBoxSymmetric->setChecked(
true );
673 spinSymmetryPointForOtherMethods->setEnabled(
true );
674 cbxAstride->setEnabled(
true );
675 cboSymmetryPointForPretty->setEnabled(
true );
679 mGroupBoxSymmetric->setChecked(
false );
680 spinSymmetryPointForOtherMethods->setEnabled(
false );
681 cbxAstride->setEnabled(
false );
682 cboSymmetryPointForPretty->setEnabled(
false );
685 if ( mRenderer->astride() )
686 cbxAstride->setChecked(
true );
688 cbxAstride->setChecked(
false );
691 int nclasses = mRenderer->ranges().count();
692 if ( nclasses && updateCount )
693 spinGraduatedClasses->setValue( mRenderer->ranges().count() );
696 QString attrName = mRenderer->classAttribute();
697 mExpressionWidget->setField( attrName );
698 mHistogramWidget->setSourceFieldExp( attrName );
701 if ( mRenderer->sourceSymbol() )
703 mGraduatedSymbol.reset( mRenderer->sourceSymbol()->clone() );
707 mModel->setRenderer( mRenderer.get() );
708 viewGraduated->setModel( mModel );
710 if ( mGraduatedSymbol )
712 mSizeUnitWidget->blockSignals(
true );
713 mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() );
714 mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() );
715 mSizeUnitWidget->blockSignals(
false );
719 methodComboBox->blockSignals(
true );
722 methodComboBox->setCurrentIndex( 0 );
723 if ( mRenderer->sourceColorRamp() )
725 btnColorRamp->setColorRamp( mRenderer->sourceColorRamp() );
730 methodComboBox->setCurrentIndex( 1 );
731 if ( !mRenderer->ranges().isEmpty() )
733 minSizeSpinBox->setValue( mRenderer->minSymbolSize() );
734 maxSizeSpinBox->setValue( mRenderer->maxSymbolSize() );
737 toggleMethodWidgets( methodComboBox->currentIndex() );
738 methodComboBox->blockSignals(
false );
741 txtLegendFormat->setText( labelFormat.
format() );
742 spinPrecision->setValue( labelFormat.
precision() );
745 viewGraduated->resizeColumnToContents( 0 );
746 viewGraduated->resizeColumnToContents( 1 );
747 viewGraduated->resizeColumnToContents( 2 );
749 mHistogramWidget->refresh();
757 mRenderer->setClassAttribute( field );
760 void QgsGraduatedSymbolRendererWidget::methodComboBox_currentIndexChanged(
int idx )
762 toggleMethodWidgets( idx );
770 QMessageBox::critical(
this, tr(
"Select Method" ), tr(
"No color ramp defined." ) );
773 mRenderer->setSourceColorRamp( ramp );
778 lblColorRamp->setVisible(
false );
779 btnColorRamp->setVisible(
false );
780 lblSize->setVisible(
true );
781 minSizeSpinBox->setVisible(
true );
782 lblSize->setVisible(
true );
783 maxSizeSpinBox->setVisible(
true );
784 mSizeUnitWidget->setVisible(
true );
791 void QgsGraduatedSymbolRendererWidget::toggleMethodWidgets(
int idx )
795 lblColorRamp->setVisible(
true );
796 btnColorRamp->setVisible(
true );
797 lblSize->setVisible(
false );
798 minSizeSpinBox->setVisible(
false );
799 lblSizeTo->setVisible(
false );
800 maxSizeSpinBox->setVisible(
false );
801 mSizeUnitWidget->setVisible(
false );
805 lblColorRamp->setVisible(
false );
806 btnColorRamp->setVisible(
false );
807 lblSize->setVisible(
true );
808 minSizeSpinBox->setVisible(
true );
809 lblSizeTo->setVisible(
true );
810 maxSizeSpinBox->setVisible(
true );
811 mSizeUnitWidget->setVisible(
true );
820 mModel->updateSymbology( reset );
824 void QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector(
QgsPanelWidget *container )
833 void QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget()
843 mSizeUnitWidget->blockSignals(
true );
844 mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() );
845 mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() );
846 mSizeUnitWidget->blockSignals(
false );
848 QItemSelectionModel *m = viewGraduated->selectionModel();
849 QModelIndexList selectedIndexes = m->selectedRows( 1 );
850 if ( m && !selectedIndexes.isEmpty() )
852 const auto constSelectedIndexes = selectedIndexes;
853 for (
const QModelIndex &idx : constSelectedIndexes )
857 int rangeIdx = idx.row();
858 QgsSymbol *newRangeSymbol = mGraduatedSymbol->clone();
859 if ( selectedIndexes.count() > 1 )
862 newRangeSymbol->
setColor( mRenderer->ranges().at( rangeIdx ).symbol()->color() );
864 mRenderer->updateRangeSymbol( rangeIdx, newRangeSymbol );
870 mRenderer->updateSymbols( mGraduatedSymbol.get() );
880 QString attrName = mExpressionWidget->currentField();
881 int nclasses = spinGraduatedClasses->value();
883 std::unique_ptr<QgsColorRamp> ramp( btnColorRamp->colorRamp() );
886 QMessageBox::critical(
this, tr(
"Apply Classification" ), tr(
"No color ramp defined." ) );
891 bool useSymmetricMode =
false;
892 bool astride =
false;
897 spinSymmetryPointForOtherMethods->setMinimum( minimum );
898 spinSymmetryPointForOtherMethods->setMaximum( maximum );
899 spinSymmetryPointForOtherMethods->setDecimals( spinPrecision->value() );
901 double symmetryPoint = spinSymmetryPointForOtherMethods->value();
911 if ( spinSymmetryPointForOtherMethods->value() < ( minimum + ( maximum - minimum ) / 100. ) || spinSymmetryPointForOtherMethods->value() > ( maximum - ( maximum - minimum ) / 100. ) )
912 spinSymmetryPointForOtherMethods->setValue( minimum + ( maximum - minimum ) / 2. );
914 if ( mGroupBoxSymmetric->isChecked() )
916 useSymmetricMode =
true;
917 symmetryPoint = spinSymmetryPointForOtherMethods->value();
918 astride = cbxAstride->isChecked();
934 if ( spinSymmetryPointForOtherMethods->value() < ( minimum + ( maximum - minimum ) / 100. ) || spinSymmetryPointForOtherMethods->value() > ( maximum - ( maximum - minimum ) / 100. ) )
935 spinSymmetryPointForOtherMethods->setValue( minimum + ( maximum - minimum ) / 2. );
937 if ( mGroupBoxSymmetric->isChecked() )
939 useSymmetricMode =
true;
940 symmetryPoint = spinSymmetryPointForOtherMethods->value();
941 astride = cbxAstride->isChecked();
949 if ( mGroupBoxSymmetric->isChecked() )
951 useSymmetricMode =
true;
952 astride = cbxAstride->isChecked();
953 symmetryPoint = cboSymmetryPointForPretty->currentText().toDouble();
971 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 ) )
975 mRenderer->setClassAttribute( attrName );
976 mRenderer->setMode( mode );
977 mRenderer->setUseSymmetricMode( useSymmetricMode );
978 mRenderer->setSymmetryPoint( symmetryPoint );
979 mRenderer->setAstride( astride );
981 if ( methodComboBox->currentIndex() == 0 )
985 QMessageBox::critical(
this, tr(
"Apply Classification" ), tr(
"No color ramp defined." ) );
988 mRenderer->setSourceColorRamp( ramp.release() );
992 mRenderer->setSourceColorRamp(
nullptr );
995 QApplication::setOverrideCursor( Qt::WaitCursor );
997 mRenderer->updateClasses(
mLayer, mode, nclasses, useSymmetricMode, symmetryPoint, astride );
999 if ( methodComboBox->currentIndex() == 1 )
1000 mRenderer->setSymbolSizes( minSizeSpinBox->value(), maxSizeSpinBox->value() );
1002 mRenderer->calculateLabelPrecision();
1003 QApplication::restoreOverrideCursor();
1011 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
1015 mRenderer->updateColorRamp( ramp.release() );
1016 mRenderer->updateSymbols( mGraduatedSymbol.get() );
1022 mRenderer->setSymbolSizes( minSizeSpinBox->value(), maxSizeSpinBox->value() );
1023 mRenderer->updateSymbols( mGraduatedSymbol.get() );
1030 std::unique_ptr< QgsSymbol > newSymbol( mGraduatedSymbol->clone() );
1044 if ( !dlg.exec() || !newSymbol )
1049 mGraduatedSymbol = std::move( newSymbol );
1057 if ( !mGraduatedSymbol )
1061 btnChangeGraduatedSymbol->setIcon( icon );
1065 int QgsRendererPropertiesDialog::currentRangeRow()
1067 QModelIndex idx = viewGraduated->selectionModel()->currentIndex();
1068 if ( !idx.isValid() )
1077 QModelIndexList selectedRows = viewGraduated->selectionModel()->selectedRows();
1079 const auto constSelectedRows = selectedRows;
1080 for (
const QModelIndex &r : constSelectedRows )
1084 rows.append( r.row() );
1093 QModelIndexList selectedRows = viewGraduated->selectionModel()->selectedRows();
1094 QModelIndexList::const_iterator sIt = selectedRows.constBegin();
1096 for ( ; sIt != selectedRows.constEnd(); ++sIt )
1098 selectedRanges.append( mModel->rendererRange( *sIt ) );
1105 if ( idx.isValid() && idx.column() == 0 )
1107 if ( idx.isValid() && idx.column() == 1 )
1113 if ( !idx.isValid() )
1116 mRowSelected = idx.row();
1126 std::unique_ptr< QgsSymbol > newSymbol( range.
symbol()->
clone() );
1128 if ( panel && panel->dockMode() )
1143 if ( !dlg.exec() || !newSymbol )
1148 mGraduatedSymbol = std::move( newSymbol );
1160 int decimalPlaces = mRenderer->labelFormat().precision() + 2;
1161 if ( decimalPlaces < 0 ) decimalPlaces = 0;
1165 if ( dialog.exec() == QDialog::Accepted )
1174 mRenderer->updateRangeUpperValue( rangeIdx, upperValue );
1175 mRenderer->updateRangeLowerValue( rangeIdx, lowerValue );
1178 if ( cbxLinkBoundaries->isChecked() )
1182 mRenderer->updateRangeUpperValue( rangeIdx - 1, lowerValue );
1185 if ( rangeIdx < mRenderer->ranges().size() - 1 )
1187 mRenderer->updateRangeLowerValue( rangeIdx + 1, upperValue );
1191 mHistogramWidget->refresh();
1197 mModel->addClass( mGraduatedSymbol.get() );
1198 mHistogramWidget->refresh();
1204 mModel->deleteRows( classIndexes );
1205 mHistogramWidget->refresh();
1210 mModel->removeAllRows();
1211 mHistogramWidget->refresh();
1217 bool ordered =
true;
1218 for (
int i = 1; i < ranges.size(); ++i )
1220 if ( ranges[i] < ranges[i - 1] )
1237 int result = QMessageBox::warning(
1239 tr(
"Link Class Boundaries" ),
1240 tr(
"Rows will be reordered before linking boundaries. Continue?" ),
1241 QMessageBox::Ok | QMessageBox::Cancel );
1242 if ( result != QMessageBox::Ok )
1244 cbxLinkBoundaries->setChecked(
false );
1247 mRenderer->sortByValue();
1251 for (
int i = 1; i < mRenderer->ranges().size(); ++i )
1253 mRenderer->updateRangeLowerValue( i, mRenderer->ranges()[i - 1].upperValue() );
1261 if ( item->column() == 2 )
1263 QString label = item->text();
1264 int idx = item->row();
1265 mRenderer->updateRangeLabel( idx, label );
1272 txtLegendFormat->text(),
1273 spinPrecision->value(),
1274 cbxTrimTrailingZeroes->isChecked() );
1275 mRenderer->setLabelFormat( labelFormat,
true );
1276 mModel->updateLabels();
1284 QItemSelectionModel *m = viewGraduated->selectionModel();
1285 QModelIndexList selectedIndexes = m->selectedRows( 1 );
1286 if ( m && !selectedIndexes.isEmpty() )
1289 QModelIndexList::const_iterator indexIt = selectedIndexes.constBegin();
1290 for ( ; indexIt != selectedIndexes.constEnd(); ++indexIt )
1292 QStringList list = m->model()->data( *indexIt ).toString().split(
' ' );
1293 if ( list.size() < 3 )
1309 selectedSymbols.append( s );
1318 int decimalPlaces = mRenderer->labelFormat().precision() + 2;
1319 if ( decimalPlaces < 0 )
1321 double precision = 1.0 / std::pow( 10, decimalPlaces );
1323 for ( QgsRangeList::const_iterator it = ranges.begin(); it != ranges.end(); ++it )
1327 return it->symbol();
1337 mModel->updateSymbology();
1339 mHistogramWidget->refresh();
1350 viewGraduated->selectionModel()->clear();
1353 cbxLinkBoundaries->setChecked(
false );
1370 if ( event->key() == Qt::Key_C &&
event->modifiers() == Qt::ControlModifier )
1372 mCopyBuffer.clear();
1375 else if ( event->key() == Qt::Key_V &&
event->modifiers() == Qt::ControlModifier )
1377 QgsRangeList::const_iterator rIt = mCopyBuffer.constBegin();
1378 for ( ; rIt != mCopyBuffer.constEnd(); ++rIt )
1380 mModel->addClass( *rIt );
1386 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...
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.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
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)
Points (e.g., for font sizes)
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.