Skip to content

Commit

Permalink
[style dock] code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jun 13, 2016
1 parent 659d916 commit 2ce4eb5
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/app/qgsmapstylingwidget.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -100,6 +101,7 @@ void QgsMapStylingWidget::setLayer( QgsMapLayer *layer )
{
mLayerCombo->setLayer( nullptr );
mStackedWidget->setCurrentIndex( mNotSupportedPage );
mLastStyleXml.clear();
return;
}

Expand Down Expand Up @@ -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" ), "" ) );
Expand All @@ -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;
Expand Down Expand Up @@ -191,6 +200,7 @@ void QgsMapStylingWidget::apply()
mRasterStyleWidget->apply();
styleWasChanged = true;
}

pushUndoItem( undoName );

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

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

QgsMapLayer* layer = mCurrentLayer;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 2ce4eb5

Please sign in to comment.