mirror of
https://github.com/SELinuxProject/setools
synced 2025-03-23 11:36:30 +00:00
parent
897427e5da
commit
e3047740a6
412
data/categoryquery.ui
Normal file
412
data/categoryquery.ui
Normal file
@ -0,0 +1,412 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CategoryQueryTab_ui</class>
|
||||||
|
<widget class="QScrollArea" name="CategoryQueryTab_ui">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>774</width>
|
||||||
|
<height>846</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||||
|
</property>
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="contents">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>772</width>
|
||||||
|
<height>844</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>11</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Categories</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="5">
|
||||||
|
<widget class="QTextEdit" name="notes">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>80</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Optionally enter notes here about the query.</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Enter notes here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>440</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QCheckBox" name="criteria_expander">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Show or hide the search criteria (no settings are lost)</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Criteria</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QCheckBox" name="notes_expander">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Show or hide the notes field (no data is lost)</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Notes</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" rowspan="2" colspan="5">
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>1</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QGroupBox" name="browser_groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Categories Browser</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="GetDetailsListView" name="cats"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="verticalLayoutWidget">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="criteria_frame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Search Criteria</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Apply</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QGroupBox" name="name_criteria">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>120</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Category Name</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_8">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="name">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>150</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>250</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QCheckBox" name="name_regex">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Use regular expressions to match the type's name.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Regex</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTabWidget" name="results_frame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>1</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="table_page">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Results</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="table_results">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||||
|
</property>
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sortingEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="raw_page">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Raw Results</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="raw_results">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Monospace</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="documentTitle">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="lineWrapMode">
|
||||||
|
<enum>QPlainTextEdit::NoWrap</enum>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
<zorder>splitter</zorder>
|
||||||
|
<zorder>notes</zorder>
|
||||||
|
<zorder>label</zorder>
|
||||||
|
<zorder>label_2</zorder>
|
||||||
|
<zorder>horizontalSpacer</zorder>
|
||||||
|
<zorder>criteria_expander</zorder>
|
||||||
|
<zorder>notes_expander</zorder>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>GetDetailsListView</class>
|
||||||
|
<extends>QListView</extends>
|
||||||
|
<header>setoolsgui/getdetailslist.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>criteria_expander</tabstop>
|
||||||
|
<tabstop>notes_expander</tabstop>
|
||||||
|
<tabstop>cats</tabstop>
|
||||||
|
<tabstop>name</tabstop>
|
||||||
|
<tabstop>name_regex</tabstop>
|
||||||
|
<tabstop>results_frame</tabstop>
|
||||||
|
<tabstop>table_results</tabstop>
|
||||||
|
<tabstop>raw_results</tabstop>
|
||||||
|
<tabstop>notes</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>notes_expander</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>notes</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>732</x>
|
||||||
|
<y>20</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>386</x>
|
||||||
|
<y>754</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>criteria_expander</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>criteria_frame</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>583</x>
|
||||||
|
<y>20</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>496</x>
|
||||||
|
<y>226</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
175
setoolsgui/apol/categoryquery.py
Normal file
175
setoolsgui/apol/categoryquery.py
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
# Copyright 2016, 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
|
||||||
|
# <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from PyQt5.QtCore import Qt, QSortFilterProxyModel, QStringListModel, QThread
|
||||||
|
from PyQt5.QtGui import QPalette, QTextCursor
|
||||||
|
from PyQt5.QtWidgets import QCompleter, QHeaderView, QMessageBox, QProgressDialog, QScrollArea
|
||||||
|
from setools import CategoryQuery
|
||||||
|
|
||||||
|
from ..logtosignal import LogHandlerToSignal
|
||||||
|
from ..models import SEToolsListModel, invert_list_selection
|
||||||
|
from ..mlsmodel import MLSComponentTableModel, category_detail
|
||||||
|
from ..widget import SEToolsWidget
|
||||||
|
from .queryupdater import QueryResultsUpdater
|
||||||
|
|
||||||
|
|
||||||
|
class CategoryQueryTab(SEToolsWidget, QScrollArea):
|
||||||
|
|
||||||
|
"""Category browser and query tab."""
|
||||||
|
|
||||||
|
def __init__(self, parent, policy, perm_map):
|
||||||
|
super(CategoryQueryTab, self).__init__(parent)
|
||||||
|
self.log = logging.getLogger(__name__)
|
||||||
|
self.policy = policy
|
||||||
|
self.query = CategoryQuery(policy)
|
||||||
|
self.setupUi()
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.thread.quit()
|
||||||
|
self.thread.wait(5000)
|
||||||
|
logging.getLogger("setools.categoryquery").removeHandler(self.handler)
|
||||||
|
|
||||||
|
def setupUi(self):
|
||||||
|
self.load_ui("categoryquery.ui")
|
||||||
|
|
||||||
|
# populate category list
|
||||||
|
self.category_model = SEToolsListModel(self)
|
||||||
|
self.category_model.item_list = sorted(self.policy.categories())
|
||||||
|
self.cats.setModel(self.category_model)
|
||||||
|
|
||||||
|
# set up results
|
||||||
|
self.table_results_model = MLSComponentTableModel(self)
|
||||||
|
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)
|
||||||
|
|
||||||
|
# setup indications of errors on level/range
|
||||||
|
self.orig_palette = self.name.palette()
|
||||||
|
self.error_palette = self.name.palette()
|
||||||
|
self.error_palette.setColor(QPalette.Base, Qt.red)
|
||||||
|
self.clear_name_error()
|
||||||
|
|
||||||
|
# set up processing thread
|
||||||
|
self.thread = QThread()
|
||||||
|
self.worker = QueryResultsUpdater(self.query, self.table_results_model)
|
||||||
|
self.worker.moveToThread(self.thread)
|
||||||
|
self.worker.raw_line.connect(self.raw_results.appendPlainText)
|
||||||
|
self.worker.finished.connect(self.update_complete)
|
||||||
|
self.worker.finished.connect(self.thread.quit)
|
||||||
|
self.thread.started.connect(self.worker.update)
|
||||||
|
|
||||||
|
# create a "busy, please wait" dialog
|
||||||
|
self.busy = QProgressDialog(self)
|
||||||
|
self.busy.setModal(True)
|
||||||
|
self.busy.setRange(0, 0)
|
||||||
|
self.busy.setMinimumDuration(0)
|
||||||
|
self.busy.canceled.connect(self.thread.requestInterruption)
|
||||||
|
self.busy.reset()
|
||||||
|
|
||||||
|
# update busy dialog from query INFO logs
|
||||||
|
self.handler = LogHandlerToSignal()
|
||||||
|
self.handler.message.connect(self.busy.setLabelText)
|
||||||
|
logging.getLogger("setools.categoryquery").addHandler(self.handler)
|
||||||
|
|
||||||
|
# Ensure settings are consistent with the initial .ui state
|
||||||
|
self.notes.setHidden(not self.notes_expander.isChecked())
|
||||||
|
|
||||||
|
# connect signals
|
||||||
|
self.cats.doubleClicked.connect(self.get_detail)
|
||||||
|
self.cats.get_detail.triggered.connect(self.get_detail)
|
||||||
|
self.name.textEdited.connect(self.clear_name_error)
|
||||||
|
self.name.editingFinished.connect(self.set_name)
|
||||||
|
self.name_regex.toggled.connect(self.set_name_regex)
|
||||||
|
self.buttonBox.clicked.connect(self.run)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Category browser
|
||||||
|
#
|
||||||
|
def get_detail(self):
|
||||||
|
# .ui is set for single item selection.
|
||||||
|
index = self.cats.selectedIndexes()[0]
|
||||||
|
item = self.category_model.data(index, Qt.UserRole)
|
||||||
|
|
||||||
|
self.log.debug("Generating detail window for {0}".format(item))
|
||||||
|
category_detail(self, item)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Name criteria
|
||||||
|
#
|
||||||
|
def clear_name_error(self):
|
||||||
|
self.name.setToolTip("Match the category name.")
|
||||||
|
self.name.setPalette(self.orig_palette)
|
||||||
|
|
||||||
|
def set_name(self):
|
||||||
|
try:
|
||||||
|
self.query.name = self.name.text()
|
||||||
|
except Exception as ex:
|
||||||
|
self.log.error("Category name error: {0}".format(ex))
|
||||||
|
self.name.setToolTip("Error: " + str(ex))
|
||||||
|
self.name.setPalette(self.error_palette)
|
||||||
|
|
||||||
|
def set_name_regex(self, state):
|
||||||
|
self.log.debug("Setting name_regex {0}".format(state))
|
||||||
|
self.query.name_regex = state
|
||||||
|
self.clear_name_error()
|
||||||
|
self.set_name()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Results runner
|
||||||
|
#
|
||||||
|
|
||||||
|
def run(self, button):
|
||||||
|
# right now there is only one button.
|
||||||
|
|
||||||
|
# start processing
|
||||||
|
self.busy.setLabelText("Processing query...")
|
||||||
|
self.busy.show()
|
||||||
|
self.raw_results.clear()
|
||||||
|
self.thread.start()
|
||||||
|
|
||||||
|
def update_complete(self, count):
|
||||||
|
self.log.info("{0} categories found.".format(count))
|
||||||
|
|
||||||
|
# update sizes/location of result displays
|
||||||
|
if not self.busy.wasCanceled():
|
||||||
|
self.busy.setLabelText("Resizing the result table's columns; GUI may be unresponsive")
|
||||||
|
self.busy.repaint()
|
||||||
|
self.table_results.resizeColumnsToContents()
|
||||||
|
# If the attrs or alias column widths are too long, pull back
|
||||||
|
# to a reasonable size
|
||||||
|
header = self.table_results.horizontalHeader()
|
||||||
|
if header.sectionSize(1) > 400:
|
||||||
|
header.resizeSection(1, 400)
|
||||||
|
if header.sectionSize(2) > 400:
|
||||||
|
header.resizeSection(2, 400)
|
||||||
|
|
||||||
|
if not self.busy.wasCanceled():
|
||||||
|
self.busy.setLabelText("Resizing the result table's rows; GUI may be unresponsive")
|
||||||
|
self.busy.repaint()
|
||||||
|
self.table_results.resizeRowsToContents()
|
||||||
|
|
||||||
|
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.busy.reset()
|
@ -24,6 +24,7 @@ from ..widget import SEToolsWidget
|
|||||||
|
|
||||||
# Analysis tabs:
|
# Analysis tabs:
|
||||||
from .boolquery import BoolQueryTab
|
from .boolquery import BoolQueryTab
|
||||||
|
from .categoryquery import CategoryQueryTab
|
||||||
from .commonquery import CommonQueryTab
|
from .commonquery import CommonQueryTab
|
||||||
from .constraintquery import ConstraintQueryTab
|
from .constraintquery import ConstraintQueryTab
|
||||||
from .dta import DomainTransitionAnalysisTab
|
from .dta import DomainTransitionAnalysisTab
|
||||||
@ -92,6 +93,7 @@ class ChooseAnalysis(SEToolsWidget, QDialog):
|
|||||||
|
|
||||||
if mls:
|
if mls:
|
||||||
rule_map["MLS Rules"] = MLSRuleQueryTab
|
rule_map["MLS Rules"] = MLSRuleQueryTab
|
||||||
|
components_map["Categories"] = CategoryQueryTab
|
||||||
|
|
||||||
# populate the item list:
|
# populate the item list:
|
||||||
self.analysisTypes.clear()
|
self.analysisTypes.clear()
|
||||||
|
77
setoolsgui/mlsmodel.py
Normal file
77
setoolsgui/mlsmodel.py
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
# Copyright 2016, 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
|
||||||
|
# <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
from PyQt5.QtCore import Qt
|
||||||
|
from PyQt5.QtGui import QPalette, QTextCursor
|
||||||
|
|
||||||
|
from .details import DetailsPopup
|
||||||
|
from .models import SEToolsTableModel
|
||||||
|
|
||||||
|
|
||||||
|
def _mls_detail(parent, obj, objtype):
|
||||||
|
"""
|
||||||
|
Create a dialog box for category or sensitivity details.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
parent The parent Qt Widget
|
||||||
|
type_ The type
|
||||||
|
"""
|
||||||
|
|
||||||
|
detail = DetailsPopup(parent, "{0} detail: {1}".format(objtype, obj))
|
||||||
|
|
||||||
|
aliases = sorted(obj.aliases())
|
||||||
|
detail.append_header("Aliases ({0}):".format(len(aliases)))
|
||||||
|
for a in aliases:
|
||||||
|
detail.append(" {0}".format(a))
|
||||||
|
|
||||||
|
detail.show()
|
||||||
|
|
||||||
|
|
||||||
|
def category_detail(parent, obj):
|
||||||
|
"""
|
||||||
|
Create a dialog box for category details.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
parent The parent Qt Widget
|
||||||
|
type_ The type
|
||||||
|
"""
|
||||||
|
_mls_detail(parent, obj, "Category")
|
||||||
|
|
||||||
|
|
||||||
|
class MLSComponentTableModel(SEToolsTableModel):
|
||||||
|
|
||||||
|
"""Table-based model for sensitivities and categories."""
|
||||||
|
|
||||||
|
headers = defaultdict(str, {0: "Name", 1: "Aliases"})
|
||||||
|
|
||||||
|
def data(self, index, role):
|
||||||
|
if self.resultlist:
|
||||||
|
row = index.row()
|
||||||
|
col = index.column()
|
||||||
|
item = self.resultlist[row]
|
||||||
|
|
||||||
|
if role == Qt.DisplayRole:
|
||||||
|
if col == 0:
|
||||||
|
return str(item)
|
||||||
|
elif col == 1:
|
||||||
|
return ", ".join(sorted(str(a) for a in item.aliases()))
|
||||||
|
|
||||||
|
elif role == Qt.UserRole:
|
||||||
|
return item
|
Loading…
Reference in New Issue
Block a user