Skip to content
Permalink
Browse files

[styledock] Inline panels for renderers

  • Loading branch information
NathanW2 committed May 30, 2016
1 parent 4c1812a commit 47916d02694d007379d6819d216412317182cb8f
@@ -249,6 +249,7 @@
%Include symbology-ng/qgsvectorfieldsymbollayerwidget.sip
%Include symbology-ng/qgsvectorgradientcolorrampv2dialog.sip
%Include symbology-ng/qgsvectorrandomcolorrampv2dialog.sip
%Include symbology-ng/qgsrendererwidgetcontainer.sip

This comment has been minimized.

Copy link
@jef-n

jef-n Jun 3, 2016

Member

missing file in commit

This comment has been minimized.

Copy link
@NathanW2

NathanW2 Jun 3, 2016

Author Member

Thanks. Just noticed it too. Not sure what happened when I merged.

This comment has been minimized.

Copy link
@NathanW2

NathanW2 Jun 3, 2016

Author Member

Fixing it now


%Include effects/qgseffectdrawmodecombobox.sip
%Include effects/qgseffectstackpropertieswidget.sip
@@ -31,6 +31,7 @@ SET(QGIS_GUI_SRCS
symbology-ng/qgspointdisplacementrendererwidget.cpp
symbology-ng/qgsrendererv2propertiesdialog.cpp
symbology-ng/qgsrendererv2widget.cpp
symbology-ng/qgsrendererwidgetcontainer.cpp
symbology-ng/qgsrulebasedrendererv2widget.cpp
symbology-ng/qgssinglesymbolrendererv2widget.cpp
symbology-ng/qgssizescalewidget.cpp
@@ -474,6 +475,7 @@ SET(QGIS_GUI_MOC_HDRS
symbology-ng/qgspointdisplacementrendererwidget.h
symbology-ng/qgsrendererv2propertiesdialog.h
symbology-ng/qgsrendererv2widget.h
symbology-ng/qgsrendererwidgetcontainer.h
symbology-ng/qgsrulebasedrendererv2widget.h
symbology-ng/qgssinglesymbolrendererv2widget.h
symbology-ng/qgssizescalewidget.h
@@ -14,6 +14,7 @@
***************************************************************************/

#include "qgscategorizedsymbolrendererv2widget.h"
#include "qgsrendererwidgetcontainer.h"

#include "qgscategorizedsymbolrendererv2.h"

@@ -565,33 +566,16 @@ void QgsCategorizedSymbolRendererV2Widget::changeSelectedSymbols()

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

if ( m && !i.isEmpty() )
{
changeSelectedSymbols();
return;
}

// When there is no selection, change the base mCategorizedSymbol
QgsSymbolV2* newSymbol = mCategorizedSymbol->clone();

QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
dlg.setMapCanvas( mMapCanvas );
if ( !dlg.exec() || !newSymbol )
{
delete newSymbol;
return;
}

delete mCategorizedSymbol;
mCategorizedSymbol = newSymbol;
updateCategorizedSymbolIcon();

mRenderer->updateSymbols( mCategorizedSymbol );
emit widgetChanged();
QgsSymbolV2SelectorDialog* dlg = new QgsSymbolV2SelectorDialog( newSymbol, mStyle, mLayer, nullptr, true );
dlg->setMapCanvas( mMapCanvas );

QgsRendererWidgetContainer* container = new QgsRendererWidgetContainer( dlg, "Select Symbol", nullptr );
connect( dlg, SIGNAL( symbolModified() ), this, SLOT( updateSymbolsFromWidget() ) );
connect( container, SIGNAL( accepted() ), this, SLOT( cleanUpSymbolSelector() ) );
int page = mStackedWidget->addWidget( container );
mStackedWidget->setCurrentIndex( page );
emit panelOpened( true );
}

void QgsCategorizedSymbolRendererV2Widget::updateCategorizedSymbolIcon()
@@ -631,16 +615,15 @@ void QgsCategorizedSymbolRendererV2Widget::changeCategorySymbol()
symbol = QgsSymbolV2::defaultSymbol( mLayer->geometryType() );
}

