btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / kits / tracker / QueryPoseView.h
blob3f5ccba0e3df33dc7f65e9b7a903563b8d12061d
1 /*
2 Open Tracker License
4 Terms and Conditions
6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
32 All rights reserved.
34 #ifndef _QUERY_POSE_VIEW_H
35 #define _QUERY_POSE_VIEW_H
38 #include "EntryIterator.h"
39 #include "PoseView.h"
42 class BQuery;
44 namespace BPrivate {
46 class BQueryContainerWindow;
47 class QueryEntryListCollection;
50 class BQueryPoseView : public BPoseView {
51 public:
52 BQueryPoseView(Model*);
53 virtual ~BQueryPoseView();
55 virtual void MessageReceived(BMessage* message);
57 const char* SearchForType() const;
58 BQueryContainerWindow* ContainerWindow() const;
59 bool ActiveOnDevice(dev_t) const;
61 void Refresh();
62 // makes queries that are static but need to appear dynamic
63 // live - for instance for a query that contains a
64 // date == today - RestartQuery gets called on midnight to update
65 // the contents
67 protected:
68 virtual void AttachedToWindow();
69 virtual void RestoreState(AttributeStreamNode*);
70 virtual void RestoreState(const BMessage&);
71 virtual void SavePoseLocations(BRect* = NULL);
72 virtual void SetUpDefaultColumnsIfNeeded();
73 virtual void SetViewMode(uint32);
74 virtual void OpenParent();
75 virtual void EditQueries();
76 virtual EntryListBase* InitDirentIterator(const entry_ref*);
77 virtual uint32 WatchNewNodeMask();
78 virtual void AddPosesCompleted();
80 private:
81 // list of all the queries this PoseView represents
82 // typically there will be one query per volume specified
83 // QueryEntryListCollection provides the abstraction layer
84 // defining the iterators for _add_poses_
85 mutable BString fSearchForMimeType;
87 BRefFilter* fRefFilter;
88 BObjectList<BQuery>* fQueryList;
89 QueryEntryListCollection* fQueryListContainer;
91 bool fCreateOldPoseList;
93 typedef BPoseView _inherited;
97 class QueryRefFilter : public BRefFilter {
98 public:
99 QueryRefFilter(bool showResultsFromTrash);
100 bool Filter(const entry_ref* ref, BNode* node, stat_beos* st,
101 const char* filetype);
103 private:
104 bool fShowResultsFromTrash;
108 class QueryEntryListCollection : public EntryListBase {
109 // This will become a replacement for BDirectory and QueryList in a
110 // PoseView, allowing PoseView to have an arbitrary collection of
111 // elements that behave as an EntryList
112 // For now just manage a list of BQueries
114 class QueryListRep {
115 public:
116 QueryListRep(BObjectList<BQuery>* queryList)
118 fQueryList(queryList),
119 fRefCount(0),
120 fShowResultsFromTrash(false),
121 fQueryListIndex(-1),
122 fDynamicDateQuery(false),
123 fRefreshEveryHour(false),
124 fRefreshEveryMinute(false),
125 fOldPoseList(NULL)
129 ~QueryListRep()
131 ASSERT(fRefCount <= 0);
132 delete fQueryList;
133 delete fOldPoseList;
136 BObjectList<BQuery>* OpenQueryList()
138 fRefCount++;
139 return fQueryList;
142 bool CloseQueryList()
144 return atomic_add(&fRefCount, -1) == 0;
147 BObjectList<BQuery>* fQueryList;
148 int32 fRefCount;
149 bool fShowResultsFromTrash;
150 int32 fQueryListIndex;
151 bool fDynamicDateQuery;
152 bool fRefreshEveryHour;
153 bool fRefreshEveryMinute;
155 PoseList* fOldPoseList;
156 // when doing a Refresh, this list is used to detect poses that
157 // are no longer a part of a fDynamicDateQuery and need to be
158 // removed
161 public:
162 QueryEntryListCollection(Model*, BHandler* = NULL,
163 PoseList* oldPoseList = NULL);
164 virtual ~QueryEntryListCollection();
166 QueryEntryListCollection* Clone();
168 BObjectList<BQuery>* QueryList() const
170 return fQueryListRep->fQueryList;
173 PoseList* OldPoseList() const
175 return fQueryListRep->fOldPoseList;
177 void ClearOldPoseList();
179 virtual status_t GetNextEntry(BEntry* entry, bool traverse = false);
180 virtual status_t GetNextRef(entry_ref* ref);
181 virtual int32 GetNextDirents(struct dirent* buffer, size_t length,
182 int32 count = INT_MAX);
184 virtual status_t Rewind();
185 virtual int32 CountEntries();
187 bool ShowResultsFromTrash() const;
188 bool DynamicDateQuery() const;
189 bool DynamicDateRefreshEveryHour() const;
190 bool DynamicDateRefreshEveryMinute() const;
192 private:
193 QueryEntryListCollection(const QueryEntryListCollection&);
194 // only to be used by the Clone routine
195 status_t FetchOneQuery(const BQuery*, BHandler* target,
196 BObjectList<BQuery>*, BVolume*);
198 QueryListRep* fQueryListRep;
201 } // namespace BPrivate
203 using namespace BPrivate;
206 #endif // _QUERY_POSE_VIEW_H