9688: Remove Unused Objects tool reports linked notes as unused.
This commit is contained in:
parent
72aafd7471
commit
3e1a0187e3
@ -63,6 +63,8 @@ class NoteType(GrampsType):
|
|||||||
# indicate a note is html code
|
# indicate a note is html code
|
||||||
HTML_CODE = 24
|
HTML_CODE = 24
|
||||||
TODO = 25
|
TODO = 25
|
||||||
|
# indicate a note used as link in another note
|
||||||
|
LINK = 26
|
||||||
|
|
||||||
_CUSTOM = CUSTOM
|
_CUSTOM = CUSTOM
|
||||||
_DEFAULT = GENERAL
|
_DEFAULT = GENERAL
|
||||||
@ -78,6 +80,7 @@ class NoteType(GrampsType):
|
|||||||
(REPORT_TEXT, _("Report"), "Report"),
|
(REPORT_TEXT, _("Report"), "Report"),
|
||||||
(HTML_CODE, _("Html code"), "Html code"),
|
(HTML_CODE, _("Html code"), "Html code"),
|
||||||
(TODO, _("notetype|To Do"), "To Do"),
|
(TODO, _("notetype|To Do"), "To Do"),
|
||||||
|
(LINK, _("notetype|Link"), "Link"),
|
||||||
]
|
]
|
||||||
|
|
||||||
_DATAMAPIGNORE = [
|
_DATAMAPIGNORE = [
|
||||||
|
@ -272,9 +272,12 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback):
|
|||||||
# get the todo list (from get_note_list method of the todo gramplet )
|
# get the todo list (from get_note_list method of the todo gramplet )
|
||||||
all_notes = self.dbstate.db.get_note_handles()
|
all_notes = self.dbstate.db.get_note_handles()
|
||||||
FilterClass = GenericFilterFactory('Note')
|
FilterClass = GenericFilterFactory('Note')
|
||||||
filter = FilterClass()
|
filter1 = FilterClass()
|
||||||
filter.add_rule(rules.note.HasType(["To Do"]))
|
filter1.add_rule(rules.note.HasType(["To Do"]))
|
||||||
todo_list = filter.apply(self.dbstate.db, all_notes)
|
todo_list = filter1.apply(self.dbstate.db, all_notes)
|
||||||
|
filter2 = FilterClass()
|
||||||
|
filter2.add_rule(rules.note.HasType(["Link"]))
|
||||||
|
link_list = filter2.apply(self.dbstate.db, all_notes)
|
||||||
|
|
||||||
for (the_type, cursor_func, total_func) in tables:
|
for (the_type, cursor_func, total_func) in tables:
|
||||||
if not self.options.handler.options_dict[the_type]:
|
if not self.options.handler.options_dict[the_type]:
|
||||||
@ -286,7 +289,7 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback):
|
|||||||
fbh = db.find_backlink_handles
|
fbh = db.find_backlink_handles
|
||||||
for handle, data in cursor:
|
for handle, data in cursor:
|
||||||
if not any(h for h in fbh(handle)):
|
if not any(h for h in fbh(handle)):
|
||||||
if handle not in todo_list:
|
if handle not in todo_list and handle not in link_list:
|
||||||
self.add_results((the_type, handle.decode('utf-8'),
|
self.add_results((the_type, handle.decode('utf-8'),
|
||||||
data))
|
data))
|
||||||
self.update()
|
self.update()
|
||||||
|
Loading…
Reference in New Issue
Block a user