2018-01-09 00:59:16 +08:00
|
|
|
#ifndef USER_H
|
|
|
|
|
#define USER_H
|
|
|
|
|
|
2020-07-31 00:13:57 +08:00
|
|
|
#include <QtNut/table.h>
|
|
|
|
|
#include <QtNut/tableset.h>
|
2018-01-09 05:44:01 +08:00
|
|
|
|
|
|
|
|
#include <QtCore/QUuid>
|
|
|
|
|
#include <QtCore/QString>
|
2022-04-28 19:53:42 +08:00
|
|
|
#include <QSharedPointer>
|
2018-01-09 00:59:16 +08:00
|
|
|
|
|
|
|
|
#ifdef NUT_NAMESPACE
|
|
|
|
|
using namespace NUT_NAMESPACE;
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-04-28 19:53:42 +08:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
|
Q_MOC_INCLUDE("comment.h")
|
|
|
|
|
Q_MOC_INCLUDE("score.h")
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-01-09 01:07:26 +08:00
|
|
|
class Comment;
|
2018-01-14 22:03:24 +08:00
|
|
|
class Score;
|
2022-04-28 19:53:42 +08:00
|
|
|
class User : public NUT_WRAP_NAMESPACE(Table)
|
2018-01-09 00:59:16 +08:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
2021-01-27 22:50:31 +08:00
|
|
|
Q_PROPERTY(int id READ id WRITE setId NOTIFY idChanged)
|
|
|
|
|
Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged)
|
|
|
|
|
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
|
|
|
|
|
|
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)
|
2018-01-09 00:59:16 +08:00
|
|
|
|
|
|
|
|
NUT_NOT_NULL(username)
|
|
|
|
|
NUT_LEN(username, 50)
|
2021-01-27 22:50:31 +08:00
|
|
|
NUT_FIELD(QString, username)
|
2018-01-09 00:59:16 +08:00
|
|
|
|
|
|
|
|
NUT_NOT_NULL(password)
|
|
|
|
|
NUT_LEN(password, 50)
|
2021-01-27 22:50:31 +08:00
|
|
|
NUT_FIELD(QString, password)
|
2018-01-09 00:59:16 +08:00
|
|
|
|
|
|
|
|
NUT_DECLARE_CHILD_TABLE(Comment, comments)
|
2018-01-14 22:03:24 +08:00
|
|
|
NUT_DECLARE_CHILD_TABLE(Score, scores)
|
2018-01-09 00:59:16 +08:00
|
|
|
|
2021-01-27 22:50:31 +08:00
|
|
|
int m_id;
|
|
|
|
|
QString m_username;
|
|
|
|
|
QString m_password;
|
|
|
|
|
|
2018-01-09 00:59:16 +08:00
|
|
|
public:
|
2018-10-15 22:34:50 +08:00
|
|
|
Q_INVOKABLE User(QObject *parentTableSet = nullptr);
|
2021-01-27 22:50:31 +08:00
|
|
|
|
|
|
|
|
int id() const;
|
|
|
|
|
QString username() const;
|
|
|
|
|
QString password() const;
|
|
|
|
|
|
2021-03-14 16:42:04 +08:00
|
|
|
public Q_SLOTS:
|
2021-01-27 22:50:31 +08:00
|
|
|
void setId(int id);
|
|
|
|
|
void setUsername(QString username);
|
|
|
|
|
void setPassword(QString password);
|
|
|
|
|
|
2021-03-14 16:42:04 +08:00
|
|
|
Q_SIGNALS:
|
2021-01-27 22:50:31 +08:00
|
|
|
void idChanged(int id);
|
|
|
|
|
void usernameChanged(QString username);
|
|
|
|
|
void passwordChanged(QString password);
|
2018-01-09 00:59:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(User*)
|
|
|
|
|
|
|
|
|
|
#endif // USER_H
|