Tracker & Deskbar: Use BStringList instead of BObjectList<BString>.

It's more efficient, and conveys ownership semantics more clearly.

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