[haiku-commits] haiku: hrev54200 - src/kits/tracker

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 14 May 2020 21:52:23 -0400 (EDT)

hrev54200 adds 1 changeset to branch 'master'
old head: 64381a7b0f04be7f46a08d00a00ed453f94c9291
new head: bf207efc2b460e92e268e7cda6cf11bf3243f583
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=bf207efc2b46+%5E64381a7b0f04

----------------------------------------------------------------------------

bf207efc2b46: Tracker: ContainerWindow style fixes only
  
  Change-Id: Ica388cf727cb9cffe03c948a64344be7f462e25a
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2330
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev54200
Commit:      bf207efc2b460e92e268e7cda6cf11bf3243f583
URL:         https://git.haiku-os.org/haiku/commit/?id=bf207efc2b46
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Sun Mar  8 05:21:46 2020 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Fri May 15 01:52:12 2020 UTC

----------------------------------------------------------------------------

1 file changed, 48 insertions(+), 51 deletions(-)
src/kits/tracker/ContainerWindow.cpp | 99 ++++++++++++++++----------------

----------------------------------------------------------------------------

diff --git a/src/kits/tracker/ContainerWindow.cpp 
b/src/kits/tracker/ContainerWindow.cpp
index d4a4b7cb5c..d32c314969 100644
--- a/src/kits/tracker/ContainerWindow.cpp
+++ b/src/kits/tracker/ContainerWindow.cpp
@@ -867,24 +867,24 @@ void
 BContainerWindow::RepopulateMenus()
 {
        // Avoid these menus to be destroyed:
-       if (fMoveToItem && fMoveToItem->Menu())
+       if (fMoveToItem != NULL && fMoveToItem->Menu() != NULL)
                fMoveToItem->Menu()->RemoveItem(fMoveToItem);
 
-       if (fCopyToItem && fCopyToItem->Menu())
+       if (fCopyToItem != NULL && fCopyToItem->Menu() != NULL)
                fCopyToItem->Menu()->RemoveItem(fCopyToItem);
 
-       if (fCreateLinkItem && fCreateLinkItem->Menu())
+       if (fCreateLinkItem != NULL && fCreateLinkItem->Menu() != NULL)
                fCreateLinkItem->Menu()->RemoveItem(fCreateLinkItem);
 
-       if (fOpenWithItem && fOpenWithItem->Menu()) {
+       if (fOpenWithItem != NULL && fOpenWithItem->Menu() != NULL) {
                fOpenWithItem->Menu()->RemoveItem(fOpenWithItem);
                delete fOpenWithItem;
                fOpenWithItem = NULL;
        }
 
-       if (fNavigationItem) {
+       if (fNavigationItem != NULL) {
                BMenu* menu = fNavigationItem->Menu();
-               if (menu) {
+               if (menu != NULL) {
                        menu->RemoveItem(fNavigationItem);
                        BMenuItem* item = menu->RemoveItem((int32)0);
                        ASSERT(item != fNavigationItem);
@@ -1785,7 +1785,7 @@ BContainerWindow::MessageReceived(BMessage* message)
                                                }
                                                // Deskbar doesn't have a menu 
bar, so check if
                                                // there is fMenuBar
-                                               if (fMenuBar && fFileMenu) {
+                                               if (fMenuBar != NULL && 
fFileMenu != NULL) {
                                                        item = 
fFileMenu->FindItem(kMoveToTrash);
                                                        if (item != NULL) {
                                                                
item->SetLabel(dontMoveToTrash
@@ -1827,7 +1827,7 @@ BContainerWindow::SetCutItem(BMenu* menu)
        item->SetEnabled(PoseView()->SelectionList()->CountItems() > 0
                || PoseView() != CurrentFocus());
 
-       if (modifiers() & B_SHIFT_KEY) {
+       if ((modifiers() & B_SHIFT_KEY) != 0) {
                item->SetLabel(B_TRANSLATE("Cut more"));
                item->SetShortcut('X', B_COMMAND_KEY | B_SHIFT_KEY);
                item->SetMessage(new BMessage(kCutMoreSelectionToClipboard));
@@ -1851,7 +1851,7 @@ BContainerWindow::SetCopyItem(BMenu* menu)
        item->SetEnabled(PoseView()->SelectionList()->CountItems() > 0
                || PoseView() != CurrentFocus());
 
-       if (modifiers() & B_SHIFT_KEY) {
+       if ((modifiers() & B_SHIFT_KEY) != 0) {
                item->SetLabel(B_TRANSLATE("Copy more"));
                item->SetShortcut('C', B_COMMAND_KEY | B_SHIFT_KEY);
                item->SetMessage(new BMessage(kCopyMoreSelectionToClipboard));
@@ -1874,7 +1874,7 @@ BContainerWindow::SetPasteItem(BMenu* menu)
 
        item->SetEnabled(FSClipboardHasRefs() || PoseView() != CurrentFocus());
 
-       if (modifiers() & B_SHIFT_KEY) {
+       if ((modifiers() & B_SHIFT_KEY) != 0) {
                item->SetLabel(B_TRANSLATE("Paste links"));
                item->SetShortcut('V', B_COMMAND_KEY | B_SHIFT_KEY);
                item->SetMessage(new BMessage(kPasteLinksFromClipboard));
@@ -1900,7 +1900,7 @@ BContainerWindow::SetArrangeMenu(BMenu* menu)
 
        BMenu* arrangeMenu;
 
-       if (modifiers() & B_SHIFT_KEY) {
+       if ((modifiers() & B_SHIFT_KEY) != 0) {
                item->SetLabel(B_TRANSLATE("Clean up all"));
                item->SetShortcut('K', B_COMMAND_KEY | B_SHIFT_KEY);
                item->SetMessage(new BMessage(kCleanupAll));
@@ -1925,7 +1925,7 @@ BContainerWindow::SetCloseItem(BMenu* menu)
                return;
        }
 
-       if (modifiers() & B_SHIFT_KEY) {
+       if ((modifiers() & B_SHIFT_KEY) != 0) {
                item->SetLabel(B_TRANSLATE("Close all"));
                item->SetShortcut('W', B_COMMAND_KEY | B_SHIFT_KEY);
                item->SetTarget(be_app);
@@ -2505,9 +2505,10 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu* 
navMenu, uint32 what,
 
        // count persistent writable volumes
        volumeRoster.Rewind();
-       while (volumeRoster.GetNextVolume(&volume) == B_OK)
+       while (volumeRoster.GetNextVolume(&volume) == B_OK) {
                if (!volume.IsReadOnly() && volume.IsPersistent())
                        volumeCount++;
+       }
 
        // add the current folder
        if (entry.SetTo(ref) == B_OK
@@ -2542,17 +2543,17 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu* 
navMenu, uint32 what,
 
        // add Desktop
        FSGetBootDeskDir(&directory);
-       if (directory.InitCheck() == B_OK
-               && directory.GetEntry(&entry) == B_OK
-               && model.SetTo(&entry) == B_OK)
+       if (directory.InitCheck() == B_OK && directory.GetEntry(&entry) == B_OK
+               && model.SetTo(&entry) == B_OK) {
                navMenu->AddNavDir(&model, what, this, true);
                        // ask NavMenu to populate submenu for us
+       }
 
        // add the home dir
        if (find_directory(B_USER_DIRECTORY, &path) == B_OK
-               && entry.SetTo(path.Path()) == B_OK
-               && model.SetTo(&entry) == B_OK)
+               && entry.SetTo(path.Path()) == B_OK && model.SetTo(&entry) == 
B_OK) {
                navMenu->AddNavDir(&model, what, this, true);
+       }
 
        navMenu->AddSeparatorItem();
 
@@ -2593,38 +2594,32 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu* 
navMenu, uint32 what,
 void
 BContainerWindow::SetupMoveCopyMenus(const entry_ref* item_ref, BMenu* parent)
 {
-       if (IsTrash() || InTrash() || IsPrintersDir() || !fMoveToItem
-               || !fCopyToItem || !fCreateLinkItem || TargetModel()->IsRoot()) 
{
+       if (IsTrash() || InTrash() || IsPrintersDir() || fMoveToItem == NULL
+               || fCopyToItem == NULL || fCreateLinkItem == NULL
+               || TargetModel()->IsRoot()) {
                return;
        }
 
-       // Grab the modifiers state since we use it twice
-       uint32 modifierKeys = modifiers();
-
        // re-parent items to this menu since they're shared
-       int32 index;
        BMenuItem* trash = parent->FindItem(kMoveToTrash);
-       if (trash)
-               index = parent->IndexOf(trash) + 2;
-       else
-               index = 0;
+       int32 index = trash != NULL ? parent->IndexOf(trash) + 2 : 0;
 
        if (fMoveToItem->Menu() != parent) {
-               if (fMoveToItem->Menu())
+               if (fMoveToItem->Menu() != NULL)
                        fMoveToItem->Menu()->RemoveItem(fMoveToItem);
 
                parent->AddItem(fMoveToItem, index++);
        }
 
        if (fCopyToItem->Menu() != parent) {
-               if (fCopyToItem->Menu())
+               if (fCopyToItem->Menu() != NULL)
                        fCopyToItem->Menu()->RemoveItem(fCopyToItem);
 
                parent->AddItem(fCopyToItem, index++);
        }
 
        if (fCreateLinkItem->Menu() != parent) {
-               if (fCreateLinkItem->Menu())
+               if (fCreateLinkItem->Menu() != NULL)
                        fCreateLinkItem->Menu()->RemoveItem(fCreateLinkItem);
 
                parent->AddItem(fCreateLinkItem, index);
@@ -2632,7 +2627,7 @@ BContainerWindow::SetupMoveCopyMenus(const entry_ref* 
item_ref, BMenu* parent)
 
        // Set the "Create Link" item label here so it
        // appears correctly when menus are disabled, too.
-       if (modifierKeys & B_SHIFT_KEY)
+       if ((modifiers() & B_SHIFT_KEY) != 0)
                fCreateLinkItem->SetLabel(B_TRANSLATE("Create relative link"));
        else
                fCreateLinkItem->SetLabel(B_TRANSLATE("Create link"));
@@ -2665,7 +2660,7 @@ BContainerWindow::SetupMoveCopyMenus(const entry_ref* 
item_ref, BMenu* parent)
 
        // Set "Create Link" menu item message and
        // add all mounted volumes (except the one this item lives on)
-       if (modifierKeys & B_SHIFT_KEY) {
+       if ((modifiers() & B_SHIFT_KEY) != 0) {
                fCreateLinkItem->SetMessage(new BMessage(kCreateRelativeLink));
                PopulateMoveCopyNavMenu(dynamic_cast<BNavMenu*>
                                (fCreateLinkItem->Submenu()),
@@ -2673,8 +2668,8 @@ BContainerWindow::SetupMoveCopyMenus(const entry_ref* 
item_ref, BMenu* parent)
        } else {
                fCreateLinkItem->SetMessage(new BMessage(kCreateLink));
                PopulateMoveCopyNavMenu(dynamic_cast<BNavMenu*>
-                       (fCreateLinkItem->Submenu()),
-               kCreateLink, item_ref, false);
+                               (fCreateLinkItem->Submenu()),
+                       kCreateLink, item_ref, false);
        }
 
        fMoveToItem->SetEnabled(true);
@@ -2684,7 +2679,7 @@ BContainerWindow::SetupMoveCopyMenus(const entry_ref* 
item_ref, BMenu* parent)
        // Set the "Identify" item label
        BMenuItem* identifyItem = parent->FindItem(kIdentifyEntry);
        if (identifyItem != NULL) {
-               if (modifierKeys & B_SHIFT_KEY) {
+               if ((modifiers() & B_SHIFT_KEY) != 0) {
                        identifyItem->SetLabel(B_TRANSLATE("Force identify"));
                        identifyItem->Message()->ReplaceBool("force", true);
                } else {
@@ -2708,16 +2703,17 @@ BContainerWindow::ShowDropContextMenu(BPoint loc)
        BMenuItem* item = fDropContextMenu->FindItem(kCreateLink);
        if (item == NULL)
                item = fDropContextMenu->FindItem(kCreateRelativeLink);
-       if (item && (modifiers() & B_SHIFT_KEY)) {
+
+       if (item != NULL && (modifiers() & B_SHIFT_KEY) != 0) {
                item->SetLabel(B_TRANSLATE("Create relative link here"));
                item->SetMessage(new BMessage(kCreateRelativeLink));
-       } else if (item) {
+       } else if (item != NULL) {
                item->SetLabel(B_TRANSLATE("Create link here"));
                item->SetMessage(new BMessage(kCreateLink));
        }
 
        item = fDropContextMenu->Go(global, true, true);
-       if (item)
+       if (item != NULL)
                return item->Command();
 
        return 0;
@@ -2751,7 +2747,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const 
entry_ref* ref, BView*)
                        fTrashContextMenu->Go(global, true, true, true);
                } else {
                        bool showAsVolume = false;
-                       bool filePanel = PoseView()->IsFilePanel();
+                       bool isFilePanel = PoseView()->IsFilePanel();
 
                        if (Dragging()) {
                                fContextMenu = NULL;
@@ -2843,7 +2839,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const 
entry_ref* ref, BView*)
                                }
 
                                SetupNavigationMenu(ref, fContextMenu);
-                               if (!showAsVolume && !filePanel) {
+                               if (!showAsVolume && !isFilePanel) {
                                        SetupMoveCopyMenus(ref, fContextMenu);
                                        SetupOpenWithMenu(fContextMenu);
                                }
@@ -2916,9 +2912,11 @@ BContainerWindow::AddFileContextMenus(BMenu* menu)
 #endif
 
        menu->AddSeparatorItem();
+
        BMessage* message = new BMessage(kIdentifyEntry);
        message->AddBool("force", false);
        menu->AddItem(new BMenuItem(B_TRANSLATE("Identify"), message));
+
        BMenu* addOnMenuItem = new BMenu(B_TRANSLATE("Add-ons"));
        addOnMenuItem->SetFont(be_plain_font);
        menu->AddItem(addOnMenuItem);
@@ -3531,14 +3529,14 @@ BContainerWindow::MarkAttributeMenu()
 void
 BContainerWindow::MarkAttributeMenu(BMenu* menu)
 {
-       if (!menu)
+       if (menu == NULL)
                return;
 
        int32 count = menu->CountItems();
        for (int32 index = 0; index < count; index++) {
                BMenuItem* item = menu->ItemAt(index);
                int32 attrHash;
-               if (item->Message()) {
+               if (item->Message() != NULL) {
                        if (item->Message()->FindInt32("attr_hash", &attrHash) 
== B_OK)
                                
item->SetMarked(PoseView()->ColumnFor((uint32)attrHash) != 0);
                        else
@@ -3546,11 +3544,11 @@ BContainerWindow::MarkAttributeMenu(BMenu* menu)
                }
 
                BMenu* submenu = item->Submenu();
-               if (submenu) {
+               if (submenu != NULL) {
                        int32 count2 = submenu->CountItems();
                        for (int32 subindex = 0; subindex < count2; subindex++) 
{
                                item = submenu->ItemAt(subindex);
-                               if (item->Message()) {
+                               if (item->Message() != NULL) {
                                        if 
(item->Message()->FindInt32("attr_hash", &attrHash)
                                                == B_OK) {
                                                
item->SetMarked(PoseView()->ColumnFor((uint32)attrHash)
@@ -3567,13 +3565,13 @@ BContainerWindow::MarkAttributeMenu(BMenu* menu)
 void
 BContainerWindow::MarkArrangeByMenu(BMenu* menu)
 {
-       if (!menu)
+       if (menu == NULL)
                return;
 
        int32 count = menu->CountItems();
        for (int32 index = 0; index < count; index++) {
                BMenuItem* item = menu->ItemAt(index);
-               if (item->Message()) {
+               if (item->Message() != NULL) {
                        uint32 attrHash;
                        if (item->Message()->FindInt32("attr_hash",
                                        (int32*)&attrHash) == B_OK) {
@@ -3690,7 +3688,7 @@ BContainerWindow::AddMimeMenu(const BMimeType& mimeType, 
bool isSuperType,
 void
 BContainerWindow::AddMimeTypesToMenu(BMenu* menu)
 {
-       if (!menu)
+       if (menu == NULL)
                return;
 
        // Remove old mime type menus
@@ -4349,11 +4347,10 @@ BContainerWindow::PopulateArrangeByMenu(BMenu* menu)
 
        item->SetTarget(PoseView());
        menu->AddItem(item);
-       menu->AddSeparatorItem();
 
+       menu->AddSeparatorItem();
 
-       item = new BMenuItem(B_TRANSLATE("Clean up"), new BMessage(kCleanup),
-               'K');
+       item = new BMenuItem(B_TRANSLATE("Clean up"), new BMessage(kCleanup), 
'K');
        item->SetTarget(PoseView());
        menu->AddItem(item);
 }


Other related posts:

  • » [haiku-commits] haiku: hrev54200 - src/kits/tracker - waddlesplash