Skip to content

Commit 4969d67

Browse files
committedAug 8, 2012
More undo/redo improvements
1 parent c2f768f commit 4969d67

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed
 

‎src/app/composer/qgscomposerhtmlwidget.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "qgscomposermultiframecommand.h"
55
#include "qgscomposerhtml.h"
66
#include <QFileDialog>
7+
#include <QSettings>
78

89
QgsComposerHtmlWidget::QgsComposerHtmlWidget( QgsComposerHtml* html, QgsComposerFrame* frame ): mHtml( html ), mFrame( frame )
910
{
@@ -48,31 +49,35 @@ void QgsComposerHtmlWidget::on_mUrlLineEdit_editingFinished()
4849
{
4950
if ( mHtml )
5051
{
51-
QgsComposerMultiFrameCommand* c = new QgsComposerMultiFrameCommand( mHtml, tr( "Change html url" ) );
52-
c->savePreviousState();
53-
mHtml->setUrl( QUrl( mUrlLineEdit->text() ) );
54-
c->saveAfterState();
55-
if ( c->containsChange() )
52+
QUrl newUrl( mUrlLineEdit->text() );
53+
if ( newUrl == mHtml->url() )
5654
{
57-
mHtml->composition()->undoStack()->push( c );
58-
mHtml->update();
55+
return;
5956
}
60-
else
57+
58+
QgsComposition* composition = mHtml->composition();
59+
if ( composition )
6160
{
62-
delete c;
61+
composition->beginMultiFrameCommand( mHtml, tr( "Change html url" ) );
62+
mHtml->setUrl( newUrl );
63+
mHtml->update();
64+
composition->endMultiFrameCommand();
6365
}
6466
}
6567
}
6668

6769
void QgsComposerHtmlWidget::on_mFileToolButton_clicked()
6870
{
69-
QString file = QFileDialog::getOpenFileName( this, tr( "Select HTML document" ), QString(), "HTML (*.html)" );
71+
QSettings s;
72+
QString lastDir = s.value( "/UI/lastHtmlDir", "" ).toString();
73+
QString file = QFileDialog::getOpenFileName( this, tr( "Select HTML document" ), lastDir, "HTML (*.html)" );
7074
if ( !file.isEmpty() )
7175
{
7276
QUrl url = QUrl::fromLocalFile( file );
73-
mHtml->setUrl( url );
7477
mUrlLineEdit->setText( url.toString() );
78+
on_mUrlLineEdit_editingFinished();
7579
mHtml->update();
80+
s.setValue( "/UI/lastHtmlDir", QFileInfo( file ).absolutePath() );
7681
}
7782
}
7883

@@ -83,7 +88,13 @@ void QgsComposerHtmlWidget::on_mResizeModeComboBox_currentIndexChanged( int inde
8388
return;
8489
}
8590

86-
mHtml->setResizeMode(( QgsComposerMultiFrame::ResizeMode )mResizeModeComboBox->itemData( index ).toInt() );
91+
QgsComposition* composition = mHtml->composition();
92+
if ( composition )
93+
{
94+
composition->beginMultiFrameCommand( mHtml, tr( "Change resize mode" ) );
95+
mHtml->setResizeMode(( QgsComposerMultiFrame::ResizeMode )mResizeModeComboBox->itemData( index ).toInt() );
96+
composition->endMultiFrameCommand();
97+
}
8798
}
8899

89100
void QgsComposerHtmlWidget::setGuiElementValues()

0 commit comments

Comments
 (0)
Please sign in to comment.