Refactored code and possibly fixed a bug
This commit is contained in:
@ -5,7 +5,7 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
UserList&& loadUserList(const QString &file)
|
UserList loadUserList(const QString &file)
|
||||||
{
|
{
|
||||||
QFile doc{std::filesystem::path{file.toStdString()}};
|
QFile doc{std::filesystem::path{file.toStdString()}};
|
||||||
QString fileContents = doc.readAll();
|
QString fileContents = doc.readAll();
|
||||||
@ -23,10 +23,7 @@ UserList&& loadUserList(const QString &file)
|
|||||||
container.append(newUser);
|
container.append(newUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
UserList returnObj;
|
return container;
|
||||||
returnObj.setList(container);
|
|
||||||
|
|
||||||
return std::move(returnObj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveUserList(const UserList &list)
|
void saveUserList(const UserList &list)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "userlist.h"
|
#include "userlist.h"
|
||||||
|
|
||||||
UserList &&loadUserList(const QString &file);
|
UserList loadUserList(const QString &file);
|
||||||
void saveUserList(const UserList &list);
|
void saveUserList(const UserList &list);
|
||||||
|
|
||||||
#endif // SERIALIZATION_H
|
#endif // SERIALIZATION_H
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "userlist.h"
|
#include "userlist.h"
|
||||||
|
|
||||||
UserList::UserList() {}
|
UserList::UserList(const QVector<User> &list):
|
||||||
|
list{list}
|
||||||
|
{}
|
||||||
|
|
||||||
QVector<User> UserList::getList() const
|
QVector<User> UserList::getList() const
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@ class UserList: public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
UserList();
|
UserList(const QVector<User> &list);
|
||||||
|
|
||||||
QVector<User> getList() const;
|
QVector<User> getList() const;
|
||||||
void setList(const QVector<User> &newList);
|
void setList(const QVector<User> &newList);
|
||||||
|
Reference in New Issue
Block a user