Commit 4e2d798a authored by Leander Schulten's avatar Leander Schulten
Browse files

Added saving to the UserManagment

parent 967b1611
......@@ -8,6 +8,7 @@
#include "device.h"
#include "programmprototype.h"
#include "programm.h"
#include "usermanagment.h"
namespace ApplicationData{
......@@ -36,6 +37,12 @@ QByteArray saveData(){
saveIDBaseObjects<Device>(o,"Devices");
saveIDBaseObjects<ProgrammPrototype>(o,"ProgrammPrototypes");
saveIDBaseObjects<Programm>(o,"Programms");
saveIDBaseObjects<Programm>(o,"Programms");
{
QJsonObject u;
UserManagment::get()->writeJsonObject(u);
o.insert("usermanagment",u);
}
return QJsonDocument(o).toJson();
}
......@@ -61,6 +68,7 @@ void loadData(QByteArray data){
loadIDBaseObjects<Device>(o,"Devices");
loadIDBaseObjects<ProgrammPrototype>(o,"ProgrammPrototypes");
loadIDBaseObjects<Programm>(o,"Programms");
UserManagment::get()->load(o["usermanagment"].toObject());
}
......
......@@ -3,6 +3,10 @@
#include <QJsonArray>
UserManagment::UserManagment(const QJsonObject &o){
load(o);
}
void UserManagment::load(const QJsonObject &o){
for(const auto o : o["user"].toArray()){
user.push_back(new User(o.toObject()));
}
......
......@@ -18,6 +18,7 @@ public:
enum Permission{Admin, Read, Write};
UserManagment();
UserManagment(const QJsonObject &o);
void load(const QJsonObject &o);
void writeJsonObject(QJsonObject &o)const;
void addUser(User * user);
Q_INVOKABLE void addUser(const QString & name, const QString & password);
......@@ -25,7 +26,7 @@ public:
Q_INVOKABLE bool changeUserName(User * user, const QString &newName,const QString &password);
Q_INVOKABLE bool changeUserPermission(User * user, Permission newPermission,const QString &password);
Q_INVOKABLE bool changeUserPasswort(User * user,const QString &password,const QString &newPassword);
const std::vector<User*>& getUser()const{return user;};
const std::vector<User*>& getUser()const{return user;}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment