diff --git a/data/exclude_types.ui b/data/exclude_types.ui new file mode 100644 index 0000000..a2cdf78 --- /dev/null +++ b/data/exclude_types.ui @@ -0,0 +1,196 @@ + + + Dialog + + + + 0 + 0 + 485 + 340 + + + + Dialog + + + + + + + 0 + 0 + + + + + 16777215 + 20 + + + + + 11 + 75 + true + + + + Included Types + + + + + + + + 0 + 0 + + + + + 16777215 + 20 + + + + + 11 + 75 + true + + + + Excluded Types + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Exclude selected types. + + + + + + + icons/Button_Next.pngicons/Button_Next.png + + + true + + + + + + + Include selected types. + + + + + + + icons/Button_Back.pngicons/Button_Back.png + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + QAbstractItemView::ExtendedSelection + + + true + + + + + + + QAbstractItemView::ExtendedSelection + + + true + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/data/icons/Button_Back.png b/data/icons/Button_Back.png new file mode 100755 index 0000000..e56e3e0 Binary files /dev/null and b/data/icons/Button_Back.png differ diff --git a/data/icons/Button_Next.png b/data/icons/Button_Next.png new file mode 100755 index 0000000..684cb9c Binary files /dev/null and b/data/icons/Button_Next.png differ diff --git a/data/infoflow.ui b/data/infoflow.ui index cd6afba..a2fa3b1 100644 --- a/data/infoflow.ui +++ b/data/infoflow.ui @@ -483,6 +483,13 @@ + + + + Limit results: + + + @@ -496,10 +503,17 @@ - - + + - Limit results: + Excluded Types: + + + + + + + Edit... diff --git a/setoolsgui/apol/excludetypes.py b/setoolsgui/apol/excludetypes.py new file mode 100644 index 0000000..c0b821c --- /dev/null +++ b/setoolsgui/apol/excludetypes.py @@ -0,0 +1,76 @@ +# Copyright 2015, Tresys Technology, LLC +# +# This file is part of SETools. +# +# SETools is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 2.1 of +# the License, or (at your option) any later version. +# +# SETools is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with SETools. If not, see +# . +# + +import logging + +from PyQt5.QtWidgets import QDialog + +from ..widget import SEToolsWidget + + +class ExcludeTypes(SEToolsWidget, QDialog): + + """Dialog for choosing excluded types.""" + + def __init__(self, parent, policy): + super(ExcludeTypes, self).__init__(parent) + self.log = logging.getLogger(self.__class__.__name__) + self.parent = parent + self.policy = policy + self.excluded_list = [str(e) for e in self.parent.query.exclude] + self.setupUi() + + def setupUi(self): + self.load_ui("exclude_types.ui") + self.exclude_a_type.clicked.connect(self.exclude_clicked) + self.include_a_type.clicked.connect(self.include_clicked) + self.buttonBox.accepted.connect(self.ok_clicked) + + # populate the lists: + self.included_types.clear() + for item in self.policy.types(): + if item not in self.excluded_list: + self.included_types.addItem(str(item)) + + self.excluded_types.clear() + for item in self.excluded_list: + self.excluded_types.addItem(item) + + def include_clicked(self): + for item in self.excluded_types.selectedItems(): + self.included_types.addItem(item.text()) + self.excluded_types.takeItem(self.excluded_types.row(item)) + + def exclude_clicked(self): + for item in self.included_types.selectedItems(): + self.excluded_types.addItem(item.text()) + self.included_types.takeItem(self.included_types.row(item)) + + def ok_clicked(self): + exclude = [] + + item = self.excluded_types.takeItem(0) + while item: + exclude.append(item.text()) + item = self.excluded_types.takeItem(0) + + self.log.debug("Chosen for exclusion: {0!r}".format(exclude)) + + self.parent.query.exclude = exclude + self.accept() diff --git a/setoolsgui/apol/infoflow.py b/setoolsgui/apol/infoflow.py index c799aae..6e3c547 100644 --- a/setoolsgui/apol/infoflow.py +++ b/setoolsgui/apol/infoflow.py @@ -24,6 +24,7 @@ from PyQt5.QtGui import QPalette, QTextCursor from PyQt5.QtWidgets import QCompleter, QHeaderView, QMessageBox, QProgressDialog, QScrollArea from setools import InfoFlowAnalysis +from .excludetypes import ExcludeTypes from ..widget import SEToolsWidget @@ -97,6 +98,7 @@ class InfoFlowAnalysisTab(SEToolsWidget, QScrollArea): self.flows_in.toggled.connect(self.flows_in_toggled) self.flows_out.toggled.connect(self.flows_out_toggled) self.min_perm_weight.valueChanged.connect(self.set_min_weight) + self.exclude_types.clicked.connect(self.choose_excluded_types) # # Analysis mode @@ -156,6 +158,10 @@ class InfoFlowAnalysisTab(SEToolsWidget, QScrollArea): def set_min_weight(self, value): self.query.min_weight = value + def choose_excluded_types(self): + chooser = ExcludeTypes(self, self.policy) + chooser.show() + # # Results runner #