Nut/tests/auto/common/user.h

63 lines
1.3 KiB
C
Raw Normal View History

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>
2018-01-09 00:59:16 +08:00
#ifdef NUT_NAMESPACE
using namespace NUT_NAMESPACE;
#endif
2018-01-09 01:07:26 +08:00
class Comment;
2018-01-14 22:03:24 +08:00
class Score;
2018-01-09 05:44:01 +08:00
class User : public Nut::Table
2018-01-09 00:59:16 +08:00
{
Q_OBJECT
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)
NUT_FIELD(int, id)
2018-01-09 00:59:16 +08:00
NUT_NOT_NULL(username)
NUT_LEN(username, 50)
NUT_FIELD(QString, username)
2018-01-09 00:59:16 +08:00
NUT_NOT_NULL(password)
NUT_LEN(password, 50)
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
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);
int id() const;
QString username() const;
QString password() const;
public slots:
void setId(int id);
void setUsername(QString username);
void setPassword(QString password);
signals:
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