QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Slots | Public Member Functions | List of all members
QgsComposerHtml Class Reference

#include <qgscomposerhtml.h>

Inheritance diagram for QgsComposerHtml:
Inheritance graph
[legend]

Public Types

enum  ContentMode { Url, ManualHtml }
 Source modes for the HTML content to render in the item. More...
 
- Public Types inherited from QgsComposerMultiFrame
enum  ResizeMode { UseExistingFrames = 0, ExtendToNextPage, RepeatOnEveryPage, RepeatUntilFinished }
 
- Public Types inherited from QgsComposerObject
enum  DataDefinedProperty {
  NoProperty = 0, AllProperties, TestProperty, PresetPaperSize,
  PaperWidth, PaperHeight, NumPages, PaperOrientation,
  PageNumber, PositionX, PositionY, ItemWidth,
  ItemHeight, ItemRotation, Transparency, BlendMode,
  ExcludeFromExports, MapRotation, MapScale, MapXMin,
  MapYMin, MapXMax, MapYMax, MapAtlasMargin,
  PictureSource, SourceUrl
}
 Data defined properties for different item types. More...
 
enum  PropertyValueType { EvaluatedValue = 0, OriginalValue }
 Specifies whether the value returned by a function should be the original, user set value, or the current evaluated value for the property. More...
 

Public Slots

void loadHtml ()
 Reloads the html source from the url and redraws the item. More...
 
void recalculateFrameSizes ()
 Recalculates the frame sizes for the current viewport dimensions. More...
 
virtual void refreshDataDefinedProperty (const QgsComposerObject::DataDefinedProperty property=QgsComposerObject::AllProperties)
 
void refreshExpressionContext ()
 
- Public Slots inherited from QgsComposerMultiFrame
void recalculateFrameRects ()
 Forces a recalculation of all the associated frame's scene rectangles. More...
 
virtual void recalculateFrameSizes ()
 Recalculates the portion of the multiframe item which is shown in each of it's component frames. More...
 
void update ()
 Forces a redraw of all child frames. More...
 
- Public Slots inherited from QgsComposerObject
virtual void refreshDataDefinedProperty (const DataDefinedProperty property=AllProperties)
 Refreshes a data defined property for the item by reevaluating the property's value and redrawing the item with this new value. More...
 
virtual void repaint ()
 Triggers a redraw for the item. More...
 

Public Member Functions

 QgsComposerHtml (QgsComposition *c, bool createUndoCommands)
 
 QgsComposerHtml ()
 
 ~QgsComposerHtml ()
 
void addFrame (QgsComposerFrame *frame, bool recalcFrameSizes=true)
 Adds a frame to the multiframe. More...
 
ContentMode contentMode () const
 Returns the source mode for item's HTML content. More...
 
virtual QString displayName () const
 Get multiframe display name. More...
 
bool evaluateExpressions () const
 Returns whether html item will evaluate QGIS expressions prior to rendering the HTML content. More...
 
double findNearbyPageBreak (double yPos)
 Finds the optimal position to break a frame at. More...
 
QString html () const
 Returns the HTML source displayed in the item if the item is using the QgsComposerHtml::ManualHtml mode. More...
 
double maxBreakDistance () const
 Returns the maximum distance allowed when calculating where to place page breaks in the html. More...
 
bool readXML (const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false)
 Reads multiframe state information from a DOM element. More...
 
void render (QPainter *p, const QRectF &renderExtent, const int frameIndex)
 Renders a portion of the multiframe's content into a painter. More...
 
void setContentMode (ContentMode mode)
 Sets the source mode for item's HTML content. More...
 
void setEvaluateExpressions (bool evaluateExpressions)
 Sets whether the html item will evaluate QGIS expressions prior to rendering the HTML content. More...
 
void setHtml (const QString html)
 Sets the HTML to display in the item when the item is using the QgsComposerHtml::ManualHtml mode. More...
 
void setMaxBreakDistance (double maxBreakDistance)
 Sets the maximum distance allowed when calculating where to place page breaks in the html. More...
 
