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