Fixed table view updating to properly show changes after moving resources/directories

This commit is contained in:
Aruki
2017-07-15 22:24:59 -06:00
parent dbe8b7922c
commit a813c4c61c
10 changed files with 152 additions and 91 deletions

View File

@@ -3,6 +3,7 @@
#include "IUndoCommand.h"
#include "Editor/CEditorApplication.h"
#include "Editor/ResourceBrowser/CResourceBrowser.h"
#include <Core/GameProject/CResourceEntry.h>
class CMoveResourceCommand : public IUndoCommand
@@ -21,25 +22,24 @@ public:
, mOldDirAutoGenerated(pEntry->HasFlag(eREF_AutoResDir))
{}
void undo()
{
bool Success = mpEntry->Move(mOldDirPath, mOldDirAutoGenerated);
ASSERT(Success); // todo better error handling
gpEdApp->ResourceRenamed(mpEntry);
}
void redo()
{
// note: it doesn't matter if the new directory was auto-generated, since the
// purpose of tracking that flag is to detect which resources have been auto-categorized.
// if this is being called, even if the new directory is auto-generated, it means the
// user is intentionally placing it here, so it should be treated as a custom directory
bool Success = mpEntry->Move(mNewDirPath);
ASSERT(Success); // todo better error handling
gpEdApp->ResourceRenamed(mpEntry);
}
// note: for redo, it doesn't matter if the new directory was auto-generated, since the
// purpose of tracking that flag is to detect which resources have been auto-categorized.
// if this is being called, even if the new directory is auto-generated, it means the
// user is intentionally placing it here, so it should be treated as a custom directory
void undo() { DoMove(mOldDirPath, mOldDirAutoGenerated); }
void redo() { DoMove(mNewDirPath, false); }
bool AffectsCleanState() const { return false; }
protected:
void DoMove(const TString& rkPath, bool IsAutoDir)
{
CVirtualDirectory *pOldDir = mpEntry->Directory();
TString OldName = mpEntry->Name();
bool Success = mpEntry->Move(rkPath, IsAutoDir);
ASSERT(Success); // todo better error handling
gpEdApp->ResourceBrowser()->ResourceMoved(mpEntry, pOldDir, OldName);
}
};
#endif // CMOVERESOURCECOMMAND_H