Tracker: Minor simplifications, remove overload methods.

Change-Id: I4f1c270039d8d863bbd109250bd204672cc4b179
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9894
Reviewed-by: John Scipione <[email protected]>
This commit is contained in:
John Scipione
2026-04-05 17:29:05 +00:00
parent 29323c568f
commit 2140f38b02
3 changed files with 19 additions and 56 deletions
+14 -48
View File
@@ -2004,13 +2004,6 @@ BContainerWindow::SetupNavigationMenu(BMenu* parent, const entry_ref* ref)
} }
void
BContainerWindow::SetupEditQueryItem(BMenu* parent)
{
SetupEditQueryItem(parent, TargetModel()->EntryRef());
}
void void
BContainerWindow::SetupEditQueryItem(BMenu* parent, const entry_ref* ref) BContainerWindow::SetupEditQueryItem(BMenu* parent, const entry_ref* ref)
{ {
@@ -2039,13 +2032,6 @@ BContainerWindow::SetupEditQueryItem(BMenu* parent, const entry_ref* ref)
} }
void
BContainerWindow::SetupOpenWithMenu(BMenu* parent)
{
SetupOpenWithMenu(parent, TargetModel()->EntryRef());
}
void void
BContainerWindow::SetupOpenWithMenu(BMenu* parent, const entry_ref* ref) BContainerWindow::SetupOpenWithMenu(BMenu* parent, const entry_ref* ref)
{ {
@@ -2150,13 +2136,6 @@ BContainerWindow::SetupNewTemplatesMenu(BMenu* parent, MenuContext context)
} }
void
BContainerWindow::SetupMountMenu(BMenu* parent, MenuContext context)
{
SetupMountMenu(parent, context, TargetModel()->EntryRef());
}
void void
BContainerWindow::SetupMountMenu(BMenu* parent, MenuContext context, const entry_ref* ref) BContainerWindow::SetupMountMenu(BMenu* parent, MenuContext context, const entry_ref* ref)
{ {
@@ -2169,9 +2148,10 @@ BContainerWindow::SetupMountMenu(BMenu* parent, MenuContext context, const entry
if (ref == NULL) if (ref == NULL)
ref = TargetModel()->EntryRef(); ref = TargetModel()->EntryRef();
Model model(ref); ASSERT(ref != NULL);
// bail out if not Desktop, root or volume // bail out if not Desktop, root or volume
Model model(ref);
if (!(model.IsDesktop() || model.IsRoot() || model.IsVolume())) if (!(model.IsDesktop() || model.IsRoot() || model.IsVolume()))
return; return;
@@ -2902,12 +2882,9 @@ BContainerWindow::UpdateFileMenuOrPoseContextMenu(BMenu* menu, MenuContext conte
ref = TargetModel()->EntryRef(); ref = TargetModel()->EntryRef();
// "Open with..." menu inserted after Open // "Open with..." menu inserted after Open
if (context == kPosePopUpContext) { if (ShouldHaveOpenWithMenu(ref)
if (ShouldHaveOpenWithMenu(ref)) && (context == kPosePopUpContext || context == kFileMenuContext)) {
SetupOpenWithMenu(menu, ref); SetupOpenWithMenu(menu, ref);
} else if (context == kFileMenuContext) {
if (ShouldHaveOpenWithMenu())
SetupOpenWithMenu(menu);
} }
// "Mount >" menu and "Unmount" are inserted here // "Mount >" menu and "Unmount" are inserted here
@@ -2915,19 +2892,13 @@ BContainerWindow::UpdateFileMenuOrPoseContextMenu(BMenu* menu, MenuContext conte
Model model(ref); Model model(ref);
if (model.IsRoot() || model.IsVolume()) if (model.IsRoot() || model.IsVolume())
SetupMountMenu(menu, kPosePopUpContext, ref); SetupMountMenu(menu, kPosePopUpContext, ref);
} else if (context == kFileMenuContext) { } else if (context == kFileMenuContext && TargetModel()->IsRoot()) {
if (TargetModel()->IsRoot()) SetupMountMenu(menu, kFileMenuContext, ref);
SetupMountMenu(menu, kFileMenuContext);
} }
// "Edit query" inserted before "Open with..." // "Edit query" inserted before "Open with..."
if (context == kPosePopUpContext) { if (ShouldHaveEditQueryItem(ref))
if (ShouldHaveEditQueryItem(ref)) SetupEditQueryItem(menu, ref);
SetupEditQueryItem(menu, ref);
} else {
if (ShouldHaveEditQueryItem())
SetupEditQueryItem(menu);
}
// "Move To", "Copy To", "Create Link" menus inserted after "Move to Trash" // "Move To", "Copy To", "Create Link" menus inserted after "Move to Trash"
if (ShouldHaveMoveCopyMenus(ref)) if (ShouldHaveMoveCopyMenus(ref))
@@ -2954,7 +2925,7 @@ BContainerWindow::UpdateWindowContextMenu(BMenu* menu)
// "Mount >" menu is inserted at the bottom // "Mount >" menu is inserted at the bottom
if (PoseView()->IsDesktopView() || TargetModel()->IsRoot()) if (PoseView()->IsDesktopView() || TargetModel()->IsRoot())
SetupMountMenu(menu, kWindowPopUpContext); SetupMountMenu(menu, kWindowPopUpContext, TargetModel()->EntryRef());
if (ShouldHaveAddOnMenus()) if (ShouldHaveAddOnMenus())
BuildAddOnsMenu(menu); BuildAddOnsMenu(menu);
@@ -3113,21 +3084,16 @@ BContainerWindow::ShouldHaveMoveCopyMenus(const entry_ref* ref)
ref = TargetModel()->EntryRef(); ref = TargetModel()->EntryRef();
Model model(ref); Model model(ref);
if (model.IsPrintersDir()) return !(model.IsPrintersDir() || model.IsRoot() || model.IsTrash() || model.InTrash());
return false;
return !(model.IsTrash() || model.InTrash());
} }
bool bool
BContainerWindow::ShouldHaveNewFolderItem() BContainerWindow::ShouldHaveNewFolderItem()
{ {
if (TargetModel()->IsPrintersDir()) return !(TargetModel()->IsQuery() || TargetModel()->IsPrintersDir()
return false; || TargetModel()->IsRoot() || TargetModel()->IsTrash() || TargetModel()->InTrash()
|| TargetModel()->IsVirtualDirectory());
return !(TargetModel()->IsQuery() || TargetModel()->IsRoot() || TargetModel()->IsTrash()
|| TargetModel()->InTrash() || TargetModel()->IsVirtualDirectory());
} }
-3
View File
@@ -253,13 +253,10 @@ protected:
virtual void PopulateMoveCopyNavMenu(BNavMenu*, uint32, virtual void PopulateMoveCopyNavMenu(BNavMenu*, uint32,
const entry_ref*, bool); const entry_ref*, bool);
virtual void SetupOpenWithMenu(BMenu*);
virtual void SetupOpenWithMenu(BMenu*, const entry_ref* ref); virtual void SetupOpenWithMenu(BMenu*, const entry_ref* ref);
virtual void SetupNewTemplatesMenu(BMenu*, MenuContext context); virtual void SetupNewTemplatesMenu(BMenu*, MenuContext context);
virtual void SetupEditQueryItem(BMenu*);
virtual void SetupEditQueryItem(BMenu*, const entry_ref* ref); virtual void SetupEditQueryItem(BMenu*, const entry_ref* ref);
virtual void SetupDiskMenu(BMenu*); virtual void SetupDiskMenu(BMenu*);
virtual void SetupMountMenu(BMenu*, MenuContext context);
virtual void SetupMountMenu(BMenu*, MenuContext context, const entry_ref* ref); virtual void SetupMountMenu(BMenu*, MenuContext context, const entry_ref* ref);
BMenuItem* DetachMountMenu(); BMenuItem* DetachMountMenu();
+5 -5
View File
@@ -176,7 +176,7 @@ OpenWithContainerWindow::EntryList() const
void void
OpenWithContainerWindow::OpenWithSelection() OpenWithContainerWindow::OpenWithSelection()
{ {
int32 count = PoseView()->SelectionList()->CountItems(); int32 count = PoseView()->CountSelected();
ASSERT(count == 1); ASSERT(count == 1);
if (count == 0) if (count == 0)
return; return;
@@ -259,7 +259,7 @@ SetDefaultAppForOneType(const BString& element, void* castToEntryRef)
void void
OpenWithContainerWindow::MakeDefaultAndOpen() OpenWithContainerWindow::MakeDefaultAndOpen()
{ {
int32 count = PoseView()->SelectionList()->CountItems(); int32 count = PoseView()->CountSelected();
ASSERT(count == 1); ASSERT(count == 1);
if (count == 0) if (count == 0)
return; return;
@@ -705,7 +705,7 @@ OpenWithPoseView::OpenSelection(BPose* pose, int32*)
{ {
OpenWithContainerWindow* window = ContainerWindow(); OpenWithContainerWindow* window = ContainerWindow();
int32 count = SelectionList()->CountItems(); int32 count = CountSelected();
if (count == 0) if (count == 0)
return; return;
@@ -774,7 +774,7 @@ OpenWithPoseView::Pulse()
OpenWithContainerWindow* window = ContainerWindow(); OpenWithContainerWindow* window = ContainerWindow();
if (!SelectionList()->CountItems()) { if (!CountSelected()) {
window->SetCanSetAppAsDefault(false); window->SetCanSetAppAsDefault(false);
window->SetCanOpen(false); window->SetCanOpen(false);
_inherited::Pulse(); _inherited::Pulse();
@@ -799,7 +799,7 @@ OpenWithPoseView::Pulse()
return; return;
} }
ASSERT(SelectionList()->CountItems() == 1); ASSERT(CountSelected() == 1);
// enable the Open and make default if selected application different // enable the Open and make default if selected application different
// from preferred app ref // from preferred app ref