MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / data

Method data

src/plugins/core/notify/gui/notificationmodel.cpp:49–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49QVariant NotificationModel::data(const QModelIndex &index, int role) const
50{
51 if (!index.isValid() || index.row() > (rowCount(QModelIndex()) - 1)) {
52 return QVariant();
53 }
54
55 EntityPtr entity = d->getEntityByRow(index.row());
56 if (entity) {
57 switch (role) {
58 case Qt::DecorationRole: {
59 auto type = entity->type();
60 switch (type) {
61 case NotificationEntity::Information:
62 return QIcon::fromTheme("notification_info");
63 case NotificationEntity::Warning:
64 return QIcon::fromTheme("notification_warning");
65 case NotificationEntity::Error:
66 return QIcon::fromTheme("notification_error");
67 }
68 }
69 case Qt::DisplayRole:
70 return entity->message();
71 case kActionsRole:
72 return entity->actions();
73 case kSourceRole: {
74 QString source = entity->name();
75 if (!source.isEmpty())
76 return tr("Source: %1").arg(source);
77 }
78 case kEntityRole:
79 return qVariantFromValue(entity);
80 default:
81 break;
82 }
83 }
84
85 return QVariant();
86}
87
88void NotificationModel::setNotifications(const QList<EntityPtr> &datas)
89{

Callers 4

editorEventMethod · 0.45
sizeHintMethod · 0.45
drawSourceTextMethod · 0.45
actionInfoListMethod · 0.45

Calls 9

rowMethod · 0.80
getEntityByRowMethod · 0.80
QModelIndexClass · 0.50
isValidMethod · 0.45
typeMethod · 0.45
messageMethod · 0.45
actionsMethod · 0.45
nameMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected