Automatically map pre-2.3.15 report option names to their new 2.3.15 equivalents.

This will ensure that users won't lose the settings they stored in saved reports
and open report windows when switching from 2.2.x to 2.4.

Note that this only works in one direction, from 2.2.x to 2.4. If a user switches
back to 2.2.x, the open report windows will lose many settings, almost resetting
them to their default state. Saved reports won't have this problem as they are
copied to a new file during the migration.

In detail:
For open reports:
pre-2.3.15 -> 2.3.15+ : options for open reports will be migrated
2.3.15+ -> pre-2.3.15 : options for open reports will be migrated

For saved reports:
2.2.x -> 2.3.15+      : all options will be migrated, if saved-reports-2.4
                        does not yet exist
pre-2.3.15 -> 2.3.15+ : options for saved reports won't be migrated but reports
                        continue to work. It would be best to save the reports again,
                        but my scheme-fu is not good enough to let the code do that
                        automatically. Alternatively users should remove the file
                        saved-reports-2.4 to recreate it on the next run, based on
                        saved-reports-2.0.
2.3.15+ -> 2.2.x      : options are unaffected, sine 2.2.x and 2.15 use different
                        saved reports files
2.3.15+ -> pre-2.3.15 : reports saved in 2.3.15 will lose their options, older reports
                        are unaffected. But returning to 2.3.15+, the options will
                        continue to work.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19451 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2010-08-21 15:16:42 +00:00
parent 7b8fbd7835
commit 72e3e084b1

View File

@ -1313,7 +1313,35 @@
(define (lookup-option section name)
(let ((section-hash (hash-ref option-hash section)))
(if section-hash
(hash-ref section-hash name)
(let ((option-hash (hash-ref section-hash name)))
(if option-hash
option-hash
; Option name was not found. Perhaps it was renamed ?
; Let's try to map it to a known new name
(let* ((new-names-list (list
"Accounts to include" "Accounts"
"Exclude transactions between selected accounts?" "Exclude transactions between selected accounts"
"Filter Accounts" "Filter By..."
"Flatten list to depth limit?" "Flatten list to depth limit"
"From" "Start Date"
"Report Accounts" "Accounts"
"Report Currency" "Report's currency"
"Show Account Code?" "Show Account Code"
"Show Full Account Name?" "Show Full Account Name"
"Show Multi-currency Totals?" "Show Multi-currency Totals"
"Show zero balance items?" "Show zero balance items"
"Sign Reverses?" "Sign Reverses"
"To" "End Date"
"Use Full Account Name?" "Use Full Account Name"
"Use Full Other Account Name?" "Use Full Other Account Name"
"Void Transactions?" "Void Transactions"
))
(name-match (member name new-names-list)))
(if name-match
(let ((new-name (cadr name-match)))
(lookup-option section new-name))
#f))))
#f)))
(define (option-changed section name)