Tracker: Style fixes related to creating links.
Change-Id: Iac673bc07c52cfd3c095ded5658f083fbeddfefd Reviewed-on: https://review.haiku-os.org/c/haiku/+/10714 Tested-by: Commit checker robot <[email protected]> Reviewed-by: John Scipione <[email protected]>
This commit is contained in:
@@ -1477,7 +1477,7 @@ BContainerWindow::MessageReceived(BMessage* message)
|
|||||||
PoseView()->MoveSelectionInto(&model, this, false, false,
|
PoseView()->MoveSelectionInto(&model, this, false, false,
|
||||||
message->what == kCreateLink,
|
message->what == kCreateLink,
|
||||||
message->what == kCreateRelativeLink);
|
message->what == kCreateRelativeLink);
|
||||||
} else if (!TargetModel()->IsQuery() && !TargetModel()->IsVirtualDirectory()) {
|
} else if (!(TargetModel()->IsQuery() || TargetModel()->IsVirtualDirectory())) {
|
||||||
// no destination specified, create link in same dir as item
|
// no destination specified, create link in same dir as item
|
||||||
PoseView()->MoveSelectionInto(TargetModel(), this, false, false,
|
PoseView()->MoveSelectionInto(TargetModel(), this, false, false,
|
||||||
message->what == kCreateLink,
|
message->what == kCreateLink,
|
||||||
@@ -2250,8 +2250,7 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu* navMenu, uint32 what, const
|
|||||||
if (entry.SetTo(ref) == B_OK
|
if (entry.SetTo(ref) == B_OK
|
||||||
&& entry.GetParent(&entry) == B_OK
|
&& entry.GetParent(&entry) == B_OK
|
||||||
&& model.SetTo(&entry) == B_OK) {
|
&& model.SetTo(&entry) == B_OK) {
|
||||||
BNavMenu* menu = new BNavMenu(B_TRANSLATE("Current folder"), what,
|
BNavMenu* menu = new BNavMenu(B_TRANSLATE("Current folder"), what, this);
|
||||||
this);
|
|
||||||
menu->SetNavDir(model.EntryRef());
|
menu->SetNavDir(model.EntryRef());
|
||||||
menu->SetShowParent(true);
|
menu->SetShowParent(true);
|
||||||
|
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ CopyLoopControl::FileError(const char* message, const char* name,
|
|||||||
|
|
||||||
void
|
void
|
||||||
CopyLoopControl::UpdateStatus(const char* name, const entry_ref& ref,
|
CopyLoopControl::UpdateStatus(const char* name, const entry_ref& ref,
|
||||||
int32 count, bool optional)
|
int32 bytes, bool optional)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,10 +375,10 @@ TrackerCopyLoopControl::FileError(const char* message, const char* name,
|
|||||||
|
|
||||||
void
|
void
|
||||||
TrackerCopyLoopControl::UpdateStatus(const char* name, const entry_ref&,
|
TrackerCopyLoopControl::UpdateStatus(const char* name, const entry_ref&,
|
||||||
int32 count, bool optional)
|
int32 bytes, bool optional)
|
||||||
{
|
{
|
||||||
if (gStatusWindow != NULL)
|
if (gStatusWindow != NULL)
|
||||||
gStatusWindow->UpdateStatus(fThread, name, count, optional);
|
gStatusWindow->UpdateStatus(fThread, name, bytes, optional);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -942,8 +942,7 @@ InitCopy(CopyLoopControl* loopControl, uint32 moveMode,
|
|||||||
*preflightResult = kPrompt;
|
*preflightResult = kPrompt;
|
||||||
*collisionCount = 0;
|
*collisionCount = 0;
|
||||||
|
|
||||||
*preflightResult = PreFlightNameCheck(srcList, destDir,
|
*preflightResult = PreFlightNameCheck(srcList, destDir, collisionCount, moveMode);
|
||||||
collisionCount, moveMode);
|
|
||||||
if (*preflightResult == kCanceled) {
|
if (*preflightResult == kCanceled) {
|
||||||
// user canceled
|
// user canceled
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -955,35 +954,31 @@ InitCopy(CopyLoopControl* loopControl, uint32 moveMode,
|
|||||||
case kCopySelectionTo:
|
case kCopySelectionTo:
|
||||||
case kDuplicateSelection:
|
case kDuplicateSelection:
|
||||||
case kMoveSelectionTo:
|
case kMoveSelectionTo:
|
||||||
{
|
{
|
||||||
loopControl->Init(moveMode == kMoveSelectionTo ? kMoveState
|
loopControl->Init(moveMode == kMoveSelectionTo ? kMoveState : kCopyState);
|
||||||
: kCopyState);
|
|
||||||
|
|
||||||
int32 totalItems = 0;
|
int32 totalItems = 0;
|
||||||
off_t totalSize = 0;
|
off_t totalSize = 0;
|
||||||
if (needSizeCalculation) {
|
if (needSizeCalculation) {
|
||||||
if (CalcItemsAndSize(loopControl, srcList,
|
if (CalcItemsAndSize(loopControl, srcList, dstVol->BlockSize(),
|
||||||
dstVol->BlockSize(), &totalItems, &totalSize)
|
&totalItems, &totalSize) != B_OK) {
|
||||||
!= B_OK) {
|
return B_ERROR;
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for free space before starting copy
|
|
||||||
if ((totalSize + (4* kKBSize)) >= dstVol->FreeBytes()) {
|
|
||||||
BAlert* alert = new BAlert("",
|
|
||||||
B_TRANSLATE_NOCOLLECT(kNoFreeSpace),
|
|
||||||
B_TRANSLATE("Cancel"),
|
|
||||||
0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
|
||||||
alert->Go();
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loopControl->Init(totalItems, totalSize, destRef);
|
// check for free space before starting copy
|
||||||
break;
|
if ((totalSize + (4* kKBSize)) >= dstVol->FreeBytes()) {
|
||||||
|
BAlert* alert = new BAlert("", B_TRANSLATE_NOCOLLECT(kNoFreeSpace),
|
||||||
|
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
|
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||||
|
alert->Go();
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loopControl->Init(totalItems, totalSize, destRef);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case kCreateLink:
|
case kCreateLink:
|
||||||
if (numItems > 10) {
|
if (numItems > 10) {
|
||||||
// this will be fast, only put up status if lots of items
|
// this will be fast, only put up status if lots of items
|
||||||
@@ -1083,10 +1078,8 @@ MoveTask(BObjectList<entry_ref, true>* srcList, BEntry* destEntry, BList* pointL
|
|||||||
moveMode = kCopySelectionTo;
|
moveMode = kCopySelectionTo;
|
||||||
|
|
||||||
bool needSizeCalculation = true;
|
bool needSizeCalculation = true;
|
||||||
if ((moveMode == kMoveSelectionTo && srcVolumeDevice == destVolumeDevice)
|
if ((moveMode == kMoveSelectionTo && srcVolumeDevice == destVolumeDevice) || destIsTrash)
|
||||||
|| destIsTrash) {
|
|
||||||
needSizeCalculation = false;
|
needSizeCalculation = false;
|
||||||
}
|
|
||||||
|
|
||||||
// we need the undo object later on, so we create it no matter
|
// we need the undo object later on, so we create it no matter
|
||||||
// if we really need it or not (it's very lightweight)
|
// if we really need it or not (it's very lightweight)
|
||||||
@@ -1107,7 +1100,8 @@ MoveTask(BObjectList<entry_ref, true>* srcList, BEntry* destEntry, BList* pointL
|
|||||||
loopControl.SetSourceList(srcList);
|
loopControl.SetSourceList(srcList);
|
||||||
|
|
||||||
if (result == B_OK) {
|
if (result == B_OK) {
|
||||||
for (int32 i = 0; i < srcList->CountItems(); i++) {
|
int32 numItems = srcList->CountItems();
|
||||||
|
for (int32 i = 0; i < numItems; i++) {
|
||||||
BPoint* loc = (BPoint*)-1;
|
BPoint* loc = (BPoint*)-1;
|
||||||
// a loc of -1 forces autoplacement, rather than copying the
|
// a loc of -1 forces autoplacement, rather than copying the
|
||||||
// position of the original node
|
// position of the original node
|
||||||
@@ -1145,9 +1139,8 @@ MoveTask(BObjectList<entry_ref, true>* srcList, BEntry* destEntry, BList* pointL
|
|||||||
if (sourceEntry.InitCheck() != B_OK) {
|
if (sourceEntry.InitCheck() != B_OK) {
|
||||||
BString error(B_TRANSLATE("Error moving \"%name\"."));
|
BString error(B_TRANSLATE("Error moving \"%name\"."));
|
||||||
error.ReplaceFirst("%name", srcRef->name);
|
error.ReplaceFirst("%name", srcRef->name);
|
||||||
BAlert* alert = new BAlert("", error.String(),
|
BAlert* alert = new BAlert("", error.String(), B_TRANSLATE("Cancel"), 0, 0,
|
||||||
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL,
|
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
B_WARNING_ALERT);
|
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||||
alert->Go();
|
alert->Go();
|
||||||
break;
|
break;
|
||||||
@@ -1160,13 +1153,11 @@ MoveTask(BObjectList<entry_ref, true>* srcList, BEntry* destEntry, BList* pointL
|
|||||||
|
|
||||||
result = MoveEntryToTrash(&sourceEntry, loc, undo);
|
result = MoveEntryToTrash(&sourceEntry, loc, undo);
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
BString error(B_TRANSLATE("Error moving \"%name\" to Trash. "
|
BString error(B_TRANSLATE("Error moving \"%name\" to Trash. (%error)"));
|
||||||
"(%error)"));
|
|
||||||
error.ReplaceFirst("%name", srcRef->name);
|
error.ReplaceFirst("%name", srcRef->name);
|
||||||
error.ReplaceFirst("%error", strerror(result));
|
error.ReplaceFirst("%error", strerror(result));
|
||||||
BAlert* alert = new BAlert("", error.String(),
|
BAlert* alert = new BAlert("", error.String(), B_TRANSLATE("Cancel"), 0, 0,
|
||||||
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL,
|
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
B_WARNING_ALERT);
|
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||||
alert->Go();
|
alert->Go();
|
||||||
break;
|
break;
|
||||||
@@ -1289,15 +1280,15 @@ CopyFile(BEntry* srcFile, StatStruct* srcStat, BDirectory* destDir,
|
|||||||
|
|
||||||
if (makeOriginalName) {
|
if (makeOriginalName) {
|
||||||
BString suffix(" ");
|
BString suffix(" ");
|
||||||
|
// execute first line, but use value from second
|
||||||
suffix << B_TRANSLATE_COMMENT("copy", "filename copy"),
|
suffix << B_TRANSLATE_COMMENT("copy", "filename copy"),
|
||||||
FSMakeOriginalName(destName, destDir, suffix.String());
|
FSMakeOriginalName(destName, destDir, suffix.String());
|
||||||
undo.UpdateEntry(srcFile, destName);
|
undo.UpdateEntry(srcFile, destName);
|
||||||
}
|
}
|
||||||
|
|
||||||
BEntry conflictingEntry;
|
BEntry conflictingEntry;
|
||||||
if (destDir->FindEntry(destName, &conflictingEntry) == B_OK) {
|
if (destDir->FindEntry(destName, &conflictingEntry) == B_OK) {
|
||||||
switch (loopControl->OverwriteOnConflict(srcFile, destName, destDir,
|
switch (loopControl->OverwriteOnConflict(srcFile, destName, destDir, false, false)) {
|
||||||
false, false)) {
|
|
||||||
case TrackerCopyLoopControl::kSkip:
|
case TrackerCopyLoopControl::kSkip:
|
||||||
// we are about to ignore this entire directory
|
// we are about to ignore this entire directory
|
||||||
return;
|
return;
|
||||||
@@ -1309,8 +1300,7 @@ CopyFile(BEntry* srcFile, StatStruct* srcStat, BDirectory* destDir,
|
|||||||
}
|
}
|
||||||
// fall through if not a directory
|
// fall through if not a directory
|
||||||
case TrackerCopyLoopControl::kMerge:
|
case TrackerCopyLoopControl::kMerge:
|
||||||
// This flag implies that the attributes should be kept
|
// This flag implies that the attributes should be kept on the file, ignore it.
|
||||||
// on the file. Just ignore it.
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1396,8 +1386,7 @@ LowLevelCopy(BEntry* srcEntry, StatStruct* srcStat, BDirectory* destDir,
|
|||||||
node_ref destNodeRef;
|
node_ref destNodeRef;
|
||||||
destDir->GetNodeRef(&destNodeRef);
|
destDir->GetNodeRef(&destNodeRef);
|
||||||
// copy or write new pose location as a first thing
|
// copy or write new pose location as a first thing
|
||||||
SetupPoseLocation(ref.directory, destNodeRef.node, &srcLink,
|
SetupPoseLocation(ref.directory, destNodeRef.node, &srcLink, &newLink, loc);
|
||||||
&newLink, loc);
|
|
||||||
|
|
||||||
BNodeInfo nodeInfo(&newLink);
|
BNodeInfo nodeInfo(&newLink);
|
||||||
nodeInfo.SetType(B_LINK_MIMETYPE);
|
nodeInfo.SetType(B_LINK_MIMETYPE);
|
||||||
@@ -1414,16 +1403,15 @@ LowLevelCopy(BEntry* srcEntry, StatStruct* srcStat, BDirectory* destDir,
|
|||||||
BFile srcFile(srcEntry, O_RDONLY);
|
BFile srcFile(srcEntry, O_RDONLY);
|
||||||
ThrowOnInitCheckError(&srcFile);
|
ThrowOnInitCheckError(&srcFile);
|
||||||
|
|
||||||
const size_t kMinBufferSize = 1024* 128;
|
const size_t kMinBufferSize = 1024 * 128;
|
||||||
const size_t kMaxBufferSize = 1024* 1024;
|
const size_t kMaxBufferSize = 1024 * 1024;
|
||||||
|
|
||||||
size_t bufsize = kMinBufferSize;
|
size_t bufsize = kMinBufferSize;
|
||||||
if ((off_t)bufsize < srcStat->st_size) {
|
if ((off_t)bufsize < srcStat->st_size) {
|
||||||
// File bigger than the buffer size: determine an optimal buffer size
|
// File bigger than the buffer size: determine an optimal buffer size
|
||||||
system_info sinfo;
|
system_info sinfo;
|
||||||
get_system_info(&sinfo);
|
get_system_info(&sinfo);
|
||||||
size_t freesize = static_cast<size_t>(
|
size_t freesize = static_cast<size_t>((sinfo.max_pages - sinfo.used_pages) * B_PAGE_SIZE);
|
||||||
(sinfo.max_pages - sinfo.used_pages) * B_PAGE_SIZE);
|
|
||||||
bufsize = freesize / 4;
|
bufsize = freesize / 4;
|
||||||
// take 1/4 of RAM max
|
// take 1/4 of RAM max
|
||||||
bufsize -= bufsize % (16* 1024);
|
bufsize -= bufsize % (16* 1024);
|
||||||
@@ -1451,8 +1439,7 @@ LowLevelCopy(BEntry* srcEntry, StatStruct* srcStat, BDirectory* destDir,
|
|||||||
node_ref destNodeRef;
|
node_ref destNodeRef;
|
||||||
destDir->GetNodeRef(&destNodeRef);
|
destDir->GetNodeRef(&destNodeRef);
|
||||||
// copy or write new pose location as a first thing
|
// copy or write new pose location as a first thing
|
||||||
SetupPoseLocation(ref.directory, destNodeRef.node, &srcFile,
|
SetupPoseLocation(ref.directory, destNodeRef.node, &srcFile, &destFile, loc);
|
||||||
&destFile, loc);
|
|
||||||
|
|
||||||
char* buffer = new char[bufsize];
|
char* buffer = new char[bufsize];
|
||||||
try {
|
try {
|
||||||
@@ -1469,7 +1456,7 @@ LowLevelCopy(BEntry* srcEntry, StatStruct* srcStat, BDirectory* destDir,
|
|||||||
throw (status_t)kCopyCanceled;
|
throw (status_t)kCopyCanceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(buffer);
|
ASSERT(buffer != NULL);
|
||||||
ssize_t bytes = srcFile.Read(buffer, bufsize);
|
ssize_t bytes = srcFile.Read(buffer, bufsize);
|
||||||
|
|
||||||
if (bytes > 0) {
|
if (bytes > 0) {
|
||||||
@@ -1494,8 +1481,7 @@ LowLevelCopy(BEntry* srcEntry, StatStruct* srcStat, BDirectory* destDir,
|
|||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
throw (status_t)result;
|
throw (status_t)result;
|
||||||
|
|
||||||
loopControl->UpdateStatus(NULL, ref, bytes - updateBytes,
|
loopControl->UpdateStatus(NULL, ref, bytes - updateBytes, true);
|
||||||
true);
|
|
||||||
} else if (bytes < 0) {
|
} else if (bytes < 0) {
|
||||||
// read error
|
// read error
|
||||||
throw (status_t)bytes;
|
throw (status_t)bytes;
|
||||||
@@ -1520,7 +1506,7 @@ LowLevelCopy(BEntry* srcEntry, StatStruct* srcStat, BDirectory* destDir,
|
|||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
|
|
||||||
if (!loopControl->ChecksumFile(&ref)) {
|
if (!loopControl->ChecksumFile(&ref)) {
|
||||||
// File no good. Remove and quit.
|
// File no good. Remove and quit.
|
||||||
destFile.Unset();
|
destFile.Unset();
|
||||||
|
|
||||||
BEntry destEntry;
|
BEntry destEntry;
|
||||||
@@ -1612,8 +1598,9 @@ CopyFolder(BEntry* srcEntry, BDirectory* destDir,
|
|||||||
|
|
||||||
if (makeOriginalName) {
|
if (makeOriginalName) {
|
||||||
BString suffix(" ");
|
BString suffix(" ");
|
||||||
|
// execute first line, but use value from second
|
||||||
suffix << B_TRANSLATE_COMMENT("copy", "filename copy"),
|
suffix << B_TRANSLATE_COMMENT("copy", "filename copy"),
|
||||||
FSMakeOriginalName(destName, destDir, suffix.String());
|
FSMakeOriginalName(destName, destDir, suffix.String());
|
||||||
undo.UpdateEntry(srcEntry, destName);
|
undo.UpdateEntry(srcEntry, destName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1685,8 +1672,7 @@ CopyFolder(BEntry* srcEntry, BDirectory* destDir,
|
|||||||
// copy or write new pose location
|
// copy or write new pose location
|
||||||
node_ref destNodeRef;
|
node_ref destNodeRef;
|
||||||
destDir->GetNodeRef(&destNodeRef);
|
destDir->GetNodeRef(&destNodeRef);
|
||||||
SetupPoseLocation(ref.directory, destNodeRef.node, &srcDir,
|
SetupPoseLocation(ref.directory, destNodeRef.node, &srcDir, &newDir, loc);
|
||||||
&newDir, loc);
|
|
||||||
|
|
||||||
while (srcDir.GetNextEntry(&entry) == B_OK) {
|
while (srcDir.GetNextEntry(&entry) == B_OK) {
|
||||||
if (loopControl->CheckUserCanceled())
|
if (loopControl->CheckUserCanceled())
|
||||||
@@ -1702,8 +1688,7 @@ CopyFolder(BEntry* srcEntry, BDirectory* destDir,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyFolder(&entry, &newDir, loopControl, 0, false, undo,
|
CopyFolder(&entry, &newDir, loopControl, 0, false, undo, removeSource);
|
||||||
removeSource);
|
|
||||||
if (removeSource)
|
if (removeSource)
|
||||||
FSDeleteFolder(&entry, loopControl, true, true, false);
|
FSDeleteFolder(&entry, loopControl, true, true, false);
|
||||||
} else if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) {
|
} else if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) {
|
||||||
@@ -1742,11 +1727,9 @@ RecursiveMove(BEntry* entry, BDirectory* destDir, CopyLoopControl* loopControl)
|
|||||||
current.Remove();
|
current.Remove();
|
||||||
} else {
|
} else {
|
||||||
name = current.Name();
|
name = current.Name();
|
||||||
if (loopControl->OverwriteOnConflict(¤t, name,
|
if (loopControl->OverwriteOnConflict(¤t, name, &subDir, true, false)
|
||||||
&subDir, true, false)
|
!= TrackerCopyLoopControl::kSkip) {
|
||||||
!= TrackerCopyLoopControl::kSkip) {
|
MoveError::FailOnError(current.MoveTo(&subDir, NULL, true));
|
||||||
MoveError::FailOnError(current.MoveTo(&subDir,
|
|
||||||
NULL, true));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1777,12 +1760,14 @@ MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, uint32 moveMode,
|
|||||||
|
|
||||||
BSymLink link;
|
BSymLink link;
|
||||||
BString suffix(" ");
|
BString suffix(" ");
|
||||||
|
// execute first line, but use value from second
|
||||||
suffix << B_TRANSLATE_COMMENT("link", "filename link"),
|
suffix << B_TRANSLATE_COMMENT("link", "filename link"),
|
||||||
FSMakeOriginalName(name, destDir, suffix.String());
|
FSMakeOriginalName(name, destDir, suffix.String());
|
||||||
undo.UpdateEntry(entry, name);
|
undo.UpdateEntry(entry, name);
|
||||||
|
|
||||||
BPath path;
|
BPath path;
|
||||||
entry->GetPath(&path);
|
entry->GetPath(&path);
|
||||||
|
|
||||||
if (loc != NULL && loc != (BPoint*)-1) {
|
if (loc != NULL && loc != (BPoint*)-1) {
|
||||||
poseInfo.fInvisible = false;
|
poseInfo.fInvisible = false;
|
||||||
poseInfo.fInitedDirectory = destNode.node;
|
poseInfo.fInitedDirectory = destNode.node;
|
||||||
@@ -1845,8 +1830,7 @@ MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, uint32 moveMode,
|
|||||||
// else source and target are in the same dir
|
// else source and target are in the same dir
|
||||||
|
|
||||||
source.Append(path.Leaf());
|
source.Append(path.Leaf());
|
||||||
err = destDir->CreateSymLink(name, source.String(),
|
err = destDir->CreateSymLink(name, source.String(), &link);
|
||||||
&link);
|
|
||||||
|
|
||||||
chdir(oldwd);
|
chdir(oldwd);
|
||||||
// change working dir back to original
|
// change working dir back to original
|
||||||
@@ -1873,6 +1857,7 @@ MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, uint32 moveMode,
|
|||||||
|
|
||||||
BNodeInfo nodeInfo(&link);
|
BNodeInfo nodeInfo(&link);
|
||||||
nodeInfo.SetType(B_LINK_MIMETYPE);
|
nodeInfo.SetType(B_LINK_MIMETYPE);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1887,14 +1872,13 @@ MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, uint32 moveMode,
|
|||||||
|
|
||||||
MoveError::FailOnError(entry->MoveTo(destDir, newName));
|
MoveError::FailOnError(entry->MoveTo(destDir, newName));
|
||||||
} else {
|
} else {
|
||||||
|
bool removeSource = moveMode == kMoveSelectionTo;
|
||||||
bool makeOriginalName = (moveMode == kDuplicateSelection);
|
bool makeOriginalName = (moveMode == kDuplicateSelection);
|
||||||
if (S_ISDIR(statbuf.st_mode)) {
|
if (S_ISDIR(statbuf.st_mode)) {
|
||||||
CopyFolder(entry, destDir, loopControl, loc, makeOriginalName,
|
CopyFolder(entry, destDir, loopControl, loc, makeOriginalName, undo, removeSource);
|
||||||
undo, moveMode == kMoveSelectionTo);
|
|
||||||
} else {
|
} else {
|
||||||
CopyFile(entry, &statbuf, destDir, loopControl, loc,
|
CopyFile(entry, &statbuf, destDir, loopControl, loc, makeOriginalName, undo);
|
||||||
makeOriginalName, undo);
|
if (removeSource)
|
||||||
if (moveMode == kMoveSelectionTo)
|
|
||||||
entry->Remove();
|
entry->Remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2053,8 +2037,7 @@ MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo)
|
|||||||
if (volume == boot) {
|
if (volume == boot) {
|
||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
volume.GetName(name);
|
volume.GetName(name);
|
||||||
BString buffer(
|
BString buffer(B_TRANSLATE("Cannot unmount the boot volume \"%name\"."));
|
||||||
B_TRANSLATE("Cannot unmount the boot volume \"%name\"."));
|
|
||||||
buffer.ReplaceFirst("%name", name);
|
buffer.ReplaceFirst("%name", name);
|
||||||
BAlert* alert = new BAlert("", buffer.String(),
|
BAlert* alert = new BAlert("", buffer.String(),
|
||||||
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL,
|
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL,
|
||||||
@@ -2110,8 +2093,9 @@ MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo)
|
|||||||
strlcpy(name, ref.name, sizeof(name));
|
strlcpy(name, ref.name, sizeof(name));
|
||||||
if (trashDir.Contains(name)) {
|
if (trashDir.Contains(name)) {
|
||||||
BString suffix(" ");
|
BString suffix(" ");
|
||||||
|
// execute first line, but use value from second
|
||||||
suffix << B_TRANSLATE_COMMENT("copy", "filename copy"),
|
suffix << B_TRANSLATE_COMMENT("copy", "filename copy"),
|
||||||
FSMakeOriginalName(name, &trashDir, suffix.String());
|
FSMakeOriginalName(name, &trashDir, suffix.String());
|
||||||
undo.UpdateEntry(entry, name);
|
undo.UpdateEntry(entry, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2145,8 +2129,8 @@ PreFlightNameCheck(BObjectList<entry_ref, true>* srcList, const BDirectory* dest
|
|||||||
// count the number of name collisions in dest folder
|
// count the number of name collisions in dest folder
|
||||||
*collisionCount = 0;
|
*collisionCount = 0;
|
||||||
|
|
||||||
int32 count = srcList->CountItems();
|
int32 numItems = srcList->CountItems();
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < numItems; i++) {
|
||||||
entry_ref* srcRef = srcList->ItemAt(i);
|
entry_ref* srcRef = srcList->ItemAt(i);
|
||||||
BEntry entry(srcRef);
|
BEntry entry(srcRef);
|
||||||
BDirectory parent;
|
BDirectory parent;
|
||||||
@@ -2242,8 +2226,8 @@ CheckName(uint32 moveMode, const BEntry* sourceEntry,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FSIsTrashDir(sourceEntry) && moveMode != kCreateLink
|
if (FSIsTrashDir(sourceEntry)
|
||||||
&& moveMode != kCreateRelativeLink) {
|
&& !(moveMode == kCreateLink || moveMode == kCreateRelativeLink)) {
|
||||||
BAlert* alert = new BAlert("",
|
BAlert* alert = new BAlert("",
|
||||||
B_TRANSLATE("You can't move or copy the trash."),
|
B_TRANSLATE("You can't move or copy the trash."),
|
||||||
B_TRANSLATE("OK"), 0, 0, B_WIDTH_AS_USUAL,
|
B_TRANSLATE("OK"), 0, 0, B_WIDTH_AS_USUAL,
|
||||||
@@ -2285,9 +2269,8 @@ CheckName(uint32 moveMode, const BEntry* sourceEntry,
|
|||||||
|
|
||||||
// ensure that the user isn't trying to replace a file with folder
|
// ensure that the user isn't trying to replace a file with folder
|
||||||
// or vice-versa
|
// or vice-versa
|
||||||
if (moveMode != kCreateLink
|
if (destIsDir != sourceIsDirectory
|
||||||
&& moveMode != kCreateRelativeLink
|
&& !(moveMode == kCreateLink || moveMode != kCreateRelativeLink)) {
|
||||||
&& destIsDir != sourceIsDirectory) {
|
|
||||||
BAlert* alert = new BAlert("", sourceIsDirectory
|
BAlert* alert = new BAlert("", sourceIsDirectory
|
||||||
? B_TRANSLATE("You cannot replace a file with a folder or a "
|
? B_TRANSLATE("You cannot replace a file with a folder or a "
|
||||||
"symbolic link.")
|
"symbolic link.")
|
||||||
@@ -3098,8 +3081,8 @@ _DeleteTask(BObjectList<entry_ref, true>* list, bool confirm)
|
|||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
loopControl.Init(totalItems, totalItems);
|
loopControl.Init(totalItems, totalItems);
|
||||||
|
|
||||||
int32 count = list->CountItems();
|
int32 numItems = list->CountItems();
|
||||||
for (int32 index = 0; index < count; index++) {
|
for (int32 index = 0; index < numItems; index++) {
|
||||||
entry_ref ref(*list->ItemAt(index));
|
entry_ref ref(*list->ItemAt(index));
|
||||||
BEntry entry(&ref);
|
BEntry entry(&ref);
|
||||||
loopControl.UpdateStatus(ref.name, ref, 1, true);
|
loopControl.UpdateStatus(ref.name, ref, 1, true);
|
||||||
@@ -3164,8 +3147,8 @@ _RestoreTask(BObjectList<entry_ref, true>* list)
|
|||||||
if (err == B_OK) {
|
if (err == B_OK) {
|
||||||
loopControl.Init(totalItems, totalItems);
|
loopControl.Init(totalItems, totalItems);
|
||||||
|
|
||||||
int32 count = list->CountItems();
|
int32 numItems = list->CountItems();
|
||||||
for (int32 index = 0; index < count; index++) {
|
for (int32 index = 0; index < numItems; index++) {
|
||||||
entry_ref ref(*list->ItemAt(index));
|
entry_ref ref(*list->ItemAt(index));
|
||||||
BEntry entry(&ref);
|
BEntry entry(&ref);
|
||||||
BPath originalPath;
|
BPath originalPath;
|
||||||
@@ -3532,9 +3515,8 @@ _TrackerLaunchAppWithDocuments(const entry_ref* appRef, const BMessage* refs,
|
|||||||
alertString.ReplaceFirst("%error", strerror(error));
|
alertString.ReplaceFirst("%error", strerror(error));
|
||||||
if (refs != NULL && openWithOK && error != B_SHUTTING_DOWN) {
|
if (refs != NULL && openWithOK && error != B_SHUTTING_DOWN) {
|
||||||
alertString << B_TRANSLATE_NOCOLLECT(kFindAlternativeStr);
|
alertString << B_TRANSLATE_NOCOLLECT(kFindAlternativeStr);
|
||||||
BAlert* alert = new BAlert("", alertString.String(),
|
BAlert* alert = new BAlert("", alertString.String(), B_TRANSLATE("Cancel"),
|
||||||
B_TRANSLATE("Cancel"), B_TRANSLATE("Find"), 0,
|
B_TRANSLATE("Find"), 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
|
||||||
alert->SetShortcut(0, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
if (alert->Go() == 1)
|
if (alert->Go() == 1)
|
||||||
error = TrackerOpenWith(refs);
|
error = TrackerOpenWith(refs);
|
||||||
@@ -4091,8 +4073,8 @@ WellKnowEntryList::MatchEntry(const node_ref* node)
|
|||||||
const WellKnowEntryList::WellKnownEntry*
|
const WellKnowEntryList::WellKnownEntry*
|
||||||
WellKnowEntryList::MatchEntryCommon(const node_ref* node)
|
WellKnowEntryList::MatchEntryCommon(const node_ref* node)
|
||||||
{
|
{
|
||||||
uint32 count = entries.size();
|
uint32 numItems = entries.size();
|
||||||
for (uint32 index = 0; index < count; index++) {
|
for (uint32 index = 0; index < numItems; index++) {
|
||||||
if (*node == entries[index].node)
|
if (*node == entries[index].node)
|
||||||
return &entries[index];
|
return &entries[index];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
bool allowContinue);
|
bool allowContinue);
|
||||||
|
|
||||||
virtual void UpdateStatus(const char* name,
|
virtual void UpdateStatus(const char* name,
|
||||||
const entry_ref& ref, int32 count,
|
const entry_ref& ref, int32 bytes,
|
||||||
bool optional = false);
|
bool optional = false);
|
||||||
|
|
||||||
//! \return \c true if canceled
|
//! \return \c true if canceled
|
||||||
@@ -134,7 +134,7 @@ public:
|
|||||||
bool allowContinue);
|
bool allowContinue);
|
||||||
|
|
||||||
virtual void UpdateStatus(const char* name,
|
virtual void UpdateStatus(const char* name,
|
||||||
const entry_ref& ref, int32 count,
|
const entry_ref& ref, int32 bytes,
|
||||||
bool optional = false);
|
bool optional = false);
|
||||||
|
|
||||||
virtual bool CheckUserCanceled();
|
virtual bool CheckUserCanceled();
|
||||||
|
|||||||
@@ -198,14 +198,11 @@ OneMatches(BPose* pose, BPoseView*, void* castToPose)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CopySelectionListToEntryRefList(const PoseList* original,
|
CopySelectionListToEntryRefList(const PoseList* original, BObjectList<entry_ref, true>* copy)
|
||||||
BObjectList<entry_ref, true>* copy)
|
|
||||||
{
|
{
|
||||||
int32 count = original->CountItems();
|
int32 selectionCount = original->CountItems();
|
||||||
for (int32 index = 0; index < count; index++) {
|
for (int32 index = 0; index < selectionCount; index++)
|
||||||
copy->AddItem(new entry_ref(*(original->ItemAt(
|
copy->AddItem(new entry_ref(*(original->ItemAt(index)->TargetModel()->EntryRef())));
|
||||||
index)->TargetModel()->EntryRef())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4323,8 +4320,7 @@ BPoseView::CanHandleDragSelection(const Model* target,
|
|||||||
|
|
||||||
for (int32 index = 0; index < selectCount; index++) {
|
for (int32 index = 0; index < selectCount; index++) {
|
||||||
// get the mime type of the model, following a possible symlink
|
// get the mime type of the model, following a possible symlink
|
||||||
BEntry entry(selectionList->ItemAt(
|
BEntry entry(selectionList->ItemAt(index)->TargetModel()->EntryRef(), true);
|
||||||
index)->TargetModel()->EntryRef(), true);
|
|
||||||
if (entry.InitCheck() != B_OK)
|
if (entry.InitCheck() != B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -4477,7 +4473,7 @@ BPoseView::HandleMessageDropped(BMessage* message)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
BContainerWindow* window = dynamic_cast<BContainerWindow*>(Window());
|
BContainerWindow* window = dynamic_cast<BContainerWindow*>(Window());
|
||||||
if (window != NULL && message->HasData("RGBColor", 'RGBC')) {
|
if (window != NULL && message->HasData("RGBColor", B_RGB_COLOR_TYPE)) {
|
||||||
// do not handle roColor-style drops here, pass them on to the desktop
|
// do not handle roColor-style drops here, pass them on to the desktop
|
||||||
BMessenger((BHandler*)window).SendMessage(message);
|
BMessenger((BHandler*)window).SendMessage(message);
|
||||||
|
|
||||||
@@ -4502,8 +4498,7 @@ BPoseView::HandleMessageDropped(BMessage* message)
|
|||||||
if (targetPose != NULL) {
|
if (targetPose != NULL) {
|
||||||
targetModel = targetPose->TargetModel();
|
targetModel = targetPose->TargetModel();
|
||||||
if (targetModel->IsSymLink()
|
if (targetModel->IsSymLink()
|
||||||
&& tmpTarget.SetTo(targetPose->TargetModel()->EntryRef(),
|
&& tmpTarget.SetTo(targetPose->TargetModel()->EntryRef(), true, true) == B_OK) {
|
||||||
true, true) == B_OK) {
|
|
||||||
targetModel = &tmpTarget;
|
targetModel = &tmpTarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4513,8 +4508,8 @@ BPoseView::HandleMessageDropped(BMessage* message)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BPoseView::HandleDropCommon(BMessage* message, Model* targetModel,
|
BPoseView::HandleDropCommon(BMessage* message, Model* targetModel, BPose* targetPose,
|
||||||
BPose* targetPose, BView* view, BPoint dropPoint)
|
BView* view, BPoint dropPoint)
|
||||||
{
|
{
|
||||||
uint32 buttons = (uint32)message->FindInt32("buttons");
|
uint32 buttons = (uint32)message->FindInt32("buttons");
|
||||||
|
|
||||||
@@ -4564,10 +4559,8 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel,
|
|||||||
BStringList actionSpecifiers(10);
|
BStringList actionSpecifiers(10);
|
||||||
for (int32 index = 0; ; index++) {
|
for (int32 index = 0; ; index++) {
|
||||||
const char* string;
|
const char* string;
|
||||||
if (message->FindString("be:actionspecifier", index,
|
if (message->FindString("be:actionspecifier", index, &string) != B_OK)
|
||||||
&string) != B_OK) {
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(string != NULL);
|
ASSERT(string != NULL);
|
||||||
actionSpecifiers.Add(string);
|
actionSpecifiers.Add(string);
|
||||||
@@ -4578,17 +4571,14 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel,
|
|||||||
BStringList typeNames(10);
|
BStringList typeNames(10);
|
||||||
for (int32 index = 0; ; index++) {
|
for (int32 index = 0; ; index++) {
|
||||||
const char* string;
|
const char* string;
|
||||||
if (message->FindString("be:filetypes", index, &string)
|
if (message->FindString("be:filetypes", index, &string) != B_OK)
|
||||||
!= B_OK) {
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(string != NULL);
|
ASSERT(string != NULL);
|
||||||
types.Add(string);
|
types.Add(string);
|
||||||
|
|
||||||
const char* typeName = "";
|
const char* typeName = "";
|
||||||
message->FindString("be:type_descriptions", index,
|
message->FindString("be:type_descriptions", index, &typeName);
|
||||||
&typeName);
|
|
||||||
typeNames.Add(typeName);
|
typeNames.Add(typeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4596,12 +4586,10 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel,
|
|||||||
int32 specificActionIndex = -1;
|
int32 specificActionIndex = -1;
|
||||||
|
|
||||||
// if control down, run a popup menu
|
// if control down, run a popup menu
|
||||||
if (canCopy
|
if (canCopy && SecondaryMouseButtonDown(modifiers(), buttons)) {
|
||||||
&& SecondaryMouseButtonDown(modifiers(), buttons)) {
|
|
||||||
if (actionSpecifiers.CountStrings() > 0) {
|
if (actionSpecifiers.CountStrings() > 0) {
|
||||||
specificActionIndex = RunMimeTypeDestinationMenu(NULL,
|
specificActionIndex = RunMimeTypeDestinationMenu(NULL, NULL,
|
||||||
NULL, &actionSpecifiers,
|
&actionSpecifiers, view->ConvertToScreen(dropPoint));
|
||||||
view->ConvertToScreen(dropPoint));
|
|
||||||
|
|
||||||
if (specificActionIndex == -1)
|
if (specificActionIndex == -1)
|
||||||
return false;
|
return false;
|
||||||
@@ -4618,9 +4606,8 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel,
|
|||||||
|
|
||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
BFile file;
|
BFile file;
|
||||||
if (CreateClippingFile(poseView, file, name, &targetDirectory,
|
if (CreateClippingFile(poseView, file, name, &targetDirectory, message,
|
||||||
message, B_TRANSLATE("Untitled clipping"),
|
B_TRANSLATE("Untitled clipping"), targetPose == NULL, dropPoint) != B_OK) {
|
||||||
targetPose == NULL, dropPoint) != B_OK) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4632,8 +4619,7 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel,
|
|||||||
reply.AddString("be:types", B_FILE_MIME_TYPE);
|
reply.AddString("be:types", B_FILE_MIME_TYPE);
|
||||||
if (specificTypeIndex != -1) {
|
if (specificTypeIndex != -1) {
|
||||||
// we had the user pick a specific type from a menu, use it
|
// we had the user pick a specific type from a menu, use it
|
||||||
reply.AddString("be:filetypes",
|
reply.AddString("be:filetypes", types.StringAt(specificTypeIndex).String());
|
||||||
types.StringAt(specificTypeIndex).String());
|
|
||||||
|
|
||||||
if (typeNames.StringAt(specificTypeIndex).Length()) {
|
if (typeNames.StringAt(specificTypeIndex).Length()) {
|
||||||
reply.AddString("be:type_descriptions",
|
reply.AddString("be:type_descriptions",
|
||||||
@@ -4659,10 +4645,9 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel,
|
|||||||
// support
|
// support
|
||||||
for (int32 index = 0; ; index++) {
|
for (int32 index = 0; ; index++) {
|
||||||
const char* type;
|
const char* type;
|
||||||
if (message->FindString("be:filetypes", index, &type)
|
if (message->FindString("be:filetypes", index, &type) != B_OK)
|
||||||
!= B_OK) {
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
reply.AddString("be:filetypes", type);
|
reply.AddString("be:filetypes", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4676,8 +4661,7 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel,
|
|||||||
// look for specific command or bring up popup
|
// look for specific command or bring up popup
|
||||||
// Unify this with local drag&drop
|
// Unify this with local drag&drop
|
||||||
|
|
||||||
if (!targetModel->IsDirectory()
|
if (!targetModel->IsDirectory() && !targetModel->IsVirtualDirectory()) {
|
||||||
&& !targetModel->IsVirtualDirectory()) {
|
|
||||||
// bail if we are not a directory
|
// bail if we are not a directory
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -4727,14 +4711,13 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle refs by performing a copy
|
// handle refs by performing a copy
|
||||||
BObjectList<entry_ref, true>* entryList
|
BObjectList<entry_ref, true>* entryList = new BObjectList<entry_ref, true>(10);
|
||||||
= new BObjectList<entry_ref, true>(10);
|
|
||||||
|
|
||||||
for (int32 index = 0; ; index++) {
|
for (int32 index = 0; ; index++) {
|
||||||
// copy all enclosed refs into a list
|
// copy all enclosed refs into a list
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
if (message->FindRef("refs", index, &ref) != B_OK)
|
if (message->FindRef("refs", index, &ref) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
entryList->AddItem(new entry_ref(ref));
|
entryList->AddItem(new entry_ref(ref));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4748,11 +4731,9 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel,
|
|||||||
// force the the icons to lay out in 5 columns
|
// force the the icons to lay out in 5 columns
|
||||||
for (int32 index = 0; count; index++) {
|
for (int32 index = 0; count; index++) {
|
||||||
for (int32 j = 0; count && j < 4; j++, count--) {
|
for (int32 j = 0; count && j < 4; j++, count--) {
|
||||||
BPoint point(
|
BPoint point(dropPoint + BPoint(j * poseView->fGrid.x,
|
||||||
dropPoint + BPoint(j * poseView->fGrid.x,
|
|
||||||
index * poseView->fGrid.y));
|
index * poseView->fGrid.y));
|
||||||
pointList->AddItem(
|
pointList->AddItem(new BPoint(poseView->PinToGrid(point,
|
||||||
new BPoint(poseView->PinToGrid(point,
|
|
||||||
poseView->fGrid, poseView->fOffset)));
|
poseView->fGrid, poseView->fOffset)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4838,12 +4819,9 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
BMessage embeddedBitmap;
|
BMessage embeddedBitmap;
|
||||||
if (message->FindMessage(kBitmapMimeType, &embeddedBitmap)
|
if (message->FindMessage(kBitmapMimeType, &embeddedBitmap) != B_OK
|
||||||
!= B_OK
|
&& message->FindMessage(kLargeIconType, &embeddedBitmap) != B_OK
|
||||||
&& message->FindMessage(kLargeIconType, &embeddedBitmap)
|
&& message->FindMessage(kMiniIconType, &embeddedBitmap) != B_OK) {
|
||||||
!= B_OK
|
|
||||||
&& message->FindMessage(kMiniIconType, &embeddedBitmap)
|
|
||||||
!= B_OK) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4948,10 +4926,9 @@ AddOneToLaunchMessage(BPose* pose, BPoseView*, void* castToParams)
|
|||||||
ThrowOnAssert(pose != NULL);
|
ThrowOnAssert(pose != NULL);
|
||||||
ThrowOnAssert(pose->TargetModel() != NULL);
|
ThrowOnAssert(pose->TargetModel() != NULL);
|
||||||
|
|
||||||
if (params->app->IsDropTarget(params->checkTypes
|
Model* model = params->checkTypes ? pose->TargetModel() : NULL;
|
||||||
? pose->TargetModel() : NULL, true)) {
|
if (params->app->IsDropTarget(model, true))
|
||||||
params->refsMessage->AddRef("refs", pose->TargetModel()->EntryRef());
|
params->refsMessage->AddRef("refs", pose->TargetModel()->EntryRef());
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -4996,19 +4973,18 @@ void
|
|||||||
BPoseView::MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow,
|
BPoseView::MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow,
|
||||||
bool forceCopy, bool forceMove, bool createLink, bool relativeLink)
|
bool forceCopy, bool forceMove, bool createLink, bool relativeLink)
|
||||||
{
|
{
|
||||||
|
BPoint dropPoint;
|
||||||
uint32 buttons;
|
uint32 buttons;
|
||||||
BPoint loc;
|
GetMouse(&dropPoint, &buttons);
|
||||||
GetMouse(&loc, &buttons);
|
MoveSelectionInto(destFolder, srcWindow, dynamic_cast<BContainerWindow*>(Window()),
|
||||||
MoveSelectionInto(destFolder, srcWindow,
|
buttons, dropPoint, forceCopy, forceMove, createLink, relativeLink);
|
||||||
dynamic_cast<BContainerWindow*>(Window()), buttons, loc, forceCopy,
|
|
||||||
forceMove, createLink, relativeLink);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPoseView::MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow,
|
BPoseView::MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow,
|
||||||
BContainerWindow* destWindow, uint32 buttons, BPoint loc, bool forceCopy,
|
BContainerWindow* destWindow, uint32 buttons, BPoint dropPoint, bool forceCopy,
|
||||||
bool forceMove, bool createLink, bool relativeLink, BPoint where, bool dropOnGrid)
|
bool forceMove, bool createLink, bool relativeLink, BPoint where, bool pinToGrid)
|
||||||
{
|
{
|
||||||
AutoLock<BWindow> lock(srcWindow);
|
AutoLock<BWindow> lock(srcWindow);
|
||||||
if (!lock)
|
if (!lock)
|
||||||
@@ -5020,10 +4996,9 @@ BPoseView::MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
bool createRelativeLink = relativeLink;
|
bool createRelativeLink = relativeLink;
|
||||||
if (SecondaryMouseButtonDown(modifiers(), buttons)
|
if (destWindow != NULL && SecondaryMouseButtonDown(modifiers(), buttons)) {
|
||||||
&& destWindow != NULL) {
|
BPoseView* poseView = (srcWindow != NULL ? srcWindow->PoseView() : NULL);
|
||||||
switch (destWindow->ShowDropContextMenu(loc,
|
switch (destWindow->ShowDropContextMenu(dropPoint, poseView)) {
|
||||||
srcWindow != NULL ? srcWindow->PoseView() : NULL)) {
|
|
||||||
case kCreateRelativeLink:
|
case kCreateRelativeLink:
|
||||||
createRelativeLink = true;
|
createRelativeLink = true;
|
||||||
break;
|
break;
|
||||||
@@ -5051,7 +5026,7 @@ BPoseView::MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow,
|
|||||||
if (*srcWindow->PoseView()->TargetModel()->NodeRef() == *destFolder->NodeRef()) {
|
if (*srcWindow->PoseView()->TargetModel()->NodeRef() == *destFolder->NodeRef()) {
|
||||||
BPoseView* targetView = srcWindow->PoseView();
|
BPoseView* targetView = srcWindow->PoseView();
|
||||||
if (forceCopy) {
|
if (forceCopy) {
|
||||||
targetView->DuplicateSelection(&where, &loc);
|
targetView->DuplicateSelection(&where, &dropPoint);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5065,7 +5040,7 @@ BPoseView::MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BPoint delta = loc - where;
|
BPoint delta = dropPoint - where;
|
||||||
int32 selectCount = targetView->CountSelected();
|
int32 selectCount = targetView->CountSelected();
|
||||||
for (int32 index = 0; index < selectCount; index++) {
|
for (int32 index = 0; index < selectCount; index++) {
|
||||||
BPose* pose = targetView->SelectionList()->ItemAt(index);
|
BPose* pose = targetView->SelectionList()->ItemAt(index);
|
||||||
@@ -5077,7 +5052,7 @@ BPoseView::MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow,
|
|||||||
targetView->RemoveFromVSList(pose);
|
targetView->RemoveFromVSList(pose);
|
||||||
BPoint location(pose->Location(targetView) + delta);
|
BPoint location(pose->Location(targetView) + delta);
|
||||||
BRect oldBounds(pose->CalcRect(targetView));
|
BRect oldBounds(pose->CalcRect(targetView));
|
||||||
if (dropOnGrid) {
|
if (pinToGrid) {
|
||||||
location = targetView->PinToGrid(location, targetView->fGrid,
|
location = targetView->PinToGrid(location, targetView->fGrid,
|
||||||
targetView->fOffset);
|
targetView->fOffset);
|
||||||
}
|
}
|
||||||
@@ -5149,8 +5124,8 @@ BPoseView::MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow,
|
|||||||
|
|
||||||
if (okToMove) {
|
if (okToMove) {
|
||||||
PoseList* selectionList = srcWindow->PoseView()->SelectionList();
|
PoseList* selectionList = srcWindow->PoseView()->SelectionList();
|
||||||
BList* pointList = destWindow->PoseView()->GetDropPointList(where, loc, selectionList,
|
BList* pointList = destWindow->PoseView()->GetDropPointList(where, dropPoint,
|
||||||
srcWindow->PoseView()->ViewMode() == kListMode, dropOnGrid);
|
selectionList, srcWindow->PoseView()->ViewMode() == kListMode, pinToGrid);
|
||||||
int32 selectionSize = selectionList->CountItems();
|
int32 selectionSize = selectionList->CountItems();
|
||||||
BObjectList<entry_ref, true>* srcList = new BObjectList<entry_ref, true>(selectionSize);
|
BObjectList<entry_ref, true>* srcList = new BObjectList<entry_ref, true>(selectionSize);
|
||||||
|
|
||||||
@@ -5212,8 +5187,8 @@ BPoseView::MoveSelectionTo(BPoint dropPoint, BPoint where, BContainerWindow* src
|
|||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
UpdateWasBrokenSymlinkBinder(BPose* pose, Model* model, int32 index,
|
UpdateWasBrokenSymlinkBinder(BPose* pose, Model* model, int32 index, BPoseView* poseView,
|
||||||
BPoseView* poseView, BObjectList<Model>* fBrokenLinks)
|
BObjectList<Model>* fBrokenLinks)
|
||||||
{
|
{
|
||||||
if (!model->IsSymLink())
|
if (!model->IsSymLink())
|
||||||
return;
|
return;
|
||||||
@@ -6053,7 +6028,7 @@ BPoseView::ConvertZombieToPose(Model* zombie, int32 index)
|
|||||||
|
|
||||||
BList*
|
BList*
|
||||||
BPoseView::GetDropPointList(BPoint dropStart, BPoint dropEnd, const PoseList* poses,
|
BPoseView::GetDropPointList(BPoint dropStart, BPoint dropEnd, const PoseList* poses,
|
||||||
bool sourceInListMode, bool dropOnGrid) const
|
bool sourceInListMode, bool pinToGrid) const
|
||||||
{
|
{
|
||||||
if (ViewMode() == kListMode)
|
if (ViewMode() == kListMode)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -6068,7 +6043,7 @@ BPoseView::GetDropPointList(BPoint dropStart, BPoint dropEnd, const PoseList* po
|
|||||||
else
|
else
|
||||||
poseLoc = dropEnd + (pose->Location(this) - dropStart);
|
poseLoc = dropEnd + (pose->Location(this) - dropStart);
|
||||||
|
|
||||||
if (dropOnGrid)
|
if (pinToGrid)
|
||||||
poseLoc = PinToGrid(poseLoc, fGrid, fOffset);
|
poseLoc = PinToGrid(poseLoc, fGrid, fOffset);
|
||||||
|
|
||||||
pointList->AddItem(new BPoint(poseLoc));
|
pointList->AddItem(new BPoint(poseLoc));
|
||||||
@@ -6110,8 +6085,9 @@ BPoseView::DuplicateSelection(BPoint* dropStart, BPoint* dropEnd)
|
|||||||
|
|
||||||
BList* dropPoints;
|
BList* dropPoints;
|
||||||
if (dropStart) {
|
if (dropStart) {
|
||||||
|
bool pinToGrid = (modifiers() & B_COMMAND_KEY) != 0;
|
||||||
dropPoints = GetDropPointList(*dropStart, *dropEnd, fSelectionList,
|
dropPoints = GetDropPointList(*dropStart, *dropEnd, fSelectionList,
|
||||||
ViewMode() == kListMode, (modifiers() & B_COMMAND_KEY) != 0);
|
ViewMode() == kListMode, pinToGrid);
|
||||||
} else
|
} else
|
||||||
dropPoints = NULL;
|
dropPoints = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -283,14 +283,11 @@ public:
|
|||||||
virtual void OpenParent();
|
virtual void OpenParent();
|
||||||
virtual bool CanOpenParent();
|
virtual bool CanOpenParent();
|
||||||
|
|
||||||
virtual void OpenSelection(BPose* clicked_pose = NULL,
|
virtual void OpenSelection(BPose* clicked_pose = NULL, int32* index = NULL);
|
||||||
int32* index = NULL);
|
void OpenSelectionUsing(BPose* clicked_pose = NULL, int32* index = NULL);
|
||||||
void OpenSelectionUsing(BPose* clicked_pose = NULL,
|
|
||||||
int32* index = NULL);
|
|
||||||
// launches the open with window
|
// launches the open with window
|
||||||
virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*);
|
virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*);
|
||||||
void DuplicateSelection(BPoint* dropStart = NULL,
|
void DuplicateSelection(BPoint* dropStart = NULL,BPoint* dropEnd = NULL);
|
||||||
BPoint* dropEnd = NULL);
|
|
||||||
|
|
||||||
// Move to trash calls try to select the next pose in the view
|
// Move to trash calls try to select the next pose in the view
|
||||||
// when they are dones
|
// when they are dones
|
||||||
@@ -661,7 +658,7 @@ protected:
|
|||||||
|
|
||||||
// misc
|
// misc
|
||||||
BList* GetDropPointList(BPoint dropPoint, BPoint startPoint,
|
BList* GetDropPointList(BPoint dropPoint, BPoint startPoint,
|
||||||
const PoseList*, bool sourceInListMode, bool dropOnGrid) const;
|
const PoseList*, bool sourceInListMode, bool pinToGrid) const;
|
||||||
void SendSelectionAsRefs(uint32 what, bool onlyQueries = false);
|
void SendSelectionAsRefs(uint32 what, bool onlyQueries = false);
|
||||||
void MoveListToTrash(BObjectList<entry_ref, true>*, bool selectNext,
|
void MoveListToTrash(BObjectList<entry_ref, true>*, bool selectNext,
|
||||||
bool deleteDirectly);
|
bool deleteDirectly);
|
||||||
|
|||||||
Reference in New Issue
Block a user