3542: Scratchpad does not remove objects when changing database
svn: r14546
This commit is contained in:
parent
4105b54984
commit
575a4bbd67
@ -948,33 +948,52 @@ class ScratchPadListView(object):
|
|||||||
|
|
||||||
def database_changed(self,db):
|
def database_changed(self,db):
|
||||||
self._db = db
|
self._db = db
|
||||||
|
# Note: delete event is emitted before the delete, so checking
|
||||||
|
# if valid on this is useless !
|
||||||
db_signals = (
|
db_signals = (
|
||||||
'person-update',
|
'person-update',
|
||||||
'person-rebuild',
|
'person-rebuild',
|
||||||
'family-update',
|
'family-update',
|
||||||
'family-delete',
|
|
||||||
'family-rebuild',
|
'family-rebuild',
|
||||||
'source-update',
|
'source-update',
|
||||||
'source-rebuild',
|
'source-rebuild',
|
||||||
'place-update',
|
'place-update',
|
||||||
'place-delete',
|
|
||||||
'place-rebuild',
|
'place-rebuild',
|
||||||
'media-update',
|
'media-update',
|
||||||
'media-delete',
|
|
||||||
'media-rebuild',
|
'media-rebuild',
|
||||||
'event-update',
|
'event-update',
|
||||||
'event-rebuild',
|
'event-rebuild',
|
||||||
'repository-update',
|
'repository-update',
|
||||||
'repository-rebuild'
|
'repository-rebuild',
|
||||||
|
'note-rebuild'
|
||||||
)
|
)
|
||||||
|
|
||||||
for signal in db_signals:
|
for signal in db_signals:
|
||||||
self._db.connect(signal,self.remove_invalid_objects)
|
self._db.connect(signal,self.remove_invalid_objects)
|
||||||
|
|
||||||
self._db.connect('person-delete', gen_del_obj(self.delete_object, 'person-link'))
|
self._db.connect('person-delete',
|
||||||
self._db.connect('source-delete', gen_del_obj(self.delete_object, 'source-link'))
|
gen_del_obj(self.delete_object, 'person-link'))
|
||||||
self._db.connect('repository-delete', gen_del_obj(self.delete_object, 'repo-link'))
|
self._db.connect('person-delete',
|
||||||
self._db.connect('event-delete', gen_del_obj(self.delete_object, 'pevent'))
|
gen_del_obj(self.delete_object_ref, 'personref'))
|
||||||
|
self._db.connect('source-delete',
|
||||||
|
gen_del_obj(self.delete_object, 'source-link'))
|
||||||
|
self._db.connect('source-delete',
|
||||||
|
gen_del_obj(self.delete_object_ref, 'srcref'))
|
||||||
|
self._db.connect('repository-delete',
|
||||||
|
gen_del_obj(self.delete_object, 'repo-link'))
|
||||||
|
self._db.connect('event-delete',
|
||||||
|
gen_del_obj(self.delete_object, 'pevent'))
|
||||||
|
self._db.connect('event-delete',
|
||||||
|
gen_del_obj(self.delete_object_ref, 'eventref'))
|
||||||
|
self._db.connect('media-delete',
|
||||||
|
gen_del_obj(self.delete_object, 'mediaobj'))
|
||||||
|
self._db.connect('media-delete',
|
||||||
|
gen_del_obj(self.delete_object_ref, 'mediaref'))
|
||||||
|
self._db.connect('place-delete',
|
||||||
|
gen_del_obj(self.delete_object, 'place-link'))
|
||||||
|
self._db.connect('note-delete',
|
||||||
|
gen_del_obj(self.delete_object, 'note-link'))
|
||||||
|
# family-delete not needed, cannot be dragged!
|
||||||
|
|
||||||
self.remove_invalid_objects()
|
self.remove_invalid_objects()
|
||||||
|
|
||||||
@ -996,6 +1015,16 @@ class ScratchPadListView(object):
|
|||||||
if data[2] in handle_list:
|
if data[2] in handle_list:
|
||||||
model.remove(o.iter)
|
model.remove(o.iter)
|
||||||
|
|
||||||
|
def delete_object_ref(self, handle_list, link_type):
|
||||||
|
model = self._widget.get_model()
|
||||||
|
|
||||||
|
if model:
|
||||||
|
for o in model:
|
||||||
|
if o[0] == link_type:
|
||||||
|
data = o[1]._obj.get_reference_handle()
|
||||||
|
if data in handle_list:
|
||||||
|
model.remove(o.iter)
|
||||||
|
|
||||||
# Method to manage the wrapper classes.
|
# Method to manage the wrapper classes.
|
||||||
|
|
||||||
def register_wrapper_classes(self):
|
def register_wrapper_classes(self):
|
||||||
@ -1153,7 +1182,6 @@ class ScratchPadListView(object):
|
|||||||
# remember time for double drop workaround.
|
# remember time for double drop workaround.
|
||||||
self._previous_drop_time = realTime
|
self._previous_drop_time = realTime
|
||||||
|
|
||||||
|
|
||||||
# proxy methods to provide access to the real widget functions.
|
# proxy methods to provide access to the real widget functions.
|
||||||
|
|
||||||
def set_model(self,model=None):
|
def set_model(self,model=None):
|
||||||
@ -1237,6 +1265,10 @@ class ScratchPadWindow(ManagedWindow.ManagedWindow):
|
|||||||
|
|
||||||
self.object_list.set_model(ScratchPadWindow.otree)
|
self.object_list.set_model(ScratchPadWindow.otree)
|
||||||
|
|
||||||
|
#Database might have changed, objects might have been removed,
|
||||||
|
#we need to reevaluate if all data is valid
|
||||||
|
self.object_list.remove_invalid_objects()
|
||||||
|
|
||||||
self.top.connect_signals({
|
self.top.connect_signals({
|
||||||
"on_close_scratchpad" : self.close,
|
"on_close_scratchpad" : self.close,
|
||||||
"on_clear_clicked": self.on_clear_clicked,
|
"on_clear_clicked": self.on_clear_clicked,
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
<property name="default_width">500</property>
|
<property name="default_width">500</property>
|
||||||
<property name="default_height">300</property>
|
<property name="default_height">300</property>
|
||||||
<property name="type_hint">dialog</property>
|
<property name="type_hint">dialog</property>
|
||||||
<signal name="delete_event" handler="on_scratch_pad_delete_event"/>
|
|
||||||
<child internal-child="vbox">
|
<child internal-child="vbox">
|
||||||
<object class="GtkVBox" id="dialog-vbox1">
|
<object class="GtkVBox" id="dialog-vbox1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow" id="scrolledwindow86">
|
<object class="GtkScrolledWindow" id="scrolledwindow86">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -58,7 +58,6 @@
|
|||||||
<property name="can_default">True</property>
|
<property name="can_default">True</property>
|
||||||
<property name="receives_default">False</property>
|
<property name="receives_default">False</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<signal name="clicked" handler="on_clear_all_clicked"/>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user