From 08028d5c57d134fb3d0ca9004730f0b2c99e5e67 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 4 Jul 2020 04:24:28 +0200 Subject: Refactor UserProfile --- src/ui/UserProfileModel.cpp | 63 --------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 src/ui/UserProfileModel.cpp (limited to 'src/ui/UserProfileModel.cpp') diff --git a/src/ui/UserProfileModel.cpp b/src/ui/UserProfileModel.cpp deleted file mode 100644 index 3fa8fe2d..00000000 --- a/src/ui/UserProfileModel.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "UserProfileModel.h" -#include - -UserProfileModel::UserProfileModel(QObject *parent) - : QAbstractListModel(parent) - , deviceList(nullptr) -{ - this->deviceList = new UserProfile(this); - - connect(this->deviceList, &UserProfile::userIdChanged, this, [this]() { - emit this->deviceList->updateDeviceList(); - }); - connect(this->deviceList, &UserProfile::deviceListUpdated, this, [this]() { - beginResetModel(); - this->beginInsertRows( - QModelIndex(), 0, this->deviceList->getDeviceList().size() - 1); - this->endInsertRows(); - endResetModel(); - }); -} - -int -UserProfileModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid() || !this->deviceList) - return 0; - return this->deviceList->getDeviceList().size(); -} - -QVariant -UserProfileModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() && - static_cast(this->deviceList->getDeviceList().size()) <= index.row()) - return QVariant(); - - const DeviceInfo device = this->deviceList->getDeviceList().at(index.row()); - switch (role) { - case DEVICEID: - return QVariant(device.device_id); - case DISPLAYNAME: - return QVariant(device.display_name); - case VERIFIED_STATUS: - return device.verification_status; - } - return QVariant(); -} - -QHash -UserProfileModel::roleNames() const -{ - QHash names; - names[DEVICEID] = "deviceID"; - names[DISPLAYNAME] = "displayName"; - names[VERIFIED_STATUS] = "verified_status"; - return names; -} - -UserProfile * -UserProfileModel::getList() const -{ - return (this->deviceList); -} -- cgit 1.5.1