Package schrodinger :: Package application :: Package msv :: Package gui :: Module viewmodel :: Class AnnotationProxyModel
[hide private]
[frames] | no frames]

Class AnnotationProxyModel

                             object --+        
                                      |        
                             ProxyMixin --+    
                                          |    
                   PostReorderingProxyMixin --+
                                              |
         object --+                           |
                  |                           |
  sip.simplewrapper --+                       |
                      |                       |
            sip.wrapper --+                   |
                          |                   |
       PyQt4.QtCore.QObject --+               |
                              |               |
PyQt4.QtCore.QAbstractItemModel --+           |
                                  |           |
    PyQt4.QtGui.QAbstractProxyModel --+       |
                                      |       |
          Qt.QtCore.QAbstractProxyModel --+   |
                                          |   |
                             NonNestedProxy --+
                                              |
                                             AnnotationProxyModel

A proxy model that creates additional rows for annotations and adds a spacer row in between sequences

Nested Classes [hide private]

Inherited from ProxyMixin: __metaclass__

Instance Methods [hide private]
 
__init__(self, parent=None)
x.__init__(...) initializes x; see help(type(x)) for signature
 
setSourceModel(self, model)
 
_sourceModelReset(self)
 
_beginRowInsDel(self, func, parent, source_start, source_end)
Respond to the rowAboutToBeInserted and rowAboutToBeRemoved signals by calling either beginInsertRows or beginRemoveRows.
 
_endRowInsDel(self, func, parent, source_start, source_end)
Respond to the rowInserted and rowRemoved signals by calling either endInsertRows or endRemoveRows.
 
_modelDataChanged(self, source_topleft, source_bottomright)
Respond to a dataChanged signal from the model by emitting dataChanged
 
_modelHeaderDataChanged(self, orientation, source_start, source_end)
Respond to a headerDataChanged signal from the model by emitting headerDataChanged
 
_fetchAnnotationTypes(self)
When we get a new model or the model is reset, fetch the enums for annotation types
 
mapFromSource(self, source_index)
int
_mapRowFromSource(self, source_row)
Return the proxy model row that corresponds to the sequence for the given source model row
generator
_mapAllRowsFromSource(self, source_row)
Return all proxy model rows that correspond to the given source model row.
 
mapToSource(self, proxy_index)
tuple
_getMappedIndex(self, proxy_index)
Determine what source index and annotation the specified index maps to
tuple
_getMappedRow(self, proxy_row, invalid_for_spacer=True)
Determine what source row and annotation the specified row maps to
 
reorderRow(self, proxy_from_row, proxy_to_row)
Pass the reorderRow request down to the next proxy after translating the row numbers.
 
data(self, proxy_index, role=0)
Returns data with the annotations split into their own row.
 
flags(self, index)
See Qt documentation for additional method documentation
 
headerData(self, section, orientation, role=0)
Header data for the table.
bool
_rowHasDragHandle(self, row)
Should the specified row should get a drag handle (for drag-and-drop operations)?
 
_headerDataDisplay(self, section, orientation, role)
DisplayRole header data
 
_headerDataFormatting(self, section, orientation, role)
Header data for the Qt.FontRole and Qt.TextAlignmentRole roles.
 
rowCount(self, parent=None)
 
columnCount(self, parent=None)
 
setGroupBy(self, group_by)
Should the rows be grouped by sequence or by annotation type?
GroupBy
getGroupBy(self)
Are the rows currently grouped by sequence or by annotation type?

Inherited from PostReorderingProxyMixin (private): _mapRowToSource

Inherited from ProxyMixin: emitResidueSelection, residueFormatChanged, residuesSelected, sourceModel

Inherited from NonNestedProxy: index, parent, resetCountCache

Inherited from Qt.QtCore.QAbstractProxyModel: reset, setRoleNames, setSupportedDragActions

Inherited from PyQt4.QtGui.QAbstractProxyModel: buddy, canFetchMore, fetchMore, hasChildren, itemData, mapSelectionFromSource, mapSelectionToSource, mimeData, mimeTypes, revert, setData, setHeaderData, setItemData, sort, span, submit, supportedDropActions

