diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index b48b683e77..e5b044bc8d 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -130,6 +130,7 @@ class DraggableContainerIcon : public BView { struct AddOneAddonParams { BObjectList *primaryList; BObjectList *secondaryList; + BObjectList *mimeTypes; }; struct StaggerOneParams { @@ -2838,34 +2839,12 @@ BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model *, BDirectory dir; BEntry entry; + + BObjectList *mimeTypes = ((AddOneAddonParams *)params)->mimeTypes; if (dir.SetTo(path.Path()) != B_OK) return false; - // build a list of the MIME types of the selected items - - BObjectList mimeTypes(10, true); - - int32 count = PoseView()->SelectionList()->CountItems(); - if (!count) { - // just add the type of the current directory - AddMimeTypeString(mimeTypes, TargetModel()); - } else { - for (int32 index = 0; index < count; index++) { - BPose *pose = PoseView()->SelectionList()->ItemAt(index); - AddMimeTypeString(mimeTypes, pose->TargetModel()); - // If it's a symlink, resolves it and add the Target's MimeType - if (pose->TargetModel()->IsSymLink()) { - Model* resolved = new Model( - pose->TargetModel()->EntryRef(), true, true); - if (resolved->InitCheck() == B_OK) { - AddMimeTypeString(mimeTypes, resolved); - } - delete resolved; - } - } - } - dir.Rewind(); while (dir.GetNextEntry(&entry) == B_OK) { Model *model = new Model(&entry); @@ -2887,7 +2866,7 @@ BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model *, bool primary = false; - if (mimeTypes.CountItems()) { + if (mimeTypes->CountItems()) { BFile file(&entry, B_READ_ONLY); if (file.InitCheck() == B_OK) { BAppFileInfo info(&file); @@ -2905,8 +2884,8 @@ BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model *, // check all supported types if it has some set if (!secondary) { - for (int32 i = mimeTypes.CountItems(); !primary && i-- > 0;) { - BString *type = mimeTypes.ItemAt(i); + for (int32 i = mimeTypes->CountItems(); !primary && i-- > 0;) { + BString *type = mimeTypes->ItemAt(i); if (info.IsSupportedType(type->String())) { BMimeType mimeType(type->String()); if (info.Supports(&mimeType)) @@ -2970,8 +2949,6 @@ BContainerWindow::BuildAddOnMenu(BMenu *menu) break; delete item; } - - _UpdateSelectionMIMEInfo(); BObjectList primaryList; BObjectList secondaryList; @@ -2980,12 +2957,39 @@ BContainerWindow::BuildAddOnMenu(BMenu *menu) params.primaryList = &primaryList; params.secondaryList = &secondaryList; + // build a list of the MIME types of the selected items + BObjectList mimeTypes(10, true); + + int32 count = PoseView()->SelectionList()->CountItems(); + if (!count) { + // just add the type of the current directory + AddMimeTypeString(mimeTypes, TargetModel()); + } else { + _UpdateSelectionMIMEInfo(); + for (int32 index = 0; index < count; index++) { + BPose *pose = PoseView()->SelectionList()->ItemAt(index); + + AddMimeTypeString(mimeTypes, pose->TargetModel()); + // If it's a symlink, resolves it and add the Target's MimeType + if (pose->TargetModel()->IsSymLink()) { + Model* resolved = new Model( + pose->TargetModel()->EntryRef(), true, true); + if (resolved->InitCheck() == B_OK) { + AddMimeTypeString(mimeTypes, resolved); + } + delete resolved; + } + } + } + + params.mimeTypes = &mimeTypes; + EachAddon(AddOneAddon, ¶ms); primaryList.SortItems(CompareLabels); secondaryList.SortItems(CompareLabels); - int32 count = primaryList.CountItems(); + count = primaryList.CountItems(); for (int32 index = 0; index < count; index++) menu->AddItem(primaryList.ItemAt(index)); diff --git a/src/kits/tracker/Model.cpp b/src/kits/tracker/Model.cpp index 7f5ea56b7f..dcf5e3e889 100644 --- a/src/kits/tracker/Model.cpp +++ b/src/kits/tracker/Model.cpp @@ -883,6 +883,8 @@ Model::AttrChanged(const char *attrName) if (!attrName || strcmp(attrName, kAttrMIMEType) == 0 || strcmp(attrName, kAttrPreferredApp) == 0) { + ModelNodeLazyOpener opener(this); + opener.OpenNode(); char mimeString[B_MIME_TYPE_LENGTH]; BNodeInfo info(fNode); if (info.GetType(mimeString) != B_OK) diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index 592c04b0d0..fba21fe3db 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -155,7 +155,7 @@ struct attr_column_relation { }; -static struct attr_column_relation attributes[] = { +static struct attr_column_relation sAttrColumnMap[] = { { AttrHashString(kAttrStatModified, B_TIME_TYPE), B_STAT_MODIFICATION_TIME }, { AttrHashString(kAttrStatSize, B_OFF_T_TYPE), @@ -5466,11 +5466,11 @@ BPoseView::AttributeChanged(const BMessage *message) if (message->FindInt32("fields", &fields) != B_OK) return true; - for (int32 i = sizeof(attributes) / sizeof(attr_column_relation); + for (int i = sizeof(sAttrColumnMap) / sizeof(attr_column_relation); i--;) { - if (attributes[i].attrHash == PrimarySort() - || attributes[i].attrHash == SecondarySort()) { - if ((fields & attributes[i].fieldMask) != 0) { + if (sAttrColumnMap[i].attrHash == PrimarySort() + || sAttrColumnMap[i].attrHash == SecondarySort()) { + if ((fields & sAttrColumnMap[i].fieldMask) != 0) { _CheckPoseSortOrder(fPoseList, pose, poseListIndex); if (fFiltering && visible) _CheckPoseSortOrder(fFilteredPoseList, pose, index);