First version
This commit is contained in:
45
src/models/note.cpp
Executable file
45
src/models/note.cpp
Executable file
@@ -0,0 +1,45 @@
|
||||
#include "note.h"
|
||||
|
||||
Note::Note()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QJsonObject Note::toJson()
|
||||
{
|
||||
QJsonObject o;
|
||||
|
||||
o["title"] = this->title;
|
||||
o["content"] = this->content;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
Note *Note::fromJson(QJsonObject o)
|
||||
{
|
||||
Note *n = new Note();
|
||||
n->title = o["title"].toString();
|
||||
n->content = o["content"].toString();
|
||||
return n;
|
||||
}
|
||||
|
||||
QString Note::getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
QString Note::getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
void Note::setTitle(QString value)
|
||||
{
|
||||
this->title = value;
|
||||
}
|
||||
|
||||
void Note::setContent(QString value)
|
||||
{
|
||||
this->content = value;
|
||||
}
|
||||
|
||||
26
src/models/note.h
Executable file
26
src/models/note.h
Executable file
@@ -0,0 +1,26 @@
|
||||
#ifndef NOTE_H
|
||||
#define NOTE_H
|
||||
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
class Note
|
||||
{
|
||||
public:
|
||||
Note();
|
||||
|
||||
QJsonObject toJson();
|
||||
static Note* fromJson(QJsonObject o);
|
||||
|
||||
QString getTitle();
|
||||
QString getContent();
|
||||
|
||||
void setTitle(QString value);
|
||||
void setContent(QString value);
|
||||
|
||||
private:
|
||||
QString title;
|
||||
QString content;
|
||||
};
|
||||
|
||||
#endif // NOTE_H
|
||||
Reference in New Issue
Block a user