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 Contains filter logic for a severity filter.
00041 If the message's severity text matches any of the text in the stored list
00042 then it is considered a match.
00043 """
00044 def __init__(self):
00045 super(SeverityFilter, self).__init__()
00046 self._selected_items = []
00047
00048 def set_selected_items(self, items):
00049 """
00050 Setter for selected items.
00051 :param list_: list of items to store for filtering ''list of QListWidgetItem''
00052 :emits filter_changed_signal: If _enabled is true
00053 """
00054 self._selected_items = items
00055 if self.is_enabled():
00056 self.start_emit_timer()
00057
00058 def has_filter(self):
00059 return len(self._selected_items) > 0
00060
00061 def test_message(self, message):
00062 """
00063 Tests if the message matches the filter.
00064 If the message's severity text matches any of the text in the stored list
00065 then it is considered a match.
00066 :param message: the message to be tested against the filters, ''Message''
00067 :returns: True if the message matches, ''bool''
00068 """
00069 if not self.is_enabled():
00070 return False
00071 for item in self._selected_items:
00072 if message.severity == item.data(Qt.UserRole):
00073 return True
00074 return False