From fc9b61467c1e16b5a76f16659454083531cdd1b5 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 22:31:25 +0700 Subject: [PATCH] UsersVM small code style update --- sea_transport/viewmodels/usersviewmodel.cpp | 15 +++++++-------- sea_transport/viewmodels/usersviewmodel.h | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/sea_transport/viewmodels/usersviewmodel.cpp b/sea_transport/viewmodels/usersviewmodel.cpp index ae938c2..72290fb 100644 --- a/sea_transport/viewmodels/usersviewmodel.cpp +++ b/sea_transport/viewmodels/usersviewmodel.cpp @@ -29,29 +29,29 @@ QVariant UsersViewModel::headerData(int section, Qt::Orientation orientation, in QVariant UsersViewModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) { auto item = apparatus::instance()->get_auth_subsystem()->users()[index.row()]; - int col = index.column(); + int col = index.column(); switch (col) { case 0: return QString::number(item.id()); case 1: return item.login(); case 2: - QString role = "unknown"; + QString _role = "unknown"; switch(item.role()) { case UserRole::ADMINISTRATOR: - role = "Administrator"; + _role = "Administrator"; break; case UserRole::DISPATCHER: - role = "Dispatcher"; + _role = "Dispatcher"; break; case UserRole::SKIPPER: - role = "Skipper"; + _role = "Skipper"; break; } - return role; + return _role; } return "UNKNOWN FIELD"; @@ -61,6 +61,5 @@ QVariant UsersViewModel::data(const QModelIndex &index, int role) const { } void UsersViewModel::update() { - this->beginResetModel(); - this->endResetModel(); + dataChanged(QModelIndex(), QModelIndex()); } diff --git a/sea_transport/viewmodels/usersviewmodel.h b/sea_transport/viewmodels/usersviewmodel.h index 2eda407..40e3813 100644 --- a/sea_transport/viewmodels/usersviewmodel.h +++ b/sea_transport/viewmodels/usersviewmodel.h @@ -5,9 +5,9 @@ #include -class UsersViewModel : public QAbstractTableModel -{ +class UsersViewModel : public QAbstractTableModel { Q_OBJECT + public: UsersViewModel(QObject *parent = nullptr); int rowCount(const QModelIndex &parent = QModelIndex()) const;