UsersVM small code style update

This commit is contained in:
Andrew nuark G 2020-12-22 22:31:25 +07:00
parent 9a4b71de36
commit fc9b61467c
2 changed files with 9 additions and 10 deletions

View file

@ -29,29 +29,29 @@ QVariant UsersViewModel::headerData(int section, Qt::Orientation orientation, in
QVariant UsersViewModel::data(const QModelIndex &index, int role) const { QVariant UsersViewModel::data(const QModelIndex &index, int role) const {
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
auto item = apparatus::instance()->get_auth_subsystem()->users()[index.row()]; auto item = apparatus::instance()->get_auth_subsystem()->users()[index.row()];
int col = index.column();
int col = index.column();
switch (col) { switch (col) {
case 0: case 0:
return QString::number(item.id()); return QString::number(item.id());
case 1: case 1:
return item.login(); return item.login();
case 2: case 2:
QString role = "unknown"; QString _role = "unknown";
switch(item.role()) { switch(item.role()) {
case UserRole::ADMINISTRATOR: case UserRole::ADMINISTRATOR:
role = "Administrator"; _role = "Administrator";
break; break;
case UserRole::DISPATCHER: case UserRole::DISPATCHER:
role = "Dispatcher"; _role = "Dispatcher";
break; break;
case UserRole::SKIPPER: case UserRole::SKIPPER:
role = "Skipper"; _role = "Skipper";
break; break;
} }
return role; return _role;
} }
return "UNKNOWN FIELD"; return "UNKNOWN FIELD";
@ -61,6 +61,5 @@ QVariant UsersViewModel::data(const QModelIndex &index, int role) const {
} }
void UsersViewModel::update() { void UsersViewModel::update() {
this->beginResetModel(); dataChanged(QModelIndex(), QModelIndex());
this->endResetModel();
} }

View file

@ -5,9 +5,9 @@
#include <QAbstractTableModel> #include <QAbstractTableModel>
class UsersViewModel : public QAbstractTableModel class UsersViewModel : public QAbstractTableModel {
{
Q_OBJECT Q_OBJECT
public: public:
UsersViewModel(QObject *parent = nullptr); UsersViewModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const;