From ea8b1e14f9519b9aaca6e6ddea8b01babc311beb Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Wed, 8 Aug 2012 12:25:51 -0400 Subject: [PATCH] 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. --- src/kits/tracker/OpenWithWindow.cpp | 29 ++++++++++++++++++++--------- src/kits/tracker/OpenWithWindow.h | 17 +++++++++++++++-- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/kits/tracker/OpenWithWindow.cpp b/src/kits/tracker/OpenWithWindow.cpp index f14f59999e..0238a464c8 100644 --- a/src/kits/tracker/OpenWithWindow.cpp +++ b/src/kits/tracker/OpenWithWindow.cpp @@ -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); } diff --git a/src/kits/tracker/OpenWithWindow.h b/src/kits/tracker/OpenWithWindow.h index 21baf5844e..e3a4c6f557 100644 --- a/src/kits/tracker/OpenWithWindow.h +++ b/src/kits/tracker/OpenWithWindow.h @@ -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);