diff --git a/headers/private/tracker/NavMenu.h b/headers/private/tracker/NavMenu.h index eaaf8c95c7..1d2d209d0c 100644 --- a/headers/private/tracker/NavMenu.h +++ b/headers/private/tracker/NavMenu.h @@ -75,9 +75,9 @@ struct TrackingHookData { class BNavMenu : public BSlowMenu { public: BNavMenu(const char* title, uint32 message, const BHandler*, - BWindow* parentWindow = NULL, const BObjectList* list = NULL); + BWindow* parentWindow = NULL, const BStringList* list = NULL); BNavMenu(const char* title, uint32 message, const BMessenger&, - BWindow* parentWindow = NULL, const BObjectList* list = NULL); + BWindow* parentWindow = NULL, const BStringList* list = NULL); // parentWindow, if specified, will be closed if nav menu item invoked // with option held down @@ -95,8 +95,8 @@ public: void SetTarget(const BMessenger&); BMessenger Target(); - void SetTypesList(const BObjectList* list); - const BObjectList* TypesList() const; + void SetTypesList(const BStringList* list); + const BStringList* TypesList() const; void AddNavDir(const Model* model, uint32 what, BHandler* target, bool populateSubmenu); @@ -113,7 +113,7 @@ public: static ModelMenuItem* NewModelItem(Model*, const BMessage*, const BMessenger&, bool suppressFolderHierarchy = false, - BContainerWindow* = NULL, const BObjectList* typeslist = NULL, + BContainerWindow* = NULL, const BStringList* typeslist = NULL, TrackingHookData* hook = NULL); TrackingHookData* InitTrackingHook(bool (*hookfunction)(BMenu*, void*), @@ -143,7 +143,7 @@ protected: EntryListBase* fContainer; bool fIteratingDesktop; - BObjectList* fTypesList; + BStringList* fTypesList; TrackingHookData fTrackingHook; }; @@ -180,11 +180,11 @@ private: _IMPEXP_TRACKER bool SpringLoadedFolderCompareMessages(const BMessage *incoming, const BMessage *dragmessage); _IMPEXP_TRACKER void SpringLoadedFolderSetMenuStates(const BMenu *menu, - const BObjectList *typeslist); + const BStringList *typeslist); _IMPEXP_TRACKER void SpringLoadedFolderAddUniqueTypeToList(entry_ref *ref, - BObjectList *typeslist); + BStringList *typeslist); _IMPEXP_TRACKER void SpringLoadedFolderCacheDragData(const BMessage *incoming, - BMessage **, BObjectList **typeslist); + BMessage **, BStringList **typeslist); } // namespace BPrivate diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 488febeb27..04440f63e9 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -46,6 +46,7 @@ All rights reserved. #include #include #include +#include #include "icons.h" #include "BarApp.h" @@ -1019,7 +1020,7 @@ TBarView::AppCanHandleTypes(const char* signature) } if (!signature || strlen(signature) == 0 - || !fCachedTypesList || fCachedTypesList->CountItems() == 0) + || !fCachedTypesList || fCachedTypesList->CountStrings() == 0) return false; if (strcasecmp(signature, kTrackerSignature) == 0) { @@ -1042,9 +1043,9 @@ TBarView::AppCanHandleTypes(const char* signature) // supports anything in the list // only one item needs to match in the list of refs - int32 count = fCachedTypesList->CountItems(); + int32 count = fCachedTypesList->CountStrings(); for (int32 i = 0 ; i < count ; i++) { - if (fileinfo.IsSupportedType(fCachedTypesList->ItemAt(i)->String())) + if (fileinfo.IsSupportedType(fCachedTypesList->StringAt(i).String())) return true; } diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h index 6c704b277f..3c060a79f2 100644 --- a/src/apps/deskbar/BarView.h +++ b/src/apps/deskbar/BarView.h @@ -126,7 +126,7 @@ public: TrackingHookData* GetTrackingHookData(); bool Dragging() const; const BMessage* DragMessage() const; - BObjectList* CachedTypesList() const; + BStringList* CachedTypesList() const; bool AppCanHandleTypes(const char* signature); void SetDragOverride(bool); bool DragOverride(); @@ -209,7 +209,7 @@ private: bigtime_t fPulseRate; bool fRefsRcvdOnly; BMessage* fDragMessage; - BObjectList* fCachedTypesList; + BStringList* fCachedTypesList; TrackingHookData fTrackingHookData; uint32 fMaxRecentDocs; @@ -250,7 +250,7 @@ TBarView::DragMessage() const } -inline BObjectList* +inline BStringList* TBarView::CachedTypesList() const { return fCachedTypesList; diff --git a/src/kits/tracker/NavMenu.cpp b/src/kits/tracker/NavMenu.cpp index 9ac94ffb6d..cbc756e3c9 100644 --- a/src/kits/tracker/NavMenu.cpp +++ b/src/kits/tracker/NavMenu.cpp @@ -134,7 +134,7 @@ SpringLoadedFolderCompareMessages(const BMessage* incoming, void SpringLoadedFolderSetMenuStates(const BMenu* menu, - const BObjectList* typeslist) + const BStringList* typeslist) { if (menu == NULL || typeslist == NULL || typeslist->IsEmpty()) return; @@ -183,7 +183,7 @@ SpringLoadedFolderSetMenuStates(const BMenu* menu, void SpringLoadedFolderAddUniqueTypeToList(entry_ref* ref, - BObjectList* typeslist) + BStringList* typeslist) { if (ref == NULL || typeslist == NULL) return; @@ -212,23 +212,23 @@ SpringLoadedFolderAddUniqueTypeToList(entry_ref* ref, } // scan the current list, don't add dups bool isUnique = true; - int32 count = typeslist->CountItems(); + int32 count = typeslist->CountStrings(); for (int32 index = 0 ; index < count ; index++) { - if (typeslist->ItemAt(index)->Compare(mimestr) == 0) { + if (typeslist->StringAt(index).Compare(mimestr) == 0) { isUnique = false; break; } } if (isUnique) - typeslist->AddItem(new BString(mimestr)); + typeslist->Add(mimestr); } } void SpringLoadedFolderCacheDragData(const BMessage* incoming, BMessage** message, - BObjectList** typeslist) + BStringList** typeslist) { if (incoming == NULL) return; @@ -237,7 +237,7 @@ SpringLoadedFolderCacheDragData(const BMessage* incoming, BMessage** message, delete* typeslist; BMessage* localMessage = new BMessage(*incoming); - BObjectList* localTypesList = new BObjectList(10, true); + BStringList* localTypesList = new BStringList(10); for (int32 index = 0; incoming->HasRef("refs", index); index++) { entry_ref ref; @@ -262,7 +262,7 @@ SpringLoadedFolderCacheDragData(const BMessage* incoming, BMessage** message, BNavMenu::BNavMenu(const char* title, uint32 message, const BHandler* target, - BWindow* parentWindow, const BObjectList* list) + BWindow* parentWindow, const BStringList* list) : BSlowMenu(title), fMessage(message), @@ -272,7 +272,7 @@ BNavMenu::BNavMenu(const char* title, uint32 message, const BHandler* target, fItemList(NULL), fContainer(NULL), fIteratingDesktop(false), - fTypesList(new BObjectList(10, true)) + fTypesList(new BStringList(10)) { if (list != NULL) *fTypesList = *list; @@ -295,7 +295,7 @@ BNavMenu::BNavMenu(const char* title, uint32 message, const BHandler* target, BNavMenu::BNavMenu(const char* title, uint32 message, const BMessenger& messenger, BWindow* parentWindow, - const BObjectList* list) + const BStringList* list) : BSlowMenu(title), fMessage(message), @@ -305,7 +305,7 @@ BNavMenu::BNavMenu(const char* title, uint32 message, fItemList(NULL), fContainer(NULL), fIteratingDesktop(false), - fTypesList(new BObjectList(10, true)) + fTypesList(new BStringList(10)) { if (list != NULL) *fTypesList = *list; @@ -582,7 +582,7 @@ BNavMenu::AddOneItem(Model* model) ModelMenuItem* BNavMenu::NewModelItem(Model* model, const BMessage* invokeMessage, const BMessenger& target, bool suppressFolderHierarchy, - BContainerWindow* parentWindow, const BObjectList* typeslist, + BContainerWindow* parentWindow, const BStringList* typeslist, TrackingHookData* hook) { if (model->InitCheck() != B_OK) @@ -844,7 +844,7 @@ BNavMenu::SetShowParent(bool show) void -BNavMenu::SetTypesList(const BObjectList* list) +BNavMenu::SetTypesList(const BStringList* list) { if (list != NULL) *fTypesList = *list; @@ -853,7 +853,7 @@ BNavMenu::SetTypesList(const BObjectList* list) } -const BObjectList* +const BStringList* BNavMenu::TypesList() const { return fTypesList; diff --git a/src/kits/tracker/OpenWithWindow.cpp b/src/kits/tracker/OpenWithWindow.cpp index f86f0c3522..fc93c24269 100644 --- a/src/kits/tracker/OpenWithWindow.cpp +++ b/src/kits/tracker/OpenWithWindow.cpp @@ -184,20 +184,10 @@ OpenWithContainerWindow::OpenWithSelection() } -static const BString* -FindOne(const BString* element, void* castToString) -{ - if (strcasecmp(element->String(), (const char*)castToString) == 0) - return element; - - return 0; -} - - static const entry_ref* AddOneUniqueDocumentType(const entry_ref* ref, void* castToList) { - BObjectList* list = (BObjectList*)castToList; + BStringList* list = (BStringList*)castToList; BEntry entry(ref, true); // traverse symlinks @@ -212,24 +202,24 @@ AddOneUniqueDocumentType(const entry_ref* ref, void* castToList) if (info.GetType(type) != B_OK) return 0; - if (list->EachElement(FindOne, &type)) + if (list->HasString(type, true)) // type already in list, bail return 0; // add type to list - list->AddItem(new BString(type)); + list->Add(type); return 0; } -static const BString* -SetDefaultAppForOneType(const BString* element, void* castToEntryRef) +static bool +SetDefaultAppForOneType(const BString& element, void* castToEntryRef) { const entry_ref* appRef = (const entry_ref*)castToEntryRef; // set entry as default handler for one mime string - BMimeType mime(element->String()); + BMimeType mime(element.String()); if (!mime.IsInstalled()) return 0; @@ -279,12 +269,12 @@ OpenWithContainerWindow::MakeDefaultAndOpen() return; // collect all the types of all the opened documents into a list - BObjectList openedFileTypes(10, true); + BStringList openedFileTypes(10); EachEntryRef(EntryList(), AddOneUniqueDocumentType, &openedFileTypes, 100); // set the default application to be the selected pose for all the // mime types in the list - openedFileTypes.EachElement(SetDefaultAppForOneType, + openedFileTypes.DoForEach(SetDefaultAppForOneType, (void*)selectedAppPose->TargetModel()->EntryRef()); // done setting the default application, now launch the app with the @@ -1371,7 +1361,7 @@ OpenWithMenu::ClearMenuBuildingState() SearchForSignatureEntryList::SearchForSignatureEntryList(bool canAddAllApps) : fIteratorList(NULL), - fSignatures(20, true), + fSignatures(20), fPreferredAppCount(0), fPreferredAppForFileCount(0), fGenericFilesOnly(true), @@ -1391,10 +1381,10 @@ void SearchForSignatureEntryList::PushUniqueSignature(const char* str) { // do a unique add - if (fSignatures.EachElement(FindOne, (void*)str)) + if (fSignatures.HasString(str, true)) return; - fSignatures.AddItem(new BString(str)); + fSignatures.Add(str); } @@ -1426,17 +1416,17 @@ struct AddOneTermParams { }; -static const BString* -AddOnePredicateTerm(const BString* item, void* castToParams) +static bool +AddOnePredicateTerm(const BString& item, void* castToParams) { AddOneTermParams* params = (AddOneTermParams*)castToParams; if (!params->first) (*params->result) << " || "; - (*params->result) << kAttrAppSignature << " = " << item->String(); + (*params->result) << kAttrAppSignature << " = " << item.String(); params->first = false; - return 0; + return false; } @@ -1446,7 +1436,7 @@ SearchForSignatureEntryList::Rewind() if (fIteratorList) return fIteratorList->Rewind(); - if (!fSignatures.CountItems()) + if (!fSignatures.CountStrings()) return ENOENT; // build up the iterator @@ -1462,7 +1452,7 @@ SearchForSignatureEntryList::Rewind() params.result = &predicateString; params.first = true; - fSignatures.EachElement(AddOnePredicateTerm, ¶ms); + fSignatures.DoForEach(AddOnePredicateTerm, ¶ms); ASSERT(predicateString.Length()); // PRINT(("query predicate %s\n", predicateString.String())); diff --git a/src/kits/tracker/OpenWithWindow.h b/src/kits/tracker/OpenWithWindow.h index 71cc93b2a5..9c64c8cfd1 100644 --- a/src/kits/tracker/OpenWithWindow.h +++ b/src/kits/tracker/OpenWithWindow.h @@ -124,7 +124,7 @@ private: // Open With window CachedEntryIteratorList* fIteratorList; - BObjectList fSignatures; + BStringList fSignatures; entry_ref fPreferredRef; int32 fPreferredAppCount; diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index 192bf40a50..988930cf56 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -234,7 +234,7 @@ BPoseView::BPoseView(Model* model, uint32 viewMode) fFilteredPoseList(new PoseList()), fVSPoseList(new PoseList()), fSelectionList(new PoseList()), - fMimeTypesInSelectionCache(20, true), + fMimeTypesInSelectionCache(20), fZombieList(new BObjectList(10, true)), fColumnList(new BObjectList(4, true)), fMimeTypeList(new BObjectList(10, true)), @@ -271,7 +271,7 @@ BPoseView::BPoseView(Model* model, uint32 viewMode) fHasPosesInClipboard(false), fCursorCheck(false), fTypeAheadFiltering(false), - fFilterStrings(4, true), + fFilterStrings(4), fLastFilterStringCount(1), fLastFilterStringLength(0), fLastKeyTime(0), @@ -299,7 +299,6 @@ BPoseView::~BPoseView() delete fVSPoseList; delete fColumnList; delete fSelectionList; - delete fMimeTypeList; delete fZombieList; delete fViewState; delete fModel; @@ -2057,7 +2056,7 @@ BPoseView::MimeTypeAt(int32 index) if (fMimeTypeListIsDirty) RefreshMimeTypeList(); - return fMimeTypeList->ItemAt(index)->String(); + return fMimeTypeList.StringAt(index).String(); } @@ -2067,27 +2066,27 @@ BPoseView::CountMimeTypes() if (fMimeTypeListIsDirty) RefreshMimeTypeList(); - return fMimeTypeList->CountItems(); + return fMimeTypeList.CountStrings(); } void BPoseView::AddMimeType(const char* mimeType) { - int32 count = fMimeTypeList->CountItems(); + int32 count = fMimeTypeList.CountStrings(); for (int32 index = 0; index < count; index++) { - if (*fMimeTypeList->ItemAt(index) == mimeType) + if (fMimeTypeList.StringAt(index) == mimeType) return; } - fMimeTypeList->AddItem(new BString(mimeType)); + fMimeTypeList.Add(mimeType); } void BPoseView::RefreshMimeTypeList() { - fMimeTypeList->MakeEmpty(); + fMimeTypeList.MakeEmpty(); fMimeTypeListIsDirty = false; for (int32 index = 0;; index++) { @@ -4116,13 +4115,6 @@ BPoseView::EachItemInDraggedSelection(const BMessage* message, } -static bool -ContainsOne(BString* string, const char* matchString) -{ - return strcmp(string->String(), matchString) == 0; -} - - bool BPoseView::FindDragNDropAction(const BMessage* dragMessage, bool &canCopy, bool &canMove, bool &canLink, bool &canErase) @@ -4250,7 +4242,7 @@ BPoseView::CanHandleDragSelection(const Model* target, if (!lock) return false; - BObjectList* mimeTypeList + BStringList* mimeTypeList = srcWindow->PoseView()->MimeTypesInSelection(); if (mimeTypeList->IsEmpty()) { PoseList* selectionList = srcWindow->PoseView()->SelectionList(); @@ -4275,11 +4267,8 @@ BPoseView::CanHandleDragSelection(const Model* target, mime.GetType(mimeType); // add unique type string - if (!WhileEachListItem(mimeTypeList, ContainsOne, - (const char*)mimeType)) { - BString* newMimeString = new BString(mimeType); - mimeTypeList->AddItem(newMimeString); - } + if (!mimeTypeList->HasString(mimeType)) + mimeTypeList->Add(mimeType); } } } @@ -4340,14 +4329,14 @@ BPoseView::CreateClippingFile(BPoseView* poseView, BFile &result, static int32 RunMimeTypeDestinationMenu(const char* actionText, - const BObjectList* types, - const BObjectList* specificItems, BPoint where) + const BStringList* types, + const BStringList* specificItems, BPoint where) { int32 count; if (types != NULL) - count = types->CountItems(); + count = types->CountStrings(); else - count = specificItems->CountItems(); + count = specificItems->CountStrings(); if (count == 0) return 0; @@ -4357,8 +4346,7 @@ RunMimeTypeDestinationMenu(const char* actionText, for (int32 index = 0; index < count; index++) { const char* embedTypeAs = NULL; char buffer[256]; - if (types) { - types->ItemAt(index)->String(); + if (types != NULL) { BMimeType mimeType(embedTypeAs); if (mimeType.GetShortDescription(buffer) == B_OK) @@ -4366,8 +4354,8 @@ RunMimeTypeDestinationMenu(const char* actionText, } BString description; - if (specificItems->ItemAt(index)->Length()) { - description << (const BString &)(*specificItems->ItemAt(index)); + if (specificItems->StringAt(index).Length()) { + description << specificItems->StringAt(index); if (embedTypeAs) description << " (" << embedTypeAs << ")"; @@ -4504,7 +4492,7 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel, // handle the promise style drag&drop // fish for specification of specialized menu items - BObjectList actionSpecifiers(10, true); + BStringList actionSpecifiers(10); for (int32 index = 0; ; index++) { const char* string; if (message->FindString("be:actionspecifier", index, @@ -4513,12 +4501,12 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel, } ASSERT(string != NULL); - actionSpecifiers.AddItem(new BString(string)); + actionSpecifiers.Add(string); } // build the list of types the drag originator offers - BObjectList types(10, true); - BObjectList typeNames(10, true); + BStringList types(10); + BStringList typeNames(10); for (int32 index = 0; ; index++) { const char* string; if (message->FindString("be:filetypes", index, &string) @@ -4527,12 +4515,12 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel, } ASSERT(string != NULL); - types.AddItem(new BString(string)); + types.Add(string); const char* typeName = ""; message->FindString("be:type_descriptions", index, &typeName); - typeNames.AddItem(new BString(typeName)); + typeNames.Add(typeName); } int32 specificTypeIndex = -1; @@ -4541,14 +4529,14 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel, // if control down, run a popup menu if (canCopy && SecondaryMouseButtonDown(modifiers(), buttons)) { - if (actionSpecifiers.CountItems() > 0) { + if (actionSpecifiers.CountStrings() > 0) { specificActionIndex = RunMimeTypeDestinationMenu(NULL, NULL, &actionSpecifiers, view->ConvertToScreen(dropPoint)); if (specificActionIndex == -1) return false; - } else if (types.CountItems() > 0) { + } else if (types.CountStrings() > 0) { specificTypeIndex = RunMimeTypeDestinationMenu( B_TRANSLATE("Create %s clipping"), &types, &typeNames, @@ -4576,18 +4564,18 @@ BPoseView::HandleDropCommon(BMessage* message, Model* targetModel, if (specificTypeIndex != -1) { // we had the user pick a specific type from a menu, use it reply.AddString("be:filetypes", - types.ItemAt(specificTypeIndex)->String()); + types.StringAt(specificTypeIndex).String()); - if (typeNames.ItemAt(specificTypeIndex)->Length()) { + if (typeNames.StringAt(specificTypeIndex).Length()) { reply.AddString("be:type_descriptions", - typeNames.ItemAt(specificTypeIndex)->String()); + typeNames.StringAt(specificTypeIndex).String()); } } if (specificActionIndex != -1) { // we had the user pick a specific type from a menu, use it reply.AddString("be:actionspecifier", - actionSpecifiers.ItemAt(specificActionIndex)->String()); + actionSpecifiers.StringAt(specificActionIndex).String()); } reply.AddRef("directory", targetModel->EntryRef()); diff --git a/src/kits/tracker/PoseView.h b/src/kits/tracker/PoseView.h index eb19c5f398..24955ea6c0 100644 --- a/src/kits/tracker/PoseView.h +++ b/src/kits/tracker/PoseView.h @@ -314,7 +314,7 @@ public: void SetSelectionHandler(BLooper* looper); - BObjectList*MimeTypesInSelection(); + BStringList* MimeTypesInSelection(); // pose selection void SelectPose(BPose*, int32 index, bool scrollIntoView = true); @@ -746,11 +746,11 @@ private: PoseList* fVSPoseList; PoseList* fSelectionList; HashSet fInsertedNodes; - BObjectList fMimeTypesInSelectionCache; + BStringList fMimeTypesInSelectionCache; // used for mime string based icon highliting during a drag BObjectList* fZombieList; BObjectList* fColumnList; - BObjectList* fMimeTypeList; + BStringList fMimeTypeList; BObjectList* fBrokenLinks; bool fMimeTypeListIsDirty; BCountView* fCountView; @@ -937,7 +937,7 @@ BPoseView::CountSelected() const return fSelectionList->CountItems(); } -inline BObjectList* +inline BStringList* BPoseView::MimeTypesInSelection() { return &fMimeTypesInSelectionCache;