Skip to content
Permalink
Browse files

[styledock] Swap rendererv2 widget back to qwidget

  • Loading branch information
NathanW2 committed Jun 6, 2016
1 parent 91cd68e commit ad5f970a2bf72e13cdad20a67c56e8e23f2f5247
@@ -430,8 +430,7 @@ QgsCategorizedSymbolRendererV2Widget::QgsCategorizedSymbolRendererV2Widget( QgsV
mOldClassificationAttribute = attrName;

// setup user interface
setupUi( mWidgetPage );
QMetaObject::connectSlotsByName( this );
setupUi( this );

mExpressionWidget->setLayer( mLayer );

@@ -575,7 +574,7 @@ void QgsCategorizedSymbolRendererV2Widget::changeCategorizedSymbol()
connect( dlg, SIGNAL( symbolModified() ), container, SLOT( emitWidgetChanged() ) );
connect( container, SIGNAL( widgetChanged( QgsRendererWidgetContainer* ) ), this, SLOT( updateSymbolsFromWidget( QgsRendererWidgetContainer* ) ) );
connect( container, SIGNAL( accepted( QgsRendererWidgetContainer* ) ), this, SLOT( cleanUpSymbolSelector( QgsRendererWidgetContainer* ) ) );
emit panelOpened( container );
emit showPanel( container );
}

void QgsCategorizedSymbolRendererV2Widget::updateCategorizedSymbolIcon()
@@ -621,7 +620,7 @@ void QgsCategorizedSymbolRendererV2Widget::changeCategorySymbol()
connect( dlg, SIGNAL( symbolModified() ), container, SLOT( emitWidgetChanged() ) );
connect( container, SIGNAL( widgetChanged( QgsRendererWidgetContainer* ) ), this, SLOT( updateSymbolsFromWidget( QgsRendererWidgetContainer* ) ) );
connect( container, SIGNAL( accepted( QgsRendererWidgetContainer* ) ), this, SLOT( cleanUpSymbolSelector( QgsRendererWidgetContainer* ) ) );
emit panelOpened( container );
emit showPanel( container );
}

static void _createCategories( QgsCategoryList& cats, QList<QVariant>& values, QgsSymbolV2* symbol )
@@ -1005,7 +1004,6 @@ void QgsCategorizedSymbolRendererV2Widget::cleanUpSymbolSelector( QgsRendererWid

void QgsCategorizedSymbolRendererV2Widget::updateSymbolsFromWidget( QgsRendererWidgetContainer* container )
{
QgsDebugMsg( "UPDATE SYMBOL!!!" );
QgsSymbolV2SelectorDialog* dlg = qobject_cast<QgsSymbolV2SelectorDialog*>( container->widget() );
delete mCategorizedSymbol;
mCategorizedSymbol = dlg->symbol()->clone();
@@ -433,8 +433,7 @@ QgsGraduatedSymbolRendererV2Widget::QgsGraduatedSymbolRendererV2Widget( QgsVecto
}

// setup user interface
setupUi( mWidgetPage );
QMetaObject::connectSlotsByName( this );
setupUi( this );

mModel = new QgsGraduatedSymbolRendererV2Model( this );

@@ -689,22 +688,17 @@ void QgsGraduatedSymbolRendererV2Widget::refreshRanges( bool reset )
emit widgetChanged();
}

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

void QgsGraduatedSymbolRendererV2Widget::updateSymbolsFromWidget()
void QgsGraduatedSymbolRendererV2Widget::updateSymbolsFromWidget( QgsRendererWidgetContainer *container )
{
QgsRendererWidgetContainer* container = qobject_cast<QgsRendererWidgetContainer*>( this->currentWidget() );
QgsSymbolV2SelectorDialog* dlg = qobject_cast<QgsSymbolV2SelectorDialog*>( container->widget() );
delete mGraduatedSymbol;
mGraduatedSymbol = dlg->symbol()->clone();
@@ -838,9 +832,10 @@ void QgsGraduatedSymbolRendererV2Widget::changeGraduatedSymbol()
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() ) );
emit panelOpened( container );
connect( dlg, SIGNAL( symbolModified() ), container, SLOT( emitWidgetChanged() ) );
connect( container, SIGNAL( widgetChanged( QgsRendererWidgetContainer* ) ), this, SLOT( updateSymbolsFromWidget( QgsRendererWidgetContainer* ) ) );
connect( container, SIGNAL( accepted( QgsRendererWidgetContainer* ) ), this, SLOT( cleanUpSymbolSelector( QgsRendererWidgetContainer* ) ) );
emit showPanel( container );
}

