File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -739,6 +739,9 @@ void QgsCategorizedSymbolRendererWidget::addCategories()
739
739
{
740
740
QgsCategoryList prevCats = mRenderer ->categories ();
741
741
keepExistingColors = !prevCats.isEmpty ();
742
+ QgsRandomColorRamp randomColors;
743
+ if ( keepExistingColors && btnColorRamp->isRandomColorRamp () )
744
+ randomColors.setTotalColorCount ( cats.size () );
742
745
for ( int i = 0 ; i < cats.size (); ++i )
743
746
{
744
747
bool contains = false ;
@@ -753,7 +756,14 @@ void QgsCategorizedSymbolRendererWidget::addCategories()
753
756
}
754
757
755
758
if ( !contains )
759
+ {
760
+ if ( keepExistingColors && btnColorRamp->isRandomColorRamp () )
761
+ {
762
+ // insure that append symbols have random colors
763
+ cats.at ( i ).symbol ()->setColor ( randomColors.color ( i ) );
764
+ }
756
765
prevCats.append ( cats.at ( i ) );
766
+ }
757
767
}
758
768
cats = prevCats;
759
769
}
You can’t perform that action at this time.
0 commit comments