Changeset View
Changeset View
Standalone View
Standalone View
libnotificationmanager/notificationfilterproxymodel.cpp
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Line(s) | |||||
132 | { | 132 | { | ||
133 | const QModelIndex sourceIdx = sourceModel()->index(source_row, 0, source_parent); | 133 | const QModelIndex sourceIdx = sourceModel()->index(source_row, 0, source_parent); | ||
134 | 134 | | |||
135 | const bool expired = sourceIdx.data(Notifications::ExpiredRole).toBool(); | 135 | const bool expired = sourceIdx.data(Notifications::ExpiredRole).toBool(); | ||
136 | if (!m_showExpired && expired) { | 136 | if (!m_showExpired && expired) { | ||
137 | return false; | 137 | return false; | ||
138 | } | 138 | } | ||
139 | 139 | | |||
140 | // If the application isn't configurable in any way, it doesn't deserve to be in the history | 140 | if (!m_showDismissed && sourceIdx.data(Notifications::DismissedRole).toBool()) { | ||
141 | // since there's no way for the user to get rid of it there. | | |||
142 | if (expired && !sourceIdx.data(Notifications::ConfigurableRole).toBool() | | |||
143 | // jobs are never configurable so this only applies to notifications | | |||
144 | && sourceIdx.data(Notifications::TypeRole).toInt() == Notifications::NotificationType) { | | |||
145 | return false; | 141 | return false; | ||
146 | } | 142 | } | ||
147 | 143 | | |||
148 | if (!m_showDismissed && sourceIdx.data(Notifications::DismissedRole).toBool()) { | 144 | QString desktopEntry = sourceIdx.data(Notifications::DesktopEntryRole).toString(); | ||
149 | return false; | 145 | if (desktopEntry.isEmpty()) { | ||
146 | // For non-configurable notifications use the fake "@other" category. | ||||
147 | if (!sourceIdx.data(Notifications::ConfigurableRole).toBool() | ||||
148 | // jobs are never configurable so this only applies to notifications | ||||
149 | && sourceIdx.data(Notifications::TypeRole).toInt() == Notifications::NotificationType) { | ||||
150 | desktopEntry = QStringLiteral("@other"); | ||||
151 | } | ||||
150 | } | 152 | } | ||
151 | 153 | | |||
152 | // Blacklist takes precedence over whitelist, i.e. when in doubt don't show | 154 | // Blacklist takes precedence over whitelist, i.e. when in doubt don't show | ||
153 | if (!m_blacklistedDesktopEntries.isEmpty()) { | 155 | if (!m_blacklistedDesktopEntries.isEmpty()) { | ||
154 | const QString desktopEntry = sourceIdx.data(Notifications::DesktopEntryRole).toString(); | | |||
155 | if (!desktopEntry.isEmpty() && m_blacklistedDesktopEntries.contains(desktopEntry)) { | 156 | if (!desktopEntry.isEmpty() && m_blacklistedDesktopEntries.contains(desktopEntry)) { | ||
156 | return false; | 157 | return false; | ||
157 | } | 158 | } | ||
158 | } | 159 | } | ||
159 | 160 | | |||
160 | if (!m_blacklistedNotifyRcNames.isEmpty()) { | 161 | if (!m_blacklistedNotifyRcNames.isEmpty()) { | ||
161 | const QString notifyRcName = sourceIdx.data(Notifications::NotifyRcNameRole).toString(); | 162 | const QString notifyRcName = sourceIdx.data(Notifications::NotifyRcNameRole).toString(); | ||
162 | if (!notifyRcName.isEmpty() && m_blacklistedNotifyRcNames.contains(notifyRcName)) { | 163 | if (!notifyRcName.isEmpty() && m_blacklistedNotifyRcNames.contains(notifyRcName)) { | ||
163 | return false; | 164 | return false; | ||
164 | } | 165 | } | ||
165 | } | 166 | } | ||
166 | 167 | | |||
167 | if (!m_whitelistedDesktopEntries.isEmpty()) { | 168 | if (!m_whitelistedDesktopEntries.isEmpty()) { | ||
168 | const QString desktopEntry = sourceIdx.data(Notifications::DesktopEntryRole).toString(); | | |||
169 | if (!desktopEntry.isEmpty() && m_whitelistedDesktopEntries.contains(desktopEntry)) { | 169 | if (!desktopEntry.isEmpty() && m_whitelistedDesktopEntries.contains(desktopEntry)) { | ||
170 | return true; | 170 | return true; | ||
171 | } | 171 | } | ||
172 | } | 172 | } | ||
173 | 173 | | |||
174 | if (!m_whitelistedNotifyRcNames.isEmpty()) { | 174 | if (!m_whitelistedNotifyRcNames.isEmpty()) { | ||
175 | const QString notifyRcName = sourceIdx.data(Notifications::NotifyRcNameRole).toString(); | 175 | const QString notifyRcName = sourceIdx.data(Notifications::NotifyRcNameRole).toString(); | ||
176 | if (!notifyRcName.isEmpty() && m_whitelistedNotifyRcNames.contains(notifyRcName)) { | 176 | if (!notifyRcName.isEmpty() && m_whitelistedNotifyRcNames.contains(notifyRcName)) { | ||
Show All 19 Lines |