1 | /* |
2 | SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <admin@leinir.dk> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
5 | */ |
6 | |
7 | #ifndef KNSCORE_COMMENTSMODEL_H |
8 | #define |
9 | |
10 | #include <QAbstractListModel> |
11 | #include <QDateTime> |
12 | |
13 | #include "enginebase.h" |
14 | |
15 | #include "knewstuffcore_export.h" |
16 | |
17 | #include <memory> |
18 | |
19 | namespace KNSCore |
20 | { |
21 | class Entry; |
22 | |
23 | struct { |
24 | QString ; |
25 | QString ; |
26 | QString ; |
27 | int = 0; |
28 | QString ; |
29 | QDateTime ; |
30 | int = 0; |
31 | std::shared_ptr<KNSCore::Comment> ; |
32 | }; |
33 | class ; |
34 | |
35 | /** |
36 | * @brief A model which takes care of the comments for a single Entry |
37 | * |
38 | * This model should preferably be constructed by asking the Engine to give a model |
39 | * instance to you for a specific entry using the commentsForEntry function. If you |
40 | * insist, you can construct an instance yourself as well, but this is not recommended. |
41 | * |
42 | * @see Engine::commentsForEntry(KNSCore::Entry) |
43 | * @since 5.63 |
44 | */ |
45 | class KNEWSTUFFCORE_EXPORT : public QAbstractListModel |
46 | { |
47 | Q_OBJECT |
48 | /** |
49 | * The Entry for which this model should handle comments |
50 | */ |
51 | Q_PROPERTY(KNSCore::Entry entry READ entry WRITE setEntry NOTIFY entryChanged) |
52 | public: |
53 | /** |
54 | * Construct a new CommentsModel instance. |
55 | * @note The class is intended to be constructed using the Engine::commentsForEntry function |
56 | * @see Engine::commentsForEntry(KNSCore::Entry) |
57 | */ |
58 | explicit (EngineBase *parent = nullptr); |
59 | () override; |
60 | |
61 | enum { |
62 | = Qt::DisplayRole, |
63 | = Qt::UserRole + 1, |
64 | , |
65 | , |
66 | , |
67 | , |
68 | , |
69 | , |
70 | , |
71 | }; |
72 | Q_ENUM(Roles) |
73 | |
74 | QHash<int, QByteArray> () const override; |
75 | QVariant (const QModelIndex &index, int role = Qt::DisplayRole) const override; |
76 | int (const QModelIndex &parent = QModelIndex()) const override; |
77 | bool (const QModelIndex &parent) const override; |
78 | void (const QModelIndex &parent) override; |
79 | |
80 | const KNSCore::Entry &() const; |
81 | void (const KNSCore::Entry &newEntry); |
82 | Q_SIGNAL void (); |
83 | |
84 | private: |
85 | friend class CommentsModelPrivate; // For beginResetModel and beginInsertRows method calls |
86 | const std::unique_ptr<CommentsModelPrivate> ; |
87 | }; |
88 | } |
89 | |
90 | #endif // KNSCORE_COMMENTSMODEL_H |
91 | |