KNewStuff

core/commentsmodel.h
1 /*
2  SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <[email protected]>
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 KNSCORE_COMMENTSMODEL_H
9 
10 #include <QAbstractListModel>
11 #include <QDateTime>
12 
13 #include "engine.h"
14 
15 #include "knewstuffcore_export.h"
16 
17 namespace KNSCore
18 {
19 class EntryInternal;
20 
21 struct Comment {
22  QString id;
23  QString subject;
24  QString text;
25  int childCount = 0;
26  QString username;
27  QDateTime date;
28  int score = 0;
29  std::shared_ptr<KNSCore::Comment> parent;
30 };
31 
42 class KNEWSTUFFCORE_EXPORT CommentsModel : public QAbstractListModel
43 {
44  Q_OBJECT
48  Q_PROPERTY(KNSCore::EntryInternal entry READ entry WRITE setEntry NOTIFY entryChanged)
49 public:
55  explicit CommentsModel(Engine *parent = nullptr);
56  ~CommentsModel() override;
57 
58  enum Roles {
59  SubjectRole = Qt::DisplayRole,
60  IdRole = Qt::UserRole + 1,
61  TextRole,
62  ChildCountRole,
63  UsernameRole,
64  DateRole,
65  ScoreRole,
66  ParentIndexRole,
67  DepthRole
68  };
69  Q_ENUM(Roles)
70 
71  QHash< int, QByteArray > roleNames() const override;
72  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
73  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
74  bool canFetchMore(const QModelIndex &parent) const override;
75  void fetchMore(const QModelIndex &parent) override;
76 
77  const KNSCore::EntryInternal &entry() const;
78  void setEntry(const KNSCore::EntryInternal &newEntry);
79  Q_SIGNAL void entryChanged();
80 
81 private:
82  class Private;
83  Private *d;
84 };
85 }
86 
87 #endif//KNSCORE_COMMENTSMODEL_H
Contains the core functionality for handling interaction with NewStuff providers. ...
Comment
DisplayRole
A model which takes care of the comments for a single EntryInternal.
KNewStuff data entry container.
Definition: entryinternal.h:49
KNewStuff engine.
Definition: engine.h:59
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Aug 11 2020 22:43:23 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.