void QgsGraduatedSymbolRendererV2Widget::updateGraduatedSymbolIcon()
@@ -917,9 +912,10 @@ void QgsGraduatedSymbolRendererV2Widget::changeRangeSymbol( int rangeIdx )
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() ) );
emit panelOpened( container );
connect( dlg, SIGNAL( symbolModified() ), container, SLOT( emitWidgetChanged() ) );
connect( container, SIGNAL( widgetChanged( QgsRendererWidgetContainer* ) ), this, SLOT( updateSymbolsFromWidget( QgsRendererWidgetContainer* ) ) );
connect( container, SIGNAL( accepted( QgsRendererWidgetContainer* ) ), this, SLOT( cleanUpSymbolSelector( QgsRendererWidgetContainer* ) ) );
emit showPanel( container );
}

void QgsGraduatedSymbolRendererV2Widget::changeRange( int rangeIdx )
@@ -119,9 +119,8 @@ class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget
void refreshRanges( bool reset = false );

private slots:

void cleanUpSymbolSelector();
void updateSymbolsFromWidget();
void cleanUpSymbolSelector( QgsRendererWidgetContainer* container );
void updateSymbolsFromWidget( QgsRendererWidgetContainer *container );

protected:
void updateUiFromRenderer( bool updateCount = true );
@@ -73,12 +73,11 @@ QgsHeatmapRendererWidget::QgsHeatmapRendererWidget( QgsVectorLayer* layer, QgsSt
QLabel* label = new QLabel( tr( "The heatmap renderer only applies to point and multipoint layers. \n"
"'%1' is not a point layer and cannot be rendered as a heatmap." )
.arg( layer->name() ), this );
mWidgetPage->layout()->addWidget( label );
layout()->addWidget( label );
return;
}

setupUi( mWidgetPage );
QMetaObject::connectSlotsByName( this );
setupUi( this );

mRadiusUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::Pixel << QgsSymbolV2::MapUnit );
mWeightExpressionWidget->registerGetExpressionContextCallback( &_getExpressionContext, this );
@@ -46,12 +46,11 @@ QgsInvertedPolygonRendererWidget::QgsInvertedPolygonRendererWidget( QgsVectorLay
QLabel* label = new QLabel( tr( "The inverted polygon renderer only applies to polygon and multipolygon layers. \n"
"'%1' is not a polygon layer and then cannot be displayed" )
.arg( layer->name() ), this );
mWidgetPage->setLayout( layout );
this->setLayout( layout );
layout->addWidget( label );
return;
}
setupUi( mWidgetPage );
QMetaObject::connectSlotsByName( this );
setupUi( this );

// try to recognize the previous renderer
// (null renderer means "no previous renderer")
@@ -130,12 +129,12 @@ void QgsInvertedPolygonRendererWidget::on_mRendererComboBox_currentIndexChanged(
connect( mEmbeddedRendererWidget.data(), SIGNAL( widgetChanged() ), this, SIGNAL( widgetChanged() ) );
mEmbeddedRendererWidget->setMapCanvas( mMapCanvas );

if ( mWidgetPage->layout()->count() > 2 )
if ( layout()->count() > 2 )
{
// remove the current renderer widget
mWidgetPage->layout()->takeAt( 2 );
layout()->takeAt( 2 );
}
mWidgetPage->layout()->addWidget( mEmbeddedRendererWidget.data() );
layout()->addWidget( mEmbeddedRendererWidget.data() );
}
}

@@ -37,7 +37,7 @@ QgsNullSymbolRendererWidget::QgsNullSymbolRendererWidget( QgsVectorLayer* layer,
mRenderer = new QgsNullSymbolRenderer();
}

QGridLayout* layout = new QGridLayout( mWidgetPage );
QGridLayout* layout = new QGridLayout( this );
QLabel* label = new QLabel( tr( "No symbols will be rendered for features in this layer." ) );
layout->addWidget( label );
}
@@ -48,8 +48,7 @@ QgsPointDisplacementRendererWidget::QgsPointDisplacementRendererWidget( QgsVecto
setupBlankUi( layer->name() );
return;
}
setupUi( mWidgetPage );
QMetaObject::connectSlotsByName( this );
setupUi( this );

mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );

@@ -384,8 +383,7 @@ void QgsPointDisplacementRendererWidget::updateCenterIcon()
void QgsPointDisplacementRendererWidget::setupBlankUi( const QString& layerName )
{
QLabel* label = new QLabel( tr( "The point displacement renderer only applies to (single) point layers. \n'%1' is not a point layer and cannot be displayed by the point displacement renderer" ).arg( layerName ), this );
QVBoxLayout* layout = new QVBoxLayout;
QVBoxLayout* layout = new QVBoxLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 );
mWidgetPage->setLayout( layout );
mWidgetPage->layout()->addWidget( label );
layout->addWidget( label );
}
@@ -245,7 +245,7 @@ void QgsRendererV2PropertiesDialog::rendererChanged()
connect( mActiveWidget, SIGNAL( layerVariablesChanged() ), this, SIGNAL( layerVariablesChanged() ) );
}
connect( mActiveWidget, SIGNAL( widgetChanged() ), this, SIGNAL( widgetChanged() ) );
connect( mActiveWidget, SIGNAL( panelOpened( QgsRendererWidgetContainer* ) ), this, SLOT( showPanel( QgsRendererWidgetContainer* ) ) );
connect( mActiveWidget, SIGNAL( showPanel( QgsRendererWidgetContainer* ) ), this, SLOT( showPanel( QgsRendererWidgetContainer* ) ) );
}
else
{
@@ -25,14 +25,11 @@
#include <QMenu>

QgsRendererV2Widget::QgsRendererV2Widget( QgsVectorLayer* layer, QgsStyleV2* style )
: QStackedWidget()
: QWidget()
, mLayer( layer )
, mStyle( style )
, mMapCanvas( nullptr )
{
mWidgetPage = new QWidget();
this->addWidget( mWidgetPage );

contextMenu = new QMenu( tr( "Renderer Options" ), this );

mCopyAction = contextMenu->addAction( tr( "Copy" ), this, SLOT( copy() ) );
@@ -39,7 +39,7 @@ class QgsRendererWidgetContainer;
- on any change of renderer type, create some default (dummy?) version and change the stacked widget
- when clicked ok/apply, get the renderer from active widget and clone it for the layer
*/
class GUI_EXPORT QgsRendererV2Widget : public QStackedWidget
class GUI_EXPORT QgsRendererV2Widget : public QWidget
{
Q_OBJECT
public:
@@ -97,10 +97,9 @@ class GUI_EXPORT QgsRendererV2Widget : public QStackedWidget
* The renderer can open inline sub panels instead of dialogs.
* @param opened True of the a sub panel is opened.
*/
void panelOpened( QgsRendererWidgetContainer* widget );
void showPanel( QgsRendererWidgetContainer* widget );

protected:
QWidget* mWidgetPage;
QgsVectorLayer* mLayer;
QgsStyleV2* mStyle;
QMenu* contextMenu;
@@ -63,8 +63,7 @@ QgsRuleBasedRendererV2Widget::QgsRuleBasedRendererV2Widget( QgsVectorLayer* laye
mRenderer = new QgsRuleBasedRendererV2( symbol );
}

setupUi( mWidgetPage );
QMetaObject::connectSlotsByName( this );
setupUi( this );

mModel = new QgsRuleBasedRendererV2Model( mRenderer );
#ifdef ENABLE_MODELTEST
@@ -54,9 +54,9 @@ QgsSingleSymbolRendererV2Widget::QgsSingleSymbolRendererV2Widget( QgsVectorLayer
mSelector = new QgsSymbolV2SelectorDialog( mSingleSymbol, mStyle, mLayer, nullptr, true );
connect( mSelector, SIGNAL( symbolModified() ), this, SLOT( changeSingleSymbol() ) );

QVBoxLayout* layout = new QVBoxLayout( mWidgetPage );
QVBoxLayout* layout = new QVBoxLayout( this );
layout->setContentsMargins( 0, 0, 0, 0 );
mWidgetPage->layout()->addWidget( mSelector );
layout->addWidget( mSelector );

// advanced actions - data defined rendering
QMenu* advMenu = mSelector->advancedMenu();

0 comments on commit ad5f970

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