Add fully-functional administration panel for administrators and dispatchers

This commit is contained in:
E. Kozlovskaya 2021-01-05 16:01:34 +07:00
parent bf599549ea
commit ff6901e3a9
22 changed files with 1257 additions and 42 deletions

View file

@ -4,6 +4,10 @@ QString Profession::title() const {
return mTitle;
}
void Profession::setTitle(const QString &newTitle) {
mTitle = newTitle;
}
PID Profession::pID() const {
return mPID;
}

View file

@ -16,6 +16,7 @@ public:
Profession() = default;
QString title() const;
void setTitle(const QString &newTitle);
PID pID() const;
static Profession createProfession(const QString &title);

View file

@ -29,6 +29,14 @@ QString User::patronymic() const {
return mPatronymic;
}
QString User::getFullName() const {
return QString("%1 %2 %3").arg(mSecondName).arg(mFirstName).arg(mPatronymic);
}
QString User::getFullNameShortForm() const {
return QString("%1 %2.%3.").arg(mSecondName).arg(mFirstName[0]).arg(mPatronymic[0]);
}
ProfessionsList User::getProfessions() const {
return mProfessions;
}
@ -69,11 +77,9 @@ bool User::addProfession(PID pid, ProfRank rank) {
if (mProfessions.size() >= 4) {
if (mCurrentProfession == mProfessions[0].getProfession()) {
mProfessions.remove(1);
}
else {
mProfessions.remove(0);
return false;
}
mProfessions.remove(0);
}
UserProfession up(pid, rank);
@ -91,12 +97,14 @@ bool User::setCurrentProfession(PID pid) {
}
void User::removeProfession(PID pid) {
auto pred = [pid](UserProfession p) {
return p.getProfession() == pid;
};
mProfessions.erase(std::remove_if(mProfessions.begin(), mProfessions.end(), pred),
mProfessions.end());
auto pred = [pid](UserProfession p) { return p.getProfession() == pid; };
if (pid == mCurrentProfession) {
mCurrentProfession = 0;
}
mProfessions.erase(
std::remove_if(mProfessions.begin(), mProfessions.end(), pred),
mProfessions.end()
);
}
bool operator==(const User &l, const User &r) {

View file

@ -42,6 +42,8 @@ public:
QString firstName() const;
QString secondName() const;
QString patronymic() const;
QString getFullName() const;
QString getFullNameShortForm() const;
ProfessionsList getProfessions() const;
PID getCurrentProfession() const;

View file

@ -3,6 +3,7 @@
UserProfession::UserProfession(PID pid, ProfRank rank) {
mProfession = pid;
mRank = rank;
mAcquired = QDate::currentDate();
}
PID UserProfession::getProfession() const {