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