2016-05-12 14:08:58 +08:00
|
|
|
#ifndef COMMENT_H
|
|
|
|
|
#define COMMENT_H
|
|
|
|
|
|
|
|
|
|
#include <QtCore/qglobal.h>
|
|
|
|
|
#include <QtCore/QDateTime>
|
2020-07-31 00:13:57 +08:00
|
|
|
#include <QtNut/table.h>
|
2016-05-12 14:08:58 +08:00
|
|
|
|
2017-02-01 18:01:21 +08:00
|
|
|
#ifdef NUT_NAMESPACE
|
|
|
|
|
using namespace NUT_NAMESPACE;
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-05-12 14:08:58 +08:00
|
|
|
class Post;
|
2018-01-09 00:59:16 +08:00
|
|
|
class User;
|
2016-05-12 14:08:58 +08:00
|
|
|
class Comment : public Table
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
2021-01-27 22:50:31 +08:00
|
|
|
Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
|
|
|
|
|
Q_PROPERTY(QString message READ message WRITE setMessage NOTIFY messageChanged)
|
|
|
|
|
Q_PROPERTY(QDateTime saveDate READ saveDate WRITE setSaveDate NOTIFY saveDateChanged)
|
|
|
|
|
Q_PROPERTY(qreal point READ point WRITE setPoint NOTIFY pointChanged)
|
|
|
|
|
|
2019-02-08 17:11:53 +08:00
|
|
|
NUT_PRIMARY_AUTO_INCREMENT(id)
|
2021-01-27 22:50:31 +08:00
|
|
|
NUT_FIELD(int, id)
|
|
|
|
|
NUT_FIELD(QString, message)
|
|
|
|
|
NUT_FIELD(QDateTime, saveDate)
|
|
|
|
|
NUT_FIELD(qreal, point)
|
2016-05-12 14:08:58 +08:00
|
|
|
|
2019-06-26 23:06:44 +08:00
|
|
|
NUT_FOREIGN_KEY_DECLARE(Post, int, post, post, setPost)
|
|
|
|
|
NUT_FOREIGN_KEY_DECLARE(User, int, author, author, setAuthor)
|
2016-05-12 14:08:58 +08:00
|
|
|
|
2021-01-27 22:50:31 +08:00
|
|
|
int m_id;
|
|
|
|
|
QString m_message;
|
|
|
|
|
QDateTime m_saveDate;
|
|
|
|
|
qreal m_point;
|
|
|
|
|
|
2016-05-12 14:08:58 +08:00
|
|
|
public:
|
2018-10-15 22:34:50 +08:00
|
|
|
Q_INVOKABLE explicit Comment(QObject *parentTableSet = nullptr);
|
2021-01-27 22:50:31 +08:00
|
|
|
|
|
|
|
|
int id() const;
|
|
|
|
|
QString message() const;
|
|
|
|
|
QDateTime saveDate() const;
|
|
|
|
|
qreal point() const;
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void setId(int id);
|
|
|
|
|
void setMessage(QString message);
|
|
|
|
|
void setSaveDate(QDateTime saveDate);
|
|
|
|
|
void setPoint(qreal point);
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void idChanged(int id);
|
|
|
|
|
void messageChanged(QString message);
|
|
|
|
|
void saveDateChanged(QDateTime saveDate);
|
|
|
|
|
void pointChanged(qreal point);
|
2016-05-12 14:08:58 +08:00
|
|
|
};
|
|
|
|
|
|
2018-01-09 00:59:16 +08:00
|
|
|
Q_DECLARE_METATYPE(Comment*)
|
|
|
|
|
|
2016-05-12 14:08:58 +08:00
|
|
|
#endif // COMMENT_H
|