QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
#include <qgscomposerhtml.h>
Public Slots | |
void | loadHtml (const bool useCache=false, const QgsExpressionContext *context=nullptr) |
Reloads the html source from the url and redraws the item. More... | |
void | recalculateFrameSizes () override |
Recalculates the frame sizes for the current viewport dimensions. More... | |
virtual void | refreshDataDefinedProperty (const QgsComposerObject::DataDefinedProperty property=QgsComposerObject::AllProperties, const QgsExpressionContext *context=nullptr) override |
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, const QgsExpressionContext *context=nullptr) |
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 () | |
void | addFrame (QgsComposerFrame *frame, bool recalcFrameSizes=true) override |
Adds a frame to the multiframe. More... | |
ContentMode | contentMode () const |
Returns the source mode for item's HTML content. More... | |
virtual QString | displayName () const override |
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) override |
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) override |
Reads multiframe state information from a DOM element. More... | |
void | render (QPainter *p, const QRectF &renderExtent, const int frameIndex) override |
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 override |
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 override |
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... | |
QgsComposition * | composition () |
Returns the parent composition for the multiframe. More... | |
QgsComposerFrame * | createNewFrame (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... | |
QgsComposerFrame * | frame (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 QgsComposition * | composition () const |
Returns the composition the item is attached to. More... | |
QgsComposition * | composition () |
virtual QgsExpressionContext * | createExpressionContext () const |
Creates an expression context relating to the objects' current state. More... | |
QStringList | customProperties () const |
Return list of keys stored in custom properties for the object. More... | |
QVariant | customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const |
Read a custom property from the object. More... | |
QgsDataDefined * | dataDefinedProperty (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 | removeCustomProperty (const QString &key) |
Remove a custom property from the object. More... | |
void | setCustomProperty (const QString &key, const QVariant &value) |
Set a custom property for the object. 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... | |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
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... | |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
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, const QgsExpressionContext &context=QgsExpressionContext()) const |
Evaluate a data defined property and return the calculated value. More... | |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
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 | |
QgsComposition * | mComposition |
QgsObjectCustomProperties | mCustomProperties |
Custom properties for object. More... | |
QMap< QgsComposerObject::DataDefinedProperty, QString > | mDataDefinedNames |
Map of data defined properties for the item to string name to use when exporting item to xml. More... | |
Properties inherited from QObject | |
objectName | |
Definition at line 32 of file qgscomposerhtml.h.
Source modes for the HTML content to render in the item.
Enumerator | |
---|---|
Url | Using this mode item fetches its content via a url |
ManualHtml | HTML content is manually set for the item |
Definition at line 39 of file qgscomposerhtml.h.
QgsComposerHtml::QgsComposerHtml | ( | QgsComposition * | c, |
bool | createUndoCommands | ||
) |
Definition at line 38 of file qgscomposerhtml.cpp.
QgsComposerHtml::~QgsComposerHtml | ( | ) |
Definition at line 91 of file qgscomposerhtml.cpp.
|
overridevirtual |
Adds a frame to the multiframe.
frame | frame to add |
recalcFrameSizes | set to true to force recalculation of all existing frame sizes |
Implements QgsComposerMultiFrame.
Definition at line 334 of file qgscomposerhtml.cpp.
|
inline |
Returns the source mode for item's HTML content.
Definition at line 65 of file qgscomposerhtml.h.
|
overridevirtual |
Get multiframe display name.
Reimplemented from QgsComposerMultiFrame.
Definition at line 475 of file qgscomposerhtml.cpp.
|
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.
Definition at line 113 of file qgscomposerhtml.h.
|
overridevirtual |
Finds the optimal position to break a frame at.
yPos | maximum vertical position for break |
Reimplemented from QgsComposerMultiFrame.
Definition at line 361 of file qgscomposerhtml.cpp.
|
inline |
Returns the HTML source displayed in the item if the item is using the QgsComposerHtml::ManualHtml mode.
Definition at line 103 of file qgscomposerhtml.h.
|
slot |
Reloads the html source from the url and redraws the item.
useCache | set to true to use a cached copy of remote html content |
context | expression context for evaluating data defined urls and expressions in html |
Definition at line 127 of file qgscomposerhtml.cpp.
|
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.
Definition at line 163 of file qgscomposerhtml.h.
|
overridevirtual |
Reads multiframe state information from a DOM element.
Implementations of readXML should also call the _readXML method to restore general multiframe properties.
itemElem | is DOM element |
doc | is the DOM document |
ignoreFrames | set to false to avoid read state information about child frames from DOM |
Implements QgsComposerMultiFrame.
Definition at line 497 of file qgscomposerhtml.cpp.
|
overrideslot |
Recalculates the frame sizes for the current viewport dimensions.
Definition at line 245 of file qgscomposerhtml.cpp.
|
overridevirtualslot |
Definition at line 581 of file qgscomposerhtml.cpp.
|
slot |
Definition at line 563 of file qgscomposerhtml.cpp.
|
overridevirtual |
Renders a portion of the multiframe's content into a painter.
painter | destination painter |
renderExtent | visible extent of content to render into the painter. |
frameIndex | frame number for content |
Reimplemented from QgsComposerMultiFrame.
Definition at line 307 of file qgscomposerhtml.cpp.
|
inline |
Sets the source mode for item's HTML content.
mode | ContentMode for the item's source |
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.
evaluateExpressions | set to true to evaluate expressions in the HTML content |
Definition at line 120 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.
html | HTML to display in item |
Definition at line 111 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.
maxBreakDistance | maximum amount of empty space to leave when calculating page break locations |
Definition at line 449 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.
url | URL of content to display in the item |
Definition at line 99 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.
stylesheet | CSS rules for user stylesheet |
Definition at line 456 of file qgscomposerhtml.cpp.
void QgsComposerHtml::setUserStylesheetEnabled | ( | const bool | stylesheetEnabled | ) |
Sets whether user stylesheets are enabled for the HTML content.
stylesheetEnabled | set to true to enable user stylesheets |
Definition at line 465 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.
useSmartBreaks | set to true to prevent content from breaking mid-way through a line of text |
Definition at line 442 of file qgscomposerhtml.cpp.
|
overridevirtual |
Returns the total size of the multiframe's content.
Implements QgsComposerMultiFrame.
Definition at line 302 of file qgscomposerhtml.cpp.
|
inline |
Returns the URL of the content displayed in the item if the item is using the QgsComposerHtml::Url mode.
Definition at line 82 of file qgscomposerhtml.h.
|
inline |
Returns the user stylesheet CSS rules used while rendering the HTML content.
These overriding the styles specified within the HTML source.
Definition at line 184 of file qgscomposerhtml.h.
|
inline |
Returns whether user stylesheets are enabled for the HTML content.
Definition at line 200 of file qgscomposerhtml.h.
|
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.
Definition at line 130 of file qgscomposerhtml.h.
|
overridevirtual |
Stores state information about multiframe in DOM element.
Implementations of writeXML should also call the _writeXML method to save general multiframe properties.
elem | is DOM element |
doc | is the DOM document |
ignoreFrames | set to false to avoid writing state information about child frames into DOM |
Implements QgsComposerMultiFrame.
Definition at line 480 of file qgscomposerhtml.cpp.