Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Don't allow null entry to be merged
- Loading branch information
|
@@ -1155,12 +1155,27 @@ void QgsCategorizedSymbolRendererWidget::dataDefinedSizeLegend() |
|
|
|
|
|
void QgsCategorizedSymbolRendererWidget::mergeClicked() |
|
|
{ |
|
|
QList<int> categoryIndexes = selectedCategories(); |
|
|
const QgsCategoryList &categories = mRenderer->categories(); |
|
|
|
|
|
QList<int> selectedCategoryIndexes = selectedCategories(); |
|
|
QList< int > categoryIndexes; |
|
|
|
|
|
// filter out "" entry |
|
|
for ( int i : selectedCategoryIndexes ) |
|
|
{ |
|
|
QVariant v = categories.at( i ).value(); |
|
|
|
|
|
if ( !v.isValid() || v == "" ) |
|
|
{ |
|
|
continue; |
|
|
} |
|
|
|
|
|
categoryIndexes.append( i ); |
|
|
} |
|
|
|
|
|
if ( categoryIndexes.count() < 2 ) |
|
|
return; |
|
|
|
|
|
const QgsCategoryList &categories = mRenderer->categories(); |
|
|
|
|
|
QStringList labels; |
|
|
QVariantList values; |
|
|
values.reserve( categoryIndexes.count() ); |
|
|
|
@@ -196,6 +196,8 @@ void TestQgsCategorizedRendererWidget::merge() |
|
|
// merging categories which are already lists |
|
|
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 0, 0 ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows ); |
|
|
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 1, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows ); |
|
|
//"" entry should be ignored |
|
|
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 2, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows ); |
|
|
widget->mergeClicked(); |
|
|
|
|
|
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 2 ); |
|
|