Port away from deprecated setRoleNames
This commit is contained in:
parent
665ba7481e
commit
968ccb22c6
4 changed files with 12 additions and 7 deletions
|
@ -54,12 +54,14 @@ DevicesModel::DevicesModel(QObject *parent)
|
|||
this, SLOT(deviceRemoved(QString)));
|
||||
|
||||
refreshDeviceList();
|
||||
}
|
||||
|
||||
//Role names for QML
|
||||
QHash<int, QByteArray> names = roleNames();
|
||||
QHash< int, QByteArray > DevicesModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> names = QAbstractItemModel::roleNames();
|
||||
names.insert(IdModelRole, "deviceId");
|
||||
names.insert(IconNameRole, "iconName");
|
||||
setRoleNames(names);
|
||||
return names;
|
||||
}
|
||||
|
||||
DevicesModel::~DevicesModel()
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
|
||||
DeviceDbusInterface* getDevice(const QModelIndex& index) const;
|
||||
virtual QHash<int, QByteArray> roleNames() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void deviceStatusChanged(const QString& id);
|
||||
|
|
|
@ -44,14 +44,15 @@ NotificationsModel::NotificationsModel(QObject* parent)
|
|||
|
||||
connect(this, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
|
||||
this, SIGNAL(anyDismissableChanged()));
|
||||
}
|
||||
|
||||
//Role names for QML
|
||||
QHash<int, QByteArray> names = roleNames();
|
||||
QHash<int, QByteArray> NotificationsModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> names = QAbstractItemModel::roleNames();
|
||||
names.insert(DbusInterfaceRole, "dbusInterface");
|
||||
names.insert(AppNameModelRole, "appName");
|
||||
names.insert(DismissableModelRole, "dismissable");
|
||||
setRoleNames(names);
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
NotificationsModel::~NotificationsModel()
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
NotificationDbusInterface* getNotification(const QModelIndex& index) const;
|
||||
|
||||
Q_INVOKABLE bool isAnyDimissable() const;
|
||||
virtual QHash<int, QByteArray> roleNames() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void dismissAll();
|
||||
|
|
Loading…
Reference in a new issue