Skip to content
Permalink
Browse files

[style dock] code clean up

  • Loading branch information
NathanW2 committed Jun 13, 2016
1 parent 659d916 commit 2ce4eb52c508ef23ee475d636a9b798233109280
Showing with 13 additions and 10 deletions.
  1. +13 −10 src/app/qgsmapstylingwidget.cpp
@@ -40,6 +40,7 @@
#include "qgsrasterlayer.h"
#include "qgsmapstylepanel.h"
#include "qgsmaplayerstylemanagerwidget.h"
#include "qgsruntimeprofiler.h"

QgsMapStylingWidget::QgsMapStylingWidget( QgsMapCanvas* canvas, QList<QgsMapStylingPanelFactory*> pages, QWidget *parent )
: QWidget( parent )
@@ -100,6 +101,7 @@ void QgsMapStylingWidget::setLayer( QgsMapLayer *layer )
{
mLayerCombo->setLayer( nullptr );
mStackedWidget->setCurrentIndex( mNotSupportedPage );
mLastStyleXml.clear();
return;
}

@@ -135,7 +137,6 @@ void QgsMapStylingWidget::setLayer( QgsMapLayer *layer )
mOptionsListWidget->addItem( item );
int row = mOptionsListWidget->row( item );
mUserPages[row] = factory;
QgsDebugMsg( QString( "ROW IS %1" ).arg( row ) );
}
}
mOptionsListWidget->addItem( new QListWidgetItem( QgsApplication::getThemeIcon( "mActionHistory.svg" ), "" ) );
@@ -150,15 +151,23 @@ void QgsMapStylingWidget::setLayer( QgsMapLayer *layer )
}

mStackedWidget->setCurrentIndex( 1 );

QString errorMsg;
QDomDocument doc( "style" );
mLastStyleXml = doc.createElement( "style" );
doc.appendChild( mLastStyleXml );
mCurrentLayer->writeStyle( mLastStyleXml, doc, errorMsg );
}

void QgsMapStylingWidget::apply()
{
disconnect( mCurrentLayer, SIGNAL( repaintRequested() ), this, SLOT( updateCurrentWidgetLayer() ) );
QString undoName = "Style Change";
if ( !mCurrentLayer )
return;

disconnect( mCurrentLayer, SIGNAL( repaintRequested() ), this, SLOT( updateCurrentWidgetLayer() ) );

QString undoName = "Style Change";

QWidget* current = mWidgetArea->widget();

bool styleWasChanged = false;
@@ -191,6 +200,7 @@ void QgsMapStylingWidget::apply()
mRasterStyleWidget->apply();
styleWasChanged = true;
}

pushUndoItem( undoName );

if ( styleWasChanged )
@@ -225,7 +235,6 @@ void QgsMapStylingWidget::redo()

void QgsMapStylingWidget::updateCurrentWidgetLayer()
{
QgsDebugMsgLevel( "UPDATE!!!", 4 );
mBlockAutoApply = true;

QgsMapLayer* layer = mCurrentLayer;
@@ -349,12 +358,6 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer()
mStackedWidget->setCurrentIndex( mNotSupportedPage );
}

QString errorMsg;
QDomDocument doc( "style" );
mLastStyleXml = doc.createElement( "style" );
doc.appendChild( mLastStyleXml );
mCurrentLayer->writeSymbology( mLastStyleXml, doc, errorMsg );

mBlockAutoApply = false;
}

0 comments on commit 2ce4eb5

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