|
16 | 16 | #include "qgscomposerhtml.h"
|
17 | 17 | #include "qgscomposerframe.h"
|
18 | 18 | #include "qgscomposition.h"
|
| 19 | +#include "qgsaddremovemultiframecommand.h" |
19 | 20 | #include <QCoreApplication>
|
20 | 21 | #include <QImage>
|
21 | 22 | #include <QPainter>
|
22 | 23 | #include <QWebFrame>
|
23 | 24 | #include <QWebPage>
|
24 | 25 |
|
25 |
| -QgsComposerHtml::QgsComposerHtml( QgsComposition* c, qreal x, qreal y, qreal width, qreal height ): QgsComposerMultiFrame( c ), mWebPage( 0 ), mLoaded( false ), mHtmlUnitsToMM( 1.0 ) |
| 26 | +QgsComposerHtml::QgsComposerHtml( QgsComposition* c, qreal x, qreal y, qreal width, qreal height, bool addCommands ): QgsComposerMultiFrame( c ), mWebPage( 0 ), |
| 27 | + mLoaded( false ), mHtmlUnitsToMM( 1.0 ) |
26 | 28 | {
|
27 | 29 | mHtmlUnitsToMM = htmlUnitsToMM();
|
28 | 30 | mWebPage = new QWebPage();
|
29 | 31 | QObject::connect( mWebPage, SIGNAL( loadFinished( bool ) ), this, SLOT( frameLoaded( bool ) ) );
|
30 | 32 |
|
31 | 33 | if ( mComposition && width > 0 && height > 0 )
|
32 | 34 | {
|
| 35 | + if ( addCommands ) |
| 36 | + { |
| 37 | + QgsAddRemoveMultiFrameCommand* c = new QgsAddRemoveMultiFrameCommand( QgsAddRemoveMultiFrameCommand::Added, this, mComposition, tr( "HTML added" ), 0 ); |
| 38 | + mComposition->undoStack()->push( c ); |
| 39 | + } |
33 | 40 | QgsComposerFrame* frame = new QgsComposerFrame( c, this, x, y, width, height );
|
34 |
| - addFrame( frame ); |
| 41 | + addFrame( frame, addCommands ); |
35 | 42 | QObject::connect( mComposition, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SLOT( handleFrameRemoval( QgsComposerItem* ) ) );
|
36 | 43 | recalculateFrameSizes();
|
37 | 44 | }
|
@@ -105,13 +112,17 @@ double QgsComposerHtml::htmlUnitsToMM()
|
105 | 112 | return ( pixelPerMM / ( img.dotsPerMeterX() / 1000.0 ) );
|
106 | 113 | }
|
107 | 114 |
|
108 |
| -void QgsComposerHtml::addFrame( QgsComposerFrame* frame ) |
| 115 | +void QgsComposerHtml::addFrame( QgsComposerFrame* frame, bool addCommand ) |
109 | 116 | {
|
110 | 117 | mFrameItems.push_back( frame );
|
111 | 118 | QObject::connect( frame, SIGNAL( sizeChanged() ), this, SLOT( recalculateFrameSizes() ) );
|
112 | 119 | if ( mComposition )
|
113 | 120 | {
|
114 | 121 | mComposition->addComposerHtmlFrame( this, frame );
|
| 122 | + if ( addCommand ) |
| 123 | + { |
| 124 | + mComposition->pushAddRemoveCommand( frame, tr( "Add Html frame" ) ); |
| 125 | + } |
115 | 126 | }
|
116 | 127 | }
|
117 | 128 |
|
|
0 commit comments