QgsSymbolV2SelectorDialog dlg( symbol, mStyle, mLayer, this );
dlg.setMapCanvas( mMapCanvas );
if ( !dlg.exec() )
{
delete symbol;
return;
}
QgsSymbolV2SelectorDialog* dlg = new QgsSymbolV2SelectorDialog( symbol, mStyle, mLayer, nullptr, true );
dlg->setMapCanvas( mMapCanvas );

mRenderer->updateCategorySymbol( catIdx, symbol );
emit widgetChanged();
QgsRendererWidgetContainer* container = new QgsRendererWidgetContainer( dlg, "Select Symbol", nullptr );
connect( dlg, SIGNAL( symbolModified() ), this, SLOT( updateSymbolsFromWidget() ) );
connect( container, SIGNAL( accepted() ), this, SLOT( cleanUpSymbolSelector() ) );
int page = mStackedWidget->addWidget( container );
mStackedWidget->setCurrentIndex( page );
emit panelOpened( true );
}

static void _createCategories( QgsCategoryList& cats, QList<QVariant>& values, QgsSymbolV2* symbol )
@@ -1013,6 +996,56 @@ void QgsCategorizedSymbolRendererV2Widget::matchToSymbolsFromXml()
}
}

void QgsCategorizedSymbolRendererV2Widget::cleanUpSymbolSelector()
{
QgsRendererWidgetContainer* container = qobject_cast<QgsRendererWidgetContainer*>( mStackedWidget->currentWidget() );
if ( container )
{
mStackedWidget->removeWidget( container );
QgsSymbolV2SelectorDialog* dlg = qobject_cast<QgsSymbolV2SelectorDialog*>( container->widget() );
delete dlg->symbol();
container->deleteLater();
mStackedWidget->setCurrentIndex( 0 );
emit panelOpened( false );
}
}

void QgsCategorizedSymbolRendererV2Widget::updateSymbolsFromWidget()
{
QgsRendererWidgetContainer* container = qobject_cast<QgsRendererWidgetContainer*>( mStackedWidget->currentWidget() );
QgsSymbolV2SelectorDialog* dlg = qobject_cast<QgsSymbolV2SelectorDialog*>( container->widget() );
delete mCategorizedSymbol;
mCategorizedSymbol = dlg->symbol()->clone();

updateCategorizedSymbolIcon();

// When there is a slection, change the selected symbols alone
QItemSelectionModel* m = viewCategories->selectionModel();
QModelIndexList i = m->selectedRows();

if ( m && !i.isEmpty() )
{
QList<int> selectedCats = selectedCategories();

if ( !selectedCats.isEmpty() )
{
Q_FOREACH ( int idx, selectedCats )
{
QgsRendererCategoryV2 category = mRenderer->categories().value( idx );

QgsSymbolV2* newCatSymbol = mCategorizedSymbol->clone();
newCatSymbol->setColor( mRenderer->categories()[idx].symbol()->color() );
mRenderer->updateCategorySymbol( idx, newCatSymbol );
}
emit widgetChanged();
}
return;
}

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

void QgsCategorizedSymbolRendererV2Widget::keyPressEvent( QKeyEvent* event )
{
if ( !event )
@@ -129,6 +129,11 @@ class GUI_EXPORT QgsCategorizedSymbolRendererV2Widget : public QgsRendererV2Widg
*/
void matchToSymbolsFromXml();

private slots:

void cleanUpSymbolSelector();
void updateSymbolsFromWidget();

protected:

void updateUiFromRenderer();
@@ -13,6 +13,7 @@
* *
***************************************************************************/
#include "qgsgraduatedsymbolrendererv2widget.h"
#include "qgsrendererwidgetcontainer.h"

#include "qgssymbolv2.h"
#include "qgssymbollayerv2utils.h"
@@ -686,6 +687,58 @@ void QgsGraduatedSymbolRendererV2Widget::refreshRanges( bool reset )
emit widgetChanged();
}

void QgsGraduatedSymbolRendererV2Widget::cleanUpSymbolSelector()
{
QgsRendererWidgetContainer* container = qobject_cast<QgsRendererWidgetContainer*>( mStackedWidget->currentWidget() );
if ( container )
{
mStackedWidget->removeWidget( container );
QgsSymbolV2SelectorDialog* dlg = qobject_cast<QgsSymbolV2SelectorDialog*>( container->widget() );
delete dlg->symbol();
container->deleteLater();
mStackedWidget->setCurrentIndex( 0 );
emit panelOpened( false );
}
}

void QgsGraduatedSymbolRendererV2Widget::updateSymbolsFromWidget()
{
QgsRendererWidgetContainer* container = qobject_cast<QgsRendererWidgetContainer*>( mStackedWidget->currentWidget() );
QgsSymbolV2SelectorDialog* dlg = qobject_cast<QgsSymbolV2SelectorDialog*>( container->widget() );
delete mGraduatedSymbol;
mGraduatedSymbol = dlg->symbol()->clone();

mSizeUnitWidget->blockSignals( true );
mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() );
mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() );
mSizeUnitWidget->blockSignals( false );

