4
4
#include " qgscomposermultiframecommand.h"
5
5
#include " qgscomposerhtml.h"
6
6
#include < QFileDialog>
7
+ #include < QSettings>
7
8
8
9
QgsComposerHtmlWidget::QgsComposerHtmlWidget ( QgsComposerHtml* html, QgsComposerFrame* frame ): mHtml( html ), mFrame( frame )
9
10
{
@@ -48,31 +49,35 @@ void QgsComposerHtmlWidget::on_mUrlLineEdit_editingFinished()
48
49
{
49
50
if ( mHtml )
50
51
{
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 () )
56
54
{
57
- mHtml ->composition ()->undoStack ()->push ( c );
58
- mHtml ->update ();
55
+ return ;
59
56
}
60
- else
57
+
58
+ QgsComposition* composition = mHtml ->composition ();
59
+ if ( composition )
61
60
{
62
- delete c;
61
+ composition->beginMultiFrameCommand ( mHtml , tr ( " Change html url" ) );
62
+ mHtml ->setUrl ( newUrl );
63
+ mHtml ->update ();
64
+ composition->endMultiFrameCommand ();
63
65
}
64
66
}
65
67
}
66
68
67
69
void QgsComposerHtmlWidget::on_mFileToolButton_clicked ()
68
70
{
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)" );
70
74
if ( !file.isEmpty () )
71
75
{
72
76
QUrl url = QUrl::fromLocalFile ( file );
73
- mHtml ->setUrl ( url );
74
77
mUrlLineEdit ->setText ( url.toString () );
78
+ on_mUrlLineEdit_editingFinished ();
75
79
mHtml ->update ();
80
+ s.setValue ( " /UI/lastHtmlDir" , QFileInfo ( file ).absolutePath () );
76
81
}
77
82
}
78
83
@@ -83,7 +88,13 @@ void QgsComposerHtmlWidget::on_mResizeModeComboBox_currentIndexChanged( int inde
83
88
return ;
84
89
}
85
90
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
+ }
87
98
}
88
99
89
100
void QgsComposerHtmlWidget::setGuiElementValues ()
0 commit comments