Changeset View
Changeset View
Standalone View
Standalone View
src/core/entrywrapper.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2020 Dan Leinir Turthra Jensen <admin@leinir.dk> | ||||
3 | * | ||||
4 | * This library is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Lesser General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | * later version accepted by the membership of KDE e.V. (or its | ||||
9 | * successor approved by the membership of KDE e.V.), which shall | ||||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | * | ||||
12 | * This library is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | * Lesser General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU Lesser General Public | ||||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | * | ||||
20 | */ | ||||
21 | | ||||
22 | #ifndef ENTRYWRAPPER_H | ||||
23 | #define ENTRYWRAPPER_H | ||||
24 | | ||||
25 | #include <QObject> | ||||
26 | | ||||
27 | #include "entryinternal.h" | ||||
28 | #include "knewstuffcore_export.h" | ||||
29 | | ||||
30 | namespace KNSCore | ||||
31 | { | ||||
32 | // This is for passing an entryinternal through qml, particularly useful for lists | ||||
33 | // such as changedEntries. This is supposed to closely approximate the current | ||||
34 | // codepaths used in client code (which expects a list of entries), but for KF6 | ||||
35 | // we will want to turn this into a model instead, probably with some handy | ||||
36 | // iteration assistance for use in places which would previously use the lists. | ||||
37 | /// TODO KF6 see above (in short, make this class irrelevant so it can be removed) | ||||
38 | | ||||
39 | /** | ||||
40 | * @short Wraps a KNSCore::EntryInternal in a QObject for passing through Qt Quick | ||||
41 | * | ||||
42 | * For those places where we need to pass a KNSCore::EntryInternal through Qt Quick, | ||||
43 | * this class wraps such objects in a QObject, and provides the ability to interact | ||||
44 | * with the data through that. | ||||
45 | * | ||||
46 | * Since that class is not a QObject (and can't easily be turned into one), until major | ||||
47 | * upheaval becomes possible in Frameworks 6, this class will have to do. | ||||
48 | * @since 5.67 | ||||
49 | */ | ||||
50 | class KNEWSTUFFCORE_EXPORT EntryWrapper : public QObject | ||||
51 | { | ||||
52 | Q_OBJECT | ||||
53 | public: | ||||
54 | explicit EntryWrapper(const EntryInternal& entry, QObject *parent = nullptr); | ||||
55 | virtual ~EntryWrapper(); | ||||
56 | | ||||
57 | /** | ||||
58 | * Get a copy of the wrapped-up entry | ||||
59 | * @return A copy of the entry | ||||
60 | */ | ||||
61 | EntryInternal entry() const; | ||||
62 | private: | ||||
63 | class Private; | ||||
64 | Private *d; | ||||
65 | }; | ||||
66 | } | ||||
67 | Q_DECLARE_METATYPE(KNSCore::EntryWrapper*) | ||||
68 | | ||||
69 | #endif//ENTRYWRAPPER_H |