void setUrl (const QUrl &url)
 Sets the URL for content to display in the item when the item is using the QgsComposerHtml::Url mode. More...
 
void setUserStylesheet (const QString stylesheet)
 Sets the user stylesheet CSS rules to use while rendering the HTML content. More...
 
void setUserStylesheetEnabled (const bool stylesheetEnabled)
 Sets whether user stylesheets are enabled for the HTML content. More...
 
void setUseSmartBreaks (bool useSmartBreaks)
 Sets whether the html item should use smart breaks. More...
 
QSizeF totalSize () const
 Returns the total size of the multiframe's content. More...
 
const QUrl & url () const
 Returns the URL of the content displayed in the item if the item is using the QgsComposerHtml::Url mode. More...
 
QString userStylesheet () const
 Returns the user stylesheet CSS rules used while rendering the HTML content. More...
 
bool userStylesheetEnabled () const
 Returns whether user stylesheets are enabled for the HTML content. More...
 
bool useSmartBreaks () const
 Returns whether html item is using smart breaks. More...
 
bool writeXML (QDomElement &elem, QDomDocument &doc, bool ignoreFrames=false) const
 Stores state information about multiframe in DOM element. More...
 
- Public Member Functions inherited from QgsComposerMultiFrame
 QgsComposerMultiFrame (QgsComposition *c, bool createUndoCommands)
 Construct a new multiframe item. More...
 
virtual ~QgsComposerMultiFrame ()
 
bool _readXML (const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false)
 Restores state information about base multiframe object from a DOM element. More...
 
bool _writeXML (QDomElement &elem, QDomDocument &doc, bool ignoreFrames=false) const
 Stores state information about base multiframe object in DOM element. More...
 
QgsCompositioncomposition ()
 Returns the parent composition for the multiframe. More...
 
QgsComposerFramecreateNewFrame (QgsComposerFrame *currentFrame, QPointF pos, QSizeF size)
 Creates a new frame and adds it to the multi frame and composition. More...
 
bool createUndoCommands () const
 Returns whether undo commands should be created for interactions with the multiframe. More...
 
void deleteFrames ()
 Removes and deletes all child frames. More...
 
virtual QSizeF fixedFrameSize (const int frameIndex=-1) const
 Returns the fixed size for a frame, if desired. More...
 
QgsComposerFrameframe (int i) const
 Returns a child frame from the multiframe. More...
 
int frameCount () const
 Returns the number of frames associated with this multiframe. More...
 
int frameIndex (QgsComposerFrame *frame) const
 Returns the index of a frame within the multiframe. More...
 
virtual QSizeF minFrameSize (const int frameIndex=-1) const
 Returns the minimum size for a frames, if desired. More...
 
void removeFrame (int i, const bool removeEmptyPages=false)
 Removes a frame from the multiframe. More...
 
virtual Q_DECL_DEPRECATED void render (QPainter *p, const QRectF &renderExtent)
 Renders a portion of the multiframe's content into a painter. More...
 
ResizeMode resizeMode () const
 Returns the resize mode for the multiframe. More...
 
void setCreateUndoCommands (bool enabled)
 Sets whether undo commands should be created for interactions with the multiframe. More...
 
void setResizeMode (ResizeMode mode)
 Sets the resize mode for the multiframe, and recalculates frame sizes to match. More...
 
- Public Member Functions inherited from QgsComposerObject
 QgsComposerObject (QgsComposition *composition)
 Constructor. More...
 
virtual ~QgsComposerObject ()
 
const QgsCompositioncomposition () const
 Returns the composition the item is attached to. More...
 
QgsCompositioncomposition ()
 
QgsDataDefineddataDefinedProperty (const DataDefinedProperty property) const
 Returns a reference to the data defined settings for one of the item's data defined properties. More...
 
virtual bool readXML (const QDomElement &itemElem, const QDomDocument &doc)
 Sets item state from DOM element. More...
 
void setDataDefinedProperty (const DataDefinedProperty property, const bool active, const bool useExpression, const QString &expression, const QString &field)
 Sets parameters for a data defined property for the item. More...
 
