Author: anevilyak Date: 2009-10-28 04:04:42 +0100 (Wed, 28 Oct 2009) New Revision: 33803 Changeset: http://dev.haiku-os.org/changeset/33803/haiku Modified: haiku/trunk/src/kits/tracker/ContainerWindow.cpp haiku/trunk/src/kits/tracker/FSUtils.cpp haiku/trunk/src/kits/tracker/FSUtils.h haiku/trunk/src/kits/tracker/PoseView.cpp Log: Move CheckDevicesEqual into FSUtils so it can be used in more places. Rework ContainerWindow's B_REFS_RECEIVED to use CheckDevicesEqual to decide move vs copy as is done elsewhere. Fixes ticket #4850. Modified: haiku/trunk/src/kits/tracker/ContainerWindow.cpp =================================================================== --- haiku/trunk/src/kits/tracker/ContainerWindow.cpp 2009-10-28 02:26:36 UTC (rev 33802) +++ haiku/trunk/src/kits/tracker/ContainerWindow.cpp 2009-10-28 03:04:42 UTC (rev 33803) @@ -1577,31 +1577,14 @@ // // compare the target and one of the drag items' parent // - BEntry item(&dragref, true); - BEntry itemparent; - item.GetParent(&itemparent); - entry_ref parentref; - itemparent.GetRef(&parentref); - - entry_ref targetref; - entry.GetRef(&targetref); - - // if they don't match, move/copy - if (targetref != parentref) { - uint32 moveMode = kMoveSelectionTo; - node_ref targetNode; - node_ref parentNode; - if (entry.GetNodeRef(&targetNode) == B_OK - && itemparent.GetNodeRef(&parentNode) - == B_OK) { - if (targetNode.device != parentNode.device) - moveMode = kCopySelectionTo; - } - // copy drag contents to target ref in message - FSMoveToFolder(list, new BEntry(entry), + uint32 moveMode = kMoveSelectionTo; + Model targetModel(&entry, true, false); + if (!CheckDevicesEqual(list->ItemAt(0), &targetModel)) + moveMode = kCopySelectionTo; + // copy drag contents to target ref in message + FSMoveToFolder(list, new BEntry(entry), moveMode); - } - + targetModel.CloseNode(); } else { // current message sent to apps is only B_REFS_RECEIVED fDragMessage->what = B_REFS_RECEIVED; Modified: haiku/trunk/src/kits/tracker/FSUtils.cpp =================================================================== --- haiku/trunk/src/kits/tracker/FSUtils.cpp 2009-10-28 02:26:36 UTC (rev 33802) +++ haiku/trunk/src/kits/tracker/FSUtils.cpp 2009-10-28 03:04:42 UTC (rev 33803) @@ -290,6 +290,17 @@ } +bool +CheckDevicesEqual(const entry_ref *srcRef, const Model *targetModel) +{ + BDirectory destDir (targetModel->EntryRef()); + struct stat deststat; + destDir.GetStat(&deststat); + + return srcRef->device == deststat.st_dev; +} + + status_t FSSetPoseLocation(ino_t destDirInode, BNode *destNode, BPoint point) { Modified: haiku/trunk/src/kits/tracker/FSUtils.h =================================================================== --- haiku/trunk/src/kits/tracker/FSUtils.h 2009-10-28 02:26:36 UTC (rev 33802) +++ haiku/trunk/src/kits/tracker/FSUtils.h 2009-10-28 03:04:42 UTC (rev 33803) @@ -229,6 +229,8 @@ bool ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *action, bool dontAsk = false, int32 *confirmedAlready = NULL); +bool CheckDevicesEqual(const entry_ref *entry, const Model *targetModel); + // Deprecated calls use newer calls above instead _IMPEXP_TRACKER void FSLaunchItem(const entry_ref *, BMessage * = NULL, int32 workspace = -1); _IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref *, BMessage *, Modified: haiku/trunk/src/kits/tracker/PoseView.cpp =================================================================== --- haiku/trunk/src/kits/tracker/PoseView.cpp 2009-10-28 02:26:36 UTC (rev 33802) +++ haiku/trunk/src/kits/tracker/PoseView.cpp 2009-10-28 03:04:42 UTC (rev 33803) @@ -4518,17 +4518,6 @@ } -static bool -CheckDevicesEqual(const entry_ref *srcRef, Model *targetModel) -{ - BDirectory destDir (targetModel->EntryRef()); - struct stat deststat; - destDir.GetStat(&deststat); - - return srcRef->device == deststat.st_dev; -} - - void BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow, bool forceCopy, bool forceMove, bool createLink, bool relativeLink)