itom 1.4.0
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2013, Institut für Technische Optik (ITO), 00005 Universität Stuttgart, Germany 00006 00007 This file is part of itom. 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 itom is distributed in the hope that it will be useful, but 00015 WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00017 General Public Licence for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with itom. If not, see <http://www.gnu.org/licenses/>. 00021 *********************************************************************** */ 00022 00023 #ifndef USEROGRANIZER_H 00024 #define USEROGRANIZER_H 00025 00026 #include "../global.h" 00027 #include <qobject.h> 00028 00029 #include "models/UserModel.h" 00030 00031 namespace ito 00032 { 00033 00034 class UserOrganizer : public QObject 00035 { 00036 Q_OBJECT 00037 00038 public: 00039 static UserOrganizer * getInstance(void); 00040 static RetVal closeInstance(void); 00041 00042 inline const QString getUserName() const { return m_userName; } 00043 inline int getUserRole() const { return m_userRole; } 00044 QString getUserID(void) const; 00045 00046 inline UserModel* getUserModel() const { return m_userModel; } 00047 00048 00049 ito::RetVal readUserDataFromFile(const QString &filename, QString &username, QString &uid, UserFeatures &features, UserRole &role); 00050 ito::RetVal writeUserDataToFile(const QString &username, const QString &uid, const UserFeatures &features, const UserRole &role); 00051 00052 UserFeatures getUserFeatures(void) const { return m_features; } 00053 00054 inline QString getSettingsFile() const { return m_settingsFile; }; 00055 ito::RetVal loadSettings(const QString &defUserName); 00056 00057 bool hasFeature(UserFeature feature) 00058 { 00059 return m_features.testFlag(feature); 00060 } 00061 00062 private: 00063 UserOrganizer(void); 00064 UserOrganizer(UserOrganizer &/*copyConstr*/) : QObject() {} 00065 ~UserOrganizer(void); 00066 static UserOrganizer *m_pUserOrganizer; 00067 00068 QString getUserID(const QString &iniFile) const; 00069 ito::RetVal scanSettingFilesAndLoadModel(); 00070 00071 UserRole m_userRole; /*< type of user: 0: "dumb" user, 1: admin user, 2: developer */ 00072 QString m_userName; /*< id of current user */ 00073 UserFeatures m_features; /*< switch for enabeling and disabeling functions of itom */ 00074 QString m_settingsFile; 00075 00076 QString m_strConstStdUser; 00077 00078 UserModel *m_userModel; 00079 00080 }; 00081 00082 } // namespace ito 00083 00084 #endif //USEROGRANIZER_H