Skip to content
Permalink
Browse files

Merge branch 'symbolselectorHelpShow' of https://github.com/DelazJ/QGIS

… into DelazJ-symbolselectorHelpShow
  • Loading branch information
elpaso committed May 8, 2018
2 parents ba04dea + 1c34339 commit 85d60f2bac4f5e7b7c5cba635f6eb203e18fa83a
@@ -96,20 +96,24 @@ from the XML file with a matching name.

int currentCategoryRow();
%Docstring
return row index for the currently selected category (-1 if on no selection)
Returns row index for the currently selected category (-1 if on no selection)
%End

QList<int> selectedCategories();
%Docstring
return a list of indexes for the categories unders selection
Returns a list of indexes for the categories under selection
%End

void changeSelectedSymbols();
%Docstring
change the selected symbols alone for the change button, if there is a selection
Changes the selected symbols alone for the change button, if there is a selection
%End

void changeCategorySymbol();
void applyChangeToSymbol();
%Docstring
Applies current symbol to selected categories, or to all categories if none is selected
%End

virtual QList<QgsSymbol *> selectedSymbols();

@@ -70,14 +70,18 @@ Toggle the link between classes boundaries

QList<int> selectedClasses();
%Docstring
return a list of indexes for the classes under selection
Returns a list of indexes for the classes under selection
%End
QgsRangeList selectedRanges();

void changeRangeSymbol( int rangeIdx );
void changeRange( int rangeIdx );

void changeSelectedSymbols();
void applyChangeToSymbol();
%Docstring
Applies current symbol to selected ranges, or to all ranges if none is selected
%End

virtual QList<QgsSymbol *> selectedSymbols();

@@ -6367,6 +6367,7 @@ skiped:skipped
skiping:skipping
slashs:slashes
slaugterhouses:slaughterhouses
slection:selection
slighly:slightly
sligth:slight
sligthly:slightly
@@ -544,17 +544,37 @@ void QgsCategorizedSymbolRendererWidget::changeSelectedSymbols()

void QgsCategorizedSymbolRendererWidget::changeCategorizedSymbol()
{
QgsSymbol *newSymbol = mCategorizedSymbol->clone();
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol, mStyle, mLayer, nullptr );
dlg->setContext( mContext );
QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
std::unique_ptr<QgsSymbol> newSymbol( mCategorizedSymbol->clone() );
if ( panel && panel->dockMode() )
{
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol.get(), mStyle, mLayer, panel );
dlg->setContext( mContext );
connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsCategorizedSymbolRendererWidget::cleanUpSymbolSelector );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsCategorizedSymbolRendererWidget::updateCategorizedSymbolIcon );
openPanel( dlg );
}
else
{
QgsSymbolSelectorDialog dlg( newSymbol.get(), mStyle, mLayer, panel );
dlg.setContext( mContext );
if ( !dlg.exec() || !newSymbol )
{
return;
}

connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsCategorizedSymbolRendererWidget::cleanUpSymbolSelector );
openPanel( dlg );
mCategorizedSymbol = std::move( newSymbol );
updateCategorizedSymbolIcon();
applyChangeToSymbol();
}
}

void QgsCategorizedSymbolRendererWidget::updateCategorizedSymbolIcon()
{
if ( !mCategorizedSymbol )
return;

QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mCategorizedSymbol.get(), btnChangeCategorizedSymbol->iconSize() );
btnChangeCategorizedSymbol->setIcon( icon );
}
@@ -579,21 +599,38 @@ void QgsCategorizedSymbolRendererWidget::changeCategorySymbol()
{
QgsRendererCategory category = mRenderer->categories().value( currentCategoryRow() );

QgsSymbol *symbol = category.symbol();
if ( symbol )
std::unique_ptr< QgsSymbol > symbol;

if ( category.symbol() )
{
symbol = symbol->clone();
symbol.reset( category.symbol()->clone() );
}
else
{
symbol = QgsSymbol::defaultSymbol( mLayer->geometryType() );
symbol.reset( QgsSymbol::defaultSymbol( mLayer->geometryType() ) );
}

QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
if ( panel && panel->dockMode() )
{
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( symbol.get(), mStyle, mLayer, panel );
dlg->setContext( mContext );
connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsCategorizedSymbolRendererWidget::cleanUpSymbolSelector );
openPanel( dlg );
}
else
{
QgsSymbolSelectorDialog dlg( symbol.get(), mStyle, mLayer, panel );
dlg.setContext( mContext );
if ( !dlg.exec() || !symbol )
{
return;
}

QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( symbol, mStyle, mLayer, nullptr );
dlg->setContext( mContext );
connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsCategorizedSymbolRendererWidget::cleanUpSymbolSelector );
openPanel( dlg );
mCategorizedSymbol = std::move( symbol );
applyChangeToSymbol();
}
}

static void _createCategories( QgsCategoryList &cats, QList<QVariant> &values, QgsSymbol *symbol )
@@ -950,9 +987,12 @@ void QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget()
QgsSymbolSelectorWidget *dlg = qobject_cast<QgsSymbolSelectorWidget *>( sender() );
mCategorizedSymbol.reset( dlg->symbol()->clone() );

updateCategorizedSymbolIcon();
applyChangeToSymbol();
}

// When there is a slection, change the selected symbols alone
void QgsCategorizedSymbolRendererWidget::applyChangeToSymbol()
{
// When there is a selection, change the selected symbols only
QItemSelectionModel *m = viewCategories->selectionModel();
QModelIndexList i = m->selectedRows();

@@ -974,10 +1014,12 @@ void QgsCategorizedSymbolRendererWidget::updateSymbolsFromWidget()
}
emit widgetChanged();
}
return;
}
else
{
mRenderer->updateSymbols( mCategorizedSymbol.get() );
}

mRenderer->updateSymbols( mCategorizedSymbol.get() );
emit widgetChanged();
}

@@ -163,16 +163,18 @@ class GUI_EXPORT QgsCategorizedSymbolRendererWidget : public QgsRendererWidget,
// Called by virtual refreshSymbolView()
void populateCategories();

//! return row index for the currently selected category (-1 if on no selection)
//! Returns row index for the currently selected category (-1 if on no selection)
int currentCategoryRow();

//! return a list of indexes for the categories unders selection
//! Returns a list of indexes for the categories under selection
QList<int> selectedCategories();

//! change the selected symbols alone for the change button, if there is a selection
//! Changes the selected symbols alone for the change button, if there is a selection
void changeSelectedSymbols();

void changeCategorySymbol();
//! Applies current symbol to selected categories, or to all categories if none is selected
void applyChangeToSymbol();

QList<QgsSymbol *> selectedSymbols() override;
QgsCategoryList selectedCategoryList();
@@ -754,6 +754,11 @@ void QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget()
QgsSymbolSelectorWidget *dlg = qobject_cast<QgsSymbolSelectorWidget *>( sender() );
mGraduatedSymbol.reset( dlg->symbol()->clone() );

applyChangeToSymbol();
}

void QgsGraduatedSymbolRendererWidget::applyChangeToSymbol()
{
mSizeUnitWidget->blockSignals( true );
mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() );
mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() );
@@ -780,7 +785,6 @@ void QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget()
}
else
{
updateGraduatedSymbolIcon();
mRenderer->updateSymbols( mGraduatedSymbol.get() );
}

@@ -874,13 +878,30 @@ void QgsGraduatedSymbolRendererWidget::reapplySizes()

void QgsGraduatedSymbolRendererWidget::changeGraduatedSymbol()
{
QgsSymbol *newSymbol = mGraduatedSymbol->clone();
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol, mStyle, mLayer, nullptr );
dlg->setContext( mContext );
std::unique_ptr< QgsSymbol > newSymbol( mGraduatedSymbol->clone() );
QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
if ( panel && panel->dockMode() )
{
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol.get(), mStyle, mLayer, panel );
dlg->setContext( mContext );

connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::updateGraduatedSymbolIcon );
panel->openPanel( dlg );
}
else
{
QgsSymbolSelectorDialog dlg( newSymbol.get(), mStyle, mLayer, panel );
if ( !dlg.exec() || !newSymbol )
{
return;
}

connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector );
openPanel( dlg );
mGraduatedSymbol = std::move( newSymbol );
updateGraduatedSymbolIcon();
applyChangeToSymbol();
}
}

void QgsGraduatedSymbolRendererWidget::updateGraduatedSymbolIcon()
@@ -952,13 +973,28 @@ void QgsGraduatedSymbolRendererWidget::changeSelectedSymbols()

void QgsGraduatedSymbolRendererWidget::changeRangeSymbol( int rangeIdx )
{
QgsSymbol *newSymbol = mRenderer->ranges()[rangeIdx].symbol()->clone();
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol, mStyle, mLayer, nullptr );
dlg->setContext( mContext );
std::unique_ptr< QgsSymbol > newSymbol( mRenderer->ranges()[rangeIdx].symbol()->clone() );
QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
if ( panel && panel->dockMode() )
{
QgsSymbolSelectorWidget *dlg = new QgsSymbolSelectorWidget( newSymbol.get(), mStyle, mLayer, panel );
dlg->setContext( mContext );
connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector );
openPanel( dlg );
}
else
{
QgsSymbolSelectorDialog dlg( newSymbol.get(), mStyle, mLayer, panel );
dlg.setContext( mContext );
if ( !dlg.exec() || !newSymbol )
{
return;
}

connect( dlg, &QgsPanelWidget::widgetChanged, this, &QgsGraduatedSymbolRendererWidget::updateSymbolsFromWidget );
connect( dlg, &QgsPanelWidget::panelAccepted, this, &QgsGraduatedSymbolRendererWidget::cleanUpSymbolSelector );
openPanel( dlg );
mGraduatedSymbol = std::move( newSymbol );
applyChangeToSymbol();
}
}

void QgsGraduatedSymbolRendererWidget::changeRange( int rangeIdx )
@@ -138,14 +138,16 @@ class GUI_EXPORT QgsGraduatedSymbolRendererWidget : public QgsRendererWidget, pr

void updateGraduatedSymbolIcon();

//! return a list of indexes for the classes under selection
//! Returns a list of indexes for the classes under selection
QList<int> selectedClasses();
QgsRangeList selectedRanges();

void changeRangeSymbol( int rangeIdx );
void changeRange( int rangeIdx );

void changeSelectedSymbols();
//! Applies current symbol to selected ranges, or to all ranges if none is selected
void applyChangeToSymbol();

QList<QgsSymbol *> selectedSymbols() override;
QgsSymbol *findSymbolForRange( double lowerBound, double upperBound, const QgsRangeList &ranges ) const;

0 comments on commit 85d60f2

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