File indexing completed on 2024-04-28 15:28:57

0001 /*
0002     SPDX-FileCopyrightText: 2020 Dan Leinir Turthra Jensen <admin@leinir.dk>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef ENTRYWRAPPER_H
0008 #define ENTRYWRAPPER_H
0009 
0010 #include <QObject>
0011 
0012 #include "entryinternal.h"
0013 #include "knewstuffcore_export.h"
0014 
0015 #include <memory>
0016 
0017 namespace KNSCore
0018 {
0019 // This is for passing an entryinternal through qml, particularly useful for lists
0020 // such as changedEntries. This is supposed to closely approximate the current
0021 // codepaths used in client code (which expects a list of entries), but for KF6
0022 // we will want to turn this into a model instead, probably with some handy
0023 // iteration assistance for use in places which would previously use the lists.
0024 /// TODO KF6 see above (in short, make this class irrelevant so it can be removed)
0025 
0026 class EntryWrapperPrivate;
0027 /**
0028  * @short Wraps a KNSCore::EntryInternal in a QObject for passing through Qt Quick
0029  *
0030  * For those places where we need to pass a KNSCore::EntryInternal through Qt Quick,
0031  * this class wraps such objects in a QObject, and provides the ability to interact
0032  * with the data through that.
0033  *
0034  * Since that class is not a QObject (and can't easily be turned into one), until major
0035  * upheaval becomes possible in Frameworks 6, this class will have to do.
0036  * @since 5.67
0037  */
0038 class KNEWSTUFFCORE_EXPORT EntryWrapper : public QObject
0039 {
0040     Q_OBJECT
0041 public:
0042     explicit EntryWrapper(const EntryInternal &entry, QObject *parent = nullptr);
0043     ~EntryWrapper() override;
0044 
0045     /**
0046      * Get a copy of the wrapped-up entry
0047      * @return A copy of the entry
0048      */
0049     EntryInternal entry() const;
0050 
0051 private:
0052     const std::unique_ptr<EntryWrapperPrivate> d;
0053 };
0054 }
0055 Q_DECLARE_METATYPE(KNSCore::EntryWrapper *)
0056 
0057 #endif // ENTRYWRAPPER_H