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'' 76 msg = self._source_model._messages[sourcerow]
77 if self._exclude_filters.test_message(msg):
82 if self._highlight_filters.count_enabled_filters() > 0:
83 highlighted = self._highlight_filters.test_message(msg, default=
True)
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:
100 msg = self._source_model._messages[index.row()]
101 if not msg.highlighted:
102 return QBrush(Qt.gray)
103 return self._source_model.data(index, role)
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), [])
129 self._exclude_filters.append(newfilter)
132 self._highlight_filters.append(newfilter)
144 self.invalidateFilter()
def add_highlight_filter(self, newfilter)
def set_show_highlighted_only(self, show_highlighted_only)
def add_exclude_filter(self, newfilter)
def handle_highlight_filters_changed(self)
def filterAcceptsRow(self, sourcerow, sourceparent)
def setSourceModel(self, source_model)
def delete_exclude_filter(self, index)
def delete_highlight_filter(self, index)
def data(self, proxy_index, role=None)
def handle_exclude_filters_changed(self)