setools/0001-Use-the-The-New-Python-Enums.patch
Petr Lautrbach 3eb6ca82a8 setools-4.4.3-2
- Use Qt 6
2023-09-05 13:28:08 +02:00

1896 lines
84 KiB
Diff

From abe184f4899cdab53f5b5c69f00c2eec64176517 Mon Sep 17 00:00:00 2001
From: Petr Lautrbach <lautrbach@redhat.com>
Date: Mon, 28 Aug 2023 19:07:06 +0200
Subject: [PATCH] Use the The New Python Enums
Content-type: text/plain
https://doc.qt.io/qtforpython-6/considerations.html#the-new-python-enums
In PyQt5, it's possible to use members of enums in the same scope as
enums, e.g. Qt.red. This is not possible in PyQt6, but both PyQt5 and
PyQt6 support the new python enums - Qt.GlobalColor.red
This change prepares the code for the future transition to PyQt6.
Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
---
setoolsgui/apol/analysistab.py | 2 +-
setoolsgui/apol/boolquery.py | 8 +++----
setoolsgui/apol/boundsquery.py | 6 +++---
setoolsgui/apol/categoryquery.py | 8 +++----
setoolsgui/apol/chooseanalysis.py | 2 +-
setoolsgui/apol/commonquery.py | 10 ++++-----
setoolsgui/apol/constraintquery.py | 10 ++++-----
setoolsgui/apol/defaultquery.py | 10 ++++-----
setoolsgui/apol/dta.py | 6 +++---
setoolsgui/apol/excludetypes.py | 12 +++++------
setoolsgui/apol/fsusequery.py | 6 +++---
setoolsgui/apol/genfsconquery.py | 6 +++---
setoolsgui/apol/ibendportconquery.py | 6 +++---
setoolsgui/apol/ibpkeyconquery.py | 6 +++---
setoolsgui/apol/infoflow.py | 8 +++----
setoolsgui/apol/initsidquery.py | 6 +++---
setoolsgui/apol/mainwindow.py | 32 ++++++++++++++--------------
setoolsgui/apol/mlsrulequery.py | 8 +++----
setoolsgui/apol/netifconquery.py | 6 +++---
setoolsgui/apol/nodeconquery.py | 8 +++----
setoolsgui/apol/objclassquery.py | 12 +++++------
setoolsgui/apol/permmapedit.py | 12 +++++------
setoolsgui/apol/portconquery.py | 8 +++----
setoolsgui/apol/rbacrulequery.py | 8 +++----
setoolsgui/apol/rolequery.py | 10 ++++-----
setoolsgui/apol/sensitivityquery.py | 8 +++----
setoolsgui/apol/terulequery.py | 16 +++++++-------
setoolsgui/apol/typeattrquery.py | 10 ++++-----
setoolsgui/apol/typequery.py | 10 ++++-----
setoolsgui/apol/userquery.py | 10 ++++-----
setoolsgui/apol/workspace.py | 8 +++----
setoolsgui/boolmodel.py | 4 ++--
setoolsgui/boundsmodel.py | 4 ++--
setoolsgui/commonmodel.py | 4 ++--
setoolsgui/constraintmodel.py | 4 ++--
setoolsgui/defaultmodel.py | 4 ++--
setoolsgui/details.py | 6 +++---
setoolsgui/fsusemodel.py | 4 ++--
setoolsgui/genfsconmodel.py | 4 ++--
setoolsgui/ibendportconmodel.py | 4 ++--
setoolsgui/ibpkeyconmodel.py | 4 ++--
setoolsgui/initsidmodel.py | 4 ++--
setoolsgui/listview.py | 6 +++---
setoolsgui/mlsmodel.py | 4 ++--
setoolsgui/mlsrulemodel.py | 4 ++--
setoolsgui/models.py | 12 +++++------
setoolsgui/netifconmodel.py | 4 ++--
setoolsgui/nodeconmodel.py | 4 ++--
setoolsgui/objclassmodel.py | 4 ++--
setoolsgui/portconmodel.py | 4 ++--
setoolsgui/rbacrulemodel.py | 4 ++--
setoolsgui/rolemodel.py | 4 ++--
setoolsgui/tableview.py | 6 +++---
setoolsgui/terulemodel.py | 4 ++--
setoolsgui/typeattrmodel.py | 4 ++--
setoolsgui/typemodel.py | 4 ++--
setoolsgui/usermodel.py | 4 ++--
57 files changed, 198 insertions(+), 198 deletions(-)
diff --git a/setoolsgui/apol/analysistab.py b/setoolsgui/apol/analysistab.py
index 1ed803419331..bc3629ff274a 100644
--- a/setoolsgui/apol/analysistab.py
+++ b/setoolsgui/apol/analysistab.py
@@ -100,7 +100,7 @@ class AnalysisTab(SEToolsWidget, QScrollArea, metaclass=TabRegistry):
self._check_query()
def _check_query(self):
- button = self.buttonBox.button(QDialogButtonBox.Apply)
+ button = self.buttonBox.button(QDialogButtonBox.StandardButton.Apply)
enabled = not self.errors
button.setEnabled(enabled)
button.setToolTip("Run the analysis." if enabled else "There are errors in the tab.")
diff --git a/setoolsgui/apol/boolquery.py b/setoolsgui/apol/boolquery.py
index 5b0cdd8b4322..6116fe48a846 100644
--- a/setoolsgui/apol/boolquery.py
+++ b/setoolsgui/apol/boolquery.py
@@ -57,13 +57,13 @@ class BoolQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
# set up processing thread
@@ -105,7 +105,7 @@ class BoolQueryTab(AnalysisTab):
def get_detail(self):
# .ui is set for single item selection.
index = self.bools.selectedIndexes()[0]
- item = self.bool_model.data(index, Qt.UserRole)
+ item = self.bool_model.data(index, Qt.ItemDataRole.UserRole)
self.log.debug("Generating detail window for {0}".format(item))
boolean_detail(self, item)
@@ -187,6 +187,6 @@ class BoolQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/boundsquery.py b/setoolsgui/apol/boundsquery.py
index 8944d1b7bf8a..5b90c2ee2ded 100644
--- a/setoolsgui/apol/boundsquery.py
+++ b/setoolsgui/apol/boundsquery.py
@@ -52,13 +52,13 @@ class BoundsQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(1, Qt.AscendingOrder)
+ self.table_results.sortByColumn(1, Qt.SortOrder.AscendingOrder)
# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.parent.palette()
self.error_palette = self.parent.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_parent_error()
self.clear_child_error()
@@ -189,6 +189,6 @@ class BoundsQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/categoryquery.py b/setoolsgui/apol/categoryquery.py
index 884b4156d75a..598f163c335f 100644
--- a/setoolsgui/apol/categoryquery.py
+++ b/setoolsgui/apol/categoryquery.py
@@ -57,13 +57,13 @@ class CategoryQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
# set up processing thread
@@ -105,7 +105,7 @@ class CategoryQueryTab(AnalysisTab):
def get_detail(self):
# .ui is set for single item selection.
index = self.cats.selectedIndexes()[0]
- item = self.category_model.data(index, Qt.UserRole)
+ item = self.category_model.data(index, Qt.ItemDataRole.UserRole)
self.log.debug("Generating detail window for {0}".format(item))
category_detail(self, item)
@@ -186,6 +186,6 @@ class CategoryQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/chooseanalysis.py b/setoolsgui/apol/chooseanalysis.py
index 892abdaac5f9..155ae6d2f4ae 100644
--- a/setoolsgui/apol/chooseanalysis.py
+++ b/setoolsgui/apol/chooseanalysis.py
@@ -52,7 +52,7 @@ class ChooseAnalysis(SEToolsWidget, QDialog):
groupitem.addChild(item)
self.analysisTypes.expandAll()
- self.analysisTypes.sortByColumn(0, Qt.AscendingOrder)
+ self.analysisTypes.sortByColumn(0, Qt.SortOrder.AscendingOrder)
super(ChooseAnalysis, self).show()
def accept(self, item=None):
diff --git a/setoolsgui/apol/commonquery.py b/setoolsgui/apol/commonquery.py
index e90ec543666b..8fb11e87290d 100644
--- a/setoolsgui/apol/commonquery.py
+++ b/setoolsgui/apol/commonquery.py
@@ -65,13 +65,13 @@ class CommonQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# setup indications of errors
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
# set up processing thread
@@ -116,7 +116,7 @@ class CommonQueryTab(AnalysisTab):
def get_detail(self):
# .ui is set for single item selection.
index = self.commons.selectedIndexes()[0]
- item = self.common_model.data(index, Qt.UserRole)
+ item = self.common_model.data(index, Qt.ItemDataRole.UserRole)
self.log.debug("Generating detail window for {0}".format(item))
common_detail(self, item)
@@ -146,7 +146,7 @@ class CommonQueryTab(AnalysisTab):
def set_perms(self):
selected_perms = []
for index in self.perms.selectionModel().selectedIndexes():
- selected_perms.append(self.perms_model.data(index, Qt.UserRole))
+ selected_perms.append(self.perms_model.data(index, Qt.ItemDataRole.UserRole))
self.query.perms = selected_perms
@@ -212,6 +212,6 @@ class CommonQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/constraintquery.py b/setoolsgui/apol/constraintquery.py
index cfa841b22cb5..ee64db0ca1df 100644
--- a/setoolsgui/apol/constraintquery.py
+++ b/setoolsgui/apol/constraintquery.py
@@ -84,7 +84,7 @@ class ConstraintQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.type_.palette()
self.error_palette = self.type_.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_user_error()
self.clear_type_error()
self.clear_role_error()
@@ -94,7 +94,7 @@ class ConstraintQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -173,7 +173,7 @@ class ConstraintQueryTab(AnalysisTab):
def set_tclass(self):
selected_classes = []
for index in self.tclass.selectionModel().selectedIndexes():
- selected_classes.append(self.class_model.data(index, Qt.UserRole))
+ selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole))
self.query.tclass = selected_classes
self.perms_model.set_classes(selected_classes)
@@ -187,7 +187,7 @@ class ConstraintQueryTab(AnalysisTab):
def set_perms(self):
selected_perms = []
for index in self.perms.selectionModel().selectedIndexes():
- selected_perms.append(self.perms_model.data(index, Qt.UserRole))
+ selected_perms.append(self.perms_model.data(index, Qt.ItemDataRole.UserRole))
self.query.perms = selected_perms
@@ -323,6 +323,6 @@ class ConstraintQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/defaultquery.py b/setoolsgui/apol/defaultquery.py
index 1efa3c468738..e09692ee6a46 100644
--- a/setoolsgui/apol/defaultquery.py
+++ b/setoolsgui/apol/defaultquery.py
@@ -52,7 +52,7 @@ class DefaultQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(1, Qt.AscendingOrder)
+ self.table_results.sortByColumn(1, Qt.SortOrder.AscendingOrder)
# populate class list
self.class_model = SEToolsListModel(self)
@@ -124,7 +124,7 @@ class DefaultQueryTab(AnalysisTab):
def set_tclass(self):
selected_classes = []
for index in self.tclass.selectionModel().selectedIndexes():
- selected_classes.append(self.class_model.data(index, Qt.UserRole))
+ selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole))
self.query.tclass = selected_classes
@@ -163,10 +163,10 @@ class DefaultQueryTab(AnalysisTab):
rule_types.append(mode.objectName())
self.query.ruletype = rule_types
- self.query.default = self.default_value.currentData(Qt.UserRole)
+ self.query.default = self.default_value.currentData(Qt.ItemDataRole.UserRole)
if self.default_range_value.isEnabled():
- self.query.default_range = self.default_range_value.currentData(Qt.UserRole)
+ self.query.default_range = self.default_range_value.currentData(Qt.ItemDataRole.UserRole)
else:
self.query.default_range = None
@@ -193,6 +193,6 @@ class DefaultQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/dta.py b/setoolsgui/apol/dta.py
index a78d96095b28..8bbed4dbe21f 100644
--- a/setoolsgui/apol/dta.py
+++ b/setoolsgui/apol/dta.py
@@ -62,7 +62,7 @@ class DomainTransitionAnalysisTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.source.palette()
self.error_palette = self.source.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_source_error()
self.clear_target_error()
@@ -281,7 +281,7 @@ class DomainTransitionAnalysisTab(AnalysisTab):
print_transition(self.browser_details.appendPlainText, current.rules)
- self.browser_details.moveCursor(QTextCursor.Start)
+ self.browser_details.moveCursor(QTextCursor.MoveOperation.Start)
if not current.child_populated:
self.busy.setLabelText("Gathering additional browser details for {0}...".format(
@@ -337,7 +337,7 @@ class DomainTransitionAnalysisTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
if self.flows_in.isChecked() or self.flows_out.isChecked():
# move to browser tab for transitions in/out
diff --git a/setoolsgui/apol/excludetypes.py b/setoolsgui/apol/excludetypes.py
index bee73c58dc66..1c4beaf84542 100644
--- a/setoolsgui/apol/excludetypes.py
+++ b/setoolsgui/apol/excludetypes.py
@@ -40,14 +40,14 @@ class ExcludeTypes(SEToolsWidget, QDialog):
if t not in self.initial_excluded_list]
self.included_sort = FilterByAttributeProxy(self)
self.included_sort.setSourceModel(self.included_model)
- self.included_sort.sort(0, Qt.AscendingOrder)
+ self.included_sort.sort(0, Qt.SortOrder.AscendingOrder)
self.included_types.setModel(self.included_sort)
self.excluded_model = SEToolsListModel(self)
self.excluded_model.item_list = self.initial_excluded_list
self.excluded_sort = FilterByAttributeProxy(self)
self.excluded_sort.setSourceModel(self.excluded_model)
- self.excluded_sort.sort(0, Qt.AscendingOrder)
+ self.excluded_sort.sort(0, Qt.SortOrder.AscendingOrder)
self.excluded_types.setModel(self.excluded_sort)
# connect signals
@@ -62,7 +62,7 @@ class ExcludeTypes(SEToolsWidget, QDialog):
selected_types = []
for index in self.excluded_types.selectionModel().selectedIndexes():
source_index = self.excluded_sort.mapToSource(index)
- item = self.excluded_model.data(source_index, Qt.UserRole)
+ item = self.excluded_model.data(source_index, Qt.ItemDataRole.UserRole)
self.included_model.append(item)
selected_types.append(item)
@@ -81,7 +81,7 @@ class ExcludeTypes(SEToolsWidget, QDialog):
selected_types = []
for index in self.included_types.selectionModel().selectedIndexes():
source_index = self.included_sort.mapToSource(index)
- item = self.included_model.data(source_index, Qt.UserRole)
+ item = self.included_model.data(source_index, Qt.ItemDataRole.UserRole)
self.excluded_model.append(item)
selected_types.append(item)
@@ -95,7 +95,7 @@ class ExcludeTypes(SEToolsWidget, QDialog):
def set_attr_filter(self, row):
index = self.attr_model.index(row)
- attr = self.attr_model.data(index, Qt.UserRole)
+ attr = self.attr_model.data(index, Qt.ItemDataRole.UserRole)
self.log.debug("Attribute set to {0!r}".format(attr))
self.included_sort.attr = attr
self.excluded_sort.attr = attr
@@ -126,7 +126,7 @@ class FilterByAttributeProxy(QSortFilterProxyModel):
if self.attr:
source = self.sourceModel()
index = source.index(row)
- item = source.data(index, Qt.UserRole)
+ item = source.data(index, Qt.ItemDataRole.UserRole)
if item not in self.attr:
return False
diff --git a/setoolsgui/apol/fsusequery.py b/setoolsgui/apol/fsusequery.py
index 9bb192b30232..4e7567f4e4c6 100644
--- a/setoolsgui/apol/fsusequery.py
+++ b/setoolsgui/apol/fsusequery.py
@@ -74,7 +74,7 @@ class FSUseQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.type_.palette()
self.error_palette = self.type_.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_fs_error()
self.clear_user_error()
self.clear_type_error()
@@ -86,7 +86,7 @@ class FSUseQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(1, Qt.AscendingOrder)
+ self.table_results.sortByColumn(1, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -312,6 +312,6 @@ class FSUseQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/genfsconquery.py b/setoolsgui/apol/genfsconquery.py
index 22112a8fb7bf..33dbed787cd6 100644
--- a/setoolsgui/apol/genfsconquery.py
+++ b/setoolsgui/apol/genfsconquery.py
@@ -74,7 +74,7 @@ class GenfsconQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.type_.palette()
self.error_palette = self.type_.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_fs_error()
self.clear_path_error()
self.clear_user_error()
@@ -87,7 +87,7 @@ class GenfsconQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -312,6 +312,6 @@ class GenfsconQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/ibendportconquery.py b/setoolsgui/apol/ibendportconquery.py
index 6db99c2b5e0f..18252dd23de0 100644
--- a/setoolsgui/apol/ibendportconquery.py
+++ b/setoolsgui/apol/ibendportconquery.py
@@ -74,7 +74,7 @@ class IbendportconQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.type_.palette()
self.error_palette = self.type_.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
self.clear_port_error()
self.clear_user_error()
@@ -87,7 +87,7 @@ class IbendportconQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -304,6 +304,6 @@ class IbendportconQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/ibpkeyconquery.py b/setoolsgui/apol/ibpkeyconquery.py
index 3efd342145f1..b7a78bf908a0 100644
--- a/setoolsgui/apol/ibpkeyconquery.py
+++ b/setoolsgui/apol/ibpkeyconquery.py
@@ -74,7 +74,7 @@ class IbpkeyconQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.type_.palette()
self.error_palette = self.type_.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_subnet_prefix_error()
self.clear_pkeys_error()
self.clear_user_error()
@@ -87,7 +87,7 @@ class IbpkeyconQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -317,6 +317,6 @@ class IbpkeyconQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/infoflow.py b/setoolsgui/apol/infoflow.py
index fb9b4099cfc0..526f3074e143 100644
--- a/setoolsgui/apol/infoflow.py
+++ b/setoolsgui/apol/infoflow.py
@@ -75,7 +75,7 @@ class InfoFlowAnalysisTab(AnalysisTab):
# set up error message for missing perm map
self.error_msg = QMessageBox(self)
- self.error_msg.setStandardButtons(QMessageBox.Ok)
+ self.error_msg.setStandardButtons(QMessageBox.StandardButton.Ok)
# set up perm map editor
self.permmap_editor = PermissionMapEditor(self, False)
@@ -93,7 +93,7 @@ class InfoFlowAnalysisTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.source.palette()
self.error_palette = self.source.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_source_error()
self.clear_target_error()
@@ -325,7 +325,7 @@ class InfoFlowAnalysisTab(AnalysisTab):
for rule in current.rules:
self.browser_details.appendPlainText(rule)
- self.browser_details.moveCursor(QTextCursor.Start)
+ self.browser_details.moveCursor(QTextCursor.MoveOperation.Start)
if not current.child_populated:
self.busy.setLabelText("Gathering additional browser details for {0}...".format(
@@ -390,7 +390,7 @@ class InfoFlowAnalysisTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
if self.flows_in.isChecked() or self.flows_out.isChecked():
# move to browser tab for flows in/out
diff --git a/setoolsgui/apol/initsidquery.py b/setoolsgui/apol/initsidquery.py
index b31c9986b3a5..d01f87130925 100644
--- a/setoolsgui/apol/initsidquery.py
+++ b/setoolsgui/apol/initsidquery.py
@@ -74,7 +74,7 @@ class InitialSIDQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.type_.palette()
self.error_palette = self.type_.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
self.clear_user_error()
self.clear_type_error()
@@ -86,7 +86,7 @@ class InitialSIDQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -287,6 +287,6 @@ class InitialSIDQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/mainwindow.py b/setoolsgui/apol/mainwindow.py
index 3cdb11d3e32e..dcbfb7590ef7 100644
--- a/setoolsgui/apol/mainwindow.py
+++ b/setoolsgui/apol/mainwindow.py
@@ -60,20 +60,20 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
# set up error message dialog
self.error_msg = QMessageBox(self)
- self.error_msg.setStandardButtons(QMessageBox.Ok)
+ self.error_msg.setStandardButtons(QMessageBox.StandardButton.Ok)
# set up permission map editor
self.permmap_editor = PermissionMapEditor(self, True)
# set up tab name editor
self.tab_editor = QLineEdit(self.AnalysisTabs)
- self.tab_editor.setWindowFlags(Qt.Popup)
+ self.tab_editor.setWindowFlags(Qt.WindowType.Popup)
# configure tab bar context menu
tabBar = self.AnalysisTabs.tabBar()
tabBar.addAction(self.rename_tab_action)
tabBar.addAction(self.close_tab_action)
- tabBar.setContextMenuPolicy(Qt.ActionsContextMenu)
+ tabBar.setContextMenuPolicy(Qt.ContextMenuPolicy.ActionsContextMenu)
# capture INFO and higher Python messages from setools lib for status bar
handler = LogHandlerToSignal()
@@ -127,9 +127,9 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
reply = QMessageBox.question(
self, "Continue?",
"Loading a policy will close all existing analyses. Continue?",
- QMessageBox.Yes | QMessageBox.No)
+ QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
- if reply == QMessageBox.No:
+ if reply == QMessageBox.StandardButton.No:
return
filename = QFileDialog.getOpenFileName(self, "Open policy file", ".",
@@ -163,9 +163,9 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
reply = QMessageBox.question(
self, "Continue?",
"Closing a policy will close all existing analyses. Continue?",
- QMessageBox.Yes | QMessageBox.No)
+ QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
- if reply == QMessageBox.No:
+ if reply == QMessageBox.StandardButton.No:
return
self.AnalysisTabs.clear()
@@ -245,7 +245,7 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
counted_name = "{0}: {1}".format(self.tab_counter, tabtitle)
newanalysis = tabclass(self, self._policy, self._permmap)
- newanalysis.setAttribute(Qt.WA_DeleteOnClose)
+ newanalysis.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
newanalysis.setObjectName(counted_name)
index = self.AnalysisTabs.addTab(newanalysis, counted_name)
@@ -444,9 +444,9 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
reply = QMessageBox.question(
self, "Continue?",
"Loading a workspace will close all existing analyses. Continue?",
- QMessageBox.Yes | QMessageBox.No)
+ QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
- if reply == QMessageBox.No:
+ if reply == QMessageBox.StandardButton.No:
return
# 2. try to load the workspace file, if we fail, bail
@@ -633,7 +633,7 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
def apol_help(self):
"""Open the main help window."""
- if self.help_process.state() != QProcess.NotRunning:
+ if self.help_process.state() != QProcess.ProcessState.NotRunning:
return
distro = pkg_resources.get_distribution("setools")
@@ -648,7 +648,7 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
@pyqtSlot(QProcess.ProcessError)
def help_failed(self, error):
"""Starting assistant failed."""
- if error != QProcess.FailedToStart:
+ if error != QProcess.ProcessError.FailedToStart:
return
self.log.error("Failed to start Qt assistant {}.".format(self.config.assistant))
@@ -669,9 +669,9 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
"This is typically in the assistant or qt5-assistant package. "
"Choose location of Qt Assistant executable?".format(
self.config.assistant),
- QMessageBox.Yes | QMessageBox.No)
+ QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
- if reply == QMessageBox.No:
+ if reply == QMessageBox.StandardButton.No:
return
filename = QFileDialog.getOpenFileName(self, "Location of qt-assistant executable",
@@ -689,12 +689,12 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
@pyqtSlot(str)
def set_help(self, location):
"""Set the help window to the specified document."""
- if self.help_process.state() == QProcess.NotStarted:
+ if self.help_process.state() == QProcess.ProcessState.NotRunning:
self.apol_help()
if not self.help_process.waitForStarted():
self.log.warning("Timed out waiting for Qt assistant to start.")
return
- elif self.help_process.state() == QProcess.Starting:
+ elif self.help_process.state() == QProcess.ProcessState.Starting:
if not self.help_process.waitForStarted():
self.log.warning("Timed out waiting for Qt assistant to start.")
return
diff --git a/setoolsgui/apol/mlsrulequery.py b/setoolsgui/apol/mlsrulequery.py
index ba2be4597982..bb554ade6657 100644
--- a/setoolsgui/apol/mlsrulequery.py
+++ b/setoolsgui/apol/mlsrulequery.py
@@ -61,7 +61,7 @@ class MLSRuleQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.source.palette()
self.error_palette = self.source.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_source_error()
self.clear_target_error()
self.clear_default_error()
@@ -76,7 +76,7 @@ class MLSRuleQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(1, Qt.AscendingOrder)
+ self.table_results.sortByColumn(1, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -181,7 +181,7 @@ class MLSRuleQueryTab(AnalysisTab):
def set_tclass(self):
selected_classes = []
for index in self.tclass.selectionModel().selectedIndexes():
- selected_classes.append(self.class_model.data(index, Qt.UserRole))
+ selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole))
self.query.tclass = selected_classes
@@ -264,6 +264,6 @@ class MLSRuleQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/netifconquery.py b/setoolsgui/apol/netifconquery.py
index ca2405f7cae6..4cf3de1a9f5c 100644
--- a/setoolsgui/apol/netifconquery.py
+++ b/setoolsgui/apol/netifconquery.py
@@ -74,7 +74,7 @@ class NetifconQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.type_.palette()
self.error_palette = self.type_.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
self.clear_user_error()
self.clear_type_error()
@@ -86,7 +86,7 @@ class NetifconQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -287,6 +287,6 @@ class NetifconQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/nodeconquery.py b/setoolsgui/apol/nodeconquery.py
index 320b0d616a67..81a33a794c05 100644
--- a/setoolsgui/apol/nodeconquery.py
+++ b/setoolsgui/apol/nodeconquery.py
@@ -80,7 +80,7 @@ class NodeconQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.type_.palette()
self.error_palette = self.type_.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_network_error()
self.clear_user_error()
self.clear_type_error()
@@ -92,7 +92,7 @@ class NodeconQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -263,7 +263,7 @@ class NodeconQueryTab(AnalysisTab):
def run(self, button):
# right now there is only one button.
self.query.network_overlap = self.network_overlap.isChecked()
- self.query.ip_version = self.ip_version.currentData(Qt.UserRole)
+ self.query.ip_version = self.ip_version.currentData(Qt.ItemDataRole.UserRole)
self.query.range_overlap = self.range_overlap.isChecked()
self.query.range_subset = self.range_subset.isChecked()
self.query.range_superset = self.range_superset.isChecked()
@@ -291,6 +291,6 @@ class NodeconQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/objclassquery.py b/setoolsgui/apol/objclassquery.py
index 9744a187ade7..23c8188e8bbd 100644
--- a/setoolsgui/apol/objclassquery.py
+++ b/setoolsgui/apol/objclassquery.py
@@ -66,13 +66,13 @@ class ObjClassQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
# set up processing thread
@@ -117,7 +117,7 @@ class ObjClassQueryTab(AnalysisTab):
def get_detail(self):
# .ui is set for single item selection.
index = self.classes.selectedIndexes()[0]
- item = self.class_model.data(index, Qt.UserRole)
+ item = self.class_model.data(index, Qt.ItemDataRole.UserRole)
self.log.debug("Generating detail window for {0}".format(item))
class_detail(self, item)
@@ -146,7 +146,7 @@ class ObjClassQueryTab(AnalysisTab):
#
def set_common(self):
for index in self.common.selectionModel().selectedIndexes():
- self.query.common = self.common_model.data(index, Qt.UserRole)
+ self.query.common = self.common_model.data(index, Qt.ItemDataRole.UserRole)
break
else:
self.query.common = None
@@ -157,7 +157,7 @@ class ObjClassQueryTab(AnalysisTab):
def set_perms(self):
selected_perms = []
for index in self.perms.selectionModel().selectedIndexes():
- selected_perms.append(self.perms_model.data(index, Qt.UserRole))
+ selected_perms.append(self.perms_model.data(index, Qt.ItemDataRole.UserRole))
self.query.perms = selected_perms
@@ -224,6 +224,6 @@ class ObjClassQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/permmapedit.py b/setoolsgui/apol/permmapedit.py
index 97482b30e1a2..d1e0b01ce854 100644
--- a/setoolsgui/apol/permmapedit.py
+++ b/setoolsgui/apol/permmapedit.py
@@ -86,7 +86,7 @@ class PermissionMapEditor(SEToolsWidget, QDialog):
def class_selected(self):
# the .ui is set to 1 selection
for index in self.classes.selectionModel().selectedIndexes():
- class_name = self.class_model.data(index, Qt.DisplayRole)
+ class_name = self.class_model.data(index, Qt.ItemDataRole.DisplayRole)
self.log.debug("Setting class to {0}".format(class_name))
@@ -99,15 +99,15 @@ class PermissionMapEditor(SEToolsWidget, QDialog):
for perm in sorted(self.perm_map.perms(class_name)):
# create permission mapping
mapping = PermissionMapping(self, perm, self.edit)
- mapping.setAttribute(Qt.WA_DeleteOnClose)
+ mapping.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
self.class_toggle.connect(mapping.enabled.setChecked)
self.perm_mappings.addWidget(mapping)
self.widgets.append(mapping)
# add horizonal line
line = QFrame(self)
- line.setFrameShape(QFrame.HLine)
- line.setFrameShadow(QFrame.Sunken)
+ line.setFrameShape(QFrame.Shape.HLine)
+ line.setFrameShadow(QFrame.Shadow.Sunken)
self.perm_mappings.addWidget(line)
self.widgets.append(line)
@@ -179,8 +179,8 @@ class PermissionMapping(SEToolsWidget, QWidget):
# setup color palettes for direction
self.orig_palette = self.direction.palette()
self.error_palette = self.direction.palette()
- self.error_palette.setColor(QPalette.Button, Qt.red)
- self.error_palette.setColor(QPalette.ButtonText, Qt.white)
+ self.error_palette.setColor(QPalette.ColorRole.Button, Qt.GlobalColor.red)
+ self.error_palette.setColor(QPalette.ColorRole.ButtonText, Qt.GlobalColor.white)
# setup direction
self.direction.insertItems(0, index_to_word)
diff --git a/setoolsgui/apol/portconquery.py b/setoolsgui/apol/portconquery.py
index 50d054f867a5..de0a16567f1c 100644
--- a/setoolsgui/apol/portconquery.py
+++ b/setoolsgui/apol/portconquery.py
@@ -75,7 +75,7 @@ class PortconQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.type_.palette()
self.error_palette = self.type_.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_ports_error()
self.clear_user_error()
self.clear_type_error()
@@ -92,7 +92,7 @@ class PortconQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -280,7 +280,7 @@ class PortconQueryTab(AnalysisTab):
self.query.ports_overlap = self.ports_overlap.isChecked()
self.query.ports_subset = self.ports_subset.isChecked()
self.query.ports_superset = self.ports_superset.isChecked()
- self.query.protocol = self.protocol.currentData(Qt.UserRole)
+ self.query.protocol = self.protocol.currentData(Qt.ItemDataRole.UserRole)
self.query.range_overlap = self.range_overlap.isChecked()
self.query.range_subset = self.range_subset.isChecked()
self.query.range_superset = self.range_superset.isChecked()
@@ -308,6 +308,6 @@ class PortconQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/rbacrulequery.py b/setoolsgui/apol/rbacrulequery.py
index 0ce4bb9ad6c6..4749d324d858 100644
--- a/setoolsgui/apol/rbacrulequery.py
+++ b/setoolsgui/apol/rbacrulequery.py
@@ -71,7 +71,7 @@ class RBACRuleQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.source.palette()
self.error_palette = self.source.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_source_error()
self.clear_target_error()
self.clear_default_error()
@@ -86,7 +86,7 @@ class RBACRuleQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -194,7 +194,7 @@ class RBACRuleQueryTab(AnalysisTab):
def set_tclass(self):
selected_classes = []
for index in self.tclass.selectionModel().selectedIndexes():
- selected_classes.append(self.class_model.data(index, Qt.UserRole))
+ selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole))
self.query.tclass = selected_classes
@@ -292,6 +292,6 @@ class RBACRuleQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/rolequery.py b/setoolsgui/apol/rolequery.py
index 29983a5961ee..e75614d9a992 100644
--- a/setoolsgui/apol/rolequery.py
+++ b/setoolsgui/apol/rolequery.py
@@ -62,13 +62,13 @@ class RoleQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
# set up processing thread
@@ -112,7 +112,7 @@ class RoleQueryTab(AnalysisTab):
def get_detail(self):
# .ui is set for single item selection.
index = self.roles.selectedIndexes()[0]
- item = self.role_model.data(index, Qt.UserRole)
+ item = self.role_model.data(index, Qt.ItemDataRole.UserRole)
self.log.debug("Generating detail window for {0}".format(item))
role_detail(self, item)
@@ -142,7 +142,7 @@ class RoleQueryTab(AnalysisTab):
def set_types(self):
selected_types = []
for index in self.types.selectionModel().selectedIndexes():
- selected_types.append(self.type_model.data(index, Qt.UserRole))
+ selected_types.append(self.type_model.data(index, Qt.ItemDataRole.UserRole))
self.query.types = selected_types
@@ -209,6 +209,6 @@ class RoleQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/sensitivityquery.py b/setoolsgui/apol/sensitivityquery.py
index d5bcbec53fda..c8a27891ae97 100644
--- a/setoolsgui/apol/sensitivityquery.py
+++ b/setoolsgui/apol/sensitivityquery.py
@@ -57,13 +57,13 @@ class SensitivityQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
# set up processing thread
@@ -105,7 +105,7 @@ class SensitivityQueryTab(AnalysisTab):
def get_detail(self):
# .ui is set for single item selection.
index = self.sens.selectedIndexes()[0]
- item = self.sensitivity_model.data(index, Qt.UserRole)
+ item = self.sensitivity_model.data(index, Qt.ItemDataRole.UserRole)
self.log.debug("Generating detail window for {0}".format(item))
sensitivity_detail(self, item)
@@ -186,6 +186,6 @@ class SensitivityQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/terulequery.py b/setoolsgui/apol/terulequery.py
index 3064710550f5..7c99469edc87 100644
--- a/setoolsgui/apol/terulequery.py
+++ b/setoolsgui/apol/terulequery.py
@@ -69,7 +69,7 @@ class TERuleQueryTab(AnalysisTab):
self.errors = set()
self.orig_palette = self.source.palette()
self.error_palette = self.source.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_source_error()
self.clear_target_error()
self.clear_default_error()
@@ -94,7 +94,7 @@ class TERuleQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# set up processing thread
self.thread = QThread()
@@ -221,7 +221,7 @@ class TERuleQueryTab(AnalysisTab):
def set_tclass(self):
selected_classes = []
for index in self.tclass.selectionModel().selectedIndexes():
- selected_classes.append(self.class_model.data(index, Qt.UserRole))
+ selected_classes.append(self.class_model.data(index, Qt.ItemDataRole.UserRole))
self.query.tclass = selected_classes
self.perms_model.set_classes(selected_classes)
@@ -236,7 +236,7 @@ class TERuleQueryTab(AnalysisTab):
def set_perms(self):
selected_perms = []
for index in self.perms.selectionModel().selectedIndexes():
- selected_perms.append(self.perms_model.data(index, Qt.UserRole))
+ selected_perms.append(self.perms_model.data(index, Qt.ItemDataRole.UserRole))
self.query.perms = selected_perms
@@ -302,7 +302,7 @@ class TERuleQueryTab(AnalysisTab):
def set_bools(self):
selected_bools = []
for index in self.bool_criteria.selectionModel().selectedIndexes():
- selected_bools.append(self.bool_model.data(index, Qt.UserRole))
+ selected_bools.append(self.bool_model.data(index, Qt.ItemDataRole.UserRole))
self.query.boolean = selected_bools
@@ -407,9 +407,9 @@ class TERuleQueryTab(AnalysisTab):
reply = QMessageBox.question(
self, "Continue?",
"This is a broad query, estimated to return {0} results. Continue?".
- format(max_results), QMessageBox.Yes | QMessageBox.No)
+ format(max_results), QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
- if reply == QMessageBox.No:
+ if reply == QMessageBox.StandardButton.No:
return
# start processing
@@ -440,6 +440,6 @@ class TERuleQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/typeattrquery.py b/setoolsgui/apol/typeattrquery.py
index 14a4141d922a..67a087a7e3f0 100644
--- a/setoolsgui/apol/typeattrquery.py
+++ b/setoolsgui/apol/typeattrquery.py
@@ -62,13 +62,13 @@ class TypeAttributeQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
# set up processing thread
@@ -112,7 +112,7 @@ class TypeAttributeQueryTab(AnalysisTab):
def get_detail(self):
# .ui is set for single item selection.
index = self.attrs.selectedIndexes()[0]
- item = self.attr_model.data(index, Qt.UserRole)
+ item = self.attr_model.data(index, Qt.ItemDataRole.UserRole)
self.log.debug("Generating detail window for {0}".format(item))
typeattr_detail(self, item)
@@ -142,7 +142,7 @@ class TypeAttributeQueryTab(AnalysisTab):
def set_types(self):
selected_types = []
for index in self.types.selectionModel().selectedIndexes():
- selected_types.append(self.type_model.data(index, Qt.UserRole))
+ selected_types.append(self.type_model.data(index, Qt.ItemDataRole.UserRole))
self.query.types = selected_types
@@ -209,6 +209,6 @@ class TypeAttributeQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/typequery.py b/setoolsgui/apol/typequery.py
index 2e261ccd52db..a22e3547cd16 100644
--- a/setoolsgui/apol/typequery.py
+++ b/setoolsgui/apol/typequery.py
@@ -62,13 +62,13 @@ class TypeQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
# set up processing thread
@@ -112,7 +112,7 @@ class TypeQueryTab(AnalysisTab):
def get_detail(self):
# .ui is set for single item selection.
index = self.types.selectedIndexes()[0]
- item = self.type_model.data(index, Qt.UserRole)
+ item = self.type_model.data(index, Qt.ItemDataRole.UserRole)
self.log.debug("Generating detail window for {0}".format(item))
type_detail(self, item)
@@ -142,7 +142,7 @@ class TypeQueryTab(AnalysisTab):
def set_attrs(self):
selected_attrs = []
for index in self.attrs.selectionModel().selectedIndexes():
- selected_attrs.append(self.attr_model.data(index, Qt.UserRole))
+ selected_attrs.append(self.attr_model.data(index, Qt.ItemDataRole.UserRole))
self.query.attrs = selected_attrs
@@ -213,6 +213,6 @@ class TypeQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/userquery.py b/setoolsgui/apol/userquery.py
index c325888db8ec..19ffb03c2975 100644
--- a/setoolsgui/apol/userquery.py
+++ b/setoolsgui/apol/userquery.py
@@ -62,13 +62,13 @@ class UserQueryTab(AnalysisTab):
self.sort_proxy = QSortFilterProxyModel(self)
self.sort_proxy.setSourceModel(self.table_results_model)
self.table_results.setModel(self.sort_proxy)
- self.table_results.sortByColumn(0, Qt.AscendingOrder)
+ self.table_results.sortByColumn(0, Qt.SortOrder.AscendingOrder)
# setup indications of errors on level/range
self.errors = set()
self.orig_palette = self.name.palette()
self.error_palette = self.name.palette()
- self.error_palette.setColor(QPalette.Base, Qt.red)
+ self.error_palette.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.red)
self.clear_name_error()
if self.policy.mls:
@@ -135,7 +135,7 @@ class UserQueryTab(AnalysisTab):
def get_detail(self):
# .ui is set for single item selection.
index = self.users.selectedIndexes()[0]
- item = self.user_model.data(index, Qt.UserRole)
+ item = self.user_model.data(index, Qt.ItemDataRole.UserRole)
self.log.debug("Generating detail window for {0}".format(item))
user_detail(self, item)
@@ -165,7 +165,7 @@ class UserQueryTab(AnalysisTab):
def set_roles(self):
selected_roles = []
for index in self.roles.selectionModel().selectedIndexes():
- selected_roles.append(self.role_model.data(index, Qt.UserRole))
+ selected_roles.append(self.role_model.data(index, Qt.ItemDataRole.UserRole))
self.query.roles = selected_roles
@@ -262,6 +262,6 @@ class UserQueryTab(AnalysisTab):
if not self.busy.wasCanceled():
self.busy.setLabelText("Moving the raw result to top; GUI may be unresponsive")
self.busy.repaint()
- self.raw_results.moveCursor(QTextCursor.Start)
+ self.raw_results.moveCursor(QTextCursor.MoveOperation.Start)
self.busy.reset()
diff --git a/setoolsgui/apol/workspace.py b/setoolsgui/apol/workspace.py
index 0f8ec82cdaea..2b4229224b85 100644
--- a/setoolsgui/apol/workspace.py
+++ b/setoolsgui/apol/workspace.py
@@ -141,7 +141,7 @@ def save_listviews(tab, settings, listviews):
selections = []
for index in listview.selectedIndexes():
- item = datamodel.data(index, Qt.DisplayRole)
+ item = datamodel.data(index, Qt.ItemDataRole.DisplayRole)
selections.append(item)
settings[entry] = selections
@@ -181,10 +181,10 @@ def load_listviews(tab, settings, listviews):
for row in range(datamodel.rowCount()):
index = datamodel.createIndex(row, 0)
- item = datamodel.data(index, Qt.DisplayRole)
+ item = datamodel.data(index, Qt.ItemDataRole.DisplayRole)
if item in selections:
- selectionmodel.select(index, QItemSelectionModel.Select)
+ selectionmodel.select(index, QItemSelectionModel.SelectionFlag.Select)
def save_comboboxes(tab, settings, comboboxes):
@@ -199,7 +199,7 @@ def save_comboboxes(tab, settings, comboboxes):
for entry in comboboxes:
combobox = getattr(tab, entry)
- settings[entry] = combobox.currentData(Qt.DisplayRole)
+ settings[entry] = combobox.currentData(Qt.ItemDataRole.DisplayRole)
def load_comboboxes(tab, settings, comboboxes):
diff --git a/setoolsgui/boolmodel.py b/setoolsgui/boolmodel.py
index 0d698c92f51b..c331fdd5057d 100644
--- a/setoolsgui/boolmodel.py
+++ b/setoolsgui/boolmodel.py
@@ -38,12 +38,12 @@ class BooleanTableModel(SEToolsTableModel):
col = index.column()
boolean = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return boolean.name
elif col == 1:
return str(boolean.state)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
# get the whole rule for boolean boolean
return boolean
diff --git a/setoolsgui/boundsmodel.py b/setoolsgui/boundsmodel.py
index c84f612a3b3a..c7ed1e7c227f 100644
--- a/setoolsgui/boundsmodel.py
+++ b/setoolsgui/boundsmodel.py
@@ -20,7 +20,7 @@ class BoundsTableModel(SEToolsTableModel):
col = index.column()
item = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return item.ruletype.name
elif col == 1:
@@ -28,5 +28,5 @@ class BoundsTableModel(SEToolsTableModel):
elif col == 2:
return item.child.name
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return item
diff --git a/setoolsgui/commonmodel.py b/setoolsgui/commonmodel.py
index a6f6fed53840..2ceb57f4f0a3 100644
--- a/setoolsgui/commonmodel.py
+++ b/setoolsgui/commonmodel.py
@@ -42,11 +42,11 @@ class CommonTableModel(SEToolsTableModel):
col = index.column()
item = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return item.name
elif col == 1:
return ", ".join(sorted(item.perms))
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return item
diff --git a/setoolsgui/constraintmodel.py b/setoolsgui/constraintmodel.py
index 122dff0b5139..d295f28f208b 100644
--- a/setoolsgui/constraintmodel.py
+++ b/setoolsgui/constraintmodel.py
@@ -21,7 +21,7 @@ class ConstraintTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return rule.ruletype.name
elif col == 1:
@@ -34,5 +34,5 @@ class ConstraintTableModel(SEToolsTableModel):
elif col == 3:
return str(rule.expression)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/defaultmodel.py b/setoolsgui/defaultmodel.py
index b9a6a58ebfea..3a699c49ce8c 100644
--- a/setoolsgui/defaultmodel.py
+++ b/setoolsgui/defaultmodel.py
@@ -22,7 +22,7 @@ class DefaultTableModel(SEToolsTableModel):
col = index.column()
item = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return item.ruletype.name
elif col == 1:
@@ -33,5 +33,5 @@ class DefaultTableModel(SEToolsTableModel):
with suppress(AttributeError):
return item.default_range.name
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return item
diff --git a/setoolsgui/details.py b/setoolsgui/details.py
index 4eb70066cfdb..8d4882cd6a1e 100644
--- a/setoolsgui/details.py
+++ b/setoolsgui/details.py
@@ -37,15 +37,15 @@ class DetailsPopup(SEToolsWidget, QDialog):
self.setWindowTitle(text)
def append(self, text):
- self.contents.setFontWeight(QFont.Normal)
+ self.contents.setFontWeight(QFont.Weight.Normal)
self.contents.setFontPointSize(9)
self.contents.append(text)
def append_header(self, text):
- self.contents.setFontWeight(QFont.Black)
+ self.contents.setFontWeight(QFont.Weight.Black)
self.contents.setFontPointSize(11)
self.contents.append(text)
def show(self):
- self.contents.moveCursor(QTextCursor.Start)
+ self.contents.moveCursor(QTextCursor.MoveOperation.Start)
super(DetailsPopup, self).show()
diff --git a/setoolsgui/fsusemodel.py b/setoolsgui/fsusemodel.py
index 2b3a3f402af9..bc100784c490 100644
--- a/setoolsgui/fsusemodel.py
+++ b/setoolsgui/fsusemodel.py
@@ -20,7 +20,7 @@ class FSUseTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return rule.ruletype.name
elif col == 1:
@@ -28,5 +28,5 @@ class FSUseTableModel(SEToolsTableModel):
elif col == 2:
return str(rule.context)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/genfsconmodel.py b/setoolsgui/genfsconmodel.py
index 6fc46408865c..1e50d929446a 100644
--- a/setoolsgui/genfsconmodel.py
+++ b/setoolsgui/genfsconmodel.py
@@ -32,7 +32,7 @@ class GenfsconTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return rule.fs
elif col == 1:
@@ -42,5 +42,5 @@ class GenfsconTableModel(SEToolsTableModel):
elif col == 3:
return str(rule.context)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/ibendportconmodel.py b/setoolsgui/ibendportconmodel.py
index 199932d39415..37b7a8d74948 100644
--- a/setoolsgui/ibendportconmodel.py
+++ b/setoolsgui/ibendportconmodel.py
@@ -20,7 +20,7 @@ class IbendportconTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return rule.name
elif col == 1:
@@ -28,5 +28,5 @@ class IbendportconTableModel(SEToolsTableModel):
elif col == 2:
return str(rule.context)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/ibpkeyconmodel.py b/setoolsgui/ibpkeyconmodel.py
index f3cd95205d51..160425504521 100644
--- a/setoolsgui/ibpkeyconmodel.py
+++ b/setoolsgui/ibpkeyconmodel.py
@@ -20,7 +20,7 @@ class IbpkeyconTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return str(rule.subnet_prefix)
elif col == 1:
@@ -32,5 +32,5 @@ class IbpkeyconTableModel(SEToolsTableModel):
elif col == 2:
return str(rule.context)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/initsidmodel.py b/setoolsgui/initsidmodel.py
index 1155a50fccb9..9ffb408024fd 100644
--- a/setoolsgui/initsidmodel.py
+++ b/setoolsgui/initsidmodel.py
@@ -20,11 +20,11 @@ class InitialSIDTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return rule.name
elif col == 1:
return str(rule.context)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/listview.py b/setoolsgui/listview.py
index a4beda50b9f6..e803975c52c6 100644
--- a/setoolsgui/listview.py
+++ b/setoolsgui/listview.py
@@ -34,14 +34,14 @@ class SEToolsListView(QListView):
for row in range(model.rowCount()):
index = model.createIndex(row, 0)
- selection_model.select(index, QItemSelectionModel.Toggle)
+ selection_model.select(index, QItemSelectionModel.SelectionFlag.Toggle)
- def selection(self, qt_role=Qt.UserRole):
+ def selection(self, qt_role=Qt.ItemDataRole.UserRole):
"""
Generator which returns the selection.
Parameter:
- qt_role The Qt model role. Default is Qt.UserRole.
+ qt_role The Qt model role. Default is Qt.ItemDataRole.UserRole.
Yield: tuple(row, data)
row The row number of the selection.
diff --git a/setoolsgui/mlsmodel.py b/setoolsgui/mlsmodel.py
index 8dfb28066d34..147378ef585a 100644
--- a/setoolsgui/mlsmodel.py
+++ b/setoolsgui/mlsmodel.py
@@ -63,11 +63,11 @@ class MLSComponentTableModel(SEToolsTableModel):
col = index.column()
item = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return item.name
elif col == 1:
return ", ".join(sorted(a for a in item.aliases()))
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return item
diff --git a/setoolsgui/mlsrulemodel.py b/setoolsgui/mlsrulemodel.py
index 4fa4f186a6cf..54ad4c216c72 100644
--- a/setoolsgui/mlsrulemodel.py
+++ b/setoolsgui/mlsrulemodel.py
@@ -20,7 +20,7 @@ class MLSRuleTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return rule.ruletype.name
elif col == 1:
@@ -32,5 +32,5 @@ class MLSRuleTableModel(SEToolsTableModel):
elif col == 4:
return str(rule.default)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/models.py b/setoolsgui/models.py
index fc7bf3df9ccf..dd864e932fbc 100644
--- a/setoolsgui/models.py
+++ b/setoolsgui/models.py
@@ -19,7 +19,7 @@ def invert_list_selection(selection_model):
rowcount = model.rowCount()
for row in range(rowcount):
index = model.createIndex(row, 0)
- selection_model.select(index, QItemSelectionModel.Toggle)
+ selection_model.select(index, QItemSelectionModel.SelectionFlag.Toggle)
class SEToolsListModel(QAbstractListModel):
@@ -27,8 +27,8 @@ class SEToolsListModel(QAbstractListModel):
"""
The purpose of this model is to have the
objects return their string representations
- for Qt.DisplayRole and return the object
- for Qt.UserRole.
+ for Qt.ItemDataRole.DisplayRole and return the object
+ for Qt.ItemDataRole.UserRole.
Some Python list-like functions are provided
for altering the model: append and remove
@@ -81,9 +81,9 @@ class SEToolsListModel(QAbstractListModel):
row = index.row()
item = self.item_list[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
return str(item)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return item
@@ -133,7 +133,7 @@ class SEToolsTableModel(QAbstractTableModel):
self.resultlist = []
def headerData(self, section, orientation, role):
- if role == Qt.DisplayRole and orientation == Qt.Horizontal:
+ if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
return self.headers[section]
def rowCount(self, parent=QModelIndex()):
diff --git a/setoolsgui/netifconmodel.py b/setoolsgui/netifconmodel.py
index 3d2e4b8b6ee1..54659203e7e5 100644
--- a/setoolsgui/netifconmodel.py
+++ b/setoolsgui/netifconmodel.py
@@ -20,7 +20,7 @@ class NetifconTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return rule.netif
elif col == 1:
@@ -28,5 +28,5 @@ class NetifconTableModel(SEToolsTableModel):
elif col == 2:
return str(rule.packet)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/nodeconmodel.py b/setoolsgui/nodeconmodel.py
index ec4d66e9a026..f8055fca194d 100644
--- a/setoolsgui/nodeconmodel.py
+++ b/setoolsgui/nodeconmodel.py
@@ -20,11 +20,11 @@ class NodeconTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return str(rule.network.with_netmask)
elif col == 1:
return str(rule.context)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/objclassmodel.py b/setoolsgui/objclassmodel.py
index 9823b73b30ee..ff1641f8cc3e 100644
--- a/setoolsgui/objclassmodel.py
+++ b/setoolsgui/objclassmodel.py
@@ -58,7 +58,7 @@ class ObjClassTableModel(SEToolsTableModel):
col = index.column()
item = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return item.name
elif col == 1:
@@ -69,5 +69,5 @@ class ObjClassTableModel(SEToolsTableModel):
return ", ".join(sorted(chain(com_perms, item.perms)))
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return item
diff --git a/setoolsgui/portconmodel.py b/setoolsgui/portconmodel.py
index 39d2c72e4625..1c3de4494af9 100644
--- a/setoolsgui/portconmodel.py
+++ b/setoolsgui/portconmodel.py
@@ -20,7 +20,7 @@ class PortconTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
low, high = rule.ports
if low == high:
@@ -32,5 +32,5 @@ class PortconTableModel(SEToolsTableModel):
elif col == 2:
return str(rule.context)
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/rbacrulemodel.py b/setoolsgui/rbacrulemodel.py
index d8df9409ed56..84d2ff09e4fc 100644
--- a/setoolsgui/rbacrulemodel.py
+++ b/setoolsgui/rbacrulemodel.py
@@ -21,7 +21,7 @@ class RBACRuleTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return rule.ruletype.name
elif col == 1:
@@ -41,5 +41,5 @@ class RBACRuleTableModel(SEToolsTableModel):
except RuleUseError:
return None
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/rolemodel.py b/setoolsgui/rolemodel.py
index 004f4e7614ba..2dd7fe64d37e 100644
--- a/setoolsgui/rolemodel.py
+++ b/setoolsgui/rolemodel.py
@@ -47,11 +47,11 @@ class RoleTableModel(SEToolsTableModel):
col = index.column()
item = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return item.name
elif col == 1:
return ", ".join(sorted(t.name for t in item.types()))
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
# get the whole object
return item
diff --git a/setoolsgui/tableview.py b/setoolsgui/tableview.py
index 9726cb053466..9ba49aa50fa3 100644
--- a/setoolsgui/tableview.py
+++ b/setoolsgui/tableview.py
@@ -45,7 +45,7 @@ class SEToolsTableView(QTableView):
elif prev_col is not None and current_col != prev_col:
selected_text.append('\t')
- selected_text.append(datamodel.data(index, Qt.DisplayRole))
+ selected_text.append(datamodel.data(index, Qt.ItemDataRole.DisplayRole))
prev_row = current_row
prev_col = current_col
@@ -76,7 +76,7 @@ class SEToolsTableView(QTableView):
# write headers
csv_row = []
for col in range(col_count):
- csv_row.append(datamodel.headerData(col, Qt.Horizontal, Qt.DisplayRole))
+ csv_row.append(datamodel.headerData(col, Qt.Orientation.Horizontal, Qt.ItemDataRole.DisplayRole))
writer.writerow(csv_row)
@@ -86,6 +86,6 @@ class SEToolsTableView(QTableView):
for col in range(col_count):
index = datamodel.index(row, col)
- csv_row.append(datamodel.data(index, Qt.DisplayRole))
+ csv_row.append(datamodel.data(index, Qt.ItemDataRole.DisplayRole))
writer.writerow(csv_row)
diff --git a/setoolsgui/terulemodel.py b/setoolsgui/terulemodel.py
index 4d51ac8e9b25..53b61a06d152 100644
--- a/setoolsgui/terulemodel.py
+++ b/setoolsgui/terulemodel.py
@@ -22,7 +22,7 @@ class TERuleTableModel(SEToolsTableModel):
col = index.column()
rule = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return rule.ruletype.name
elif col == 1:
@@ -50,5 +50,5 @@ class TERuleTableModel(SEToolsTableModel):
except RuleNotConditional:
return None
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return rule
diff --git a/setoolsgui/typeattrmodel.py b/setoolsgui/typeattrmodel.py
index 1a752fcd82f0..0b7c7ffe65a5 100644
--- a/setoolsgui/typeattrmodel.py
+++ b/setoolsgui/typeattrmodel.py
@@ -44,11 +44,11 @@ class TypeAttributeTableModel(SEToolsTableModel):
col = index.column()
item = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return item.name
elif col == 1:
return ", ".join(sorted(t.name for t in item.expand()))
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return item
diff --git a/setoolsgui/typemodel.py b/setoolsgui/typemodel.py
index 841cc42a52d3..037996b96a8c 100644
--- a/setoolsgui/typemodel.py
+++ b/setoolsgui/typemodel.py
@@ -50,7 +50,7 @@ class TypeTableModel(SEToolsTableModel):
col = index.column()
item = self.resultlist[row]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if col == 0:
return item.name
elif col == 1:
@@ -60,5 +60,5 @@ class TypeTableModel(SEToolsTableModel):
elif col == 3 and item.ispermissive:
return "Permissive"
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return item
diff --git a/setoolsgui/usermodel.py b/setoolsgui/usermodel.py
index d0a4b0ed1a63..d5aca7bc11a0 100644
--- a/setoolsgui/usermodel.py
+++ b/setoolsgui/usermodel.py
@@ -56,7 +56,7 @@ class UserTableModel(SEToolsTableModel):
def data(self, index, role):
if self.resultlist and index.isValid():
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
row = index.row()
col = index.column()
user = self.resultlist[row]
@@ -76,5 +76,5 @@ class UserTableModel(SEToolsTableModel):
except MLSDisabled:
return None
- elif role == Qt.UserRole:
+ elif role == Qt.ItemDataRole.UserRole:
return user
--
2.41.0