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