TreeFrogFramework  1.18
Public Member Functions | Protected Member Functions | List of all members
TViewHelper Class Referenceabstract

#include <tviewhelper.h>

Inheritance diagram for TViewHelper:
Inheritance graph
[legend]

Public Member Functions

virtual ~TViewHelper ()
 
QString linkTo (const QString &text, const QUrl &url, Tf::HttpMethod method=Tf::Get, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString linkTo (const QString &text, const QUrl &url, Tf::HttpMethod method, const QString &jsCondition, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString linkToPopup (const QString &text, const QUrl &url, const QString &windowTitle=QString(), const QSize &size=QSize(), const QPoint &topLeft=QPoint(), const QString &windowStyle=QString(), const QString &jsCondition=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString linkToIf (bool condition, const QString &text, const QUrl &url, Tf::HttpMethod method=Tf::Get, const QString &jsCondition=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString linkToUnless (bool condition, const QString &text, const QUrl &url, Tf::HttpMethod method=Tf::Get, const QString &jsCondition=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString linkToFunction (const QString &text, const QString &function, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString buttonToFunction (const QString &text, const QString &function, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString anchor (const QString &text, const QUrl &url, Tf::HttpMethod method=Tf::Get, const QString &jsCondition=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString anchorPopup (const QString &text, const QUrl &url, const QString &windowTitle=QString(), const QSize &size=QSize(), const QPoint &topLeft=QPoint(), const QString &windowStyle=QString(), const QString &jsCondition=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString anchorIf (bool condition, const QString &text, const QUrl &url, Tf::HttpMethod method=Tf::Get, const QString &jsCondition=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString anchorUnless (bool condition, const QString &text, const QUrl &url, Tf::HttpMethod method=Tf::Get, const QString &jsCondition=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString anchorFunction (const QString &text, const QString &function, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString formTag (const QUrl &url, Tf::HttpMethod method=Tf::Post, bool multipart=false, const THtmlAttribute &attributes=THtmlAttribute())
 
QString inputTag (const QString &type, const QString &name, const QVariant &value, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString inputTextTag (const QString &name, const QVariant &value, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString inputFileTag (const QString &name, const QVariant &value, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString inputFileTag (const QString &name, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString inputPasswordTag (const QString &name, const QVariant &value, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString inputHiddenTag (const QString &name, const QVariant &value, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString checkBoxTag (const QString &name, const QVariant &value, bool checked=false, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString checkBoxTag (const QString &name, const QString &value, const QStringList &checkedValues, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString checkBoxTag (const QString &name, const QVariant &value, const QVariantList &checkedValues, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString checkBoxTag (const QString &name, const QVariant &value, const QVariant &checkedValue, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString radioButtonTag (const QString &name, const QVariant &value, bool checked=false, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString radioButtonTag (const QString &name, const QVariant &value, const QVariant &checkedValue, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString selectTag (const QString &name, int size=1, bool multiple=false, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString optionTag (const QString &text, const QVariant &value, bool selected=false, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString optionTags (const QStringList &valueList, const QVariant &selectedValue=QVariant(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString optionTags (const QVariantList &valueList, const QVariant &selectedValue=QVariant(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString optionTags (const QList< QPair< QString, QVariant >> &valueList, const QVariant &selectedValue=QVariant(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString inputAuthenticityTag () const
 
QString textAreaTag (const QString &name, int rows, int cols, const QString &content=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString submitTag (const QString &value, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString submitImageTag (const QString &src, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString resetTag (const QString &value, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString imageTag (const QString &src, const QSize &size=QSize(), const QString &alt=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString imageTag (const QString &src, bool withTimestamp, const QSize &size=QSize(), const QString &alt=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString imageTag (const QString &src, const THtmlAttribute &attributes) const
 
QString inlineImageTag (const QFileInfo &file, const QString &mediaType, const QSize &size=QSize(), const QString &alt=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString inlineImageTag (const QFileInfo &file, const QString &mediaType, const THtmlAttribute &attributes) const
 
QString inlineImageTag (const QByteArray &data, const QString &mediaType, const QSize &size=QSize(), const QString &alt=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString inlineImageTag (const QByteArray &data, const QString &mediaType, const THtmlAttribute &attributes) const
 
QString imageLinkTo (const QUrl &url, const QString &src, bool withTimestamp, const QString &alt=QString(), const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString imageLinkTo (const QUrl &url, const QString &src, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString styleSheetTag (const QString &src, const THtmlAttribute &attributes) const
 
QString styleSheetTag (const QString &src, bool withTimestamp=true, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString scriptTag (const QString &src, const THtmlAttribute &attributes) const
 
QString scriptTag (const QString &src, bool withTimestamp=true, const THtmlAttribute &attributes=THtmlAttribute()) const
 
QString tag (const QString &name, const THtmlAttribute &attributes)
 
QString tag (const QString &name, const THtmlAttribute &attributes, bool selfClose)
 
QString tag (const QString &name, const THtmlAttribute &attributes, const QString &content) const
 
QString selfClosingTag (const QString &name, const THtmlAttribute &attributes) const
 
QString endTag (const QString &name) const
 
QString endTag ()
 
QString allEndTags ()
 
QString imagePath (const QString &src, bool withTimestamp=true) const
 
QString cssPath (const QString &src, bool withTimestamp=true) const
 
QString jsPath (const QString &src, bool withTimestamp=true) const
 
QString srcPath (const QString &src, const QString &dir, bool withTimestamp=true) const
 
THtmlAttribute a (const QString &key, const QString &value) const
 
THtmlAttribute a () const
 

Protected Member Functions

virtual const TActionViewactionView () const =0
 

Detailed Description

The TViewHelper class provides some functionality for views.

Constructor & Destructor Documentation

virtual TViewHelper::~TViewHelper ( )
inlinevirtual

Member Function Documentation

THtmlAttribute TViewHelper::a ( const QString &  key,
const QString &  value 
) const

Creates and returns a THtmlAttribute object with key ="value".

THtmlAttribute TViewHelper::a ( ) const
inline

Returns a null THtmlAttribute object.

const TActionView * TViewHelper::actionView ( ) const
protectedpure virtual

Must be overridden by subclasses to return the current action view.

QString TViewHelper::allEndTags ( )

Returns all end tags if there are buffered tags.

QString TViewHelper::anchor ( const QString &  text,
const QUrl &  url,
Tf::HttpMethod  method = Tf::Get,
const QString &  jsCondition = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a <a> link tag with the given arguments.

Equivalent to linkTo().

QString TViewHelper::anchorFunction ( const QString &  text,
const QString &  function,
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a <a> link tag with the given arguments.

Equivalent to linkToFunction().

QString TViewHelper::anchorIf ( bool  condition,
const QString &  text,
const QUrl &  url,
Tf::HttpMethod  method = Tf::Get,
const QString &  jsCondition = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a <a> link tag with the given arguments.

Equivalent to linkToIf().

QString TViewHelper::anchorPopup ( const QString &  text,
const QUrl &  url,
const QString &  windowTitle = QString(),
const QSize &  size = QSize(),
const QPoint &  topLeft = QPoint(),
const QString &  windowStyle = QString(),
const QString &  jsCondition = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a <a> link tag with the given arguments.

Equivalent to linkToPopup().

QString TViewHelper::anchorUnless ( bool  condition,
const QString &  text,
const QUrl &  url,
Tf::HttpMethod  method = Tf::Get,
const QString &  jsCondition = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a <a> link tag with the given arguments.

Equivalent to linkToUnless().

QString TViewHelper::buttonToFunction ( const QString &  text,
const QString &  function,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a input tag (type="button") whose onclick handler triggers the passed JavaScript.

QString TViewHelper::checkBoxTag ( const QString &  name,
const QVariant &  value,
bool  checked = false,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a input tag with type="checkbox", name="name" and value="value".

QString TViewHelper::checkBoxTag ( const QString &  name,
const QString &  value,
const QStringList &  checkedValues,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a input tag with type="checkbox", name="name" and value="value".

If the checkedValues parameter contains the value parameter, this checkbox is checked.

QString TViewHelper::checkBoxTag ( const QString &  name,
const QVariant &  value,
const QVariantList &  checkedValues,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a input tag with type="checkbox", name="name" and value="value".

If the checkedValues parameter contains the value parameter, this checkbox is checked.

QString TViewHelper::checkBoxTag ( const QString &  name,
const QVariant &  value,
const QVariant &  checkedValue,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a input tag with type="checkbox", name="name" and value="value".

If the checkedValue parameter is equal to the value parameter, this checkbox is checked.

QString TViewHelper::cssPath ( const QString &  src,
bool  withTimestamp = true 
) const

Returns a css path to src.

The src must be one of URL, a absolute path or a relative path. If src is a relative path, it must exist in the public/css directory.

QString TViewHelper::endTag ( const QString &  name) const

Creates a end-tag of name.

QString TViewHelper::endTag ( )

Returns an end tag if there is a buffered tags.

QString TViewHelper::formTag ( const QUrl &  url,
Tf::HttpMethod  method = Tf::Post,
bool  multipart = false,
const THtmlAttribute attributes = THtmlAttribute() 
)

Creates a form tag that points to an url.

If multipart is true, this function creates a form tag of multipart/form-data.

QString TViewHelper::imageLinkTo ( const QUrl &  url,
const QString &  src,
bool  withTimestamp,
const QString &  alt = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a <a> link tag of a given url with a <img> tag of src="src".

QString TViewHelper::imageLinkTo ( const QUrl &  url,
const QString &  src,
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a <a> link tag of a given url with a <img> tag of src="src".

QString TViewHelper::imagePath ( const QString &  src,
bool  withTimestamp = true 
) const

Returns a image path to src.

The src must be one of URL, a absolute path or a relative path. If src is a relative path, it must exist in the public/images directory.

QString TViewHelper::imageTag ( const QString &  src,
const QSize &  size = QSize(),
const QString &  alt = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a <img> image tag with src="src".

The src must be one of URL, a absolute path or a relative path. If src is a relative path, it must exist in the public/images directory.

QString TViewHelper::imageTag ( const QString &  src,
bool  withTimestamp,
const QSize &  size = QSize(),
const QString &  alt = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a <img> image tag with src="src".

The src must be one of URL, a absolute path or a relative path. If src is a relative path, it must exist in the public/images directory. If withTimestamp is true, the timestamp of the image file is append to src as a query parameter.

QString TViewHelper::imageTag ( const QString &  src,
const THtmlAttribute attributes 
) const
inline

Creates a <img> image tag with src="src".

QString TViewHelper::inlineImageTag ( const QFileInfo &  file,
const QString &  mediaType,
const QSize &  size = QSize(),
const QString &  alt = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const
QString TViewHelper::inlineImageTag ( const QFileInfo &  file,
const QString &  mediaType,
const THtmlAttribute attributes 
) const
inline
QString TViewHelper::inlineImageTag ( const QByteArray &  data,
const QString &  mediaType,
const QSize &  size = QSize(),
const QString &  alt = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const
QString TViewHelper::inlineImageTag ( const QByteArray &  data,
const QString &  mediaType,
const THtmlAttribute attributes 
) const
inline

Creates a inline image tag with data and mediaType.

QString TViewHelper::inputAuthenticityTag ( ) const

Creates a input tag with a authenticity token for CSRF protection.

QString TViewHelper::inputFileTag ( const QString &  name,
const QVariant &  value,
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline
QString TViewHelper::inputFileTag ( const QString &  name,
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a input tag with type="file", name="name".

This function overloads inputTag().

QString TViewHelper::inputHiddenTag ( const QString &  name,
const QVariant &  value,
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a input tag with type="hidden", name="name" and value="value".

This function overloads inputTag().

QString TViewHelper::inputPasswordTag ( const QString &  name,
const QVariant &  value,
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a input tag with type="password", name="name" and value="value".

This function overloads inputTag().

QString TViewHelper::inputTag ( const QString &  type,
const QString &  name,
const QVariant &  value,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a <input> input tag with type="type", name="name" and value="value".

QString TViewHelper::inputTextTag ( const QString &  name,
const QVariant &  value,
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a input tag with type="text", name="name" and value="value".

This function overloads inputTag().

QString TViewHelper::jsPath ( const QString &  src,
bool  withTimestamp = true 
) const

Returns a javascript path to src.

The src must be one of URL, a absolute path or a relative path. If src is a relative path, it must exist in the public/js directory.

QString TViewHelper::linkTo ( const QString &  text,
const QUrl &  url,
Tf::HttpMethod  method = Tf::Get,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a <a> link tag of the given text using the given URL url and HTML attributes attributes.

If method is Tf::Post, the link submits a POST request instead of GET.

QString TViewHelper::linkTo ( const QString &  text,
const QUrl &  url,
Tf::HttpMethod  method,
const QString &  jsCondition,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a <a> link tag of the given text using the given url.

This is an overloaded function. The jsCondition argument serves for for creating Javascript confirm alerts where if you pass 'confirm' => 'Are you sure?', the link will be guarded with a Javascript popup asking that question. If the user accepts, the link is processed, otherwise not.

QString TViewHelper::linkToFunction ( const QString &  text,
const QString &  function,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a <a> link tag whose onclick handler triggers the passed JavaScript.

QString TViewHelper::linkToIf ( bool  condition,
const QString &  text,
const QUrl &  url,
Tf::HttpMethod  method = Tf::Get,
const QString &  jsCondition = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a <a> link tag of the given text using the given url.

This is an overloaded function. Returns a link tag if condition is true; otherwise returns a null string.

QString TViewHelper::linkToPopup ( const QString &  text,
const QUrl &  url,
const QString &  windowTitle = QString(),
const QSize &  size = QSize(),
const QPoint &  topLeft = QPoint(),
const QString &  windowStyle = QString(),
const QString &  jsCondition = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a <a> link tag of the given text using a given URL url in a popup window with the name windowName.

QString TViewHelper::linkToUnless ( bool  condition,
const QString &  text,
const QUrl &  url,
Tf::HttpMethod  method = Tf::Get,
const QString &  jsCondition = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const
inline

Creates a <a> link tag of the given text using the given url.

This is an overloaded function. Returns a link tag if condition is false; otherwise returns a null string.

QString TViewHelper::optionTag ( const QString &  text,
const QVariant &  value,
bool  selected = false,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a option tag for a select tag;.

QString TViewHelper::optionTags ( const QStringList &  valueList,
const QVariant &  selectedValue = QVariant(),
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates option tags for a select tag; The option tag which value is equal to selectedValue parameter is selected.

QString TViewHelper::optionTags ( const QVariantList &  valueList,
const QVariant &  selectedValue = QVariant(),
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates option tags for a select tag; The option tag which value is equal to selectedValue parameter is selected.

QString TViewHelper::optionTags ( const QList< QPair< QString, QVariant >> &  valueList,
const QVariant &  selectedValue = QVariant(),
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates option tags for a select tag;.

QString TViewHelper::radioButtonTag ( const QString &  name,
const QVariant &  value,
bool  checked = false,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a input tag with type="radio", name="name" and value="value".

QString TViewHelper::radioButtonTag ( const QString &  name,
const QVariant &  value,
const QVariant &  checkedValue,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a input tag with type="radio", name="name" and value="value".

If the checkedValue parameter is equal to the value parameter, this radio button is checked.

QString TViewHelper::resetTag ( const QString &  value,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a input tag with type="reset" and value="value".

QString TViewHelper::scriptTag ( const QString &  src,
const THtmlAttribute attributes 
) const

Creates a <script> script tag with src="src".

The src must be one of URL, a absolute path or a relative path. If src is a relative path, it must exist in the public/js directory.

QString TViewHelper::scriptTag ( const QString &  src,
bool  withTimestamp = true,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a <script> script tag with src="src".

The src must be one of URL, a absolute path or a relative path. If src is a relative path, it must exist in the public/js directory.

QString TViewHelper::selectTag ( const QString &  name,
int  size = 1,
bool  multiple = false,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a select tag with name="name".

QString TViewHelper::selfClosingTag ( const QString &  name,
const THtmlAttribute attributes 
) const

Creates a self closing tag of name with the given HTML attributes attributes.

QString TViewHelper::srcPath ( const QString &  src,
const QString &  dir,
bool  withTimestamp = true 
) const

Returns a path to src.

The src must be one of URL, a absolute path or a relative path. If src is a relative path, it must exist in the public directory.

QString TViewHelper::styleSheetTag ( const QString &  src,
const THtmlAttribute attributes 
) const

Creates a <link> link tag for a style sheet with href="src".

The src must be one of URL, a absolute path or a relative path. If src is a relative path, it must exist in the public/css directory.

QString TViewHelper::styleSheetTag ( const QString &  src,
bool  withTimestamp = true,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a <link> link tag for a style sheet with href="src".

The src must be one of URL, a absolute path or a relative path. If src is a relative path, it must exist in the public/css directory.

QString TViewHelper::submitImageTag ( const QString &  src,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a input tag with type="image" and src="src".

The src must be one of URL, a absolute path or a relative path. If src is a relative path, it must exist in the public/images directory.

QString TViewHelper::submitTag ( const QString &  value,
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a input tag with type="submit" and value="value".

QString TViewHelper::tag ( const QString &  name,
const THtmlAttribute attributes 
)

Creates a start-tag of name with the given HTML attributes attributes.

QString TViewHelper::tag ( const QString &  name,
const THtmlAttribute attributes,
bool  selfClose 
)

Creates a start-tag of name with the given HTML attributes attributes.

QString TViewHelper::tag ( const QString &  name,
const THtmlAttribute attributes,
const QString &  content 
) const

Creates an HTML element composed of a start-tag of name with HTML attributes attributes, a content content and an end-tag.

QString TViewHelper::textAreaTag ( const QString &  name,
int  rows,
int  cols,
const QString &  content = QString(),
const THtmlAttribute attributes = THtmlAttribute() 
) const

Creates a <textarea> text area tag with name="name", rows="rows" and cols="cols".


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