Skip to content

Commit

Permalink
[styledock] Fix undo redo
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed May 28, 2016
1 parent 17b4856 commit 705d4f5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
28 changes: 17 additions & 11 deletions src/app/qgsmapstylingwidget.cpp
Expand Up @@ -42,6 +42,13 @@ QgsMapStylingWidget::QgsMapStylingWidget( QgsMapCanvas* canvas, QWidget *parent

mAutoApplyTimer = new QTimer( this );
mAutoApplyTimer->setSingleShot( true );

mUndoWidget = new QgsUndoWidget( this, mMapCanvas );
mUndoWidget->setObjectName( "Undo Styles" );
mUndoWidget->hide();
connect( mUndoButton, SIGNAL( pressed() ), mUndoWidget, SLOT( undo() ) );
connect( mRedoButton, SIGNAL( pressed() ), mUndoWidget, SLOT( redo() ) );

connect( mAutoApplyTimer, SIGNAL( timeout() ), this, SLOT( apply() ) );

connect( mOptionsListWidget, SIGNAL( currentRowChanged( int ) ), this, SLOT( updateCurrentWidgetLayer() ) );
Expand Down Expand Up @@ -168,6 +175,8 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer()

QgsMapLayer* layer = mCurrentLayer;

mUndoWidget->setUndoStack( layer->undoStackStyles() );

mLayerTitleLabel->setText( layer->name() );

if ( layer->type() == QgsMapLayer::VectorLayer )
Expand All @@ -181,6 +190,10 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer()
{
mLabelingWidget = widget;
}
else if ( QgsUndoWidget* widget = qobject_cast<QgsUndoWidget*>( current ) )
{
mUndoWidget = widget;
}
else
{
current->deleteLater();
Expand Down Expand Up @@ -208,11 +221,6 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer()
break;
}
case 2: // History
mUndoWidget = new QgsUndoWidget( mOptionsListWidget, mMapCanvas );
mUndoWidget->setObjectName( "Undo Styles" );
mUndoWidget->setUndoStack( layer->undoStackStyles() );
connect( mUndoButton, SIGNAL( pressed() ), mUndoWidget, SLOT( undo() ) );
connect( mRedoButton, SIGNAL( pressed() ), mUndoWidget, SLOT( redo() ) );
mWidgetArea->setWidget( mUndoWidget );
break;
default:
Expand All @@ -235,6 +243,10 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer()
{
mRasterStyleWidget = widget;
}
else if ( QgsUndoWidget* widget = qobject_cast<QgsUndoWidget*>( current ) )
{
mUndoWidget = widget;
}
else
{
current->deleteLater();
Expand Down Expand Up @@ -276,12 +288,6 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer()
break;
}
case 3: // History
mUndoWidget = new QgsUndoWidget( mOptionsListWidget, mMapCanvas );
mUndoWidget->setObjectName( "Undo Styles" );
mUndoWidget->setUndoStack( layer->undoStackStyles() );

connect( mUndoButton, SIGNAL( pressed() ), mUndoWidget, SLOT( undo() ) );
connect( mRedoButton, SIGNAL( pressed() ), mUndoWidget, SLOT( redo() ) );
mWidgetArea->setWidget( mUndoWidget );
break;
default:
Expand Down
40 changes: 26 additions & 14 deletions src/ui/qgsmapstylingwidgetbase.ui
Expand Up @@ -14,13 +14,22 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QStackedWidget" name="mStackedWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_3">
Expand All @@ -35,16 +44,25 @@
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>3</number>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="margin">
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>3</number>
</property>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QToolButton" name="mRedoButton">
<widget class="QToolButton" name="mUndoButton">
<property name="text">
<string>...</string>
</property>
Expand All @@ -55,7 +73,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="mUndoButton">
<widget class="QToolButton" name="mRedoButton">
<property name="text">
<string>...</string>
</property>
Expand Down Expand Up @@ -184,7 +202,7 @@
<x>0</x>
<y>0</y>
<width>320</width>
<height>388</height>
<height>401</height>
</rect>
</property>
</widget>
Expand All @@ -195,12 +213,6 @@
</widget>
</item>
</layout>
<zorder>mLayerTitleLabel</zorder>
<zorder>mLiveApplyCheck</zorder>
<zorder>mStackedWidget</zorder>
<zorder>mRedoButton</zorder>
<zorder>mUndoButton</zorder>
<zorder>mButtonBox</zorder>
</widget>
<resources>
<include location="../../images/images.qrc"/>
Expand Down

0 comments on commit 705d4f5

Please sign in to comment.