Remove subject filtering, keep only priority buttons
- Remove subject filter menu and related code - Simplify filtering to priority groups only - Keep Remove Filters button for priority reset - Clean up unused code and UI elements
This commit is contained in:
@@ -95,7 +95,6 @@ class MainApplication(QtWidgets.QApplication):
|
||||
self.messages_model = MessagesModel()
|
||||
self.messages_proxy_model = MessagesProxyModel()
|
||||
self.messages_proxy_model.setSourceModel(self.messages_model)
|
||||
self.messages_proxy_model.update_unique_titles() # Ensure initial update
|
||||
self.application_model = ApplicationModel()
|
||||
self.application_proxy_model = ApplicationProxyModel(self.application_model)
|
||||
|
||||
@@ -122,10 +121,6 @@ class MainApplication(QtWidgets.QApplication):
|
||||
self.main_window.priority_filter_changed.connect(
|
||||
self.on_priority_filter_changed
|
||||
)
|
||||
self.main_window.subject_filter_changed.connect(self.on_subject_filter_changed)
|
||||
self.messages_proxy_model.unique_titles_updated.connect(
|
||||
self.main_window.update_subject_filters
|
||||
)
|
||||
self.init_shortcuts()
|
||||
|
||||
self.gotify_client.listen()
|
||||
@@ -216,9 +211,6 @@ class MainApplication(QtWidgets.QApplication):
|
||||
def on_priority_filter_changed(self, priorities: set[int]):
|
||||
self.messages_proxy_model.set_allowed_priorities(priorities)
|
||||
|
||||
def on_subject_filter_changed(self, titles: set[str]):
|
||||
self.messages_proxy_model.set_allowed_titles(titles)
|
||||
|
||||
def abort_get_messages_task(self):
|
||||
"""
|
||||
Abort any tasks that will result in new messages getting appended to messages_model
|
||||
|
||||
@@ -77,9 +77,6 @@ class Ui_MainWindow(object):
|
||||
self.label_subject = QtWidgets.QLabel(parent=self.verticalLayoutWidget)
|
||||
self.label_subject.setObjectName("label_subject")
|
||||
self.filtersLayout.addWidget(self.label_subject)
|
||||
self.pb_subject = QtWidgets.QPushButton(parent=self.verticalLayoutWidget)
|
||||
self.pb_subject.setObjectName("pb_subject")
|
||||
self.filtersLayout.addWidget(self.pb_subject)
|
||||
self.pb_remove_filters = QtWidgets.QPushButton(parent=self.verticalLayoutWidget)
|
||||
self.pb_remove_filters.setObjectName("pb_remove_filters")
|
||||
self.filtersLayout.addWidget(self.pb_remove_filters)
|
||||
@@ -109,7 +106,6 @@ class Ui_MainWindow(object):
|
||||
self.pb_high.setText(_translate("MainWindow", "HIGH"))
|
||||
self.pb_critical.setText(_translate("MainWindow", "CRITICAL"))
|
||||
self.label_subject.setText(_translate("MainWindow", "Subject:"))
|
||||
self.pb_subject.setText(_translate("MainWindow", "Subject"))
|
||||
self.pb_remove_filters.setText(_translate("MainWindow", "Remove Filters"))
|
||||
|
||||
|
||||
|
||||
@@ -171,13 +171,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_subject">
|
||||
<property name="text">
|
||||
<string>Subject</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_remove_filters">
|
||||
<property name="text">
|
||||
|
||||
@@ -41,42 +41,14 @@ class MessagesModel(QtGui.QStandardItemModel):
|
||||
|
||||
|
||||
class MessagesProxyModel(QtCore.QSortFilterProxyModel):
|
||||
unique_titles_updated = QtCore.pyqtSignal(set)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.allowed_priorities = set(range(11)) # 0-10
|
||||
self.allowed_titles = set() # empty means all
|
||||
self.unique_titles = set()
|
||||
|
||||
def set_allowed_priorities(self, priorities: set[int]):
|
||||
self.allowed_priorities = priorities
|
||||
self.invalidateFilter()
|
||||
|
||||
def set_allowed_titles(self, titles: set[str]):
|
||||
print("Proxy setting allowed titles:", titles)
|
||||
self.allowed_titles = titles
|
||||
self.invalidateFilter()
|
||||
|
||||
def update_unique_titles(self):
|
||||
if not self.sourceModel():
|
||||
return
|
||||
titles = set()
|
||||
for row in range(self.sourceModel().rowCount()):
|
||||
index = self.sourceModel().index(row, 0)
|
||||
item = self.sourceModel().itemFromIndex(index)
|
||||
message = item.data(MessageItemDataRole.MessageRole)
|
||||
if message.title:
|
||||
titles.add(message.title)
|
||||
print("Unique titles found:", titles)
|
||||
for row in range(self.sourceModel().rowCount()):
|
||||
index = self.sourceModel().index(row, 0)
|
||||
item = self.sourceModel().itemFromIndex(index)
|
||||
message = item.data(MessageItemDataRole.MessageRole)
|
||||
print(f"Message {row}: title={message.title}, priority={message.priority}")
|
||||
self.unique_titles = titles
|
||||
self.unique_titles_updated.emit(self.unique_titles)
|
||||
|
||||
def filterAcceptsRow(
|
||||
self, source_row: int, source_parent: QtCore.QModelIndex
|
||||
) -> bool:
|
||||
@@ -86,10 +58,4 @@ class MessagesProxyModel(QtCore.QSortFilterProxyModel):
|
||||
priority = message.priority if message.priority is not None else 0
|
||||
if self.allowed_priorities and priority not in self.allowed_priorities:
|
||||
return False
|
||||
if (
|
||||
self.allowed_titles
|
||||
and message.title is not None
|
||||
and message.title not in self.allowed_titles
|
||||
):
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -28,7 +28,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
hidden = QtCore.pyqtSignal()
|
||||
activated = QtCore.pyqtSignal()
|
||||
priority_filter_changed = QtCore.pyqtSignal(set)
|
||||
subject_filter_changed = QtCore.pyqtSignal(set)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -100,10 +99,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
self.pb_critical.setChecked(True)
|
||||
self.pb_critical.setCheckable(False)
|
||||
|
||||
self.subject_menu = QtWidgets.QMenu(self.pb_subject)
|
||||
self.pb_subject.setMenu(self.subject_menu)
|
||||
self.subject_actions = {}
|
||||
|
||||
self.pb_remove_filters.clicked.connect(self.on_remove_filters_clicked)
|
||||
|
||||
# set refresh shortcut (usually ctrl-r)
|
||||
@@ -280,32 +275,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
priorities.add(9)
|
||||
self.priority_filter_changed.emit(priorities)
|
||||
|
||||
def on_subject_action_toggled(self):
|
||||
titles = set()
|
||||
for title, action in self.subject_actions.items():
|
||||
if action.isChecked():
|
||||
titles.add(title)
|
||||
print("Subject filter toggled, allowed titles:", titles)
|
||||
self.subject_filter_changed.emit(titles)
|
||||
|
||||
def on_remove_filters_clicked(self):
|
||||
# Reset priority buttons
|
||||
self.pb_low.setChecked(True)
|
||||
self.pb_normal.setChecked(True)
|
||||
self.pb_high.setChecked(True)
|
||||
# Critical is always on
|
||||
# Reset subject filters
|
||||
self.messages_proxy_model.set_allowed_titles(set())
|
||||
for action in self.subject_actions.values():
|
||||
action.setChecked(True)
|
||||
|
||||
def update_subject_filters(self, titles: set[str]):
|
||||
print("Updating subject filters with titles:", titles)
|
||||
self.subject_menu.clear()
|
||||
self.subject_actions.clear()
|
||||
for title in sorted(titles):
|
||||
action = self.subject_menu.addAction(title)
|
||||
action.setCheckable(True)
|
||||
action.setChecked(True)
|
||||
action.triggered.connect(self.on_subject_action_toggled)
|
||||
self.subject_actions[title] = action
|
||||
|
||||
Reference in New Issue
Block a user