Model: Add accessor for Trash node property and cleanup spacing between inlines.
Rest: Use the IsTrash() accessor on Model where possible in place of the more expensive FSIsTrashDir() check. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35132 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -743,7 +743,7 @@ BContainerWindow::UpdateIfTrash(Model *model)
|
|||||||
BEntry entry(model->EntryRef());
|
BEntry entry(model->EntryRef());
|
||||||
|
|
||||||
if (entry.InitCheck() == B_OK) {
|
if (entry.InitCheck() == B_OK) {
|
||||||
fIsTrash = FSIsTrashDir(&entry);
|
fIsTrash = model->IsTrash();
|
||||||
fInTrash = FSInTrashDir(model->EntryRef());
|
fInTrash = FSInTrashDir(model->EntryRef());
|
||||||
fIsPrinters = FSIsPrintersDir(&entry);
|
fIsPrinters = FSIsPrintersDir(&entry);
|
||||||
}
|
}
|
||||||
@@ -2487,8 +2487,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref *ref, BView *)
|
|||||||
// clicked on a pose, show file or volume context menu
|
// clicked on a pose, show file or volume context menu
|
||||||
Model model(ref);
|
Model model(ref);
|
||||||
|
|
||||||
BEntry entry;
|
if (model.IsTrash()) {
|
||||||
if (entry.SetTo(ref) == B_OK && FSIsTrashDir(&entry)) {
|
|
||||||
|
|
||||||
if (fTrashContextMenu->Window() || Dragging())
|
if (fTrashContextMenu->Window() || Dragging())
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 moveMode,
|
|||||||
model->GetEntry(&entry);
|
model->GetEntry(&entry);
|
||||||
if (model->IsVolume()
|
if (model->IsVolume()
|
||||||
|| model->IsRoot()
|
|| model->IsRoot()
|
||||||
|| FSIsTrashDir(&entry)
|
|| model->IsTrash()
|
||||||
|| FSIsDeskDir(&entry))
|
|| FSIsDeskDir(&entry))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ FSClipboardPaste(Model *model, uint32 linksMode)
|
|||||||
model->GetEntry(&entry);
|
model->GetEntry(&entry);
|
||||||
|
|
||||||
// can't copy items into the trash
|
// can't copy items into the trash
|
||||||
if (copyList->CountItems() > 0 && FSIsTrashDir(&entry)) {
|
if (copyList->CountItems() > 0 && model->IsTrash()) {
|
||||||
BAlert *alert = new BAlert("", kNoCopyToTrashStr, "Cancel",
|
BAlert *alert = new BAlert("", kNoCopyToTrashStr, "Cancel",
|
||||||
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
alert->SetShortcut(0, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
|
|||||||
@@ -1207,10 +1207,9 @@ AttributeView::ReLinkTargetModel(Model *model)
|
|||||||
void
|
void
|
||||||
AttributeView::MouseDown(BPoint point)
|
AttributeView::MouseDown(BPoint point)
|
||||||
{
|
{
|
||||||
// Make sure this isn't the trash directory
|
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
fModel->GetEntry(&entry);
|
fModel->GetEntry(&entry);
|
||||||
|
|
||||||
// Assume this isn't part of a double click
|
// Assume this isn't part of a double click
|
||||||
fDoubleClick = false;
|
fDoubleClick = false;
|
||||||
|
|
||||||
@@ -1223,7 +1222,7 @@ AttributeView::MouseDown(BPoint point)
|
|||||||
fTrackingState = path_track;
|
fTrackingState = path_track;
|
||||||
} else if (fTitleRect.Contains(point)) {
|
} else if (fTitleRect.Contains(point)) {
|
||||||
// You can't change the name of the trash
|
// You can't change the name of the trash
|
||||||
if (!FSIsTrashDir(&entry)
|
if (!fModel->IsTrash()
|
||||||
&& ConfirmChangeIfWellKnownDirectory(&entry, "rename", true)
|
&& ConfirmChangeIfWellKnownDirectory(&entry, "rename", true)
|
||||||
&& fTitleEditView == 0)
|
&& fTitleEditView == 0)
|
||||||
BeginEditingTitle();
|
BeginEditingTitle();
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ class Model {
|
|||||||
bool IsExecutable() const;
|
bool IsExecutable() const;
|
||||||
bool IsSymLink() const;
|
bool IsSymLink() const;
|
||||||
bool IsRoot() const;
|
bool IsRoot() const;
|
||||||
|
bool IsTrash() const;
|
||||||
bool IsVolume() const;
|
bool IsVolume() const;
|
||||||
|
|
||||||
IconSource IconFrom() const;
|
IconSource IconFrom() const;
|
||||||
@@ -306,12 +307,14 @@ Model::MimeType() const
|
|||||||
return fMimeType.String();
|
return fMimeType.String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const entry_ref *
|
inline const entry_ref *
|
||||||
Model::EntryRef() const
|
Model::EntryRef() const
|
||||||
{
|
{
|
||||||
return &fEntryRef;
|
return &fEntryRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const node_ref *
|
inline const node_ref *
|
||||||
Model::NodeRef() const
|
Model::NodeRef() const
|
||||||
{
|
{
|
||||||
@@ -319,30 +322,35 @@ Model::NodeRef() const
|
|||||||
return (node_ref *)&fStatBuf;
|
return (node_ref *)&fStatBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline BNode *
|
inline BNode *
|
||||||
Model::Node() const
|
Model::Node() const
|
||||||
{
|
{
|
||||||
return fNode;
|
return fNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const StatStruct *
|
inline const StatStruct *
|
||||||
Model::StatBuf() const
|
Model::StatBuf() const
|
||||||
{
|
{
|
||||||
return &fStatBuf;
|
return &fStatBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline IconSource
|
inline IconSource
|
||||||
Model::IconFrom() const
|
Model::IconFrom() const
|
||||||
{
|
{
|
||||||
return (IconSource)fIconFrom;
|
return (IconSource)fIconFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
Model::SetIconFrom(IconSource from)
|
Model::SetIconFrom(IconSource from)
|
||||||
{
|
{
|
||||||
fIconFrom = from;
|
fIconFrom = from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Model *
|
inline Model *
|
||||||
Model::LinkTo() const
|
Model::LinkTo() const
|
||||||
{
|
{
|
||||||
@@ -350,6 +358,7 @@ Model::LinkTo() const
|
|||||||
return fLinkTo;
|
return fLinkTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
Model::IsFile() const
|
Model::IsFile() const
|
||||||
{
|
{
|
||||||
@@ -359,12 +368,14 @@ Model::IsFile() const
|
|||||||
|| fBaseType == kExecutableNode;
|
|| fBaseType == kExecutableNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
Model::IsVolume() const
|
Model::IsVolume() const
|
||||||
{
|
{
|
||||||
return fBaseType == kVolumeNode;
|
return fBaseType == kVolumeNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
Model::IsDirectory() const
|
Model::IsDirectory() const
|
||||||
{
|
{
|
||||||
@@ -374,18 +385,21 @@ Model::IsDirectory() const
|
|||||||
|| fBaseType == kTrashNode;
|
|| fBaseType == kTrashNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
Model::IsQuery() const
|
Model::IsQuery() const
|
||||||
{
|
{
|
||||||
return fBaseType == kQueryNode;
|
return fBaseType == kQueryNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
Model::IsQueryTemplate() const
|
Model::IsQueryTemplate() const
|
||||||
{
|
{
|
||||||
return fBaseType == kQueryTemplateNode;
|
return fBaseType == kQueryTemplateNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
Model::IsContainer() const
|
Model::IsContainer() const
|
||||||
{
|
{
|
||||||
@@ -394,24 +408,35 @@ Model::IsContainer() const
|
|||||||
return IsQuery() || IsDirectory();
|
return IsQuery() || IsDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
Model::IsRoot() const
|
Model::IsRoot() const
|
||||||
{
|
{
|
||||||
return fBaseType == kRootNode;
|
return fBaseType == kRootNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
Model::IsTrash() const
|
||||||
|
{
|
||||||
|
return fBaseType == kTrashNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
Model::IsExecutable() const
|
Model::IsExecutable() const
|
||||||
{
|
{
|
||||||
return fBaseType == kExecutableNode;
|
return fBaseType == kExecutableNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
Model::IsSymLink() const
|
Model::IsSymLink() const
|
||||||
{
|
{
|
||||||
return fBaseType == kLinkNode;
|
return fBaseType == kLinkNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
ModelNodeLazyOpener::ModelNodeLazyOpener(Model *model, bool writable, bool openLater)
|
ModelNodeLazyOpener::ModelNodeLazyOpener(Model *model, bool writable, bool openLater)
|
||||||
: fModel(model),
|
: fModel(model),
|
||||||
@@ -422,6 +447,7 @@ ModelNodeLazyOpener::ModelNodeLazyOpener(Model *model, bool writable, bool openL
|
|||||||
OpenNode(writable);
|
OpenNode(writable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
ModelNodeLazyOpener::~ModelNodeLazyOpener()
|
ModelNodeLazyOpener::~ModelNodeLazyOpener()
|
||||||
{
|
{
|
||||||
@@ -433,30 +459,35 @@ ModelNodeLazyOpener::~ModelNodeLazyOpener()
|
|||||||
fModel->OpenNode();
|
fModel->OpenNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
ModelNodeLazyOpener::IsOpen() const
|
ModelNodeLazyOpener::IsOpen() const
|
||||||
{
|
{
|
||||||
return fModel->IsNodeOpen();
|
return fModel->IsNodeOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
ModelNodeLazyOpener::IsOpenForWriting() const
|
ModelNodeLazyOpener::IsOpenForWriting() const
|
||||||
{
|
{
|
||||||
return fModel->IsNodeOpenForWriting();
|
return fModel->IsNodeOpenForWriting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
ModelNodeLazyOpener::IsOpen(bool forWriting) const
|
ModelNodeLazyOpener::IsOpen(bool forWriting) const
|
||||||
{
|
{
|
||||||
return forWriting ? fModel->IsNodeOpenForWriting() : fModel->IsNodeOpen();
|
return forWriting ? fModel->IsNodeOpenForWriting() : fModel->IsNodeOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Model *
|
inline Model *
|
||||||
ModelNodeLazyOpener::TargetModel() const
|
ModelNodeLazyOpener::TargetModel() const
|
||||||
{
|
{
|
||||||
return fModel;
|
return fModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
ModelNodeLazyOpener::OpenNode(bool writable)
|
ModelNodeLazyOpener::OpenNode(bool writable)
|
||||||
{
|
{
|
||||||
@@ -469,6 +500,7 @@ ModelNodeLazyOpener::OpenNode(bool writable)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ BNavMenu::StartBuildingItemList()
|
|||||||
fContainer = DesktopPoseView::InitDesktopDirentIterator(0, startModel.EntryRef());
|
fContainer = DesktopPoseView::InitDesktopDirentIterator(0, startModel.EntryRef());
|
||||||
AddRootItemsIfNeeded();
|
AddRootItemsIfNeeded();
|
||||||
AddTrashItem();
|
AddTrashItem();
|
||||||
} else if (FSIsTrashDir(&entry)) {
|
} else if (startModel.IsTrash()) {
|
||||||
// the trash window needs to display a union of all the
|
// the trash window needs to display a union of all the
|
||||||
// trash folders from all the mounted volumes
|
// trash folders from all the mounted volumes
|
||||||
BVolumeRoster volRoster;
|
BVolumeRoster volRoster;
|
||||||
|
|||||||
@@ -758,9 +758,7 @@ BPoseView::SavePoseLocations(BRect *frameIfDesktop)
|
|||||||
ASSERT(model->InitCheck() == B_OK);
|
ASSERT(model->InitCheck() == B_OK);
|
||||||
// special handling for "root" disks icon
|
// special handling for "root" disks icon
|
||||||
// and trash pose on desktop dir
|
// and trash pose on desktop dir
|
||||||
BEntry entry;
|
bool isTrash = model->IsTrash() && IsDesktopView();
|
||||||
model->GetEntry(&entry);
|
|
||||||
bool isTrash = FSIsTrashDir(&entry) && IsDesktopView();
|
|
||||||
if (model->IsRoot() || isTrash) {
|
if (model->IsRoot() || isTrash) {
|
||||||
BDirectory dir;
|
BDirectory dir;
|
||||||
if (FSGetDeskDir(&dir) == B_OK) {
|
if (FSGetDeskDir(&dir) == B_OK) {
|
||||||
@@ -2648,7 +2646,7 @@ BPoseView::ReadPoseInfo(Model *model, PoseInfo *poseInfo)
|
|||||||
ReadAttrResult result = kReadAttrFailed;
|
ReadAttrResult result = kReadAttrFailed;
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
model->GetEntry(&entry);
|
model->GetEntry(&entry);
|
||||||
bool isTrash = FSIsTrashDir(&entry) && IsDesktopView();
|
bool isTrash = model->IsTrash() && IsDesktopView();
|
||||||
|
|
||||||
// special case the "root" disks icon
|
// special case the "root" disks icon
|
||||||
// as well as the trash on desktop
|
// as well as the trash on desktop
|
||||||
@@ -3813,8 +3811,7 @@ BPoseView::FindDragNDropAction(const BMessage *dragMessage, bool &canCopy,
|
|||||||
bool
|
bool
|
||||||
BPoseView::CanTrashForeignDrag(const Model *targetModel)
|
BPoseView::CanTrashForeignDrag(const Model *targetModel)
|
||||||
{
|
{
|
||||||
BEntry entry(targetModel->EntryRef());
|
return targetModel->IsTrash();
|
||||||
return FSIsTrashDir(&entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4635,7 +4632,7 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow,
|
|||||||
|
|
||||||
|
|
||||||
BEntry *destEntry = new BEntry(destFolder->EntryRef());
|
BEntry *destEntry = new BEntry(destFolder->EntryRef());
|
||||||
bool destIsTrash = FSIsTrashDir(destEntry);
|
bool destIsTrash = destFolder->IsTrash();
|
||||||
|
|
||||||
// perform asynchronous copy/move
|
// perform asynchronous copy/move
|
||||||
forceCopy = forceCopy || (modifiers() & B_OPTION_KEY);
|
forceCopy = forceCopy || (modifiers() & B_OPTION_KEY);
|
||||||
@@ -5385,8 +5382,7 @@ BPoseView::DuplicateSelection(BPoint *dropStart, BPoint *dropEnd)
|
|||||||
Model *model = pose->TargetModel();
|
Model *model = pose->TargetModel();
|
||||||
|
|
||||||
// can't duplicate a volume or the trash
|
// can't duplicate a volume or the trash
|
||||||
BEntry entry(model->EntryRef());
|
if (model->IsTrash() || model->IsVolume()) {
|
||||||
if (FSIsTrashDir(&entry) || model->IsVolume()) {
|
|
||||||
fSelectionList->RemoveItemAt(index);
|
fSelectionList->RemoveItemAt(index);
|
||||||
index--;
|
index--;
|
||||||
selectionSize--;
|
selectionSize--;
|
||||||
@@ -6017,8 +6013,7 @@ BPoseView::KeyDown(const char *bytes, int32 count)
|
|||||||
case B_DELETE:
|
case B_DELETE:
|
||||||
{
|
{
|
||||||
// Make sure user can't trash something already in the trash.
|
// Make sure user can't trash something already in the trash.
|
||||||
BEntry entry(TargetModel()->EntryRef());
|
if (TargetModel()->IsTrash()) {
|
||||||
if (FSIsTrashDir(&entry)) {
|
|
||||||
// Delete without asking from the trash
|
// Delete without asking from the trash
|
||||||
DeleteSelection(true, false);
|
DeleteSelection(true, false);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -318,15 +318,16 @@ BTextWidget::StartEdit(BRect bounds, BPoseView *view, BPose *pose)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// don't allow editing of the trash directory name
|
// don't allow editing of the trash directory name
|
||||||
BEntry entry(pose->TargetModel()->EntryRef());
|
if (pose->TargetModel()->IsTrash())
|
||||||
if (entry.InitCheck() == B_OK && FSIsTrashDir(&entry))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// don't allow editing of the "Disks" icon name
|
// don't allow editing of the "Disks" icon name
|
||||||
if (pose->TargetModel()->IsRoot())
|
if (pose->TargetModel()->IsRoot())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ConfirmChangeIfWellKnownDirectory(&entry, "rename"))
|
BEntry entry(pose->TargetModel()->EntryRef());
|
||||||
|
if (entry.InitCheck() == B_OK
|
||||||
|
&& !ConfirmChangeIfWellKnownDirectory(&entry, "rename"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// get bounds with full text length
|
// get bounds with full text length
|
||||||
|
|||||||
Reference in New Issue
Block a user