Changeset View
Changeset View
Standalone View
Standalone View
libnotificationmanager/notificationsmodel.cpp
Show First 20 Lines • Show All 302 Lines • ▼ Show 20 Line(s) | 255 | { | |||
---|---|---|---|---|---|
303 | 303 | | |||
304 | case Notifications::TimeoutRole: return notification.timeout(); | 304 | case Notifications::TimeoutRole: return notification.timeout(); | ||
305 | 305 | | |||
306 | case Notifications::ClosableRole: return true; | 306 | case Notifications::ClosableRole: return true; | ||
307 | case Notifications::ConfigurableRole: return notification.configurable(); | 307 | case Notifications::ConfigurableRole: return notification.configurable(); | ||
308 | case Notifications::ConfigureActionLabelRole: return notification.configureActionLabel(); | 308 | case Notifications::ConfigureActionLabelRole: return notification.configureActionLabel(); | ||
309 | 309 | | |||
310 | case Notifications::ExpiredRole: return notification.expired(); | 310 | case Notifications::ExpiredRole: return notification.expired(); | ||
311 | case Notifications::ReadRole: return notification.read(); | ||||
311 | } | 312 | } | ||
312 | 313 | | |||
313 | return QVariant(); | 314 | return QVariant(); | ||
314 | } | 315 | } | ||
315 | 316 | | |||
317 | bool NotificationsModel::setData(const QModelIndex &index, const QVariant &value, int role) | ||||
318 | { | ||||
319 | if (!checkIndex(index)) { | ||||
320 | return false; | ||||
321 | } | ||||
322 | | ||||
323 | Notification ¬ification = d->notifications[index.row()]; | ||||
324 | | ||||
325 | switch (role) { | ||||
326 | case Notifications::ReadRole: | ||||
327 | if (value.toBool() != notification.read()) { | ||||
328 | notification.setRead(value.toBool()); | ||||
329 | return true; | ||||
330 | } | ||||
331 | break; | ||||
332 | } | ||||
333 | | ||||
334 | return false; | ||||
335 | } | ||||
336 | | ||||
316 | int NotificationsModel::rowCount(const QModelIndex &parent) const | 337 | int NotificationsModel::rowCount(const QModelIndex &parent) const | ||
317 | { | 338 | { | ||
318 | if (parent.isValid()) { | 339 | if (parent.isValid()) { | ||
319 | return 0; | 340 | return 0; | ||
320 | } | 341 | } | ||
321 | 342 | | |||
322 | return d->notifications.count(); | 343 | return d->notifications.count(); | ||
323 | } | 344 | } | ||
▲ Show 20 Lines • Show All 163 Lines • Show Last 20 Lines |