| 72 | Type clipboardSpaceUsage; |
| 73 | |
| 74 | void Calculate( UndoManager &manager ) |
| 75 | { |
| 76 | SampleBlockIDSet seen; |
| 77 | |
| 78 | // After copies and pastes, a block file may be used in more than |
| 79 | // one place in one undo history state, and it may be used in more than |
| 80 | // one undo history state. It might even be used in two states, but not |
| 81 | // in another state that is between them -- as when you have state A, |
| 82 | // then make a cut to get state B, but then paste it back into state C. |
| 83 | |
| 84 | // So be sure to count each block file once only, in the last undo item that |
| 85 | // contains it. |
| 86 | |
| 87 | // Why the last and not the first? Because the user of the History dialog |
| 88 | // may DELETE undo states, oldest first. To reclaim disk space you must |
| 89 | // DELETE all states containing the block file. So the block file's |
| 90 | // contribution to space usage should be counted only in that latest |
| 91 | // state. |
| 92 | |
| 93 | manager.VisitStates( |
| 94 | [this, &seen](const UndoStackElem &elem) { |
| 95 | // Scan all tracks at current level |
| 96 | if (auto pTracks = UndoTracks::Find(elem)) |
| 97 | space.push_back(CalculateUsage(*pTracks, seen)); |
| 98 | }, |
| 99 | true // newest state first |
| 100 | ); |
| 101 | |
| 102 | // Count the usage of the clipboard separately, using another set. Do not |
| 103 | // multiple-count any block occurring multiple times within the clipboard. |
| 104 | seen.clear(); |
| 105 | clipboardSpaceUsage = CalculateUsage( |
| 106 | Clipboard::Get().GetTracks(), seen); |
| 107 | |
| 108 | //TIMER_STOP( space_calc ); |
| 109 | } |
| 110 | }; |
| 111 | } |
| 112 |
no test coverage detected