]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/undo/UndoLoad.java
Version 12, December 2010
[GpsPrune.git] / tim / prune / undo / UndoLoad.java
index 5c0818fc94a65eade07b5d0fd391f482ebbc4469..377f21c22f93f7b0a95f7c73378a30a09d5276c7 100644 (file)
@@ -16,6 +16,8 @@ public class UndoLoad implements UndoOperation
        private DataPoint[] _contents = null;\r
        private PhotoList _photoList = null;\r
        private FileInfo _oldFileInfo = null;\r
+       // Numbers of each media before operation\r
+       private int _numPhotos = -1, _numAudios = -1;\r
 \r
 \r
        /**\r
@@ -58,6 +60,16 @@ public class UndoLoad implements UndoOperation
                return desc;\r
        }\r
 \r
+       /**\r
+        * Set the number of photos and audios before the load operation\r
+        * @param inNumPhotos number of photos\r
+        * @param inNumAudios number of audios\r
+        */\r
+       public void setNumPhotosAudios(int inNumPhotos, int inNumAudios)\r
+       {\r
+               _numPhotos = inNumPhotos;\r
+               _numAudios = inNumAudios;\r
+       }\r
 \r
        /**\r
         * Perform the undo operation on the given Track\r
@@ -81,10 +93,12 @@ public class UndoLoad implements UndoOperation
                else\r
                {\r
                        // replace photos how they were\r
-                       if (_photoList != null)\r
-                       {\r
+                       if (_photoList != null) {\r
                                inTrackInfo.getPhotoList().restore(_photoList);\r
                        }\r
+                       // Crop media lists to previous size (if specified)\r
+                       if (_numPhotos > -1) {inTrackInfo.getPhotoList().cropTo(_numPhotos);}\r
+                       if (_numAudios > -1) {inTrackInfo.getAudioList().cropTo(_numAudios);}\r
                        // replace track contents with old\r
                        if (!inTrackInfo.getTrack().replaceContents(_contents))\r
                        {\r
@@ -94,4 +108,4 @@ public class UndoLoad implements UndoOperation
                // clear selection\r
                inTrackInfo.getSelection().clearAll();\r
        }\r
-}
\ No newline at end of file
+}\r