CMS 3D CMS Logo

AbstractView.py
Go to the documentation of this file.
1 import logging
2 
3 from PyQt4.QtCore import SIGNAL,Qt
4 from PyQt4.QtGui import QWidget
5 
6 from Vispa.Share.ObjectHolder import ObjectHolder
7 
9  """ Abstract class for views which show a list of objects using a data accessor.
10 
11  A view handles the selection of objects and allows to restore selection after refreshing.
12  On selection of an object the signal "selected" shall be emitted.
13  """
14 
15  LABEL = "&Abstract View"
16 
17  def __init__(self):
18  ObjectHolder.__init__(self)
19 
20  def updateContent(self):
21  """ Update content of view.
22 
23  Return True if successful.
24  """
25  return True
26 
27  def select(self, object):
28  """ Select an object in the view.
29  """
30  pass
31 
32  def selection(self):
33  """ Return the last selected object in the view.
34  """
35  return None
36 
37  def restoreSelection(self):
38  """ Select the last selected object in the view.
39  """
40  self.select(self.selection())
41 
42  def cancel(self):
43  """ Stop all operations in view.
44  """
45  pass
46 
47  def isBusy(self):
48  """ Return is operations are ongoing in view.
49  """
50  return False
51 
52 class NoneView(AbstractView, QWidget):
53 
54  LABEL = "&None View"
55 
56  def __init__(self, parent=None):
57  QWidget.__init__(self)
58  AbstractView.__init__(self)
59 
60  def mousePressEvent(self,event):
61  QWidget.mousePressEvent(self,event)
62  if event.button()==Qt.RightButton:
63  self.emit(SIGNAL("mouseRightPressed"), event.globalPos())
def __init__(self, parent=None)
Definition: AbstractView.py:56