Inherited from PyQt4.QtCore.QAbstractItemModel: beginInsertColumns, beginInsertRows, beginMoveColumns, beginMoveRows, beginRemoveColumns, beginRemoveRows, beginResetModel, changePersistentIndex, changePersistentIndexList, columnsAboutToBeInserted, columnsAboutToBeMoved, columnsAboutToBeRemoved, columnsInserted, columnsMoved, columnsRemoved, createIndex, dataChanged, decodeData, dropMimeData, encodeData, endInsertColumns, endInsertRows, endMoveColumns, endMoveRows, endRemoveColumns, endRemoveRows, endResetModel, hasIndex, headerDataChanged, insertColumn, insertColumns, insertRow, insertRows, layoutAboutToBeChanged, layoutChanged, match, modelAboutToBeReset, modelReset, persistentIndexList, removeColumn, removeColumns, removeRow, removeRows, resetInternalData, roleNames, rowsAboutToBeInserted, rowsAboutToBeMoved, rowsAboutToBeRemoved, rowsInserted, rowsMoved, rowsRemoved, sibling, supportedDragActions

Inherited from PyQt4.QtCore.QObject: __getattr__, blockSignals, childEvent, children, connect, connectNotify, customEvent, deleteLater, destroyed, disconnect, disconnectNotify, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, emit, event, eventFilter, findChild, findChildren, inherits, installEventFilter, isWidgetType, killTimer, metaObject, moveToThread, objectName, property, pyqtConfigure, receivers, removeEventFilter, sender, senderSignalIndex, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent, tr, trUtf8

Inherited from sip.simplewrapper: __new__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from PyQt4.QtCore.QObject: staticMetaObject

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, parent=None)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

setSourceModel(self, model)

 
Decorators:
  • @table_helper.model_reset_method
Overrides: PyQt4.QtGui.QAbstractProxyModel.setSourceModel

_beginRowInsDel(self, func, parent, source_start, source_end)

 

Respond to the rowAboutToBeInserted and rowAboutToBeRemoved signals by calling either beginInsertRows or beginRemoveRows.

Parameters:
  • func (function) - The method to call. Should be either beginInsertRows or beginRemoveRows
  • parent (QtCore.QModelIndex) - The parent index. Should be an invalid index
  • source_start (int) - The index of the first source row that was inserted or removed
  • source_end (int) - The index of the last source row that was inserted or removed

_endRowInsDel(self, func, parent, source_start, source_end)

 

Respond to the rowInserted and rowRemoved signals by calling either endInsertRows or endRemoveRows.

Parameters:
  • func (function) - The method to call. Should be either endInsertRows or endRemoveRows
  • parent (QtCore.QModelIndex) - The parent index. Should be an invalid index
  • source_start (int) - The index of the first source row that was inserted or removed
  • source_end (int) - The index of the last source row that was inserted or removed

_modelDataChanged(self, source_topleft, source_bottomright)

 

Respond to a dataChanged signal from the model by emitting dataChanged

Parameters:
  • source_topleft (QtCore.QModelIndex) - The top-left-most index to update
  • source_bottomright (QtCore.QModelIndex) - The bottom-right-most index to update

_modelHeaderDataChanged(self, orientation, source_start, source_end)

 

Respond to a headerDataChanged signal from the model by emitting headerDataChanged

Parameters:
  • orientation () - The orientation of the header to update. Must be Qt.Vertical.
  • source_start (int) - The index of the first source row where the header was changed.
  • source_end (int) - The index of the last source row where the header was changed.

mapFromSource(self, source_index)

 
Overrides: PyQt4.QtGui.QAbstractProxyModel.mapFromSource

_mapRowFromSource(self, source_row)

 

Return the proxy model row that corresponds to the sequence for the given source model row

Parameters:
  • source_row (int) - The source row
Returns: int
The corresponding proxy row

_mapAllRowsFromSource(self, source_row)

 

Return all proxy model rows that correspond to the given source model row. Note that this method is only valid when rows are grouped by annotation and should not be used when rows are grouped by sequence.

Parameters:
  • source_row (int) - The source row
Returns: generator
A generator for all appropriate proxy model rows

mapToSource(self, proxy_index)

 
Overrides: PyQt4.QtGui.QAbstractProxyModel.mapToSource

