39 #include <QMessageBox> 40 #include <QStandardItemModel> 41 #include <QStandardItem> 49 QgsGraduatedSymbolRendererModel::QgsGraduatedSymbolRendererModel( QObject *parent ) : QAbstractItemModel( parent )
50 , mMimeFormat( QStringLiteral(
"application/x-qgsgraduatedsymbolrendererv2model" ) )
58 if ( mRenderer->
ranges().size() )
60 beginRemoveRows( QModelIndex(), 0, mRenderer->
ranges().size() - 1 );
71 if ( renderer->
ranges().size() )
73 beginInsertRows( QModelIndex(), 0, renderer->
ranges().size() - 1 );
84 void QgsGraduatedSymbolRendererModel::addClass(
QgsSymbol *symbol )
86 if ( !mRenderer )
return;
87 int idx = mRenderer->
ranges().size();
88 beginInsertRows( QModelIndex(), idx, idx );
93 void QgsGraduatedSymbolRendererModel::addClass(
const QgsRendererRange &range )
99 int idx = mRenderer->
ranges().size();
100 beginInsertRows( QModelIndex(), idx, idx );
105 QgsRendererRange QgsGraduatedSymbolRendererModel::rendererRange(
const QModelIndex &index )
107 if ( !index.isValid() || !mRenderer || mRenderer->
ranges().size() <= index.row() )
112 return mRenderer->
ranges().value( index.row() );
115 Qt::ItemFlags QgsGraduatedSymbolRendererModel::flags(
const QModelIndex &index )
const 117 if ( !index.isValid() )
119 return Qt::ItemIsDropEnabled;
122 Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable;
124 if ( index.column() == 2 )
126 flags |= Qt::ItemIsEditable;
132 Qt::DropActions QgsGraduatedSymbolRendererModel::supportedDropActions()
const 134 return Qt::MoveAction;
137 QVariant QgsGraduatedSymbolRendererModel::data(
const QModelIndex &index,
int role )
const 139 if ( !index.isValid() || !mRenderer )
return QVariant();
143 if ( role == Qt::CheckStateRole && index.column() == 0 )
145 return range.
renderState() ? Qt::Checked : Qt::Unchecked;
147 else if ( role == Qt::DisplayRole || role == Qt::ToolTipRole )
149 switch ( index.column() )
154 if ( decimalPlaces < 0 ) decimalPlaces = 0;
155 return QLocale().toString( range.
lowerValue(),
'f', decimalPlaces ) +
" - " + QLocale().toString( range.
upperValue(),
'f', decimalPlaces );
158 return range.
label();
163 else if ( role == Qt::DecorationRole && index.column() == 0 && range.
symbol() )
168 else if ( role == Qt::TextAlignmentRole )
170 return ( index.column() == 0 ) ? Qt::AlignHCenter : Qt::AlignLeft;
172 else if ( role == Qt::EditRole )
174 switch ( index.column() )
178 return range.
label();
187 bool QgsGraduatedSymbolRendererModel::setData(
const QModelIndex &index,
const QVariant &value,
int role )
189 if ( !index.isValid() )
192 if ( index.column() == 0 && role == Qt::CheckStateRole )
195 emit dataChanged( index, index );
199 if ( role != Qt::EditRole )
202 switch ( index.column() )
213 emit dataChanged( index, index );
217 QVariant QgsGraduatedSymbolRendererModel::headerData(
int section, Qt::Orientation orientation,
int role )
const 219 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < 3 )
222 lst << tr(
"Symbol" ) << tr(
"Values" ) << tr(
"Legend" );
223 return lst.value( section );
228 int QgsGraduatedSymbolRendererModel::rowCount(
const QModelIndex &parent )
const 230 if ( parent.isValid() || !mRenderer )
234 return mRenderer->
ranges().size();
237 int QgsGraduatedSymbolRendererModel::columnCount(
const QModelIndex &index )
const 243 QModelIndex QgsGraduatedSymbolRendererModel::index(
int row,
int column,
const QModelIndex &parent )
const 245 if ( hasIndex( row, column, parent ) )
247 return createIndex( row, column );
249 return QModelIndex();
252 QModelIndex QgsGraduatedSymbolRendererModel::parent(
const QModelIndex &index )
const 255 return QModelIndex();
258 QStringList QgsGraduatedSymbolRendererModel::mimeTypes()
const 261 types << mMimeFormat;
265 QMimeData *QgsGraduatedSymbolRendererModel::mimeData(
const QModelIndexList &indexes )
const 267 QMimeData *mimeData =
new QMimeData();
268 QByteArray encodedData;
270 QDataStream stream( &encodedData, QIODevice::WriteOnly );
273 Q_FOREACH (
const QModelIndex &index, indexes )
275 if ( !index.isValid() || index.column() != 0 )
278 stream << index.row();
280 mimeData->setData( mMimeFormat, encodedData );
284 bool QgsGraduatedSymbolRendererModel::dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
288 if ( action != Qt::MoveAction )
return true;
290 if ( !data->hasFormat( mMimeFormat ) )
return false;
292 QByteArray encodedData = data->data( mMimeFormat );
293 QDataStream stream( &encodedData, QIODevice::ReadOnly );
296 while ( !stream.atEnd() )
303 int to = parent.row();
306 if ( to == -1 ) to = mRenderer->
ranges().size();
307 for (
int i = rows.size() - 1; i >= 0; i-- )
309 QgsDebugMsg( QStringLiteral(
"move %1 to %2" ).arg( rows[i] ).arg( to ) );
312 if ( rows[i] < t ) t--;
315 for (
int j = 0; j < i; j++ )
317 if ( to < rows[j] && rows[i] > rows[j] ) rows[j] += 1;
320 if ( rows[i] < to ) to--;
322 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->
ranges().size(), 0 ) );
327 void QgsGraduatedSymbolRendererModel::deleteRows( QList<int> rows )
329 for (
int i = rows.size() - 1; i >= 0; i-- )
331 beginRemoveRows( QModelIndex(), rows[i], rows[i] );
337 void QgsGraduatedSymbolRendererModel::removeAllRows()
339 beginRemoveRows( QModelIndex(), 0, mRenderer->
ranges().size() - 1 );
344 void QgsGraduatedSymbolRendererModel::sort(
int column, Qt::SortOrder order )
354 else if ( column == 2 )
359 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->
ranges().size(), 0 ) );
362 void QgsGraduatedSymbolRendererModel::updateSymbology(
bool resetModel )
370 emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->
ranges().size(), 0 ) );
374 void QgsGraduatedSymbolRendererModel::updateLabels()
376 emit dataChanged( createIndex( 0, 2 ), createIndex( mRenderer->
ranges().size(), 2 ) );
380 QgsGraduatedSymbolRendererViewStyle::QgsGraduatedSymbolRendererViewStyle( QWidget *parent )
384 void QgsGraduatedSymbolRendererViewStyle::drawPrimitive( PrimitiveElement element,
const QStyleOption *option, QPainter *painter,
const QWidget *widget )
const 386 if ( element == QStyle::PE_IndicatorItemViewItemDrop && !option->rect.isNull() )
388 QStyleOption opt( *option );
389 opt.rect.setLeft( 0 );
391 opt.rect.setHeight( 0 );
392 if ( widget ) opt.rect.setRight( widget->width() );
393 QProxyStyle::drawPrimitive( element, &opt, painter, widget );
396 QProxyStyle::drawPrimitive( element, option, painter, widget );
415 if ( mContext.mapCanvas() )
448 mRenderer = qgis::make_unique< QgsGraduatedSymbolRenderer >( QString(),
QgsRangeList() );
460 connect( methodComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsGraduatedSymbolRendererWidget::methodComboBox_currentIndexChanged );
461 this->layout()->setContentsMargins( 0, 0, 0, 0 );
463 mModel =
new QgsGraduatedSymbolRendererModel(
this );
466 mExpressionWidget->setLayer(
mLayer );
474 btnColorRamp->setShowRandomColorRamp(
true );
477 QString defaultColorRamp =
QgsProject::instance()->
readEntry( QStringLiteral(
"DefaultStyles" ), QStringLiteral(
"/ColorRamp" ), QString() );
478 if ( !defaultColorRamp.isEmpty() )
480 btnColorRamp->setColorRampFromName( defaultColorRamp );
485 btnColorRamp->setColorRamp( ramp );
490 viewGraduated->setStyle(
new QgsGraduatedSymbolRendererViewStyle( viewGraduated ) );
494 methodComboBox->blockSignals(
true );
495 methodComboBox->addItem( QStringLiteral(
"Color" ) );
498 methodComboBox->addItem( QStringLiteral(
"Size" ) );
499 minSizeSpinBox->setValue( 1 );
500 maxSizeSpinBox->setValue( 8 );
504 methodComboBox->addItem( QStringLiteral(
"Size" ) );
505 minSizeSpinBox->setValue( .1 );
506 maxSizeSpinBox->setValue( 2 );
508 methodComboBox->blockSignals(
false );
529 mGroupBoxSymmetric->setCollapsed(
true );
532 QMenu *advMenu =
new QMenu(
this );
534 advMenu->addAction( tr(
"Symbol Levels…" ),
this, SLOT(
showSymbolLevels() ) );
537 QAction *actionDdsLegend = advMenu->addAction( tr(
"Data-defined Size Legend…" ) );
539 connect( actionDdsLegend, &QAction::triggered,
this, &QgsGraduatedSymbolRendererWidget::dataDefinedSizeLegend );
542 btnAdvanced->setMenu( advMenu );
544 mHistogramWidget->setLayer(
mLayer );
545 mHistogramWidget->setRenderer( mRenderer.get() );
549 mExpressionWidget->registerExpressionContextGenerator(
this );
552 void QgsGraduatedSymbolRendererWidget::mSizeUnitWidget_changed()
554 if ( !mGraduatedSymbol )
return;
555 mGraduatedSymbol->setOutputUnit( mSizeUnitWidget->unit() );
556 mGraduatedSymbol->setMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
558 mRenderer->updateSymbols( mGraduatedSymbol.get() );
569 return mRenderer.get();
618 spinSymmetryPointForOtherMethods->setShowClearButton(
false );
621 if ( cboGraduatedMode->findData( mRenderer->mode() ) >= 0 )
623 cboGraduatedMode->setCurrentIndex( cboGraduatedMode->findData( mRenderer->mode() ) );
633 mGroupBoxSymmetric->setVisible(
true );
634 cbxAstride->setVisible(
true );
635 cboSymmetryPointForPretty->setVisible(
false );
636 spinSymmetryPointForOtherMethods->setVisible(
true );
637 spinSymmetryPointForOtherMethods->setValue( mRenderer->symmetryPoint() );
643 mGroupBoxSymmetric->setVisible(
true );
644 cbxAstride->setVisible(
true );
645 spinSymmetryPointForOtherMethods->setVisible(
false );
646 cboSymmetryPointForPretty->setVisible(
true );
647 cboSymmetryPointForPretty->clear();
648 cboSymmetryPointForPretty->addItems( mRenderer->listForCboPrettyBreaks() );
650 cboSymmetryPointForPretty->setCurrentText( QString::number( mRenderer->symmetryPoint(),
'f', 2 ) );
658 mGroupBoxSymmetric->setVisible(
false );
659 cbxAstride->setVisible(
false );
660 cboSymmetryPointForPretty->setVisible(
false );
661 spinSymmetryPointForOtherMethods->setVisible(
false );
662 spinSymmetryPointForOtherMethods->setValue( mRenderer->symmetryPoint() );
667 if ( mRenderer->useSymmetricMode() )
669 mGroupBoxSymmetric->setChecked(
true );
670 spinSymmetryPointForOtherMethods->setEnabled(
true );
671 cbxAstride->setEnabled(
true );
672 cboSymmetryPointForPretty->setEnabled(
true );
676 mGroupBoxSymmetric->setChecked(
false );
677 spinSymmetryPointForOtherMethods->setEnabled(
false );
678 cbxAstride->setEnabled(
false );
679 cboSymmetryPointForPretty->setEnabled(
false );
682 if ( mRenderer->astride() )
683 cbxAstride->setChecked(
true );
685 cbxAstride->setChecked(
false );
688 int nclasses = mRenderer->ranges().count();
689 if ( nclasses && updateCount )
690 spinGraduatedClasses->setValue( mRenderer->ranges().count() );
693 QString attrName = mRenderer->classAttribute();
694 mExpressionWidget->setField( attrName );
695 mHistogramWidget->setSourceFieldExp( attrName );
698 if ( mRenderer->sourceSymbol() )
700 mGraduatedSymbol.reset( mRenderer->sourceSymbol()->clone() );
704 mModel->setRenderer( mRenderer.get() );
705 viewGraduated->setModel( mModel );
707 if ( mGraduatedSymbol )
709 mSizeUnitWidget->blockSignals(
true );
710 mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() );
711 mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() );
712 mSizeUnitWidget->blockSignals(
false );
716 methodComboBox->blockSignals(
true );
719 methodComboBox->setCurrentIndex( 0 );
720 if ( mRenderer->sourceColorRamp() )
722 btnColorRamp->setColorRamp( mRenderer->sourceColorRamp() );
727 methodComboBox->setCurrentIndex( 1 );
728 if ( !mRenderer->ranges().isEmpty() )
730 minSizeSpinBox->setValue( mRenderer->minSymbolSize() );
731 maxSizeSpinBox->setValue( mRenderer->maxSymbolSize() );
734 toggleMethodWidgets( methodComboBox->currentIndex() );
735 methodComboBox->blockSignals(
false );
738 txtLegendFormat->setText( labelFormat.
format() );
739 spinPrecision->setValue( labelFormat.
precision() );
742 viewGraduated->resizeColumnToContents( 0 );
743 viewGraduated->resizeColumnToContents( 1 );
744 viewGraduated->resizeColumnToContents( 2 );
746 mHistogramWidget->refresh();
754 mRenderer->setClassAttribute( field );
757 void QgsGraduatedSymbolRendererWidget::methodComboBox_currentIndexChanged(
int idx )
759 toggleMethodWidgets( idx );
767 QMessageBox::critical(
this, tr(
"Select Method" ), tr(
"No color ramp defined." ) );
770 mRenderer->setSourceColorRamp( ramp );
775 lblColorRamp->setVisible(
false );
776 btnColorRamp->setVisible(
false );
777 lblSize->setVisible(
true );
778 minSizeSpinBox->setVisible(
true );
779 lblSize->setVisible(
true );
780 maxSizeSpinBox->setVisible(
true );
781 mSizeUnitWidget->setVisible(
true );
788 void QgsGraduatedSymbolRendererWidget::toggleMethodWidgets(
int idx )
792 lblColorRamp->setVisible(
true );
793 btnColorRamp->setVisible(
true );
794 lblSize->setVisible(
false );
795 minSizeSpinBox->setVisible(
false );
796 lblSizeTo->setVisible(
false );
797 maxSizeSpinBox->setVisible(
false );
798 mSizeUnitWidget->setVisible(
false );
802 lblColorRamp->setVisible(
false );
803 btnColorRamp->setVisible(
false );
804 lblSize->setVisible(
true );
805 minSizeSpinBox->setVisible(
true );
806 lblSizeTo->setVisible(
true );
807 maxSizeSpinBox->setVisible(
true );
808 mSizeUnitWidget->setVisible(
true );
817 mModel->updateSymbology( reset );
820 spinGraduatedClasses->setValue( mRenderer->ranges().count() );
826 void QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector(
QgsPanelWidget *container )
835 void QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget()
845 mSizeUnitWidget->blockSignals(
true );
846 mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() );
847 mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() );
848 mSizeUnitWidget->blockSignals(
false );
850 QItemSelectionModel *m = viewGraduated->selectionModel();
851 QModelIndexList selectedIndexes = m->selectedRows( 1 );
852 if ( m && !selectedIndexes.isEmpty() )
854 Q_FOREACH (
const QModelIndex &idx, selectedIndexes )
858 int rangeIdx = idx.row();
859 QgsSymbol *newRangeSymbol = mGraduatedSymbol->clone();
860 if ( selectedIndexes.count() > 1 )
863 newRangeSymbol->
setColor( mRenderer->ranges().at( rangeIdx ).symbol()->color() );
865 mRenderer->updateRangeSymbol( rangeIdx, newRangeSymbol );
871 mRenderer->updateSymbols( mGraduatedSymbol.get() );
881 QString attrName = mExpressionWidget->currentField();
882 int nclasses = spinGraduatedClasses->value();
884 std::unique_ptr<QgsColorRamp> ramp( btnColorRamp->colorRamp() );
887 QMessageBox::critical(
this, tr(
"Apply Classification" ), tr(
"No color ramp defined." ) );
892 bool useSymmetricMode =
false;
893 bool astride =
false;
898 spinSymmetryPointForOtherMethods->setMinimum( minimum );
899 spinSymmetryPointForOtherMethods->setMaximum( maximum );
900 spinSymmetryPointForOtherMethods->setDecimals( spinPrecision->value() );
902 double symmetryPoint = spinSymmetryPointForOtherMethods->value();
912 if ( spinSymmetryPointForOtherMethods->value() < ( minimum + ( maximum - minimum ) / 100. ) || spinSymmetryPointForOtherMethods->value() > ( maximum - ( maximum - minimum ) / 100. ) )
913 spinSymmetryPointForOtherMethods->setValue( minimum + ( maximum - minimum ) / 2. );
915 if ( mGroupBoxSymmetric->isChecked() )
917 useSymmetricMode =
true;
918 symmetryPoint = spinSymmetryPointForOtherMethods->value();
919 astride = cbxAstride->isChecked();
935 if ( spinSymmetryPointForOtherMethods->value() < ( minimum + ( maximum - minimum ) / 100. ) || spinSymmetryPointForOtherMethods->value() > ( maximum - ( maximum - minimum ) / 100. ) )
936 spinSymmetryPointForOtherMethods->setValue( minimum + ( maximum - minimum ) / 2. );
938 if ( mGroupBoxSymmetric->isChecked() )
940 useSymmetricMode =
true;
941 symmetryPoint = spinSymmetryPointForOtherMethods->value();
942 astride = cbxAstride->isChecked();
950 if ( mGroupBoxSymmetric->isChecked() )
952 useSymmetricMode =
true;
953 astride = cbxAstride->isChecked();
954 symmetryPoint = cboSymmetryPointForPretty->currentText().toDouble();
972 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 ) )
976 mRenderer->setClassAttribute( attrName );
977 mRenderer->setMode( mode );
978 mRenderer->setUseSymmetricMode( useSymmetricMode );
979 mRenderer->setSymmetryPoint( symmetryPoint );
980 mRenderer->setAstride( astride );
982 if ( methodComboBox->currentIndex() == 0 )
986 QMessageBox::critical(
this, tr(
"Apply Classification" ), tr(
"No color ramp defined." ) );
989 mRenderer->setSourceColorRamp( ramp.release() );
993 mRenderer->setSourceColorRamp(
nullptr );
996 QApplication::setOverrideCursor( Qt::WaitCursor );
998 mRenderer->updateClasses(
mLayer, mode, nclasses, useSymmetricMode, symmetryPoint, astride );
1000 if ( methodComboBox->currentIndex() == 1 )
1001 mRenderer->setSymbolSizes( minSizeSpinBox->value(), maxSizeSpinBox->value() );
1003 mRenderer->calculateLabelPrecision();
1004 QApplication::restoreOverrideCursor();
1012 std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() );
1016 mRenderer->updateColorRamp( ramp.release() );
1017 mRenderer->updateSymbols( mGraduatedSymbol.get() );
1023 mRenderer->setSymbolSizes( minSizeSpinBox->value(), maxSizeSpinBox->value() );
1024 mRenderer->updateSymbols( mGraduatedSymbol.get() );
1031 std::unique_ptr< QgsSymbol > newSymbol( mGraduatedSymbol->clone() );
1045 if ( !dlg.exec() || !newSymbol )
1050 mGraduatedSymbol = std::move( newSymbol );
1058 if ( !mGraduatedSymbol )
1062 btnChangeGraduatedSymbol->setIcon( icon );
1066 int QgsRendererPropertiesDialog::currentRangeRow()
1068 QModelIndex idx = viewGraduated->selectionModel()->currentIndex();
1069 if ( !idx.isValid() )
1078 QModelIndexList selectedRows = viewGraduated->selectionModel()->selectedRows();
1080 Q_FOREACH (
const QModelIndex &r, selectedRows )
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();
1125 std::unique_ptr< QgsSymbol > newSymbol( mRenderer->ranges()[rangeIdx].symbol()->clone() );
1127 if ( panel && panel->dockMode() )
1141 if ( !dlg.exec() || !newSymbol )
1146 mGraduatedSymbol = std::move( newSymbol );
1158 int decimalPlaces = mRenderer->labelFormat().precision() + 2;
1159 if ( decimalPlaces < 0 ) decimalPlaces = 0;
1163 if ( dialog.exec() == QDialog::Accepted )
1172 mRenderer->updateRangeUpperValue( rangeIdx, upperValue );
1173 mRenderer->updateRangeLowerValue( rangeIdx, lowerValue );
1176 if ( cbxLinkBoundaries->isChecked() )
1180 mRenderer->updateRangeUpperValue( rangeIdx - 1, lowerValue );
1183 if ( rangeIdx < mRenderer->ranges().size() - 1 )
1185 mRenderer->updateRangeLowerValue( rangeIdx + 1, upperValue );
1189 mHistogramWidget->refresh();
1195 mModel->addClass( mGraduatedSymbol.get() );
1196 mHistogramWidget->refresh();
1202 mModel->deleteRows( classIndexes );
1203 mHistogramWidget->refresh();
1208 mModel->removeAllRows();
1209 mHistogramWidget->refresh();
1215 bool ordered =
true;
1216 for (
int i = 1; i < ranges.size(); ++i )
1218 if ( ranges[i] < ranges[i - 1] )
1235 int result = QMessageBox::warning(
1237 tr(
"Link Class Boundaries" ),
1238 tr(
"Rows will be reordered before linking boundaries. Continue?" ),
1239 QMessageBox::Ok | QMessageBox::Cancel );
1240 if ( result != QMessageBox::Ok )
1242 cbxLinkBoundaries->setChecked(
false );
1245 mRenderer->sortByValue();
1249 for (
int i = 1; i < mRenderer->ranges().size(); ++i )
1251 mRenderer->updateRangeLowerValue( i, mRenderer->ranges()[i - 1].upperValue() );
1259 if ( item->column() == 2 )
1261 QString label = item->text();
1262 int idx = item->row();
1263 mRenderer->updateRangeLabel( idx, label );
1270 txtLegendFormat->text(),
1271 spinPrecision->value(),
1272 cbxTrimTrailingZeroes->isChecked() );
1273 mRenderer->setLabelFormat( labelFormat,
true );
1274 mModel->updateLabels();
1282 QItemSelectionModel *m = viewGraduated->selectionModel();
1283 QModelIndexList selectedIndexes = m->selectedRows( 1 );
1284 if ( m && !selectedIndexes.isEmpty() )
1287 QModelIndexList::const_iterator indexIt = selectedIndexes.constBegin();
1288 for ( ; indexIt != selectedIndexes.constEnd(); ++indexIt )
1290 QStringList list = m->model()->data( *indexIt ).toString().split(
' ' );
1291 if ( list.size() < 3 )
1307 selectedSymbols.append( s );
1316 int decimalPlaces = mRenderer->labelFormat().precision() + 2;
1317 if ( decimalPlaces < 0 )
1319 double precision = 1.0 / std::pow( 10, decimalPlaces );
1321 for ( QgsRangeList::const_iterator it = ranges.begin(); it != ranges.end(); ++it )
1325 return it->symbol();
1335 mModel->updateSymbology();
1337 mHistogramWidget->refresh();
1348 viewGraduated->selectionModel()->clear();
1351 cbxLinkBoundaries->setChecked(
false );
1368 if ( event->key() == Qt::Key_C &&
event->modifiers() == Qt::ControlModifier )
1370 mCopyBuffer.clear();
1373 else if ( event->key() == Qt::Key_V &&
event->modifiers() == Qt::ControlModifier )
1375 QgsRangeList::const_iterator rIt = mCopyBuffer.constBegin();
1376 for ( ; rIt != mCopyBuffer.constEnd(); ++rIt )
1378 mModel->addClass( *rIt );
1384 void QgsGraduatedSymbolRendererWidget::dataDefinedSizeLegend()
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value...
static QgsGraduatedSymbolRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
creates a QgsGraduatedSymbolRenderer from an existing renderer.
Abstract base class for all rendered symbols.
QString upperValue() const
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.
double lowerValue() const
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
QgsSymbol * symbol() const
A QProxyStyle subclass which correctly sets the base style to match the QGIS application style...
QString readEntry(const QString &scope, const QString &key, const QString &def=QString(), bool *ok=nullptr) const
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 upperValue() 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.
static QIcon symbolPreviewIcon(QgsSymbol *symbol, QSize size, int padding=0)
Returns an icon preview for a color ramp.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
points (e.g., for font sizes)
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
QVariant minimumValue(int index) const FINAL
Returns the minimum value for an attribute column or an invalid variant in case of error...
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
Single scope for storing variables and functions for use within a QgsExpressionContext.
const QgsRangeList & ranges() const
void moveClass(int from, int to)
Moves the category at index position from to index position to.
const QgsRendererRangeLabelFormat & labelFormat() const
Returns the label format used to generate default classification labels.
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)
bool updateRangeRenderState(int rangeIndex, bool render)
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
bool updateRangeLabel(int rangeIndex, const QString &label)
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.
QString lowerValue() const
void deleteClass(int idx)
void setColor(const QColor &color)
Sets the color for the symbol.