Add a special node type for the Trash analogous to the one used for the root dir. This allows the model to return an arbitrary name not directly tied to the on-disk name for the Trash directory, which a) makes it localizable in the future, and b) means it's not tied to the on-disk name, which removes the requirement that the Trash dir name be uppercase on disk.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35126 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2010-01-17 18:12:39 +00:00
parent 782fbf00a7
commit 6abd81fcf0
2 changed files with 20 additions and 3 deletions

View File

@ -331,10 +331,17 @@ Model::Name() const
switch (fBaseType) { switch (fBaseType) {
case kRootNode: case kRootNode:
return "Disks"; return "Disks";
case kVolumeNode: case kVolumeNode:
if (fVolumeName) if (fVolumeName)
return fVolumeName; return fVolumeName;
// fall thru
case kTrashNode:
return "Trash";
default:
break;
} }
return fEntryRef.name; return fEntryRef.name;
} }
@ -402,6 +409,7 @@ Model::OpenNodeCommon(bool writable)
case kDirectoryNode: case kDirectoryNode:
case kVolumeNode: case kVolumeNode:
case kRootNode: case kRootNode:
case kTrashNode:
if (!IsNodeOpen()) if (!IsNodeOpen())
fNode = new BDirectory(&fEntryRef); fNode = new BDirectory(&fEntryRef);
@ -542,6 +550,7 @@ void
Model::FinishSettingUpType() Model::FinishSettingUpType()
{ {
char mimeString[B_MIME_TYPE_LENGTH]; char mimeString[B_MIME_TYPE_LENGTH];
BEntry entry;
// while we are reading the node, do a little // while we are reading the node, do a little
// snooping to see if it even makes sense to look for a node-based // snooping to see if it even makes sense to look for a node-based
@ -587,6 +596,10 @@ Model::FinishSettingUpType()
switch (fBaseType) { switch (fBaseType) {
case kDirectoryNode: case kDirectoryNode:
entry.SetTo(&fEntryRef);
if (entry.InitCheck() == B_OK && FSIsTrashDir(&entry))
fBaseType = kTrashNode;
fMimeType = B_DIR_MIMETYPE; // should use a shared string here fMimeType = B_DIR_MIMETYPE; // should use a shared string here
if (IsNodeOpen()) { if (IsNodeOpen()) {
BNodeInfo info(fNode); BNodeInfo info(fNode);
@ -672,7 +685,8 @@ Model::ResetIconFrom()
return; return;
// mirror the logic from FinishSettingUpType // mirror the logic from FinishSettingUpType
if ((fBaseType == kDirectoryNode || fBaseType == kVolumeNode) if ((fBaseType == kDirectoryNode || fBaseType == kVolumeNode
|| fBaseType == kTrashNode)
&& !CheckNodeIconHintPrivate(fNode, dynamic_cast<TTracker *>(be_app) == NULL)) { && !CheckNodeIconHintPrivate(fNode, dynamic_cast<TTracker *>(be_app) == NULL)) {
if (WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) { if (WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) {
fIconFrom = kTrackerSupplied; fIconFrom = kTrackerSupplied;
@ -1249,6 +1263,7 @@ Model::PrintToStream(int32 level, bool deep)
break; break;
case kDirectoryNode: case kDirectoryNode:
case kTrashNode:
PRINT(("dir\n")); PRINT(("dir\n"));
break; break;

View File

@ -227,6 +227,7 @@ class Model {
kQueryTemplateNode, kQueryTemplateNode,
kVolumeNode, kVolumeNode,
kRootNode, kRootNode,
kTrashNode,
kUnknownNode kUnknownNode
}; };
@ -369,7 +370,8 @@ Model::IsDirectory() const
{ {
return fBaseType == kDirectoryNode return fBaseType == kDirectoryNode
|| fBaseType == kVolumeNode || fBaseType == kVolumeNode
|| fBaseType == kRootNode; || fBaseType == kRootNode
|| fBaseType == kTrashNode;
} }
inline bool inline bool