X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fundo%2FUndoLoad.java;h=377f21c22f93f7b0a95f7c73378a30a09d5276c7;hb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;hp=c9aee483868cac1d4f4c20b2e481331f112c18bf;hpb=da0b1f449260a0b4a94318006382a9039726ef3e;p=GpsPrune.git diff --git a/tim/prune/undo/UndoLoad.java b/tim/prune/undo/UndoLoad.java index c9aee48..377f21c 100644 --- a/tim/prune/undo/UndoLoad.java +++ b/tim/prune/undo/UndoLoad.java @@ -2,6 +2,7 @@ package tim.prune.undo; import tim.prune.I18nManager; import tim.prune.data.DataPoint; +import tim.prune.data.FileInfo; import tim.prune.data.PhotoList; import tim.prune.data.TrackInfo; @@ -13,8 +14,10 @@ public class UndoLoad implements UndoOperation private int _cropIndex = -1; private int _numLoaded = -1; private DataPoint[] _contents = null; - private String _previousFilename = null; private PhotoList _photoList = null; + private FileInfo _oldFileInfo = null; + // Numbers of each media before operation + private int _numPhotos = -1, _numAudios = -1; /** @@ -27,7 +30,6 @@ public class UndoLoad implements UndoOperation _cropIndex = inIndex; _numLoaded = inNumLoaded; _contents = null; - _previousFilename = null; } @@ -42,8 +44,7 @@ public class UndoLoad implements UndoOperation _cropIndex = -1; _numLoaded = inNumLoaded; _contents = inOldTrackInfo.getTrack().cloneContents(); - if (inOldTrackInfo.getFileInfo().getNumFiles() == 1) - _previousFilename = inOldTrackInfo.getFileInfo().getFilename(); + _oldFileInfo = inOldTrackInfo.getFileInfo().clone(); _photoList = inPhotoList; } @@ -59,6 +60,16 @@ public class UndoLoad implements UndoOperation return desc; } + /** + * Set the number of photos and audios before the load operation + * @param inNumPhotos number of photos + * @param inNumAudios number of audios + */ + public void setNumPhotosAudios(int inNumPhotos, int inNumAudios) + { + _numPhotos = inNumPhotos; + _numAudios = inNumAudios; + } /** * Perform the undo operation on the given Track @@ -66,11 +77,12 @@ public class UndoLoad implements UndoOperation */ public void performUndo(TrackInfo inTrackInfo) throws UndoException { - // remove file from fileinfo - inTrackInfo.getFileInfo().removeFile(); - if (_previousFilename != null) - { - inTrackInfo.getFileInfo().setFile(_previousFilename); + // remove source from fileinfo + if (_oldFileInfo == null) { + inTrackInfo.getFileInfo().removeSource(); + } + else { + inTrackInfo.setFileInfo(_oldFileInfo); } // Crop / replace if (_contents == null) @@ -81,10 +93,12 @@ public class UndoLoad implements UndoOperation else { // replace photos how they were - if (_photoList != null) - { + if (_photoList != null) { inTrackInfo.getPhotoList().restore(_photoList); } + // Crop media lists to previous size (if specified) + if (_numPhotos > -1) {inTrackInfo.getPhotoList().cropTo(_numPhotos);} + if (_numAudios > -1) {inTrackInfo.getAudioList().cropTo(_numAudios);} // replace track contents with old if (!inTrackInfo.getTrack().replaceContents(_contents)) { @@ -94,4 +108,4 @@ public class UndoLoad implements UndoOperation // clear selection inTrackInfo.getSelection().clearAll(); } -} \ No newline at end of file +}