OpenWithWindow: Fix crash at closing, and fix filtering

Following hrev44493, the way ShouldShowPose was used changed a bit,
to harmonize with type ahead filtering.

This updates OpenWithWindow to use a BRefFilter to do its
filtering rather than overloading ShouldShowPose.
This commit is contained in:
Philippe Saint-Pierre 2012-08-08 12:25:51 -04:00
parent e21fe3ff33
commit ea8b1e14f9
2 changed files with 35 additions and 11 deletions

View File

@ -648,6 +648,8 @@ OpenWithPoseView::InitDirentIterator(const entry_ref*)
HideBarberPole();
return NULL;
}
SetRefFilter(new OpenWithRefFilter(fIterator, entryList,
(fHaveCommonPreferredApp ? &fPreferredRef : 0)));
return fIterator;
}
@ -935,16 +937,25 @@ OpenWithPoseView::OpenWithRelationDescription(const Model* model,
}
bool
OpenWithPoseView::ShouldShowPose(const Model* model, const PoseInfo* poseInfo)
{
OpenWithContainerWindow* window = ContainerWindow();
// filter for add_poses
if (!fIterator->CanOpenWithFilter(model, window->EntryList(),
fHaveCommonPreferredApp ? &fPreferredRef : 0))
return false;
// #pragma mark -
return _inherited::ShouldShowPose(model, poseInfo);
OpenWithRefFilter::OpenWithRefFilter(SearchForSignatureEntryList* iterator,
const BMessage *entryList, entry_ref* preferredRef)
:
fIterator(iterator),
fEntryList(entryList),
fPreferredRef(preferredRef)
{
}
bool
OpenWithRefFilter::Filter(const entry_ref* ref, BNode* node, stat_beos* st,
const char* filetype)
{
Model *model = new Model(ref, true, true);
return fIterator->CanOpenWithFilter(model, fEntryList, fPreferredRef);
}

View File

@ -252,8 +252,6 @@ class OpenWithPoseView : public BPoseView {
// override to add selecting the default handling app
// for selection
virtual bool ShouldShowPose(const Model*, const PoseInfo*);
virtual void Pulse();
virtual void KeyDown(const char* bytes, int32 count);
@ -269,6 +267,21 @@ class OpenWithPoseView : public BPoseView {
};
class OpenWithRefFilter: public BRefFilter
{
public:
OpenWithRefFilter(SearchForSignatureEntryList*, const BMessage*,
entry_ref*);
bool Filter(const entry_ref* ref, BNode* node, stat_beos* st,
const char* filetype);
private:
SearchForSignatureEntryList* fIterator;
const BMessage *fEntryList;
entry_ref* fPreferredRef;
};
class RelationCachingModelProxy {
public:
RelationCachingModelProxy(Model* model);