7#include "notificationfilterproxymodel_p.h"
9using namespace NotificationManager;
11NotificationFilterProxyModel::NotificationFilterProxyModel(
QObject *parent)
14 setRecursiveFilteringEnabled(
true);
17NotificationFilterProxyModel::~NotificationFilterProxyModel() =
default;
26 if (m_urgencies != urgencies) {
27 m_urgencies = urgencies;
29 Q_EMIT urgenciesChanged();
33bool NotificationFilterProxyModel::showExpired()
const
38void NotificationFilterProxyModel::setShowExpired(
bool show)
40 if (m_showExpired != show) {
43 Q_EMIT showExpiredChanged();
47bool NotificationFilterProxyModel::showDismissed()
const
49 return m_showDismissed;
52void NotificationFilterProxyModel::setShowDismissed(
bool show)
54 if (m_showDismissed != show) {
55 m_showDismissed = show;
57 Q_EMIT showDismissedChanged();
61QStringList NotificationFilterProxyModel::blacklistedDesktopEntries()
const
63 return m_blacklistedDesktopEntries;
66void NotificationFilterProxyModel::setBlackListedDesktopEntries(
const QStringList &blacklist)
68 if (m_blacklistedDesktopEntries != blacklist) {
69 m_blacklistedDesktopEntries = blacklist;
71 Q_EMIT blacklistedDesktopEntriesChanged();
75QStringList NotificationFilterProxyModel::blacklistedNotifyRcNames()
const
77 return m_blacklistedNotifyRcNames;
80void NotificationFilterProxyModel::setBlacklistedNotifyRcNames(
const QStringList &blacklist)
82 if (m_blacklistedNotifyRcNames != blacklist) {
83 m_blacklistedNotifyRcNames = blacklist;
85 Q_EMIT blacklistedNotifyRcNamesChanged();
89QStringList NotificationFilterProxyModel::whitelistedDesktopEntries()
const
91 return m_whitelistedDesktopEntries;
94void NotificationFilterProxyModel::setWhiteListedDesktopEntries(
const QStringList &whitelist)
96 if (m_whitelistedDesktopEntries != whitelist) {
97 m_whitelistedDesktopEntries = whitelist;
99 Q_EMIT whitelistedDesktopEntriesChanged();
103QStringList NotificationFilterProxyModel::whitelistedNotifyRcNames()
const
105 return m_whitelistedNotifyRcNames;
108void NotificationFilterProxyModel::setWhitelistedNotifyRcNames(
const QStringList &whitelist)
110 if (m_whitelistedNotifyRcNames != whitelist) {
111 m_whitelistedNotifyRcNames = whitelist;
113 Q_EMIT whitelistedNotifyRcNamesChanged();
117bool NotificationFilterProxyModel::filterAcceptsRow(
int source_row,
const QModelIndex &source_parent)
const
119 const QModelIndex sourceIdx = sourceModel()->index(source_row, 0, source_parent);
122 if (!m_showExpired && expired) {
136 desktopEntry = QStringLiteral(
"@other");
141 if (!m_blacklistedDesktopEntries.isEmpty()) {
142 if (!desktopEntry.
isEmpty() && m_blacklistedDesktopEntries.contains(desktopEntry)) {
147 if (!m_blacklistedNotifyRcNames.isEmpty()) {
149 if (!notifyRcName.
isEmpty() && m_blacklistedNotifyRcNames.contains(notifyRcName)) {
154 if (!m_whitelistedDesktopEntries.isEmpty()) {
155 if (!desktopEntry.
isEmpty() && m_whitelistedDesktopEntries.contains(desktopEntry)) {
160 if (!m_whitelistedNotifyRcNames.isEmpty()) {
162 if (!notifyRcName.
isEmpty() && m_whitelistedNotifyRcNames.contains(notifyRcName)) {
168 if (userActionFeedback) {
175 if (!m_urgencies.testFlag(urgency)) {
@ NotificationType
This item represents a notification.
Urgency
The notification urgency.
@ ConfigurableRole
Whether the notification can be configured because a desktopEntry or notifyRcName is known,...
@ NotifyRcNameRole
The notifyrc name (e.g. spectaclerc) of the application that sent the notification.
@ DismissedRole
The notification got temporarily hidden by the user but could still be interacted with.
@ DesktopEntryRole
The desktop entry (without .desktop suffix, e.g. org.kde.spectacle) of the application that sent the ...
@ ExpiredRole
The notification timed out and closed. Actions on it cannot be invoked anymore.
@ UserActionFeedbackRole
Whether this notification is a response/confirmation to an explicit user action.
@ UrgencyRole
The notification urgency, either LowUrgency, NormalUrgency, or CriticalUrgency. Jobs do not have an u...
@ TypeRole
The type of model entry, either NotificationType or JobType.
QVariant data(int role) const const
bool isEmpty() const const
bool toBool() const const
int toInt(bool *ok) const const
QString toString() const const