[haiku-commits] r35132 - haiku/trunk/src/kits/tracker

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 17 Jan 2010 20:58:46 +0100 (CET)

Author: anevilyak
Date: 2010-01-17 20:58:46 +0100 (Sun, 17 Jan 2010)
New Revision: 35132
Changeset: http://dev.haiku-os.org/changeset/35132/haiku

Modified:
   haiku/trunk/src/kits/tracker/ContainerWindow.cpp
   haiku/trunk/src/kits/tracker/FSClipboard.cpp
   haiku/trunk/src/kits/tracker/InfoWindow.cpp
   haiku/trunk/src/kits/tracker/Model.h
   haiku/trunk/src/kits/tracker/NavMenu.cpp
   haiku/trunk/src/kits/tracker/PoseView.cpp
   haiku/trunk/src/kits/tracker/TextWidget.cpp
Log:
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.



Modified: haiku/trunk/src/kits/tracker/ContainerWindow.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/ContainerWindow.cpp    2010-01-17 19:47:22 UTC 
(rev 35131)
+++ haiku/trunk/src/kits/tracker/ContainerWindow.cpp    2010-01-17 19:58:46 UTC 
(rev 35132)
@@ -743,7 +743,7 @@
        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 @@
                // 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;

Modified: haiku/trunk/src/kits/tracker/FSClipboard.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/FSClipboard.cpp        2010-01-17 19:47:22 UTC 
(rev 35131)
+++ haiku/trunk/src/kits/tracker/FSClipboard.cpp        2010-01-17 19:58:46 UTC 
(rev 35132)
@@ -228,7 +228,7 @@
                        model->GetEntry(&entry);
                        if (model->IsVolume()
                                || model->IsRoot()
-                               || FSIsTrashDir(&entry)
+                               || model->IsTrash()
                                || FSIsDeskDir(&entry))
                                continue;
 
@@ -479,7 +479,7 @@
        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);

Modified: haiku/trunk/src/kits/tracker/InfoWindow.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/InfoWindow.cpp 2010-01-17 19:47:22 UTC (rev 
35131)
+++ haiku/trunk/src/kits/tracker/InfoWindow.cpp 2010-01-17 19:58:46 UTC (rev 
35132)
@@ -1207,10 +1207,9 @@
 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 @@
                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();

Modified: haiku/trunk/src/kits/tracker/Model.h
===================================================================
--- haiku/trunk/src/kits/tracker/Model.h        2010-01-17 19:47:22 UTC (rev 
35131)
+++ haiku/trunk/src/kits/tracker/Model.h        2010-01-17 19:58:46 UTC (rev 
35132)
@@ -135,6 +135,7 @@
                bool IsExecutable() const;
                bool IsSymLink() const;
                bool IsRoot() const;
+               bool IsTrash() const;
                bool IsVolume() const;
 
                IconSource IconFrom() const;
@@ -306,12 +307,14 @@
        return fMimeType.String();
 }
 
+
 inline const entry_ref *
 Model::EntryRef() const
 {
        return &fEntryRef;
 }
 
+
 inline const node_ref *
 Model::NodeRef() const
 {
@@ -319,30 +322,35 @@
        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 @@
        return fLinkTo;
 }
 
+
 inline bool
 Model::IsFile() const
 {
@@ -359,12 +368,14 @@
                || fBaseType == kExecutableNode;
 }
 
+
 inline bool
 Model::IsVolume() const
 {
        return fBaseType == kVolumeNode;
 }
 
+
 inline bool
 Model::IsDirectory() const
 {
@@ -374,18 +385,21 @@
                || 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 @@
        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 @@
                OpenNode(writable);
 }
 
+
 inline
 ModelNodeLazyOpener::~ModelNodeLazyOpener()
 {
@@ -433,30 +459,35 @@
                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 @@
        return B_OK;
 }
 
+
 } // namespace BPrivate
 
 

Modified: haiku/trunk/src/kits/tracker/NavMenu.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/NavMenu.cpp    2010-01-17 19:47:22 UTC (rev 
35131)
+++ haiku/trunk/src/kits/tracker/NavMenu.cpp    2010-01-17 19:58:46 UTC (rev 
35132)
@@ -413,7 +413,7 @@
                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;

Modified: haiku/trunk/src/kits/tracker/PoseView.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/PoseView.cpp   2010-01-17 19:47:22 UTC (rev 
35131)
+++ haiku/trunk/src/kits/tracker/PoseView.cpp   2010-01-17 19:58:46 UTC (rev 
35132)
@@ -758,9 +758,7 @@
                        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 @@
        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 @@
 bool
 BPoseView::CanTrashForeignDrag(const Model *targetModel)
 {
-       BEntry entry(targetModel->EntryRef());
-       return FSIsTrashDir(&entry);
+       return targetModel->IsTrash();
 }
 
 
@@ -4635,7 +4632,7 @@
 
 
        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 @@
                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 @@
                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 {

Modified: haiku/trunk/src/kits/tracker/TextWidget.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/TextWidget.cpp 2010-01-17 19:47:22 UTC (rev 
35131)
+++ haiku/trunk/src/kits/tracker/TextWidget.cpp 2010-01-17 19:58:46 UTC (rev 
35132)
@@ -318,15 +318,16 @@
                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


Other related posts:

  • » [haiku-commits] r35132 - haiku/trunk/src/kits/tracker - anevilyak