Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
Loading...
Searching...
No Matches
utils.h File Reference
#include <QObject>
#include <QSharedPointer>
#include <QVariant>

Go to the source code of this file.

Functions

template<typename W , typename D >
W * wrapQObject (D data, QObject *parent)
 Wraps a data object in a QObject.
 
template<typename W , typename D , typename It >
QVariantList wrapQVariantList (It begin, It end, QObject *parent)
 Wraps a list of DTO items in a QVariantList of QObject's.
 
template<typename W , typename D , typename It >
QObjectList wrapQObjectList (It begin, It end, QObject *parent)
 Wraps a list of DTO items in a QObjectList.
 

Function Documentation

◆ wrapQObject()

template<typename W , typename D >
W * wrapQObject ( D data,
QObject * parent )

Wraps a data object in a QObject.

This class is made for use in the ViewModel namespace, since many objects follow the pattern of having a constructor with a QSharedPointer<DTO::SomeItem> and a parent.

The QObject wrapper class W must have a accessible constructor which takes only a QSharedPointer<D> as argument.

Template Parameters
WThe QObject wrapper class
DThe DTO class
Parameters
dataThe data to wrap in a QObject
parentThe QObject to set as the parent of the newly created type.

◆ wrapQObjectList()

template<typename W , typename D , typename It >
QObjectList wrapQObjectList ( It begin,
It end,
QObject * parent )

Wraps a list of DTO items in a QObjectList.

See also
wrapQObject()
Parameters
beginThe begin iterator of the list of DTO items
endThe end iterator of the list of DTO items
parentThe QObject to set as the parent of the QObjects in the newly created list.

◆ wrapQVariantList()

template<typename W , typename D , typename It >
QVariantList wrapQVariantList ( It begin,
It end,
QObject * parent )

Wraps a list of DTO items in a QVariantList of QObject's.

See also
wrapQObject()
Parameters
beginThe begin iterator of the list of DTO items
endThe end iterator of the list of DTO items
parentThe QObject to set as the parent of the QObjects in the newly created list.