Skip to content
Permalink
Browse files

Rename some methods for consistency/clarity

  • Loading branch information
nyalldawson committed Jan 7, 2019
1 parent a6849ca commit 1051f9b48d02a0b64ca631bba359c65a54bd233d
@@ -557,9 +557,9 @@ QgsCategorizedSymbolRendererWidget::QgsCategorizedSymbolRendererWidget( QgsVecto
mExpressionWidget->registerExpressionContextGenerator( this );

mMergeCategoriesAction = new QAction( tr( "Merge Categories" ), this );
connect( mMergeCategoriesAction, &QAction::triggered, this, &QgsCategorizedSymbolRendererWidget::mergeClicked );
connect( mMergeCategoriesAction, &QAction::triggered, this, &QgsCategorizedSymbolRendererWidget::mergeSelectedCategories );
mUnmergeCategoriesAction = new QAction( tr( "Unmerge Categories" ), this );
connect( mUnmergeCategoriesAction, &QAction::triggered, this, &QgsCategorizedSymbolRendererWidget::unmerge );
connect( mUnmergeCategoriesAction, &QAction::triggered, this, &QgsCategorizedSymbolRendererWidget::unmergeSelectedCategories );
}

QgsCategorizedSymbolRendererWidget::~QgsCategorizedSymbolRendererWidget()
@@ -1163,7 +1163,7 @@ void QgsCategorizedSymbolRendererWidget::dataDefinedSizeLegend()
}
}

void QgsCategorizedSymbolRendererWidget::mergeClicked()
void QgsCategorizedSymbolRendererWidget::mergeSelectedCategories()
{
const QgsCategoryList &categories = mRenderer->categories();

@@ -1214,7 +1214,7 @@ void QgsCategorizedSymbolRendererWidget::mergeClicked()
emit widgetChanged();
}

void QgsCategorizedSymbolRendererWidget::unmerge()
void QgsCategorizedSymbolRendererWidget::unmergeSelectedCategories()
{
const QList<int> categoryIndexes = selectedCategories();
if ( categoryIndexes.isEmpty() )
@@ -153,8 +153,21 @@ class GUI_EXPORT QgsCategorizedSymbolRendererWidget : public QgsRendererWidget,
void cleanUpSymbolSelector( QgsPanelWidget *container );
void updateSymbolsFromWidget();
void dataDefinedSizeLegend();
void mergeClicked();
void unmerge();

/**
* Merges all selected categories into a single multi-value category.
*
* \see unmergeSelectedCategories()
*/
void mergeSelectedCategories();

/**
* Unmerges all selected multi-value categories into a individual value categories.
*
* \see mergeSelectedCategories()
*/
void unmergeSelectedCategories();

void showContextMenu( QPoint p );

protected:
@@ -151,17 +151,17 @@ void TestQgsCategorizedRendererWidget::merge()
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 5 ).value().toString(), QString() );

// no selection, should have no effect
widget->mergeClicked();
widget->mergeSelectedCategories();
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 6 );

widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 1, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows );
// one selection, should have no effect
widget->mergeClicked();
widget->mergeSelectedCategories();
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 6 );

widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 3, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows );
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 4, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows );
widget->mergeClicked();
widget->mergeSelectedCategories();
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 4 );

QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "a" ) );
@@ -179,7 +179,7 @@ void TestQgsCategorizedRendererWidget::merge()
// selection should always "merge into" first selected item
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 2, 0 ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 0, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows );
widget->mergeClicked();
widget->mergeSelectedCategories();
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 3 );

QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toList().at( 0 ).toString(), QStringLiteral( "b" ) );
@@ -198,7 +198,7 @@ void TestQgsCategorizedRendererWidget::merge()
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();
widget->mergeSelectedCategories();

QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 2 );

@@ -214,15 +214,15 @@ void TestQgsCategorizedRendererWidget::merge()

widget->viewCategories->selectionModel()->clearSelection();
// unmerge
widget->unmerge();
widget->unmergeSelectedCategories();
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 2 );
// not a list
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 1, 0 ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
widget->unmerge();
widget->unmergeSelectedCategories();
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 2 );
// list
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 0, 0 ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
widget->unmerge();
widget->unmergeSelectedCategories();

QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 6 );
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "b" ) );
@@ -240,15 +240,15 @@ void TestQgsCategorizedRendererWidget::merge()

widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 2, 0 ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 3, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows );
widget->mergeClicked();
widget->mergeSelectedCategories();
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 3, 0 ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 4, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows );
widget->mergeClicked();
widget->mergeSelectedCategories();
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 );
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 2, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows );
widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 3, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows );
widget->unmerge();
widget->unmergeSelectedCategories();
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 6 );
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "b" ) );
QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toString(), QString() );

0 comments on commit 1051f9b

Please sign in to comment.
You can’t perform that action at this time.