33 from python_qt_binding.QtCore
import Qt, qVersion, qWarning
35 from python_qt_binding.QtCore
import QSortFilterProxyModel
37 from python_qt_binding.QtGui
import QSortFilterProxyModel
38 from python_qt_binding.QtGui
import QBrush, QColor
40 from .filters.filter_collection
import FilterCollection
41 from .message
import Message
47 Provides sorting and filtering capabilities for the MessageDataModel.
48 Filtering is based on a collection of exclude and highlight filters.
52 super(MessageProxyModel, self).
__init__()
53 self.setDynamicSortFilter(
True)
54 self.setFilterRole(Qt.UserRole)
55 self.setSortCaseSensitivity(Qt.CaseInsensitive)
56 self.setSortRole(Qt.UserRole)
73 returns: True if the row does not match any exclude filter AND (_show_highlighted_only is
74 False OR it matches any highlight filter), ''bool''
90 msg.highlighted = highlighted
94 def data(self, proxy_index, role=None):
96 Set colors of items based on highlight filters.
98 index = self.mapToSource(proxy_index)
99 if role == Qt.ForegroundRole:
101 if not msg.highlighted:
102 return QBrush(Qt.gray)
109 Invalidate filters and trigger refiltering.
111 self.invalidateFilter()
115 Invalidate filters and trigger refiltering.
118 self.invalidateFilter()
120 self.invalidateFilter()
121 if qVersion().startswith(
'4.'):
122 self.dataChanged.emit(
123 self.index(0, 0), self.index(self.rowCount() - 1, self.columnCount() - 1))
125 self.dataChanged.emit(
126 self.index(0, 0), self.index(self.rowCount() - 1, self.columnCount() - 1), [])
144 self.invalidateFilter()