Add registration dialog and bare-minimum auth
This commit is contained in:
parent
42bf5da2a3
commit
1e30ca20e7
13 changed files with 658 additions and 41 deletions
56
iFacility/viewmodels/userprofessionviewmodel.cpp
Normal file
56
iFacility/viewmodels/userprofessionviewmodel.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include "userprofessionviewmodel.h"
|
||||
|
||||
UserProfessionViewModel::UserProfessionViewModel(QObject *parent) : QAbstractTableModel(parent) {
|
||||
|
||||
}
|
||||
|
||||
int UserProfessionViewModel::rowCount(const QModelIndex &/*parent*/) const {
|
||||
return mProfList.length();
|
||||
}
|
||||
|
||||
int UserProfessionViewModel::columnCount(const QModelIndex &/*parent*/) const {
|
||||
return 3;
|
||||
}
|
||||
|
||||
QVariant UserProfessionViewModel::headerData(int section,
|
||||
Qt::Orientation orientation, int role) const {
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
||||
switch (section) {
|
||||
case 0:
|
||||
return QString("Profession");
|
||||
case 1:
|
||||
return QString("Date of acquirement");
|
||||
case 2:
|
||||
return QString("Rank");
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant UserProfessionViewModel::data(const QModelIndex &index, int role) const {
|
||||
if (role == Qt::DisplayRole) {
|
||||
auto item = mProfList[index.row()];
|
||||
auto prof = Database::instance()->getProfession(item.getProfession());
|
||||
|
||||
int col = index.column();
|
||||
switch (col) {
|
||||
case 0:
|
||||
return prof == nullptr? "ERROR:UNKNOWN" : prof->title();
|
||||
case 1:
|
||||
return item.getAcquiredDate();
|
||||
case 2:
|
||||
return item.getRank();
|
||||
}
|
||||
|
||||
return "UNKNOWN FIELD";
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void UserProfessionViewModel::setProfessionsList(const ProfessionsList &profList) {
|
||||
beginResetModel();
|
||||
mProfList.clear();
|
||||
mProfList += profList;
|
||||
endResetModel();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue