/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/base.py
ViewVC logotype

Annotation of /branches/WIP-pyshapelib-bramz/Thuban/Model/base.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1121 - (hide annotations)
Mon Jun 2 13:46:45 2003 UTC (21 years, 9 months ago) by bh
Original Path: trunk/thuban/Thuban/Model/base.py
File MIME type: text/x-python
File size: 2272 byte(s)
(TitledObject.SetTitle): Call changed
instead of issue so that the modified flags get updated.

1 bh 1121 # Copyright (c) 2001, 2002, 2003 by Intevation GmbH
2 bh 6 # Authors:
3     # Bernhard Herzog <[email protected]>
4     #
5     # This program is free software under the GPL (>=v2)
6     # Read the file COPYING coming with Thuban for details.
7    
8     """
9     Various base classes that didn't fir elsewhere
10     """
11    
12     __version__ = "$Revision$"
13    
14     from Thuban.Lib.connector import Publisher
15    
16 bh 320 from messages import TITLE_CHANGED, CHANGED
17 bh 6
18     class TitledObject:
19    
20     """Mix-in class for objects that have titles"""
21    
22     def __init__(self, title):
23     self.title = title
24    
25     def Title(self):
26     return self.title
27    
28     def SetTitle(self, title):
29     self.title = title
30    
31 bh 1121 # FIXME: The TitledObject is almost always used in conjunction
32     # with Modifiable (the only exceptions currently are the
33     # tables). We should reall derive TitledObject from modifiable
34     # (would be good for the tables too) but that's taking things a
35     # bit far at the moment.
36     if hasattr(self, 'changed'):
37     self.changed(TITLE_CHANGED, self)
38    
39 bh 6 class Modifiable(Publisher):
40    
41     """Class for objects maintaining a modified flag."""
42    
43     def __init__(self):
44     self.modified = 0
45    
46     def WasModified(self):
47     """Return true if the layer was modified"""
48     return self.modified
49    
50     def UnsetModified(self):
51 bh 320 """Unset the modified flag.
52    
53     If the modified flag is changed from set to inset by he call,
54     issue a CHANGED message.
55    
56     The modified flag itself is part of the state of the object so
57     some other objects such as a field in the status bar indication
58     whether e.g. the session has changed might be interested in
59     being notified when this flag has changed.
60     """
61     was_modified = self.modified
62 bh 6 self.modified = 0
63 bh 320 if was_modified:
64     self.issue(CHANGED)
65 bh 6
66     def changed(self, channel = None, *args):
67 bh 320 """Set the modified flag and optionally issue a message
68 bh 127
69     The message is issued on the channel given by channel with args
70 bh 320 as the arguments. If channel is None issue no message.
71 bh 127
72     Subclasses should call this method whenever anything has
73     changed.
74     """
75 bh 6 self.modified = 1
76     if channel is not None:
77 bh 240 self.issue(channel, *args)

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26