2016-03-29 13:01:28 +00:00
|
|
|
# Copyright 2016, Tresys Technology, LLC
|
|
|
|
#
|
2021-11-20 19:03:26 +00:00
|
|
|
# SPDX-License-Identifier: LGPL-2.1-only
|
2016-03-29 13:01:28 +00:00
|
|
|
#
|
|
|
|
#
|
2016-04-01 18:50:25 +00:00
|
|
|
from PyQt5.QtCore import Qt
|
2016-03-29 13:01:28 +00:00
|
|
|
from PyQt5.QtGui import QPalette, QTextCursor
|
|
|
|
|
|
|
|
from .details import DetailsPopup
|
2016-04-01 13:00:17 +00:00
|
|
|
from .models import SEToolsTableModel
|
2016-03-29 13:01:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
def boolean_detail(parent, boolean):
|
|
|
|
"""
|
|
|
|
Create a dialog box for Booleanean details.
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
parent The parent Qt Widget
|
|
|
|
bool The boolean
|
|
|
|
"""
|
|
|
|
|
|
|
|
detail = DetailsPopup(parent, "Boolean detail: {0}".format(boolean))
|
|
|
|
|
|
|
|
detail.append_header("Default State: {0}".format(boolean.state))
|
|
|
|
|
|
|
|
detail.show()
|
|
|
|
|
|
|
|
|
2016-04-01 13:00:17 +00:00
|
|
|
class BooleanTableModel(SEToolsTableModel):
|
2016-03-29 13:01:28 +00:00
|
|
|
|
|
|
|
"""Table-based model for booleans."""
|
|
|
|
|
2016-06-08 11:26:32 +00:00
|
|
|
headers = ["Name", "Default State"]
|
2016-03-29 13:01:28 +00:00
|
|
|
|
|
|
|
def data(self, index, role):
|
2016-04-21 14:07:12 +00:00
|
|
|
if self.resultlist and index.isValid():
|
2016-03-29 13:01:28 +00:00
|
|
|
row = index.row()
|
|
|
|
col = index.column()
|
|
|
|
boolean = self.resultlist[row]
|
|
|
|
|
|
|
|
if role == Qt.DisplayRole:
|
|
|
|
if col == 0:
|
2018-08-18 17:35:09 +00:00
|
|
|
return boolean.name
|
2016-03-29 13:01:28 +00:00
|
|
|
elif col == 1:
|
|
|
|
return str(boolean.state)
|
|
|
|
|
|
|
|
elif role == Qt.UserRole:
|
|
|
|
# get the whole rule for boolean boolean
|
|
|
|
return boolean
|