Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 from .base_filter import BaseFilter
00034
00035 from python_qt_binding.QtCore import Qt
00036
00037
00038 class SeverityFilter(BaseFilter):
00039
00040 """
00041 Contains filter logic for a severity filter.
00042 If the message's severity text matches any of the text in the stored list
00043 then it is considered a match.
00044 """
00045
00046 def __init__(self):
00047 super(SeverityFilter, self).__init__()
00048 self._selected_items = []
00049
00050 def set_selected_items(self, items):
00051 """
00052 Setter for selected items.
00053 :param list_: list of items to store for filtering ''list of QListWidgetItem''
00054 :emits filter_changed_signal: If _enabled is true
00055 """
00056 self._selected_items = items
00057 if self.is_enabled():
00058 self.start_emit_timer()
00059
00060 def has_filter(self):
00061 return len(self._selected_items) > 0
00062
00063 def test_message(self, message):
00064 """
00065 Tests if the message matches the filter.
00066 If the message's severity text matches any of the text in the stored list
00067 then it is considered a match.
00068 :param message: the message to be tested against the filters, ''Message''
00069 :returns: True if the message matches, ''bool''
00070 """
00071 if not self.is_enabled():
00072 return False
00073 for item in self._selected_items:
00074 if message.severity == item.data(Qt.UserRole):
00075 return True
00076 return False