Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
Toggle main menu visibility
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1
/*
2
* Sailfin: a Jellyfin client written using Qt
3
* Copyright (C) 2022 Chris Josten and the Sailfin Contributors.
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
9
*
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
*/
19
#ifndef JELLYFIN_VIEWMODEL_UTILS_H
20
#define JELLYFIN_VIEWMODEL_UTILS_H
21
22
#include <QObject>
23
#include <QSharedPointer>
24
#include <QVariant>
25
41
template
<
typename
W,
typename
D>
42
W *
wrapQObject
(D data, QObject *parent) {
43
return
new
W(QSharedPointer<D>::create(data), parent);
44
}
45
53
template
<
typename
W,
typename
D,
typename
It>
54
QVariantList
wrapQVariantList
(It begin, It end, QObject *parent) {
55
QVariantList result;
56
for
(It it = begin; it != end; it++) {
57
result.append(QVariant::fromValue(
wrapQObject<W, D>
(*it, parent)));
58
}
59
return
result;
60
}
61
69
template
<
typename
W,
typename
D,
typename
It>
70
QObjectList
wrapQObjectList
(It begin, It end, QObject *parent) {
71
QObjectList result;
72
for
(It it = begin; it != end; it++) {
73
result.append(
wrapQObject<W, D>
(*it, parent));
74
}
75
return
result;
76
}
77
78
#endif
// JELLYFIN_VIEWMODEL_UTILS_H
wrapQObject
W * wrapQObject(D data, QObject *parent)
Wraps a data object in a QObject.
Definition
utils.h:42
wrapQObjectList
QObjectList wrapQObjectList(It begin, It end, QObject *parent)
Wraps a list of DTO items in a QObjectList.
Definition
utils.h:70
wrapQVariantList
QVariantList wrapQVariantList(It begin, It end, QObject *parent)
Wraps a list of DTO items in a QVariantList of QObject's.
Definition
utils.h:54
core
include
JellyfinQt
viewmodel
utils.h
Generated by
1.17.0