Skip to content
Permalink
Browse files

Restore some tests

  • Loading branch information
nyalldawson committed Nov 24, 2017
1 parent 2a75ad8 commit 604e51d3905867d7c0546c19c5e0cd2a05ec4f6a
@@ -388,6 +388,27 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
The item will also be deleted.
%End

void addMultiFrame( QgsLayoutMultiFrame *multiFrame /Transfer/ );
%Docstring
Adds a ``multiFrame`` to the layout. The object is owned by the layout until removeMultiFrame() is called.
.. seealso:: removeMultiFrame()
.. seealso:: multiFrames()
%End

void removeMultiFrame( QgsLayoutMultiFrame *multiFrame );
%Docstring
Removes a ``multiFrame`` from the layout (but does not delete it).
.. seealso:: addMultiFrame()
.. seealso:: multiFrames()
%End

QList< QgsLayoutMultiFrame * > multiFrames() const;
%Docstring
Returns a list of multi frames contained in the layout.
.. seealso:: addMultiFrame()
.. seealso:: removeMultiFrame()
:rtype: list of QgsLayoutMultiFrame
%End

QDomElement writeXml( QDomDocument &document, const QgsReadWriteContext &context ) const;
%Docstring
@@ -9,6 +9,228 @@



class QgsLayoutItemHtml: QgsLayoutMultiFrame
{
%Docstring
A layout multiframe subclass for HTML content.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgslayoutitemhtml.h"
%End
public:

enum ContentMode
{
Url,
ManualHtml
};

QgsLayoutItemHtml( QgsLayout *layout );
%Docstring
Constructor for QgsLayoutItemHtml, with the specified parent ``layout``.
%End

~QgsLayoutItemHtml();

virtual int type() const;

virtual QString stringType() const;


static QgsLayoutItemHtml *create( QgsLayout *layout ) /Factory/;
%Docstring
Returns a new QgsLayoutItemHtml for the specified parent ``layout``.
:rtype: QgsLayoutItemHtml
%End

void setContentMode( ContentMode mode );
%Docstring
Sets the source ``mode`` for item's HTML content.
.. seealso:: contentMode()
.. seealso:: setUrl()
.. seealso:: setHtml()
%End

ContentMode contentMode() const;
%Docstring
Returns the source mode for item's HTML content.
.. seealso:: setContentMode()
.. seealso:: url()
.. seealso:: html()
:rtype: ContentMode
%End

void setUrl( const QUrl &url );
%Docstring
Sets the ``url`` for content to display in the item when the item is using
the QgsLayoutItemHtml.Url mode. Content is automatically fetched and the
HTML item refreshed after calling this function.
.. seealso:: url()
.. seealso:: contentMode()
%End

QUrl url() const;
%Docstring
Returns the URL of the content displayed in the item if the item is using
the QgsLayoutItemHtml.Url mode.
.. seealso:: setUrl()
.. seealso:: contentMode()
:rtype: QUrl
%End

void setHtml( const QString &html );
%Docstring
Sets the ``html`` to display in the item when the item is using
the QgsLayoutItemHtml.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.
.. seealso:: html()
.. seealso:: contentMode()
.. seealso:: loadHtml()
%End

QString html() const;
%Docstring
Returns the HTML source displayed in the item if the item is using
the QgsLayoutItemHtml.ManualHtml mode.
.. seealso:: setHtml()
.. seealso:: contentMode()
:rtype: str
%End

bool evaluateExpressions() const;
%Docstring
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.
.. seealso:: setEvaluateExpressions()
:rtype: bool
%End

void setEvaluateExpressions( bool evaluateExpressions );
%Docstring
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.
.. seealso:: evaluateExpressions()
%End

bool useSmartBreaks() const;
%Docstring
Returns whether html item is using smart breaks. Smart breaks prevent
the html frame contents from breaking mid-way though a line of text.
.. seealso:: setUseSmartBreaks()
:rtype: bool
%End

void setUseSmartBreaks( bool useSmartBreaks );
%Docstring
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.
.. seealso:: useSmartBreaks()
%End

void setMaxBreakDistance( double distance );
%Docstring
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.
.. seealso:: maxBreakDistance()
.. seealso:: setUseSmartBreaks()
%End

double maxBreakDistance() const;
%Docstring
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.
.. seealso:: setMaxBreakDistance()
.. seealso:: useSmartBreaks()
:rtype: float
%End

void setUserStylesheet( const QString &stylesheet );
%Docstring
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.
.. seealso:: userStylesheet()
.. seealso:: setUserStylesheetEnabled()
.. seealso:: loadHtml()
%End

QString userStylesheet() const;
%Docstring
Returns the user stylesheet CSS rules used while rendering the HTML content. These
overriding the styles specified within the HTML source.
.. seealso:: setUserStylesheet()
.. seealso:: userStylesheetEnabled()
:rtype: str
%End

void setUserStylesheetEnabled( const bool enabled );
%Docstring
Sets whether user stylesheets are ``enabled`` for the HTML content.
.. seealso:: userStylesheetEnabled()
.. seealso:: setUserStylesheet()
%End

bool userStylesheetEnabled() const;
%Docstring
Returns whether user stylesheets are enabled for the HTML content.
.. seealso:: setUserStylesheetEnabled()
.. seealso:: userStylesheet()
:rtype: bool
%End

virtual QString displayName() const;

virtual QSizeF totalSize() const;

virtual void render( QgsRenderContext &context, const QRectF &renderExtent, const int frameIndex,
const QStyleOptionGraphicsItem *itemStyle = 0 );

virtual double findNearbyPageBreak( double yPos );


public slots:

void loadHtml( const bool useCache = false, const QgsExpressionContext *context = 0 );
%Docstring
Reloads the html source from the url and redraws the item.
\param useCache set to true to use a cached copy of remote html
content
\param context expression context for evaluating data defined urls and expressions in html
.. seealso:: setUrl
.. seealso:: url
%End

virtual void recalculateFrameSizes();

%Docstring
Recalculates the frame sizes for the current viewport dimensions
%End
void refreshExpressionContext();

void refreshDataDefinedProperty( const QgsLayoutObject::DataDefinedProperty property = QgsLayoutObject::AllProperties );

protected:

virtual bool writePropertiesToElement( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const;

virtual bool readPropertiesFromElement( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context );


};

/************************************************************************
* This file has been generated automatically from *
@@ -184,6 +184,21 @@ class QgsLayoutMultiFrame: QgsLayoutObject, QgsLayoutUndoObjectInterface
:rtype: bool
%End


int frameCount() const;
%Docstring
Returns the number of frames associated with this multiframe.
.. seealso:: frames()
:rtype: int
%End

QgsLayoutFrame *frame( int index ) const;
%Docstring
Returns the child frame at a specified ``index`` from the multiframe.
.. seealso:: frameIndex()
:rtype: QgsLayoutFrame
%End

QgsLayoutFrame *createNewFrame( QgsLayoutFrame *currentFrame, QPointF pos, QSizeF size );
%Docstring
Creates a new frame and adds it to the multi frame and layout.
@@ -435,15 +435,16 @@ void QgsLayout::addMultiFrame( QgsLayoutMultiFrame *multiFrame )
if ( !multiFrame )
return;

mMultiFrames.insert( multiFrame );
if ( !mMultiFrames.contains( multiFrame ) )
mMultiFrames << multiFrame;
}

void QgsLayout::removeMultiFrame( QgsLayoutMultiFrame *multiFrame )
{
mMultiFrames.remove( multiFrame );
mMultiFrames.removeAll( multiFrame );
}

QSet<QgsLayoutMultiFrame *> QgsLayout::multiFrames() const
QList<QgsLayoutMultiFrame *> QgsLayout::multiFrames() const
{
return mMultiFrames;
}
@@ -437,8 +437,6 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
*/
void removeLayoutItem( QgsLayoutItem *item );

#ifndef SIP_RUN

/**
* Adds a \a multiFrame to the layout. The object is owned by the layout until removeMultiFrame() is called.
* \see removeMultiFrame()
@@ -458,8 +456,7 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
* \see addMultiFrame()
* \see removeMultiFrame()
*/
QSet< QgsLayoutMultiFrame * > multiFrames() const;
#endif
QList< QgsLayoutMultiFrame * > multiFrames() const;

/**
* Returns the layout's state encapsulated in a DOM element.
@@ -560,7 +557,7 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
QgsLayoutExporter mExporter;

//! List of multiframe objects
QSet<QgsLayoutMultiFrame *> mMultiFrames;
QList<QgsLayoutMultiFrame *> mMultiFrames;

//! Writes only the layout settings (not member settings like grid settings, etc) to XML
void writeXmlLayoutSettings( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
@@ -28,8 +28,6 @@ class QImage;
class QgsVectorLayer;
class QgsNetworkContentFetcher;

#ifndef SIP_RUN

/**
* \ingroup core
* A layout multiframe subclass for HTML content.
@@ -275,6 +273,4 @@ class CORE_EXPORT QgsLayoutItemHtml: public QgsLayoutMultiFrame
double maxFrameWidth() const;
};

#endif

#endif // QGSLAYOUTITEMHTML_H
@@ -87,6 +87,7 @@ ADD_PYTHON_TEST(PyQgsLayoutPageCollection test_qgslayoutpagecollection.py)
ADD_PYTHON_TEST(PyQgsLayoutView test_qgslayoutview.py)
ADD_PYTHON_TEST(PyQgsLayoutGridSettings test_qgslayoutgridsettings.py)
ADD_PYTHON_TEST(PyQgsLayoutGuide test_qgslayoutguides.py)
ADD_PYTHON_TEST(PyQgsLayoutHtml test_qgslayouthtml.py)
ADD_PYTHON_TEST(PyQgsLayoutItem test_qgslayoutitem.py)
ADD_PYTHON_TEST(PyQgsLayoutItemPropertiesDialog test_qgslayoutitempropertiesdialog.py)
ADD_PYTHON_TEST(PyQgsLayoutLabel test_qgslayoutlabel.py)

0 comments on commit 604e51d

Please sign in to comment.
You can’t perform that action at this time.