Source code for schrodinger.application.msv.gui.homology_modeling.view_tab_table

from schrodinger.application.msv.gui.gui_models import PageModel
from schrodinger.Qt import QtCore
from schrodinger.Qt import QtGui
from schrodinger.Qt.QtCore import Qt
from schrodinger.ui.qt import table_helper
from schrodinger.ui.qt.mapperwidgets import plptable

SETTINGS_ICON = ":/msv/icons/settings-light.png"
SETTINGS_WARNING_ICON = ":/msv/icons/settings-warning.png"
SETTINGS_TT = "Click to review tab settings"
SETTINGS_WARNING_TT = "Tab is not ready for modeling - click to set it up"


[docs]class ViewTabSpec(plptable.TableSpec): tab_name = plptable.FieldColumn(PageModel.title, title="Tab Name") # TODO will show the wrong title in combined chain view @plptable.FieldColumn(PageModel.split_aln, title="Reference Sequence") def reference_sequence(self, field): ref_seq = field.getReferenceSeq() if ref_seq is not None: return ref_seq.name @plptable.ParamColumn(title="", sample_data="_") def settings_icon(self, _): return ""
[docs] @settings_icon.data_method(Qt.DecorationRole) def settings_icon_icon(self, page): # TODO do a hover effect ready = page.homology_modeling_input.ready path = SETTINGS_ICON if ready else SETTINGS_WARNING_ICON return QtGui.QIcon(path)
[docs] @settings_icon.data_method(Qt.ToolTipRole) def settings_icon_tooltip(self, page): ready = page.homology_modeling_input.ready return SETTINGS_TT if ready else SETTINGS_WARNING_TT
class _View(table_helper.SampleDataTableView): """ View with customized selection behavior for the settings column """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setSelectionMode(self.MultiSelection) def selectionCommand(self, index, event=None): command = super().selectionCommand(index, event) QISM = QtCore.QItemSelectionModel if (isinstance(event, QtGui.QMouseEvent) and (command & QISM.Toggle or command & QISM.Deselect) and index.column() == ViewTabTable.settings_column_index and index in self.selectedIndexes()): # Don't deselect when clicking on settings column command = QISM.NoUpdate return command class _ViewFilterProxyModel(QtCore.QSortFilterProxyModel): """ Filter proxy to only show non-workspace rows """ def filterAcceptsRow(self, source_row, source_parent=None): source_col = 0 # doesn't matter because we are getting row-only data source_index = self.sourceModel().index(source_row, source_col) page = source_index.data(plptable.ROW_OBJECT_ROLE) return not page.is_workspace
[docs]class ViewTabTable(plptable.PLPTableWidget): settings_column_index = 2 # Determined by declaration order in TableSpec
[docs] def __init__(self, *args, **kwargs): super().__init__(*args, spec=ViewTabSpec(), view=_View(), **kwargs) self.setMaximumSize(400, 300) self._filter_model = _ViewFilterProxyModel() self.addProxy(self._filter_model)