Tracker: Change QueryPoseView over to using a BRefFilter.
Fixes #12640 (was broken by hrev44493).
This commit is contained in:
parent
ecca8a5937
commit
d455c57ea2
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue