1
2 from PyQt4.QtCore import Qt
3 from PyQt4 import QtGui, QtCore
4
5 import camelot.types
6 from camelot.core.constants import *
7 from camelot.view.proxy import ValueLoading
8 from camelot.core.utils import create_constant_function
9
10 editingFinished = QtCore.SIGNAL('editingFinished()')
11
13 """Helper class to be used to build custom editors. This class provides
14 functionallity to store and retrieve `ValueLoading` as an editor's value.
15 """
16
18 self._value_loading = True
19
21 if value==ValueLoading:
22 self._value_loading = True
23 return None
24 else:
25 self._value_loading = False
26 return value
27
29 if self._value_loading:
30 return ValueLoading
31 return None
32
33
34 """
35 Get the 'standard' height for a cell
36 """
38
39 height = [QtGui.QLineEdit().sizeHint().height(),
40 QtGui.QDateEdit().sizeHint().height(),
41 QtGui.QDateTimeEdit().sizeHint().height(),
42 QtGui.QSpinBox().sizeHint().height(),
43 QtGui.QDateEdit().sizeHint().height(),
44 QtGui.QComboBox().sizeHint().height()]
45
46 finalHeight = max(height)
47
48 return finalHeight
49
51 if background_color not in (None, ValueLoading):
52 palette = self.palette()
53 for x in [QtGui.QPalette.Active, QtGui.QPalette.Inactive, QtGui.QPalette.Disabled]:
54 for y in [self.backgroundRole(), QtGui.QPalette.Window]:
55 palette.setColor(x, y, background_color)
56 self.setPalette(palette)
57 else:
58 return False
59
61 """Base class for implementing custom editor widgets. This class provides
62 dual state functionality. Each editor should have the posibility to have as
63 its value `ValueLoading` specifying that no value has been set yet.
64 """
68