Rename UserList to GetDetailsListView for reuse.

This commit is contained in:
Chris PeBenito 2016-03-14 11:23:14 -04:00
parent c697009f24
commit a7232507a8
3 changed files with 39 additions and 21 deletions

View File

@ -134,7 +134,7 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="UserList" name="users"/>
<widget class="GetDetailsListView" name="users"/>
</item>
</layout>
</widget>
@ -647,9 +647,9 @@
</widget>
<customwidgets>
<customwidget>
<class>UserList</class>
<class>GetDetailsListView</class>
<extends>QListView</extends>
<header>setoolsgui/apol/usermodel.h</header>
<header>setoolsgui/getdetailslist.h</header>
</customwidget>
</customwidgets>
<tabstops>

View File

@ -17,8 +17,6 @@
# <http://www.gnu.org/licenses/>.
#
from PyQt5.QtCore import Qt, QAbstractTableModel, QModelIndex
from PyQt5.QtGui import QCursor
from PyQt5.QtWidgets import QAction, QListView, QMenu
from setools.policyrep.exception import MLSDisabled
from .details import DetailsPopup
@ -53,22 +51,6 @@ def user_detail(parent, user):
detail.show()
class UserList(QListView):
"""A QListView widget for listing users."""
def __init__(self, parent):
super(UserList, self).__init__(parent)
# set up right-click context menu
self.get_detail = QAction("More details...", self)
self.menu = QMenu(self)
self.menu.addAction(self.get_detail)
def contextMenuEvent(self, event):
self.menu.popup(QCursor.pos())
class UserTableModel(QAbstractTableModel):
"""Table-based model for users."""

View File

@ -0,0 +1,36 @@
# 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 PyQt5.QtGui import QCursor
from PyQt5.QtWidgets import QAction, QListView, QMenu
class GetDetailsListView(QListView):
"""A QListView widget with more details context menu."""
def __init__(self, parent):
super(GetDetailsListView, self).__init__(parent)
# set up right-click context menu
self.get_detail = QAction("More details...", self)
self.menu = QMenu(self)
self.menu.addAction(self.get_detail)
def contextMenuEvent(self, event):
self.menu.popup(QCursor.pos())