_getMappedIndex(self, proxy_index)

 

Determine what source index and annotation the specified index maps to

Parameters:
  • proxy_index (QtCore.QModelIndex) - The index to map
Returns: tuple
A tuple of
  • The source index that proxy_index maps to (QtCore.QModelIndex)
  • If the proxy_index row represents an annotation, returns an AnnotationType enum representing the annotation type. If the proxy_index row represents a sequence or a spacer, returns a RowType enum representing the row type.
  • If the proxy_index row represents an annotation, returns an integer representing the annotation enum index.

_getMappedRow(self, proxy_row, invalid_for_spacer=True)

 

Determine what source row and annotation the specified row maps to

Parameters:
  • proxy_row (int) - The row to map
  • invalid_for_spacer (bool) - If True, an invalid source row number (-1) will be returned for spacer rows. If False, the source row number of the preceeding sequence will be returned.
Returns: tuple
A tuple of
  • The source row that proxy_row maps to. Will be -1 for spacer rows. (int)
  • If the proxy_index row represents an annotation, will be an AnnotationType enum representing the annotation type. If the proxy_index row represents a sequence or a spacer, will be a RowType enum representing the row type.
  • If the proxy_index row represents an annotation, will be an integer representing the annotation enum index. If the proxy_index row represents a sequence, will be 0. If the proxy_index row represents a spacer and rows are grouped by annotation, will be an integer representing the annotation for the previous row. (If the proxy_index row represents a spacer and rows are grouped by sequence, then will be the number of sequence annotations + 1, although nothing currently depends on this behavior.)

reorderRow(self, proxy_from_row, proxy_to_row)

 

Pass the reorderRow request down to the next proxy after translating the row numbers. We override DragAndDropReorderingProxy.reorderRow so we can handle drops on annotation rows appropriately. (Drops on an annotation row are treated as a drop *after* the sequence.)

See DragAndDropReorderingProxy.reorderRow for documentation on arguments and the return value.

Overrides: PostReorderingProxyMixin.reorderRow

data(self, proxy_index, role=0)

 

Returns data with the annotations split into their own row.

Data for role CustomRole.RowType will provide the type of data contained in that row. The return value will be either a RowType enum or an annotation enum.

Data for role CustomRole.DataRange will provide the range of values contained in that row.

Data for the role CustomRole.SpacerType will provide the annotation type for spacer rows that contain labels. When grouping by annotation, the spacer row in between two annotation types is used to label the following annotation type. These rows need to be filtered out if the labeled annotation type is filtered out. (Note that the filtering is done in AnnotationFilterProxyModel, not here.) This role will return RowType.Spacer for unlabeled spacers.

See Qt documentation for argument documentation

Overrides: PyQt4.QtCore.QAbstractItemModel.data

flags(self, index)

 

See Qt documentation for additional method documentation

Everything is selectable except for spacers

Overrides: PyQt4.QtCore.QAbstractItemModel.flags

headerData(self, section, orientation, role=0)

 

Header data for the table. Annotation rows will be titled based on the type of annotation.

See Qt documentation for argument and return value documentation

Overrides: PyQt4.QtCore.QAbstractItemModel.headerData

_rowHasDragHandle(self, row)

 

Should the specified row should get a drag handle (for drag-and-drop operations)?

Parameters:
  • row (int) - The row number
Returns: bool
True if the specified row number should get a drag handle. False otherwise

_headerDataFormatting(self, section, orientation, role)

 

Header data for the Qt.FontRole and Qt.TextAlignmentRole roles. The title of each grouping (i.e. the sequence name when grouping by sequence and the annotation type when grouping by annotation) will be bolded and centered.

rowCount(self, parent=None)

 
Overrides: PyQt4.QtCore.QAbstractItemModel.rowCount

columnCount(self, parent=None)

 
Overrides: PyQt4.QtCore.QAbstractItemModel.columnCount

setGroupBy(self, group_by)

 

Should the rows be grouped by sequence or by annotation type?

Parameters:
  • group_by (GroupBy) - The setting to apply
Decorators:
  • @table_helper.model_reset_method

getGroupBy(self)

 

Are the rows currently grouped by sequence or by annotation type?

Returns: GroupBy
The current setting