QItemSelectionModel* m = viewGraduated->selectionModel();
QModelIndexList selectedIndexes = m->selectedRows( 1 );
if ( m && !selectedIndexes.isEmpty() )
{
Q_FOREACH ( const QModelIndex& idx, selectedIndexes )
{
if ( idx.isValid() )
{
int rangeIdx = idx.row();
QgsSymbolV2* newRangeSymbol = mGraduatedSymbol->clone();
newRangeSymbol->setColor( mRenderer->ranges()[rangeIdx].symbol()->color() );
mRenderer->updateRangeSymbol( rangeIdx, newRangeSymbol );
}
}
}
else
{
updateGraduatedSymbolIcon();
mRenderer->updateSymbols( mGraduatedSymbol );
}

refreshSymbolView();
emit widgetChanged();
}


void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
{
QString attrName = mExpressionWidget->currentField();
@@ -779,37 +832,16 @@ void QgsGraduatedSymbolRendererV2Widget::reapplySizes()

void QgsGraduatedSymbolRendererV2Widget::changeGraduatedSymbol()
{
// Change the selected symbols alone if anything is selected
QItemSelectionModel* m = viewGraduated->selectionModel();
QModelIndexList i = m->selectedRows();
if ( m && !i.isEmpty() )
{
changeSelectedSymbols();
return;
}

// Otherwise change the base mGraduatedSymbol
QgsSymbolV2* newSymbol = mGraduatedSymbol->clone();
QgsSymbolV2SelectorDialog* dlg = new QgsSymbolV2SelectorDialog( newSymbol, mStyle, mLayer, nullptr, true );
dlg->setMapCanvas( mMapCanvas );

QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
dlg.setMapCanvas( mMapCanvas );
if ( !dlg.exec() )
{
delete newSymbol;
return;
}

delete mGraduatedSymbol;
mGraduatedSymbol = newSymbol;

mSizeUnitWidget->blockSignals( true );
mSizeUnitWidget->setUnit( mGraduatedSymbol->outputUnit() );
mSizeUnitWidget->setMapUnitScale( mGraduatedSymbol->mapUnitScale() );
mSizeUnitWidget->blockSignals( false );

updateGraduatedSymbolIcon();
mRenderer->updateSymbols( mGraduatedSymbol );
refreshSymbolView();
QgsRendererWidgetContainer* container = new QgsRendererWidgetContainer( dlg, "Select Symbol", nullptr );
connect( dlg, SIGNAL( symbolModified() ), this, SLOT( updateSymbolsFromWidget() ) );
connect( container, SIGNAL( accepted() ), this, SLOT( cleanUpSymbolSelector() ) );
int page = mStackedWidget->addWidget( container );
mStackedWidget->setCurrentIndex( page );
emit panelOpened( true );
}

void QgsGraduatedSymbolRendererV2Widget::updateGraduatedSymbolIcon()
@@ -877,48 +909,20 @@ void QgsGraduatedSymbolRendererV2Widget::rangesClicked( const QModelIndex & idx

void QgsGraduatedSymbolRendererV2Widget::changeSelectedSymbols()
{
QItemSelectionModel* m = viewGraduated->selectionModel();
QModelIndexList selectedIndexes = m->selectedRows( 1 );
if ( m && !selectedIndexes.isEmpty() )
{
QgsSymbolV2* newSymbol = mGraduatedSymbol->clone();
QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
dlg.setMapCanvas( mMapCanvas );
if ( !dlg.exec() )
{
delete newSymbol;
return;
}

Q_FOREACH ( const QModelIndex& idx, selectedIndexes )
{
if ( idx.isValid() )
{
int rangeIdx = idx.row();
QgsSymbolV2* newRangeSymbol = newSymbol->clone();
newRangeSymbol->setColor( mRenderer->ranges()[rangeIdx].symbol()->color() );
mRenderer->updateRangeSymbol( rangeIdx, newRangeSymbol );
}
}
}
refreshSymbolView();
}

void QgsGraduatedSymbolRendererV2Widget::changeRangeSymbol( int rangeIdx )
{
QgsSymbolV2* newSymbol = mRenderer->ranges()[rangeIdx].symbol()->clone();

QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
dlg.setMapCanvas( mMapCanvas );
if ( !dlg.exec() )
{
delete newSymbol;
return;
}

mRenderer->updateRangeSymbol( rangeIdx, newSymbol );
mHistogramWidget->refresh();
emit widgetChanged();
QgsSymbolV2SelectorDialog* dlg = new QgsSymbolV2SelectorDialog( newSymbol, mStyle, mLayer, nullptr, true );
dlg->setMapCanvas( mMapCanvas );

QgsRendererWidgetContainer* container = new QgsRendererWidgetContainer( dlg, "Select Symbol", nullptr );
connect( dlg, SIGNAL( symbolModified() ), this, SLOT( updateSymbolsFromWidget() ) );
connect( container, SIGNAL( accepted() ), this, SLOT( cleanUpSymbolSelector() ) );
int page = mStackedWidget->addWidget( container );
mStackedWidget->setCurrentIndex( page );
emit panelOpened( true );
}

void QgsGraduatedSymbolRendererV2Widget::changeRange( int rangeIdx )
@@ -118,6 +118,11 @@ class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget
void on_methodComboBox_currentIndexChanged( int );
void refreshRanges( bool reset = false );

private slots:

void cleanUpSymbolSelector();
void updateSymbolsFromWidget();

protected:
void updateUiFromRenderer( bool updateCount = true );
void connectUpdateHandlers();
@@ -270,6 +270,7 @@ void QgsRendererV2PropertiesDialog::rendererChanged()
connect( mActiveWidget, SIGNAL( layerVariablesChanged() ), this, SIGNAL( layerVariablesChanged() ) );
}
connect( mActiveWidget, SIGNAL( widgetChanged() ), this, SIGNAL( widgetChanged() ) );
connect( mActiveWidget, SIGNAL( panelOpened(bool)), this, SLOT( updateUIState(bool) ));
}
else
{
@@ -331,6 +332,12 @@ void QgsRendererV2PropertiesDialog::changeOrderBy( const QgsFeatureRequest::Orde
checkboxEnableOrderBy->setChecked( orderByEnabled );
}

void QgsRendererV2PropertiesDialog::updateUIState(bool hidden)
{
groupBox->setHidden( hidden );
cboRenderers->setHidden( hidden );
}


void QgsRendererV2PropertiesDialog::keyPressEvent( QKeyEvent * e )
{
@@ -32,6 +32,7 @@ class QgsPaintEffect;
class QgsRendererV2Widget;
class QgsMapCanvas;


class GUI_EXPORT QgsRendererV2PropertiesDialog : public QDialog, private Ui::QgsRendererV2PropsDialogBase
{
Q_OBJECT
@@ -76,6 +77,8 @@ class GUI_EXPORT QgsRendererV2PropertiesDialog : public QDialog, private Ui::Qgs

void changeOrderBy( const QgsFeatureRequest::OrderBy& orderBy, bool orderByEnabled );

void updateUIState( bool hidden );

protected:
/**
* Connect the given slot to the value changed event for the set of widgets

0 comments on commit 47916d0

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