Add user and profession entity
This commit is contained in:
parent
170a24670d
commit
f41052337c
7 changed files with 222 additions and 10 deletions
|
|
@ -10,10 +10,14 @@ CONFIG += c++11
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
loginwindow.cpp
|
loginwindow.cpp \
|
||||||
|
objects/profession.cpp \
|
||||||
|
objects/user.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
loginwindow.h
|
loginwindow.h \
|
||||||
|
objects/profession.h \
|
||||||
|
objects/user.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
loginwindow.ui
|
loginwindow.ui
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]) {
|
||||||
{
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
LoginWindow w;
|
LoginWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
32
iFacility/objects/profession.cpp
Normal file
32
iFacility/objects/profession.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include "profession.h"
|
||||||
|
|
||||||
|
QString Profession::title() const {
|
||||||
|
return mTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
PID Profession::pID() const {
|
||||||
|
return mPID;
|
||||||
|
}
|
||||||
|
|
||||||
|
Profession Profession::createProfession(const QString &title) {
|
||||||
|
Profession p;
|
||||||
|
|
||||||
|
p.mPID = QUuid::createUuid();
|
||||||
|
p.mTitle = title;
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const Profession &l, const Profession &r) {
|
||||||
|
return l.mPID == r.mPID;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream& operator<<(QDataStream &stream, const Profession &prof) {
|
||||||
|
stream << prof.mPID << prof.mTitle;
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream& operator>>(QDataStream &stream, Profession &prof) {
|
||||||
|
stream >> prof.mPID >> prof.mTitle;
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
28
iFacility/objects/profession.h
Normal file
28
iFacility/objects/profession.h
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef PROFESSION_H
|
||||||
|
#define PROFESSION_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QUuid>
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
typedef QUuid PID;
|
||||||
|
|
||||||
|
class Profession {
|
||||||
|
private:
|
||||||
|
PID mPID;
|
||||||
|
QString mTitle;
|
||||||
|
|
||||||
|
Profession() = default;
|
||||||
|
|
||||||
|
public:
|
||||||
|
QString title() const;
|
||||||
|
PID pID() const;
|
||||||
|
|
||||||
|
static Profession createProfession(const QString &title);
|
||||||
|
|
||||||
|
friend bool operator==(const Profession &l, const Profession &r);
|
||||||
|
friend QDataStream& operator<<(QDataStream &stream, const Profession &prof);
|
||||||
|
friend QDataStream& operator>>(QDataStream &stream, Profession &prof);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PROFESSION_H
|
||||||
78
iFacility/objects/user.cpp
Normal file
78
iFacility/objects/user.cpp
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
#include "user.h"
|
||||||
|
|
||||||
|
UID User::uID() const {
|
||||||
|
return mUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString User::getLogin() const {
|
||||||
|
return mLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool User::checkPassword(const QString &password) {
|
||||||
|
return mPassword == password;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString User::firstName() const {
|
||||||
|
return mFirstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString User::secondName() const {
|
||||||
|
return mSecondName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString User::patronymic() const {
|
||||||
|
return mPatronymic;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfessionsList User::getProfessions() const {
|
||||||
|
return mProfessions;
|
||||||
|
}
|
||||||
|
|
||||||
|
PID User::getCurrentProfession() const {
|
||||||
|
return mCurrentProfession;
|
||||||
|
}
|
||||||
|
|
||||||
|
User User::createUser(QString login, QString password,
|
||||||
|
QString firstName, QString secondName, QString patronymic) {
|
||||||
|
User u;
|
||||||
|
|
||||||
|
u.mUID = QUuid::createUuid();
|
||||||
|
u.mLogin = login;
|
||||||
|
u.mPassword = password;
|
||||||
|
u.mFirstName = firstName;
|
||||||
|
u.mSecondName = secondName;
|
||||||
|
u.mPatronymic = patronymic;
|
||||||
|
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool User::addProfession(const Profession &p) {
|
||||||
|
if (p.pID() == mCurrentProfession) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mProfessions.contains(p)) {
|
||||||
|
if (mProfessions.size() >= 4) {
|
||||||
|
mProfessions.remove(0);
|
||||||
|
}
|
||||||
|
mProfessions.push_back(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool User::setCurrentProfession(const Profession &p) {
|
||||||
|
if (!mProfessions.contains(p)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.pID() != mCurrentProfession) {
|
||||||
|
mCurrentProfession = p.pID();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void User::removeProfession(const Profession &p) {
|
||||||
|
mProfessions.removeAll(p);
|
||||||
|
}
|
||||||
44
iFacility/objects/user.h
Normal file
44
iFacility/objects/user.h
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
#ifndef USER_H
|
||||||
|
#define USER_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QUuid>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "profession.h"
|
||||||
|
|
||||||
|
typedef QUuid UID;
|
||||||
|
typedef QVector<Profession> ProfessionsList;
|
||||||
|
|
||||||
|
class User {
|
||||||
|
private:
|
||||||
|
UID mUID;
|
||||||
|
QString mLogin;
|
||||||
|
QString mPassword;
|
||||||
|
QString mFirstName;
|
||||||
|
QString mSecondName;
|
||||||
|
QString mPatronymic;
|
||||||
|
ProfessionsList mProfessions;
|
||||||
|
PID mCurrentProfession = 0;
|
||||||
|
|
||||||
|
User() = default;
|
||||||
|
|
||||||
|
public:
|
||||||
|
UID uID() const;
|
||||||
|
QString getLogin() const;
|
||||||
|
bool checkPassword(const QString &password);
|
||||||
|
QString firstName() const;
|
||||||
|
QString secondName() const;
|
||||||
|
QString patronymic() const;
|
||||||
|
ProfessionsList getProfessions() const;
|
||||||
|
PID getCurrentProfession() const;
|
||||||
|
|
||||||
|
static User createUser(QString login, QString password,
|
||||||
|
QString firstName, QString secondName, QString patronymic);
|
||||||
|
|
||||||
|
bool addProfession(const Profession &p);
|
||||||
|
bool setCurrentProfession(const Profession &p);
|
||||||
|
void removeProfession(const Profession &p);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USER_H
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.13.3, 2021-01-03T21:12:11. -->
|
<!-- Written by QtCreator 4.13.3, 2021-01-03T22:07:43. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
|
@ -56,7 +56,32 @@
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||||
<valuemap type="QVariantMap"/>
|
<valuemap type="QVariantMap">
|
||||||
|
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||||
|
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||||
|
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||||
|
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||||
|
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
|
||||||
|
<value type="QString">-fno-delayed-template-parsing</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
|
||||||
|
<value type="QString" key="ClangCodeModel.WarningConfigId">Builtin.Questionable</value>
|
||||||
|
<valuemap type="QVariantMap" key="ClangTools">
|
||||||
|
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||||
|
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||||
|
<value type="int" key="ClangTools.ParallelJobs">4</value>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||||
|
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
|
|
@ -300,19 +325,19 @@
|
||||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Admin/Documents/repos/iFacilityProject/iFacility/iFacility.pro</value>
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/Admin/Documents/repos/iFacilityProject/iFacility/iFacility.pro</value>
|
||||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
|
||||||
<value type="QString" key="RunConfiguration.Arguments"></value>
|
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||||
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
|
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
|
||||||
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
|
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
||||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/Admin/Documents/repos/build-iFacilityProject-Desktop_Qt_5_15_0_MinGW_64_bit-Debug/iFacility</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
</valuemap>
|
</valuemap>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue