xref: /haiku/src/kits/tracker/FSUndoRedo.h (revision 10d876dedef488fbef8798cb8137262bd365a30c)
1086eaa58SJohn Scipione /*
2086eaa58SJohn Scipione Open Tracker License
3086eaa58SJohn Scipione 
4086eaa58SJohn Scipione Terms and Conditions
5086eaa58SJohn Scipione 
6086eaa58SJohn Scipione Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
7086eaa58SJohn Scipione 
8086eaa58SJohn Scipione Permission is hereby granted, free of charge, to any person obtaining a copy of
9086eaa58SJohn Scipione this software and associated documentation files (the "Software"), to deal in
10086eaa58SJohn Scipione the Software without restriction, including without limitation the rights to
11086eaa58SJohn Scipione use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12086eaa58SJohn Scipione of the Software, and to permit persons to whom the Software is furnished to do
13086eaa58SJohn Scipione so, subject to the following conditions:
14086eaa58SJohn Scipione 
15086eaa58SJohn Scipione The above copyright notice and this permission notice applies to all licensees
16086eaa58SJohn Scipione and shall be included in all copies or substantial portions of the Software.
17086eaa58SJohn Scipione 
18086eaa58SJohn Scipione THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19086eaa58SJohn Scipione IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20086eaa58SJohn Scipione FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21086eaa58SJohn Scipione BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22086eaa58SJohn Scipione AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23086eaa58SJohn Scipione WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24086eaa58SJohn Scipione 
25086eaa58SJohn Scipione Except as contained in this notice, the name of Be Incorporated shall not be
26086eaa58SJohn Scipione used in advertising or otherwise to promote the sale, use or other dealings in
27086eaa58SJohn Scipione this Software without prior written authorization from Be Incorporated.
28086eaa58SJohn Scipione 
29086eaa58SJohn Scipione Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30086eaa58SJohn Scipione of Be Incorporated in the United States and other countries. Other brand product
31086eaa58SJohn Scipione names are registered trademarks or trademarks of their respective holders.
32086eaa58SJohn Scipione All rights reserved.
33086eaa58SJohn Scipione */
3402be5353SAxel Dörfler #ifndef _FS_UNDO_REDO_H
3502be5353SAxel Dörfler #define _FS_UNDO_REDO_H
3602be5353SAxel Dörfler 
37b05aa8b5SJohn Scipione 
3802be5353SAxel Dörfler #include <Entry.h>
39086eaa58SJohn Scipione #include <ObjectList.h>
4002be5353SAxel Dörfler 
41b05aa8b5SJohn Scipione 
4202be5353SAxel Dörfler namespace BPrivate {
4302be5353SAxel Dörfler 
445bc37860SAdrien Destugues static const uint32_t kUndoOperation = 'U' << 24;
455bc37860SAdrien Destugues static const uint32_t kDoOperation = 'T' << 24;
465bc37860SAdrien Destugues 
4702be5353SAxel Dörfler class UndoItem;
4802be5353SAxel Dörfler 
4902be5353SAxel Dörfler class Undo {
5002be5353SAxel Dörfler 	public:
5102be5353SAxel Dörfler 		~Undo();
5202be5353SAxel Dörfler 		void UpdateEntry(BEntry* entry, const char* destName);
5302be5353SAxel Dörfler 		void Remove();
5402be5353SAxel Dörfler 
5502be5353SAxel Dörfler 	protected:
5602be5353SAxel Dörfler 		UndoItem* fUndo;
5702be5353SAxel Dörfler };
5802be5353SAxel Dörfler 
59b05aa8b5SJohn Scipione 
6002be5353SAxel Dörfler class MoveCopyUndo : public Undo {
6102be5353SAxel Dörfler 	public:
6202be5353SAxel Dörfler 		MoveCopyUndo(BObjectList<entry_ref>* sourceList, BDirectory &dest,
6302be5353SAxel Dörfler 			BList* pointList, uint32 moveMode);
6402be5353SAxel Dörfler };
6502be5353SAxel Dörfler 
66b05aa8b5SJohn Scipione 
6702be5353SAxel Dörfler class NewFolderUndo : public Undo {
6802be5353SAxel Dörfler 	public:
6902be5353SAxel Dörfler 		NewFolderUndo(const entry_ref &ref);
7002be5353SAxel Dörfler };
7102be5353SAxel Dörfler 
72b05aa8b5SJohn Scipione 
7302be5353SAxel Dörfler class RenameUndo : public Undo {
7402be5353SAxel Dörfler 	public:
7502be5353SAxel Dörfler 		RenameUndo(BEntry &entry, const char* newName);
7602be5353SAxel Dörfler };
7702be5353SAxel Dörfler 
78b05aa8b5SJohn Scipione 
7902be5353SAxel Dörfler class RenameVolumeUndo : public Undo {
8002be5353SAxel Dörfler 	public:
8102be5353SAxel Dörfler 		RenameVolumeUndo(BVolume &volume, const char* newName);
8202be5353SAxel Dörfler };
8302be5353SAxel Dörfler 
84b05aa8b5SJohn Scipione 
8502be5353SAxel Dörfler static
FSIsUndoMoveMode(uint32 moveMode)8602be5353SAxel Dörfler inline bool FSIsUndoMoveMode(uint32 moveMode)
8702be5353SAxel Dörfler {
885bc37860SAdrien Destugues 	return (moveMode & 0xFF000000) == kUndoOperation;
8902be5353SAxel Dörfler }
9002be5353SAxel Dörfler 
91b05aa8b5SJohn Scipione 
9202be5353SAxel Dörfler static
FSUndoMoveMode(uint32 moveMode)9302be5353SAxel Dörfler inline uint32 FSUndoMoveMode(uint32 moveMode)
9402be5353SAxel Dörfler {
955bc37860SAdrien Destugues 	return (moveMode & 0x00FFFFFF) | kUndoOperation;
9602be5353SAxel Dörfler }
9702be5353SAxel Dörfler 
98b05aa8b5SJohn Scipione 
9902be5353SAxel Dörfler static
FSMoveMode(uint32 moveMode)10002be5353SAxel Dörfler inline uint32 FSMoveMode(uint32 moveMode)
10102be5353SAxel Dörfler {
102*10d876deSAugustin Cavalier 	return (moveMode & 0x00FFFFFF) | kDoOperation;
10302be5353SAxel Dörfler }
10402be5353SAxel Dörfler 
105b05aa8b5SJohn Scipione 
10602be5353SAxel Dörfler extern void FSUndo();
10702be5353SAxel Dörfler extern void FSRedo();
10802be5353SAxel Dörfler 
10902be5353SAxel Dörfler }	// namespace BPrivate
11002be5353SAxel Dörfler 
111b05aa8b5SJohn Scipione #endif	// _FS_UNDO_REDO_H
112