Port away from deprecated setRoleNames

This commit is contained in:
Aleix Pol 2014-09-23 19:27:47 +02:00
parent 665ba7481e
commit 968ccb22c6
4 changed files with 12 additions and 7 deletions

View file

@ -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()

View file

@ -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);

View file

@ -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()

View file

@ -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();