pypersyst-cvs Mailing List for Pypersyst - Python Persistence System
Brought to you by:
pobrien
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
(12) |
Apr
(11) |
May
(45) |
Jun
(97) |
Jul
(5) |
Aug
(73) |
Sep
(266) |
Oct
(222) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(81) |
Jun
(57) |
Jul
(279) |
Aug
(88) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Patrick K. O'B. <po...@us...> - 2004-08-12 12:28:36
|
Update of /cvsroot/pypersyst/pypersyst/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1522/doc Modified Files: todo.txt Log Message: Entity fields are now virtual, as is the enitity's sys namespace. Index: todo.txt =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/doc/todo.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** todo.txt 11 Aug 2004 01:54:32 -0000 1.2 --- todo.txt 12 Aug 2004 12:28:24 -0000 1.3 *************** *** 17,24 **** "full-range" apps are proprietary) - * To reduce memory consumption, Field instances should not be attached - to entity instances, and should only be used for value conversion - and validation in that context. - * Put the sort indicator back into the collection list view, and resize column 0 to snugly fit the icon that's in it rather than be --- 17,20 ---- |
From: Patrick K. O'B. <po...@us...> - 2004-08-12 12:10:43
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29368/pypersyst/ui/qt Modified Files: field.py Log Message: Tweaked the string control so that it treats blank strings as UNASSIGNED. The control needs to be a bit more intelligent about UNASSIGNED vs. empty strings, but for now this is at least closer to the expected behavior 99% of the time. Index: field.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/field.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** field.py 10 Aug 2004 22:45:54 -0000 1.8 --- field.py 12 Aug 2004 12:10:33 -0000 1.9 *************** *** 724,727 **** --- 724,729 ---- if not field.readonly: value = str(self.text()) + if value == '': + value = field.UNASSIGNED try: field.assign(value) |
From: Patrick K. O'B. <po...@us...> - 2004-08-11 12:31:28
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15643/pypersyst/test Modified Files: test_entity.py Log Message: Removed timestamps in the name of memory consumption reduction. If an application needs to keep track of that sort of thing, they can subclass Entity and put them back in. Otherwise, they are YAGNI for now. Index: test_entity.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/test_entity.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** test_entity.py 11 Aug 2004 02:47:07 -0000 1.24 --- test_entity.py 11 Aug 2004 12:31:19 -0000 1.25 *************** *** 82,89 **** self.assertEqual(self.entity.sys.rev, self.entity._rev) self.assertEqual(self.entity.sys.root, self.entity._root) - self.assertEqual(self.entity.sys.timestampCreate, - self.entity._timestampCreate) - self.assertEqual(self.entity.sys.timestampUpdate, - self.entity._timestampUpdate) self.assertEqual(self.entity.sys.version, self.entity._version) --- 82,85 ---- |
From: Patrick K. O'B. <po...@us...> - 2004-08-11 12:31:27
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/entity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15643/pypersyst/entity Modified Files: entity.py Log Message: Removed timestamps in the name of memory consumption reduction. If an application needs to keep track of that sort of thing, they can subclass Entity and put them back in. Otherwise, they are YAGNI for now. Index: entity.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/entity/entity.py,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** entity.py 11 Aug 2004 04:28:57 -0000 1.62 --- entity.py 11 Aug 2004 12:31:18 -0000 1.63 *************** *** 54,59 **** self.__dict__['_oid'] = None self.__dict__['_rev'] = 0 # starts at zero and increments by one - self.__dict__['_timestampCreate'] = time - self.__dict__['_timestampUpdate'] = time self.__dict__['_version'] = VERSION # If subclasses are using self._prep(), then self._initattrs --- 54,57 ---- *************** *** 196,200 **** """Update fields specified in attrs.""" self._validate(attrs) - self.__dict__['_timestampUpdate'] = time self.__dict__['_rev'] += 1 fields = self._fields --- 194,197 ---- *************** *** 294,309 **** root = property(fget=root, doc=root.__doc__) - def timestampCreate(self): - """Return the timestamp when the instance was created.""" - return self._instance._timestampCreate - timestampCreate = property(fget=timestampCreate, - doc=timestampCreate.__doc__) - - def timestampUpdate(self): - """Return the timestamp when the instance was last updated.""" - return self._instance._timestampUpdate - timestampUpdate = property(fget=timestampUpdate, - doc=timestampUpdate.__doc__) - def version(self): """Return the version number of the Entity class definition.""" --- 291,294 ---- |
From: Patrick K. O'B. <po...@us...> - 2004-08-11 04:29:07
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/entity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4391/pypersyst/entity Modified Files: entity.py Log Message: Made sys a property as well, to cut down on memory consumption. Index: entity.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/entity/entity.py,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** entity.py 11 Aug 2004 03:13:18 -0000 1.61 --- entity.py 11 Aug 2004 04:28:57 -0000 1.62 *************** *** 57,64 **** self.__dict__['_timestampUpdate'] = time self.__dict__['_version'] = VERSION - # Setup the sys namespace to avoid namespace conflicts in the - # public api between system-defined attributes and - # schema-defined attributes. - self.__dict__['sys'] = SysNamespace(self) # If subclasses are using self._prep(), then self._initattrs # will be populated with name: value pairs. --- 57,60 ---- *************** *** 96,100 **** Allows slots to be defined on subclasses.""" d = self.__dict__.copy() - del d['sys'] return d --- 92,95 ---- *************** *** 111,115 **** converter() self.__dict__['_version'] = newVersion - self.__dict__['sys'] = SysNamespace(self) def _convertToVersion2(self): --- 106,109 ---- *************** *** 194,197 **** --- 188,196 ---- self.__dict__['_oid'] = oid + # Setup the sys namespace to avoid namespace conflicts in the + # public api between system-defined attributes and schema-defined + # attributes. + sys = property(fget=lambda instance: SysNamespace(instance)) + def _update(self, time, attrs): """Update fields specified in attrs.""" |
From: Patrick K. O'B. <po...@us...> - 2004-08-11 03:13:28
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/entity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27768/pypersyst/entity Modified Files: entity.py Log Message: Cleaned up the code, removing commented out stuff. Index: entity.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/entity/entity.py,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** entity.py 11 Aug 2004 02:52:41 -0000 1.60 --- entity.py 11 Aug 2004 03:13:18 -0000 1.61 *************** *** 52,56 **** # Assign some attributes, bypassing __setattr__. self.__dict__['_extent'] = root[self.__class__.__name__] - # self.__dict__['_fields'] = {} # 'field name': field instance self.__dict__['_oid'] = None self.__dict__['_rev'] = 0 # starts at zero and increments by one --- 52,55 ---- *************** *** 68,72 **** # Clean up after ourselves. del self.__dict__['_initattrs'] - fields = {} for name, FieldClass in self._spec: # Make sure they don't try to assign to an attribute we --- 67,70 ---- *************** *** 82,90 **** value = field.default field.set(value) - # fields[name] = field self.__dict__[name] = field.get() # If we got this far, all individual field attrs were valid. ! # self._fields.update(fields) ! # Any remaining attrs are regular instance attributes. for name, value in attrs.iteritems(): self.__dict__[name] = value --- 80,86 ---- value = field.default field.set(value) self.__dict__[name] = field.get() # If we got this far, all individual field attrs were valid. ! # Any remaining attrs are non-field-based instance attributes. for name, value in attrs.iteritems(): self.__dict__[name] = value *************** *** 203,211 **** self.__dict__['_timestampUpdate'] = time self.__dict__['_rev'] += 1 - ## for name, value in attrs.iteritems(): - ## if name in self._fields: - ## self._fields[name].set(value) - ## else: - ## self.__dict__[name] = value fields = self._fields for name, value in attrs.iteritems(): --- 199,202 ---- *************** *** 228,235 **** combined = self._attrs combined.update(attrs) - # XXX Is it really necessary to validate the fields here, - # since setting the value on a field already calls validate? - ## if self._fields: - ## self._validateFields(combined) self._validateAttrs(combined) self._validateEntity(combined) --- 219,222 ---- *************** *** 247,265 **** pass - ## def _validateFields(self, attrs): - ## """Validate the field attrs individually.""" - ## fieldNames = [name for name, fieldClass in self._spec - ## if fieldClass is not None] - ## fields = self._fields - ## for name, value in attrs.iteritems(): - ## # If the attr is a field, validate it individually. - ## if name in fieldNames: - ## # Make sure they don't try to assign to an attribute - ## # we are already using, such as self._oid. - ## if name in self.__dict__: - ## raise AttributeError, '%r is a reserved attribute' % name - ## # Ask the field to validate itself. - ## fields[name].validate(value) - def __int__(self): """Return the oid of the Entity instance.""" --- 234,237 ---- |
From: Patrick K. O'B. <po...@us...> - 2004-08-11 02:52:51
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/entity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24762/pypersyst/entity Modified Files: entity.py Log Message: Initial stab at making fields virtual, to save memory consumption. Index: entity.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/entity/entity.py,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** entity.py 9 Aug 2004 22:38:30 -0000 1.59 --- entity.py 11 Aug 2004 02:52:41 -0000 1.60 *************** *** 52,56 **** # Assign some attributes, bypassing __setattr__. self.__dict__['_extent'] = root[self.__class__.__name__] ! self.__dict__['_fields'] = {} # 'field name': field instance self.__dict__['_oid'] = None self.__dict__['_rev'] = 0 # starts at zero and increments by one --- 52,56 ---- # Assign some attributes, bypassing __setattr__. self.__dict__['_extent'] = root[self.__class__.__name__] ! # self.__dict__['_fields'] = {} # 'field name': field instance self.__dict__['_oid'] = None self.__dict__['_rev'] = 0 # starts at zero and increments by one *************** *** 58,61 **** --- 58,65 ---- self.__dict__['_timestampUpdate'] = time self.__dict__['_version'] = VERSION + # Setup the sys namespace to avoid namespace conflicts in the + # public api between system-defined attributes and + # schema-defined attributes. + self.__dict__['sys'] = SysNamespace(self) # If subclasses are using self._prep(), then self._initattrs # will be populated with name: value pairs. *************** *** 66,69 **** --- 70,78 ---- fields = {} for name, FieldClass in self._spec: + # Make sure they don't try to assign to an attribute we + # are already using, such as self._oid or self.sys or any + # attribute that starts with an underscore. + if hasattr(self, name) or name.startswith('_'): + raise AttributeError, '%r is a reserved attribute' % name if FieldClass is None: continue *************** *** 73,79 **** value = field.default field.set(value) ! fields[name] = field # If we got this far, all individual field attrs were valid. ! self._fields.update(fields) # Any remaining attrs are regular instance attributes. for name, value in attrs.iteritems(): --- 82,89 ---- value = field.default field.set(value) ! # fields[name] = field ! self.__dict__[name] = field.get() # If we got this far, all individual field attrs were valid. ! # self._fields.update(fields) # Any remaining attrs are regular instance attributes. for name, value in attrs.iteritems(): *************** *** 84,91 **** # cause of failure has been dealt with. self._extent._insert(self) - # Setup the sys namespace to avoid namespace conflicts in the - # public api between system-defined attributes and - # schema-defined attributes. - self.__dict__['sys'] = SysNamespace(self) def __getstate__(self): --- 94,97 ---- *************** *** 152,155 **** --- 158,172 ---- return False + def _fields(self): + """Return dictionary of 'field name': field instance.""" + d = {} + for name, fieldClass in self._spec: + if fieldClass is not None: + field = fieldClass(instance=self, attribute=name) + field._value = getattr(self, name) + d[name] = field + return d + _fields = property(fget=_fields, doc=_fields.__doc__) + def _getAttributeNames(self): """Return list of hidden attribute names, for PyCrust.""" *************** *** 186,194 **** self.__dict__['_timestampUpdate'] = time self.__dict__['_rev'] += 1 for name, value in attrs.iteritems(): ! if name in self._fields: ! self._fields[name].set(value) ! else: ! self.__dict__[name] = value def _validate(self, attrs): --- 203,218 ---- self.__dict__['_timestampUpdate'] = time self.__dict__['_rev'] += 1 + ## for name, value in attrs.iteritems(): + ## if name in self._fields: + ## self._fields[name].set(value) + ## else: + ## self.__dict__[name] = value + fields = self._fields for name, value in attrs.iteritems(): ! if name in fields: ! field = fields[name] ! field.set(value) ! value = field.get() ! self.__dict__[name] = value def _validate(self, attrs): *************** *** 204,209 **** combined = self._attrs combined.update(attrs) ! if self._fields: ! self._validateFields(combined) self._validateAttrs(combined) self._validateEntity(combined) --- 228,235 ---- combined = self._attrs combined.update(attrs) ! # XXX Is it really necessary to validate the fields here, ! # since setting the value on a field already calls validate? ! ## if self._fields: ! ## self._validateFields(combined) self._validateAttrs(combined) self._validateEntity(combined) *************** *** 221,238 **** pass ! def _validateFields(self, attrs): ! """Validate the field attrs individually.""" ! fieldNames = [name for name, fieldClass in self._spec ! if fieldClass is not None] ! fields = self._fields ! for name, value in attrs.iteritems(): ! # If the attr is a field, validate it individually. ! if name in fieldNames: ! # Make sure they don't try to assign to an attribute ! # we are already using, such as self._oid. ! if name in self.__dict__: ! raise AttributeError, '%r is a reserved attribute' % name ! # Ask the field to validate itself. ! fields[name].validate(value) def __int__(self): --- 247,264 ---- pass ! ## def _validateFields(self, attrs): ! ## """Validate the field attrs individually.""" ! ## fieldNames = [name for name, fieldClass in self._spec ! ## if fieldClass is not None] ! ## fields = self._fields ! ## for name, value in attrs.iteritems(): ! ## # If the attr is a field, validate it individually. ! ## if name in fieldNames: ! ## # Make sure they don't try to assign to an attribute ! ## # we are already using, such as self._oid. ! ## if name in self.__dict__: ! ## raise AttributeError, '%r is a reserved attribute' % name ! ## # Ask the field to validate itself. ! ## fields[name].validate(value) def __int__(self): *************** *** 308,311 **** --- 334,338 ---- timestampUpdate = property(fget=timestampUpdate, doc=timestampUpdate.__doc__) + def version(self): """Return the version number of the Entity class definition.""" |
From: Patrick K. O'B. <po...@us...> - 2004-08-11 02:47:17
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24112/pypersyst/test Modified Files: test_domain.py test_entity.py Log Message: Fixed broken tests, added a few new ones. Index: test_domain.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/test_domain.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** test_domain.py 9 Aug 2004 22:38:30 -0000 1.31 --- test_domain.py 11 Aug 2004 02:47:07 -0000 1.32 *************** *** 228,232 **** create = domain.ICreate(collection) label = domain.ILabel(create) ! self.assertEqual(label, 'Create') create.data.name = 'foo' display = create.execute() --- 228,232 ---- create = domain.ICreate(collection) label = domain.ILabel(create) ! self.assertEqual(label, 'New') create.data.name = 'foo' display = create.execute() *************** *** 238,242 **** update = domain.IUpdate(display) label = domain.ILabel(update) ! self.assertEqual(label, 'Update') def test_entitySupplierCustomLabels(self): --- 238,242 ---- update = domain.IUpdate(display) label = domain.ILabel(update) ! self.assertEqual(label, 'Edit') def test_entitySupplierCustomLabels(self): *************** *** 263,267 **** # should have labels defined for them already. label = domain.ILabel(domain.ICreate) ! self.assertEqual(label, 'Create') label = domain.ILabel(domain.IDelete) self.assertEqual(label, 'Delete') --- 263,267 ---- # should have labels defined for them already. label = domain.ILabel(domain.ICreate) ! self.assertEqual(label, 'New') label = domain.ILabel(domain.IDelete) self.assertEqual(label, 'Delete') *************** *** 269,273 **** self.assertEqual(label, 'Display') label = domain.ILabel(domain.IUpdate) ! self.assertEqual(label, 'Update') --- 269,273 ---- self.assertEqual(label, 'Display') label = domain.ILabel(domain.IUpdate) ! self.assertEqual(label, 'Edit') *************** *** 280,284 **** actions = domain.actions(collection) self.assertEqual(len(list(actions)), 1) ! self.assert_(('Create', domain.ICreate) in actions) # A realm display supplier should be able to delete or # update. --- 280,284 ---- actions = domain.actions(collection) self.assertEqual(len(list(actions)), 1) ! self.assert_(('New', domain.ICreate) in actions) # A realm display supplier should be able to delete or # update. *************** *** 289,297 **** self.assertEqual(len(list(actions)), 2) self.assert_(('Delete', domain.IDelete) in actions) ! self.assert_(('Update', domain.IUpdate) in actions) # A thing collection should be able to create. collection = domain['Thing'] actions = domain.actions(collection) ! self.assert_(('Create', domain.ICreate) in actions) # A thing display supplier should not be able to do # anything. --- 289,297 ---- self.assertEqual(len(list(actions)), 2) self.assert_(('Delete', domain.IDelete) in actions) ! self.assert_(('Edit', domain.IUpdate) in actions) # A thing collection should be able to create. collection = domain['Thing'] actions = domain.actions(collection) ! self.assert_(('New', domain.ICreate) in actions) # A thing display supplier should not be able to do # anything. Index: test_entity.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/test_entity.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** test_entity.py 9 Aug 2004 22:38:30 -0000 1.23 --- test_entity.py 11 Aug 2004 02:47:07 -0000 1.24 *************** *** 479,482 **** --- 479,513 ---- + class SysEntity(Entity): + + _spec = [ + ('sys', field.Field), + ] + + + class SysEntityTestCase(unittest.TestCase): + + def test_init(self): + Root._EntityClasses = [SysEntity] + self.root = Root() + self.assertRaises(AttributeError, SysEntity, self.root, sys='foo') + + + class PrivateEntity(Entity): + + _spec = [ + ('_private', field.Field), + ] + + + class PrivateEntityTestCase(unittest.TestCase): + + def test_init(self): + Root._EntityClasses = [PrivateEntity] + self.root = Root() + self.assertRaises(AttributeError, PrivateEntity, self.root, + _private='foo') + + class ExtentTestCase(unittest.TestCase): |
From: Matthew R. S. <gld...@us...> - 2004-08-11 02:32:51
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19766/pypersyst/ui/qt Modified Files: field.py Log Message: More icon support. Index: field.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/field.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** field.py 7 Aug 2004 00:56:23 -0000 1.3 --- field.py 10 Aug 2004 19:58:13 -0000 1.4 *************** *** 236,240 **** def onActivated(self, index): ! value = self._values[index][1] if hasattr(value, 'data'): self.field.assign(value.data) --- 236,240 ---- def onActivated(self, index): ! value = self._values[index][2] if hasattr(value, 'data'): self.field.assign(value.data) *************** *** 259,273 **** except: pass ! values.append((label, display)) values.sort() if self.field.allowNone: ! values.insert(0, ('(None)', None)) ! values.insert(0, ('', field.UNASSIGNED)) self.setCurrentItem(0) # Create combo box items. self.clear() index = 0 ! for label, value in values: ! self.insertItem(label) if value == fieldValue: self.setCurrentItem(index) --- 259,282 ---- except: pass ! icon = domain.IIcon(display.collection) ! values.append((label, icon, display)) values.sort() if self.field.allowNone: ! values.insert(0, ('(None)', None, None)) ! values.insert(0, ('', None, field.UNASSIGNED)) self.setCurrentItem(0) # Create combo box items. self.clear() index = 0 ! for label, icon, value in values: ! if icon is not None: ! iconSet = qt.QIconSet() ! image = qt.QImage() ! image.loadFromData(icon) ! iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) ! self.insertItem(iconSet.pixmap(iconSet.Small, iconSet.Normal), ! label) ! else: ! self.insertItem(label) if value == fieldValue: self.setCurrentItem(index) |
From: Matthew R. S. <gld...@us...> - 2004-08-11 01:54:41
|
Update of /cvsroot/pypersyst/pypersyst/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17532/doc Modified Files: todo.txt Log Message: Todo list updates. Index: todo.txt =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/doc/todo.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** todo.txt 10 Aug 2004 23:14:04 -0000 1.1 --- todo.txt 11 Aug 2004 01:54:32 -0000 1.2 *************** *** 18,22 **** * To reduce memory consumption, Field instances should not be attached ! to entity instances, and only be used for value conversion and ! validation in that context. --- 18,26 ---- * To reduce memory consumption, Field instances should not be attached ! to entity instances, and should only be used for value conversion ! and validation in that context. ! ! * Put the sort indicator back into the collection list view, and ! resize column 0 to snugly fit the icon that's in it rather than be ! "too wide" because of the sort indicator visibility. |
From: Matthew R. S. <gld...@us...> - 2004-08-10 23:14:19
|
Update of /cvsroot/pypersyst/pypersyst/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23742/doc Modified Files: domains.txt Added Files: todo.txt Log Message: Add todo list. --- NEW FILE: todo.txt --- .. -*- mode: rst -*- ================ PyPerSyst TODO ================ * ExtentCollection.find() and findone() should adapt their keyword args to IEntity if possible, in order to convert entity-like things such as Fieldspaces to their related Entity instances. * More complete unit tests for domains. * More complete unit tests for fields. * Real-world, rather than simple and contrived, GPL'd example app(s) that use the full range of PyPerSyst domains. (All the current "full-range" apps are proprietary) * To reduce memory consumption, Field instances should not be attached to entity instances, and only be used for value conversion and validation in that context. Index: domains.txt =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/doc/domains.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** domains.txt 10 Aug 2004 16:02:10 -0000 1.3 --- domains.txt 10 Aug 2004 23:14:03 -0000 1.4 *************** *** 178,189 **** - **Domain** instances should have icons that could be used in an ! About box, or as an application icon. - **Field** classes should have icons that represent the data they ! contain. - **Fieldspace** instances should have icons that represent the data they contain. Often, Fieldspace instances will have the same icons ! as their associated collection. - **Supplier** instances should have icons that represent what the --- 178,189 ---- - **Domain** instances should have icons that could be used in an ! About box, or as an application icon. (XXX: Not yet supported) - **Field** classes should have icons that represent the data they ! contain. (XXX: Not yet supported) - **Fieldspace** instances should have icons that represent the data they contain. Often, Fieldspace instances will have the same icons ! as their associated collection. (XXX: Not yet supported) - **Supplier** instances should have icons that represent what the |
From: Matthew R. S. <gld...@us...> - 2004-08-10 22:46:13
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18905/pypersyst/ui/qt Modified Files: field.py Log Message: More icon support. Index: field.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/field.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** field.py 10 Aug 2004 22:39:29 -0000 1.7 --- field.py 10 Aug 2004 22:45:54 -0000 1.8 *************** *** 611,616 **** def __init__(self, domain, ob, parent): self.ob = ob ! qt.QCheckListItem.__init__(self, parent, domain.ILabel(ob), ! self.CheckBox) def stateChange(self, newState): field = self.listView().field --- 611,622 ---- def __init__(self, domain, ob, parent): self.ob = ob ! # If the object's class is a valid collection name, the ! # icon is the named collection's icon. ! label = domain.ILabel(ob) ! qt.QCheckListItem.__init__(self, parent, label, self.CheckBox) ! className = ob.__class__.__name__ ! if className in domain: ! self.setPixmap(0, iconcache.smallPixmap(domain, ! domain[className])) def stateChange(self, newState): field = self.listView().field |
From: Matthew R. S. <gld...@us...> - 2004-08-10 22:39:38
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17649/pypersyst/ui/qt Modified Files: field.py Log Message: More icon support. Index: field.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/field.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** field.py 10 Aug 2004 21:49:33 -0000 1.6 --- field.py 10 Aug 2004 22:39:29 -0000 1.7 *************** *** 311,315 **** ! class EntityInstanceLink(qt.QLabel): """A link to an entity instance. --- 311,315 ---- ! class EntityInstanceLink(qt.QWidget): """A link to an entity instance. *************** *** 321,330 **** def __init__(self, domain, field, parent, name, *args, **kwargs): self._domain = domain self.field = field ! qt.QLabel.__init__(self, parent, name, *args) self._origCursor = self.cursor() ! self.setTextFormat(self.PlainText) ! self._origColor = self.paletteForegroundColor() self.reset() --- 321,337 ---- def __init__(self, domain, field, parent, name, *args, **kwargs): + qt.QWidget.__init__(self, parent, name, *args) self._domain = domain self.field = field ! # Set up child widgets. ! hbox = qt.QHBoxLayout(self, 0, 0) ! pixmapLabel = self.pixmapLabel = qt.QLabel(self) ! hbox.addWidget(pixmapLabel) ! textLabel = self.textLabel = qt.QLabel(self) ! hbox.addWidget(textLabel, 1) ! # Set up initial state. self._origCursor = self.cursor() ! textLabel.setTextFormat(self.PlainText) ! self._origColor = textLabel.paletteForegroundColor() self.reset() *************** *** 341,344 **** --- 348,353 ---- domain = self._domain field = self.field + pixmapLabel = self.pixmapLabel + textLabel = self.textLabel value = field.get() if value is field.UNASSIGNED or value is None: *************** *** 355,368 **** label = '(No Label)' self._isLink = True ! font = self.font() font.setUnderline(self._isLink) ! self.setFont(font) if self._isLink: ! self.setPaletteForegroundColor(qt.QColor('blue')) self.setCursor(qt.QCursor(self.PointingHandCursor)) else: ! self.setPaletteForegroundColor(self._origColor) self.setCursor(self._origCursor) ! self.setText(label) --- 364,384 ---- label = '(No Label)' self._isLink = True ! # Set text. ! font = textLabel.font() font.setUnderline(self._isLink) ! textLabel.setFont(font) if self._isLink: ! textLabel.setPaletteForegroundColor(qt.QColor('blue')) self.setCursor(qt.QCursor(self.PointingHandCursor)) else: ! textLabel.setPaletteForegroundColor(self._origColor) self.setCursor(self._origCursor) ! textLabel.setText(label) ! # Set pixmap. ! if self._isLink: ! pixmap = iconcache.smallPixmap(domain, display.collection) ! pixmapLabel.setPixmap(pixmap) ! else: ! pixmapLabel.setPixmap(qt.QPixmap()) |
From: Matthew R. S. <gld...@us...> - 2004-08-10 22:24:46
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14048/pypersyst/ui/qt Modified Files: collection.py Log Message: More icon support. Index: collection.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/collection.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** collection.py 10 Aug 2004 22:00:11 -0000 1.35 --- collection.py 10 Aug 2004 22:24:37 -0000 1.36 *************** *** 473,476 **** --- 473,477 ---- pass self._oid = data.sys.oid + self._pixmap = iconcache.smallPixmap(domain, collection) def acceptDrop(self, mime): *************** *** 494,497 **** --- 495,502 ---- return retval + def pixmap(self, col): + if col == 0: + return self._pixmap + def supplier(self): """Return a display supplier based on this item.""" *************** *** 955,962 **** values = self._values = [] pixmaps = self._pixmaps = [] for name, label in listView._colnames: if name == 'sys.oid': value = self._oid - pixmap = self._pixmap else: value = getattr(data, name) --- 960,967 ---- values = self._values = [] pixmaps = self._pixmaps = [] + colNo = 0 for name, label in listView._colnames: if name == 'sys.oid': value = self._oid else: value = getattr(data, name) *************** *** 968,973 **** --- 973,985 ---- else: pixmap = None + if colNo == 0: + pixmap = self._pixmap + if name == 'sys.oid': + self._hideCol0Text = True + else: + self._hideCol0Text = False values.append(value) pixmaps.append(pixmap) + colNo += 1 def supplier(self): *************** *** 978,982 **** """Return the text that should show for this column.""" listView = self.listView() ! if col == 0: # Don't actually show the OID. # --- 990,994 ---- """Return the text that should show for this column.""" listView = self.listView() ! if col == 0 and self._hideCol0Text: # Don't actually show the OID. # |
From: Matthew R. S. <gld...@us...> - 2004-08-10 22:00:35
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9165/pypersyst/ui/qt Modified Files: collection.py Log Message: More icon support. Index: collection.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/collection.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** collection.py 10 Aug 2004 21:49:33 -0000 1.34 --- collection.py 10 Aug 2004 22:00:11 -0000 1.35 *************** *** 640,644 **** self._collection = collection self._filter = filter ! self._hiddenColnames = ['sys.oid'] # Set default property values. self.setDraggable(False) --- 640,646 ---- self._collection = collection self._filter = filter ! # Don't hide any columns, since we want to show the collection ! # pixmap. ! self._hiddenColnames = [] # Set default property values. self.setDraggable(False) *************** *** 727,731 **** def _setup(self): - self.setShowSortIndicator(True) self.setAllColumnsShowFocus(True) self.setDragAutoScroll(True) --- 729,732 ---- *************** *** 742,746 **** def _setupColumns(self): domain = self._domain ! colnames = self._colnames = [('sys.oid', 'OID')] collection = self._collection spec = collection._spec --- 743,748 ---- def _setupColumns(self): domain = self._domain ! # First column is the collection pixmap and hidden OID for sorting. ! colnames = self._colnames = [('sys.oid', '')] collection = self._collection spec = collection._spec *************** *** 903,906 **** --- 905,909 ---- self._rev = supplier.data.sys.rev self._collection = collection + self._pixmap = iconcache.smallPixmap(domain, collection) # Calculate values right away rather than storing supplier. self.refreshData(supplier.data) *************** *** 940,943 **** --- 943,949 ---- return qt.QListViewItem.paintCell(self, p, cg, column, width, align) + def pixmap(self, col): + return self._pixmaps[col] + def refreshData(self, data=None): """Refresh data shown by self to be current with latest revision.""" *************** *** 952,959 **** if name == 'sys.oid': value = self._oid else: value = getattr(data, name) values.append(value) ! pixmaps.append(value) def supplier(self): --- 958,973 ---- if name == 'sys.oid': value = self._oid + pixmap = self._pixmap else: value = getattr(data, name) + # If the value's class name is a collection name, the + # pixmap is the named collection's pixmap. + className = value.__class__.__name__ + if className in domain: + pixmap = iconcache.smallPixmap(domain, domain[className]) + else: + pixmap = None values.append(value) ! pixmaps.append(pixmap) def supplier(self): |
From: Matthew R. S. <gld...@us...> - 2004-08-10 21:49:44
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7383/pypersyst/ui/qt Modified Files: action.py collection.py field.py Added Files: iconcache.py Log Message: Iconset caching. --- NEW FILE: iconcache.py --- """Cache of iconsets for objects.""" import weakref import qt _cache = weakref.WeakKeyDictionary() def iconset(domain, ob): if domain in _cache: iconCache = _cache[domain] else: iconCache = weakref.WeakKeyDictionary() _cache[domain] = iconCache if ob in iconCache: iconSet = iconCache[ob] else: icon = domain.IIcon(ob, None) iconSet = qt.QIconSet() if icon is not None: image = qt.QImage() image.loadFromData(icon) iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) iconCache[ob] = iconSet return iconSet def largePixmap(domain, ob): iconSet = iconset(domain, ob) return iconSet.pixmap(iconSet.Large, iconSet.Normal) def smallPixmap(domain, ob): iconSet = iconset(domain, ob) return iconSet.pixmap(iconSet.Small, iconSet.Normal) Index: field.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/field.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** field.py 10 Aug 2004 20:14:23 -0000 1.5 --- field.py 10 Aug 2004 21:49:33 -0000 1.6 *************** *** 10,13 **** --- 10,14 ---- from pypersyst.field import field as pfield + from pypersyst.ui.qt import iconcache from pypersyst.ui.qt import interface from pypersyst.ui.qt.image.image import uic_findImage as image *************** *** 259,264 **** except: pass ! icon = domain.IIcon(display.collection, None) ! values.append((label, icon, display)) values.sort() if self.field.allowNone: --- 260,265 ---- except: pass ! pixmap = iconcache.smallPixmap(domain, display.collection) ! values.append((label, pixmap, display)) values.sort() if self.field.allowNone: *************** *** 269,280 **** self.clear() index = 0 ! for label, icon, value in values: ! if icon is not None: ! iconSet = qt.QIconSet() ! image = qt.QImage() ! image.loadFromData(icon) ! iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) ! self.insertItem(iconSet.pixmap(iconSet.Small, iconSet.Normal), ! label) else: self.insertItem(label) --- 270,276 ---- self.clear() index = 0 ! for label, pixmap, value in values: ! if pixmap is not None: ! self.insertItem(pixmap, label) else: self.insertItem(label) Index: action.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/action.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** action.py 10 Aug 2004 19:30:21 -0000 1.5 --- action.py 10 Aug 2004 21:49:30 -0000 1.6 *************** *** 4,7 **** --- 4,8 ---- from pypersyst.ui.qt.autoconnector import AutoConnector + from pypersyst.ui.qt import iconcache from pypersyst.ui.qt import signal *************** *** 99,108 **** menu.insertSeparator() for actionlabel, action in actions: ! iconSet = qt.QIconSet() ! icon = domain.IIcon(action, None) ! if icon is not None: ! image = qt.QImage() ! image.loadFromData(icon) ! iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) qAction = qt.QAction(iconSet, '&' + actionlabel, qt.QKeySequence(), parent) --- 100,104 ---- menu.insertSeparator() for actionlabel, action in actions: ! iconSet = iconcache.iconset(domain, action) qAction = qt.QAction(iconSet, '&' + actionlabel, qt.QKeySequence(), parent) *************** *** 136,145 **** buttons = [] for actionlabel, action in domain.actions(item): ! iconSet = qt.QIconSet() ! icon = domain.IIcon(action, None) ! if icon is not None: ! image = qt.QImage() ! image.loadFromData(icon) ! iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) button = buttonClass(parent) button.setText(actionlabel) --- 132,136 ---- buttons = [] for actionlabel, action in domain.actions(item): ! iconSet = iconcache.iconset(domain, action) button = buttonClass(parent) button.setText(actionlabel) Index: collection.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/collection.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** collection.py 10 Aug 2004 19:46:26 -0000 1.33 --- collection.py 10 Aug 2004 21:49:33 -0000 1.34 *************** *** 14,17 **** --- 14,18 ---- from pypersyst.ui.qt.autoconnector import AutoConnector import pypersyst.ui.qt.dragdrop + from pypersyst.ui.qt import iconcache from pypersyst.ui.qt import interface from pypersyst.ui.qt import signal *************** *** 143,152 **** collection = payload.collection plural = domain.IPluralLabel(collection) ! iconSet = qt.QIconSet() ! icon = domain.IIcon(collection, None) ! if icon is not None: ! image = qt.QImage() ! image.loadFromData(icon) ! iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) # Create a submenu if requested. submenu = None --- 144,148 ---- collection = payload.collection plural = domain.IPluralLabel(collection) ! iconSet = iconcache.iconset(domain, collection) # Create a submenu if requested. submenu = None *************** *** 540,549 **** domain = self._domain collection = payload.collection ! iconSet = qt.QIconSet() ! icon = domain.IIcon(collection, None) ! if icon is not None: ! image = qt.QImage() ! image.loadFromData(icon) ! iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) # Create a widget to contain the action buttons. widget = qt.QWidget(self) --- 536,540 ---- domain = self._domain collection = payload.collection ! iconSet = iconcache.iconset(domain, collection) # Create a widget to contain the action buttons. widget = qt.QWidget(self) *************** *** 555,564 **** buttons = widget._buttons = [] for label, action in domain.actions(collection): ! iconSet = qt.QIconSet() ! icon = domain.IIcon(action, None) ! if icon is not None: ! image = qt.QImage() ! image.loadFromData(icon) ! iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) button = qt.QToolButton(widget) button.setAutoRaise(True) --- 546,550 ---- buttons = widget._buttons = [] for label, action in domain.actions(collection): ! iconSet = iconcache.iconset(domain, action) button = qt.QToolButton(widget) button.setAutoRaise(True) *************** *** 956,963 **** --- 942,952 ---- def refreshData(self, data=None): """Refresh data shown by self to be current with latest revision.""" + domain = self._domain + collection = self._collection if data is None: data = self.supplier().data listView = self.listView() values = self._values = [] + pixmaps = self._pixmaps = [] for name, label in listView._colnames: if name == 'sys.oid': *************** *** 966,969 **** --- 955,959 ---- value = getattr(data, name) values.append(value) + pixmaps.append(value) def supplier(self): *************** *** 974,980 **** """Return the text that should show for this column.""" listView = self.listView() ! value = self._values[col] ! value = self._domain.ILabel(value, value) ! return str(value) --- 964,977 ---- """Return the text that should show for this column.""" listView = self.listView() ! if col == 0: ! # Don't actually show the OID. ! # ! # XXX: Make sure that this can be overridden in the case ! # of someone wanting to debug. Or not. :-) ! return '' ! else: ! value = self._values[col] ! value = self._domain.ILabel(value, value) ! return str(value) |
From: Matthew R. S. <gld...@us...> - 2004-08-10 21:21:54
|
Update of /cvsroot/pypersyst/pypersyst/tools/navigator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2920/tools/navigator Modified Files: nav.py Log Message: More reasonable icon sizes. Index: nav.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/tools/navigator/nav.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** nav.py 28 Jul 2004 03:05:10 -0000 1.1 --- nav.py 10 Aug 2004 21:21:46 -0000 1.2 *************** *** 5,12 **** --- 5,16 ---- import sys + import qt + import navigator.main if __name__ == '__main__': + qt.QIconSet.setIconSize(qt.QIconSet.Small, qt.QSize(16, 16)) + qt.QIconSet.setIconSize(qt.QIconSet.Large, qt.QSize(32, 32)) sys.exit(navigator.main.main()) |
From: Matthew R. S. <gld...@us...> - 2004-08-10 20:18:24
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23495/pypersyst/ui/qt Modified Files: supplier.py Log Message: Default labels now more intuitive for non-programmers. Index: supplier.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/supplier.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** supplier.py 10 Aug 2004 16:34:38 -0000 1.9 --- supplier.py 10 Aug 2004 20:18:15 -0000 1.10 *************** *** 212,216 **** If the supplier is executable, two buttons will appear labeled ! 'Execute' and 'Cancel' by default. Emits the following signals based on user interactions: --- 212,216 ---- If the supplier is executable, two buttons will appear labeled ! 'OK' and 'Cancel' by default. Emits the following signals based on user interactions: *************** *** 278,282 **** def __init__(self, domain, supplier, parent, name, cancelLabel='Cancel', ! executeLabel='Execute', spacerBelow=True, *args): self._domain = domain self._supplier = supplier --- 278,282 ---- def __init__(self, domain, supplier, parent, name, cancelLabel='Cancel', ! executeLabel='OK', spacerBelow=True, *args): self._domain = domain self._supplier = supplier |
From: Matthew R. S. <gld...@us...> - 2004-08-10 20:18:24
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/domain In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23495/pypersyst/domain Modified Files: interface.py supplier.py Log Message: Default labels now more intuitive for non-programmers. Index: interface.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/domain/interface.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** interface.py 10 Aug 2004 16:02:10 -0000 1.24 --- interface.py 10 Aug 2004 20:18:15 -0000 1.25 *************** *** 238,242 **** """A supplier used for creating things.""" protocol.advise(classProvides=[IAction]) ! declareLabel(ICreate, 'Create') --- 238,242 ---- """A supplier used for creating things.""" protocol.advise(classProvides=[IAction]) ! declareLabel(ICreate, 'New') *************** *** 255,259 **** """A supplier used for updating things.""" protocol.advise(classProvides=[IAction]) ! declareLabel(IUpdate, 'Update') --- 255,259 ---- """A supplier used for updating things.""" protocol.advise(classProvides=[IAction]) ! declareLabel(IUpdate, 'Edit') Index: supplier.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/domain/supplier.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** supplier.py 9 Aug 2004 16:00:20 -0000 1.25 --- supplier.py 10 Aug 2004 20:18:15 -0000 1.26 *************** *** 43,47 **** return tx.Create(self._entityName, **attrs) ! interface.declareLabel(EntityCreate, 'Create') --- 43,47 ---- return tx.Create(self._entityName, **attrs) ! interface.declareLabel(EntityCreate, 'New') *************** *** 144,147 **** return tx.Update(self._instance, **attrs) ! interface.declareLabel(EntityUpdate, 'Update') --- 144,147 ---- return tx.Update(self._instance, **attrs) ! interface.declareLabel(EntityUpdate, 'Edit') |
From: Matthew R. S. <gld...@us...> - 2004-08-10 20:14:31
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22785/pypersyst/ui/qt Modified Files: field.py Log Message: Icon fix. Index: field.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/field.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** field.py 10 Aug 2004 19:58:13 -0000 1.4 --- field.py 10 Aug 2004 20:14:23 -0000 1.5 *************** *** 259,263 **** except: pass ! icon = domain.IIcon(display.collection) values.append((label, icon, display)) values.sort() --- 259,263 ---- except: pass ! icon = domain.IIcon(display.collection, None) values.append((label, icon, display)) values.sort() |
From: Matthew R. S. <gld...@us...> - 2004-08-10 19:46:48
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16964/pypersyst/ui/qt Modified Files: collection.py Log Message: More icon support. Index: collection.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/collection.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** collection.py 10 Aug 2004 18:25:40 -0000 1.32 --- collection.py 10 Aug 2004 19:46:26 -0000 1.33 *************** *** 555,558 **** --- 555,564 ---- buttons = widget._buttons = [] for label, action in domain.actions(collection): + iconSet = qt.QIconSet() + icon = domain.IIcon(action, None) + if icon is not None: + image = qt.QImage() + image.loadFromData(icon) + iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) button = qt.QToolButton(widget) button.setAutoRaise(True) *************** *** 560,563 **** --- 566,570 ---- button.setTextPosition(button.BesideIcon) button.setUsesTextLabel(True) + button.setIconSet(iconSet) def onClicked(action=action, collection=collection): payload = signal.ActionActivated( |
From: Matthew R. S. <gld...@us...> - 2004-08-10 19:30:31
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14255/pypersyst/ui/qt Modified Files: action.py Log Message: More icon support. Index: action.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/action.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** action.py 10 Aug 2004 19:12:18 -0000 1.4 --- action.py 10 Aug 2004 19:30:21 -0000 1.5 *************** *** 136,141 **** --- 136,148 ---- buttons = [] for actionlabel, action in domain.actions(item): + iconSet = qt.QIconSet() + icon = domain.IIcon(action, None) + if icon is not None: + image = qt.QImage() + image.loadFromData(icon) + iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) button = buttonClass(parent) button.setText(actionlabel) + button.setIconSet(iconSet) def onClicked(action=action, item=item): onAction(action, item) |
From: Matthew R. S. <gld...@us...> - 2004-08-10 19:12:27
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11244/pypersyst/ui/qt Modified Files: action.py Log Message: More icon support. Index: action.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/action.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** action.py 30 Jul 2004 17:00:11 -0000 1.3 --- action.py 10 Aug 2004 19:12:18 -0000 1.4 *************** *** 99,103 **** menu.insertSeparator() for actionlabel, action in actions: ! qAction = qt.QAction('&' + actionlabel, qt.QKeySequence(), parent) qActions.append(action) help = getStatusTip(action, item) --- 99,110 ---- menu.insertSeparator() for actionlabel, action in actions: ! iconSet = qt.QIconSet() ! icon = domain.IIcon(action, None) ! if icon is not None: ! image = qt.QImage() ! image.loadFromData(icon) ! iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) ! qAction = qt.QAction(iconSet, '&' + actionlabel, qt.QKeySequence(), ! parent) qActions.append(action) help = getStatusTip(action, item) |
From: Matthew R. S. <gld...@us...> - 2004-08-10 18:25:49
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1734/pypersyst/ui/qt Modified Files: collection.py Log Message: Performance improvements for showing ListViews of ExtentCollections. Index: collection.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/collection.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** collection.py 10 Aug 2004 16:34:38 -0000 1.31 --- collection.py 10 Aug 2004 18:25:40 -0000 1.32 *************** *** 1,4 **** --- 1,5 ---- """Collection widgets for PyPerSyst's PyQt UI.""" + from sets import Set as set import types *************** *** 383,387 **** --- 384,390 ---- scroll = self.verticalScrollBar() scrollValue = scroll.value() + qt.QApplication.setOverrideCursor(qt.QCursor(self.WaitCursor)) self._setupItems() + qt.QApplication.restoreOverrideCursor() scroll.setValue(scrollValue) *************** *** 735,739 **** --- 738,744 ---- self.setDragAutoScroll(True) self._setupColumns() + qt.QApplication.setOverrideCursor(qt.QCursor(self.WaitCursor)) self._setupItems() + qt.QApplication.restoreOverrideCursor() # Sort by OID by default, even though the column is also # hidden by default. *************** *** 781,784 **** --- 786,790 ---- item = ListViewItem(self._domain, self._collection, supplier, self) sid = supplierId(supplier) + item._supplierId = sid supplierItems[sid] = item if sid in prevSelected: *************** *** 787,790 **** --- 793,849 ---- self.setCurrentSupplierId(prevCurrent) + def _setupItemsPartial(self): + """Intelligently refresh the list. + + Depends on certain extensions available only via + ExtentCollection instances. + """ + domain = self._domain + collection = self._collection + # If collection extensions aren't available, do a full, 'dumb' + # refresh. + if not hasattr(collection, 'allOidsRevs'): + return self._setupItems() + # Iterate through all listview items to modify and delete. + updated = False + visibleOids = set() + iterator = qt.QListViewItemIterator(self) + current = iterator.current() + allOidsRevs = collection.allOidsRevs() + toTake = [] + while current is not None: + oid = current._oid + rev = current._rev + if oid in allOidsRevs: + # Keep track of the fact that the supplier exists. + visibleOids.add(oid) + # If the latest rev is newer than the listview item's + # rev, refresh the listview item. + if allOidsRevs[oid] > rev: + current.refreshData() + updated = True + else: + # Remove the listview item since the oid no longer + # exists. + del self._supplierItems[current._supplierId] + toTake.append(current) + iterator += 1 + current = iterator.current() + for item in toTake: + self.takeItem(item) + # Add listview items for newly-created suppliers. + if len(collection) > len(visibleOids): + diff = list(set(allOidsRevs).difference(visibleOids)) + for oid in diff: + supplier = collection[oid] + item = ListViewItem(domain, collection, supplier, self) + sid = supplierId(supplier) + item._supplierId = sid + self._supplierItems[sid] = item + updated = True + # Sort if items have changed or have been created. + if updated: + self.sort() + def _setDragEnabledIfDraggable(self): iterator = qt.QListViewItemIterator(self) *************** *** 799,803 **** scroll = self.verticalScrollBar() scrollValue = scroll.value() ! self._setupItems() scroll.setValue(scrollValue) --- 858,862 ---- scroll = self.verticalScrollBar() scrollValue = scroll.value() ! self._setupItemsPartial() scroll.setValue(scrollValue) *************** *** 849,863 **** self._domain = domain self._oid = supplier.data.sys.oid self._collection = collection # Calculate values right away rather than storing supplier. ! listView = self.listView() ! values = self._values = [] ! data = supplier.data ! for name, label in listView._colnames: ! if name == 'sys.oid': ! value = data.sys.oid ! else: ! value = getattr(data, name) ! values.append(value) def compare(self, item, col, ascending): --- 908,915 ---- self._domain = domain self._oid = supplier.data.sys.oid + self._rev = supplier.data.sys.rev self._collection = collection # Calculate values right away rather than storing supplier. ! self.refreshData(supplier.data) def compare(self, item, col, ascending): *************** *** 895,898 **** --- 947,963 ---- return qt.QListViewItem.paintCell(self, p, cg, column, width, align) + def refreshData(self, data=None): + """Refresh data shown by self to be current with latest revision.""" + if data is None: + data = self.supplier().data + listView = self.listView() + values = self._values = [] + for name, label in listView._colnames: + if name == 'sys.oid': + value = self._oid + else: + value = getattr(data, name) + values.append(value) + def supplier(self): """Return the supplier associated with this item.""" |
From: Matthew R. S. <gld...@us...> - 2004-08-10 18:25:49
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/domain In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1734/pypersyst/domain Modified Files: collection.py Log Message: Performance improvements for showing ListViews of ExtentCollections. Index: collection.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/domain/collection.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** collection.py 9 Aug 2004 22:38:29 -0000 1.19 --- collection.py 10 Aug 2004 18:25:40 -0000 1.20 *************** *** 41,44 **** --- 41,48 ---- def __contains__(self, item): + """Returns True if item is in the collection. + + item can be either a display supplier, or an OID. + """ domain = self._domain # If item is an IDisplay supplier whose Fieldspace is the same *************** *** 63,66 **** --- 67,80 ---- return len(self._extent) + def allOidsRevs(self): + """Return a list of all OIDs in this collection. + + This is a performance-enhancing extension beyond the + ICollection interface. + """ + return dict([(oid, instance._rev) + for oid, instance + in self._extent._instances.items()]) + def find(self, **criteria): L = self._extent.find(**criteria) *************** *** 76,79 **** --- 90,94 ---- + # By default, ExtentCollection labels are mirrors of the labels for # their associated Entity classes. |