[haiku-commits] haiku: hrev50315 - src/kits/tracker

  • From: waddlesplash@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 14 May 2016 19:24:48 +0200 (CEST)

hrev50315 adds 1 changeset to branch 'master'
old head: ecca8a59378d8d12c4291b48529c6ae3ffb949c5
new head: d455c57ea268e9f0cebd991644cf171c6843ea2d
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=d455c57ea268+%5Eecca8a59378d

----------------------------------------------------------------------------

d455c57ea268: Tracker: Change QueryPoseView over to using a BRefFilter.
  
  Fixes #12640 (was broken by hrev44493).

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev50315
Commit:      d455c57ea268e9f0cebd991644cf171c6843ea2d
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d455c57ea268
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat May 14 17:22:14 2016 UTC

Ticket:      https://dev.haiku-os.org/ticket/12640

----------------------------------------------------------------------------

2 files changed, 35 insertions(+), 32 deletions(-)
src/kits/tracker/QueryPoseView.cpp | 53 +++++++++++++++-------------------
src/kits/tracker/QueryPoseView.h   | 14 +++++++--

----------------------------------------------------------------------------

diff --git a/src/kits/tracker/QueryPoseView.cpp 
b/src/kits/tracker/QueryPoseView.cpp
index bafe85f..7d80612 100644
--- a/src/kits/tracker/QueryPoseView.cpp
+++ b/src/kits/tracker/QueryPoseView.cpp
@@ -80,7 +80,7 @@ using std::nothrow;
 BQueryPoseView::BQueryPoseView(Model* model)
        :
        BPoseView(model, kListMode),
-       fShowResultsFromTrash(false),
+       fRefFilter(NULL),
        fQueryList(NULL),
        fQueryListContainer(NULL),
        fCreateOldPoseList(false)
@@ -201,33 +201,6 @@ BQueryPoseView::Refresh()
 }
 
 
-bool
-BQueryPoseView::ShouldShowPose(const Model* model, const PoseInfo* poseInfo)
-{
-       // add_poses, etc. filter
-       ASSERT(TargetModel());
-
-       TTracker* tracker = dynamic_cast<TTracker*>(be_app);
-       if (!fShowResultsFromTrash && tracker != NULL
-               && tracker->InTrashNode(model->EntryRef())) {
-               return false;
-       }
-
-       bool result = _inherited::ShouldShowPose(model, poseInfo);
-
-       PoseList* oldPoseList = fQueryListContainer->OldPoseList();
-       if (result && oldPoseList != NULL) {
-               // pose will get added - remove it from the old pose list
-               // because it is supposed to be showing
-               BPose* pose = oldPoseList->FindPose(model);
-               if (pose != NULL)
-                       oldPoseList->RemoveItem(pose);
-       }
-
-       return result;
-}
-
-
 void
 BQueryPoseView::AddPosesCompleted()
 {
@@ -281,8 +254,6 @@ BQueryPoseView::InitDirentIterator(const entry_ref* ref)
                return NULL;
        }
 
-       fShowResultsFromTrash = fQueryListContainer->ShowResultsFromTrash();
-
        TTracker::WatchNode(sourceModel.NodeRef(), B_WATCH_NAME | B_WATCH_STAT
                | B_WATCH_ATTR, this);
 
@@ -360,6 +331,8 @@ BQueryPoseView::InitDirentIterator(const entry_ref* ref)
                        delta);
        }
 
+       SetRefFilter(new 
QueryRefFilter(fQueryListContainer->ShowResultsFromTrash()));
+
        return fQueryListContainer->Clone();
 }
 
@@ -417,6 +390,26 @@ BQueryPoseView::ActiveOnDevice(dev_t device) const
 }
 
 
+//     #pragma mark - QueryRefFilter
+
+
+QueryRefFilter::QueryRefFilter(bool showResultsFromTrash)
+       :
+       fShowResultsFromTrash(showResultsFromTrash)
+{
+}
+
+
+bool
+QueryRefFilter::Filter(const entry_ref* ref, BNode* node, stat_beos* st,
+       const char* filetype)
+{
+       TTracker* tracker = dynamic_cast<TTracker*>(be_app);
+       return !(!fShowResultsFromTrash && tracker != NULL
+               && tracker->InTrashNode(ref));
+}
+
+
 //     #pragma mark - QueryEntryListCollection
 
 
diff --git a/src/kits/tracker/QueryPoseView.h b/src/kits/tracker/QueryPoseView.h
index 26524ce..3f5ccba 100644
--- a/src/kits/tracker/QueryPoseView.h
+++ b/src/kits/tracker/QueryPoseView.h
@@ -75,7 +75,6 @@ protected:
        virtual void EditQueries();
        virtual EntryListBase* InitDirentIterator(const entry_ref*);
        virtual uint32 WatchNewNodeMask();
-       virtual bool ShouldShowPose(const Model*, const PoseInfo*);
        virtual void AddPosesCompleted();
 
 private:
@@ -83,9 +82,9 @@ private:
                // typically there will be one query per volume specified
                // QueryEntryListCollection provides the abstraction layer
                // defining the iterators for _add_poses_
-       bool fShowResultsFromTrash;
        mutable BString fSearchForMimeType;
 
+       BRefFilter* fRefFilter;
        BObjectList<BQuery>* fQueryList;
        QueryEntryListCollection* fQueryListContainer;
 
@@ -95,6 +94,17 @@ private:
 };
 
 
+class QueryRefFilter : public BRefFilter {
+public:
+       QueryRefFilter(bool showResultsFromTrash);
+       bool Filter(const entry_ref* ref, BNode* node, stat_beos* st,
+               const char* filetype);
+
+private:
+       bool fShowResultsFromTrash;
+};
+
+
 class QueryEntryListCollection : public EntryListBase {
        // This will become a replacement for BDirectory and QueryList in a
        // PoseView, allowing PoseView to have an arbitrary collection of


Other related posts:

  • » [haiku-commits] haiku: hrev50315 - src/kits/tracker - waddlesplash