virtual bool writeXML (QDomElement &elem, QDomDocument &doc) const
 Stores item state in DOM element. More...
 

Additional Inherited Members

- Signals inherited from QgsComposerMultiFrame
void changed ()
 Emitted when the properties of a multi frame have changed, and the GUI item widget must be updated. More...
 
void contentsChanged ()
 Emitted when the contents of the multi frame have changed and the frames must be redrawn. More...
 
- Signals inherited from QgsComposerObject
void itemChanged ()
 Emitted when the item changes. More...
 
- Protected Slots inherited from QgsComposerMultiFrame
void handleFrameRemoval (QgsComposerItem *item)
 Called before a frame is going to be removed. More...
 
void handlePageChange ()
 Adapts to changed number of composition pages if resize type is RepeatOnEveryPage. More...
 
- Protected Member Functions inherited from QgsComposerObject
bool dataDefinedEvaluate (const QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue)
 Evaluate a data defined property and return the calculated value. More...
 
- Protected Attributes inherited from QgsComposerMultiFrame
bool mCreateUndoCommands
 True: creates QgsMultiFrameCommands on internal changes (e.g. More...
 
QList< QgsComposerFrame * > mFrameItems
 
ResizeMode mResizeMode
 
- Protected Attributes inherited from QgsComposerObject
QgsCompositionmComposition
 
QMap
< QgsComposerObject::DataDefinedProperty,
QString > 
mDataDefinedNames
 Map of data defined properties for the item to string name to use when exporting item to xml. More...
 

Detailed Description

Definition at line 29 of file qgscomposerhtml.h.

Member Enumeration Documentation

Source modes for the HTML content to render in the item.

Enumerator
Url 
ManualHtml 

Definition at line 36 of file qgscomposerhtml.h.

Constructor & Destructor Documentation

QgsComposerHtml::QgsComposerHtml ( QgsComposition c,
bool  createUndoCommands 
)

Definition at line 35 of file qgscomposerhtml.cpp.

QgsComposerHtml::QgsComposerHtml ( )

Definition at line 88 of file qgscomposerhtml.cpp.

QgsComposerHtml::~QgsComposerHtml ( )

Definition at line 107 of file qgscomposerhtml.cpp.

Member Function Documentation

void QgsComposerHtml::addFrame ( QgsComposerFrame frame,
bool  recalcFrameSizes = true 
)
virtual

Adds a frame to the multiframe.

Parameters
frameframe to add
recalcFrameSizesset to true to force recalculation of all existing frame sizes
See also
removeFrame

Implements QgsComposerMultiFrame.

Definition at line 330 of file qgscomposerhtml.cpp.

ContentMode QgsComposerHtml::contentMode ( ) const
inline

Returns the source mode for item's HTML content.

Returns
ContentMode for the item's source
See also
setContentMode
url
html
Note
added in 2.5

Definition at line 65 of file qgscomposerhtml.h.

QString QgsComposerHtml::displayName ( ) const
virtual

Get multiframe display name.

Returns
display name for item
Note
added in version 2.5

Reimplemented from QgsComposerMultiFrame.

Definition at line 467 of file qgscomposerhtml.cpp.

bool QgsComposerHtml::evaluateExpressions ( ) const
inline

Returns whether html item will evaluate QGIS expressions prior to rendering the HTML content.

If set, any content inside [% %] tags will be treated as a QGIS expression and evaluated against the current atlas feature.

Returns
true if html item will evaluate expressions in the content
See also
setEvaluateExpressions
Note
added in QGIS 2.5

Definition at line 113 of file qgscomposerhtml.h.

double QgsComposerHtml::findNearbyPageBreak ( double  yPos)
virtual

Finds the optimal position to break a frame at.

Parameters
yPosmaximum vertical position for break
Returns
the optimal breakable position which occurs in the multi frame close to and before the specified yPos
Note
added in version 2.3

Reimplemented from QgsComposerMultiFrame.

Definition at line 357 of file qgscomposerhtml.cpp.

QString QgsComposerHtml::html ( ) const
inline

Returns the HTML source displayed in the item if the item is using the QgsComposerHtml::ManualHtml mode.

Returns
HTML displayed in item
See also
setHtml
contentMode
Note
added in 2.5

Definition at line 103 of file qgscomposerhtml.h.

void QgsComposerHtml::loadHtml ( )
slot

Reloads the html source from the url and redraws the item.

See also
setUrl
url

Definition at line 143 of file qgscomposerhtml.cpp.

double QgsComposerHtml::maxBreakDistance ( ) const
inline

Returns the maximum distance allowed when calculating where to place page breaks in the html.

This distance is the maximum amount of empty space allowed at the bottom of a frame after calculating the optimum break location. This setting is only effective if useSmartBreaks is true.

Returns
maximum amount of empty space to leave when calculating page break locations
Note
added in 2.3
See also
setMaxBreakDistance
useSmartBreaks

Definition at line 163 of file qgscomposerhtml.h.

bool QgsComposerHtml::readXML ( const QDomElement &  itemElem,
const QDomDocument &  doc,
bool  ignoreFrames = false 
)
virtual

Reads multiframe state information from a DOM element.

Implementations of readXML should also call the _readXML method to restore general multiframe properties.

Parameters
itemElemis DOM element
docis the DOM document
ignoreFramesset to false to avoid read state information about child frames from DOM
See also
_readXML

Implements QgsComposerMultiFrame.

Definition at line 489 of file qgscomposerhtml.cpp.

void QgsComposerHtml::recalculateFrameSizes ( )
slot

Recalculates the frame sizes for the current viewport dimensions.

Definition at line 242 of file qgscomposerhtml.cpp.

void QgsComposerHtml::refreshDataDefinedProperty ( const QgsComposerObject::DataDefinedProperty  property = QgsComposerObject::AllProperties)
virtualslot

Definition at line 568 of file qgscomposerhtml.cpp.

void QgsComposerHtml::refreshExpressionContext ( )
slot

Definition at line 550 of file qgscomposerhtml.cpp.

void QgsComposerHtml::render ( QPainter *  painter,
const QRectF &  renderExtent,
const int  frameIndex 
)
virtual

Renders a portion of the multiframe's content into a painter.

Parameters
painterdestination painter
renderExtentvisible extent of content to render into the painter.
frameIndexframe number for content
Note
added in version 2.5

Reimplemented from QgsComposerMultiFrame.

Definition at line 303 of file qgscomposerhtml.cpp.

void QgsComposerHtml::setContentMode ( ContentMode  mode)
inline

Sets the source mode for item's HTML content.

Parameters
modeContentMode for the item's source
See also
contentMode
setUrl
setHtml
Note
added in 2.5

Definition at line 56 of file qgscomposerhtml.h.

void QgsComposerHtml::setEvaluateExpressions ( bool  evaluateExpressions)

Sets whether the html item will evaluate QGIS expressions prior to rendering the HTML content.

If set, any content inside [% %] tags will be treated as a QGIS expression and evaluated against the current atlas feature.

Parameters
evaluateExpressionsset to true to evaluate expressions in the HTML content
See also
evaluateExpressions
Note
added in QGIS 2.5

Definition at line 136 of file qgscomposerhtml.cpp.

void QgsComposerHtml::setHtml ( const QString  html)

Sets the HTML to display in the item when the item is using the QgsComposerHtml::ManualHtml mode.

Setting the HTML using this function does not automatically refresh the item's contents. Call loadHtml to trigger a refresh of the item after setting the HTML content.

Parameters
htmlHTML to display in item
See also
html
contentMode
loadHtml
Note
added in 2.5

Definition at line 127 of file qgscomposerhtml.cpp.

void QgsComposerHtml::setMaxBreakDistance ( double  maxBreakDistance)

Sets the maximum distance allowed when calculating where to place page breaks in the html.

This distance is the maximum amount of empty space allowed at the bottom of a frame after calculating the optimum break location. Setting a larger value will result in better choice of page break location, but more wasted space at the bottom of frames. This setting is only effective if useSmartBreaks is true.

Parameters
maxBreakDistancemaximum amount of empty space to leave when calculating page break locations
Note
added in 2.3
See also
maxBreakDistance
setUseSmartBreaks

Definition at line 441 of file qgscomposerhtml.cpp.

void QgsComposerHtml::setUrl ( const QUrl &  url)

Sets the URL for content to display in the item when the item is using the QgsComposerHtml::Url mode.

Content is automatically fetched and the HTML item refreshed after calling this function.

Parameters
urlURL of content to display in the item
See also
url
contentMode

Definition at line 115 of file qgscomposerhtml.cpp.

void QgsComposerHtml::setUserStylesheet ( const QString  stylesheet)

Sets the user stylesheet CSS rules to use while rendering the HTML content.

These allow for overriding the styles specified within the HTML source. Setting the stylesheet using this function does not automatically refresh the item's contents. Call loadHtml to trigger a refresh of the item after setting the stylesheet rules.

Parameters
stylesheetCSS rules for user stylesheet
See also
userStylesheet
setUserStylesheetEnabled
loadHtml
Note
added in 2.5

Definition at line 448 of file qgscomposerhtml.cpp.

void QgsComposerHtml::setUserStylesheetEnabled ( const bool  stylesheetEnabled)

Sets whether user stylesheets are enabled for the HTML content.

Parameters
stylesheetEnabledset to true to enable user stylesheets
See also
userStylesheetEnabled
setUserStylesheet
Note
added in 2.5

Definition at line 457 of file qgscomposerhtml.cpp.

void QgsComposerHtml::setUseSmartBreaks ( bool  useSmartBreaks)

Sets whether the html item should use smart breaks.

Smart breaks prevent the html frame contents from breaking mid-way though a line of text.

Parameters
useSmartBreaksset to true to prevent content from breaking mid-way through a line of text
See also
useSmartBreaks

Definition at line 434 of file qgscomposerhtml.cpp.

QSizeF QgsComposerHtml::totalSize ( ) const
virtual

Returns the total size of the multiframe's content.

Returns
total size required for content

Implements QgsComposerMultiFrame.

Definition at line 298 of file qgscomposerhtml.cpp.

const QUrl& QgsComposerHtml::url ( ) const
inline

Returns the URL of the content displayed in the item if the item is using the QgsComposerHtml::Url mode.

Returns
url for content displayed in item
See also
setUrl
contentMode

Definition at line 82 of file qgscomposerhtml.h.

QString QgsComposerHtml::userStylesheet ( ) const
inline

Returns the user stylesheet CSS rules used while rendering the HTML content.

These overriding the styles specified within the HTML source.

Returns
CSS rules for user stylesheet
See also
setUserStylesheet
userStylesheetEnabled
Note
added in 2.5

Definition at line 184 of file qgscomposerhtml.h.

bool QgsComposerHtml::userStylesheetEnabled ( ) const
inline

Returns whether user stylesheets are enabled for the HTML content.

Returns
true if user stylesheets are enabled
See also
setUserStylesheetEnabled
userStylesheet
Note
added in 2.5

Definition at line 200 of file qgscomposerhtml.h.

bool QgsComposerHtml::useSmartBreaks ( ) const
inline

Returns whether html item is using smart breaks.

Smart breaks prevent the html frame contents from breaking mid-way though a line of text.

Returns
true if html item is using smart breaks
See also
setUseSmartBreaks

Definition at line 130 of file qgscomposerhtml.h.

bool QgsComposerHtml::writeXML ( QDomElement &  elem,
QDomDocument &  doc,
bool  ignoreFrames = false 
) const
virtual

Stores state information about multiframe in DOM element.

Implementations of writeXML should also call the _writeXML method to save general multiframe properties.

Parameters
elemis DOM element
docis the DOM document
ignoreFramesset to false to avoid writing state information about child frames into DOM
See also
_writeXML

Implements QgsComposerMultiFrame.

Definition at line 472 of file qgscomposerhtml.cpp.


The documentation for this class was generated from the following files: