1 /* 2 Open Tracker License 3 4 Terms and Conditions 5 6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 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: 14 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. 17 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. 24 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. 28 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. 33 */ 34 #ifndef _QUERY_POSE_VIEW_H 35 #define _QUERY_POSE_VIEW_H 36 37 38 #include "EntryIterator.h" 39 #include "PoseView.h" 40 41 42 class BQuery; 43 44 namespace BPrivate { 45 46 class BQueryContainerWindow; 47 class QueryEntryListCollection; 48 49 50 class BQueryPoseView : public BPoseView { 51 public: 52 BQueryPoseView(Model*); 53 virtual ~BQueryPoseView(); 54 55 virtual void MessageReceived(BMessage* message); 56 57 const char* SearchForType() const; 58 BQueryContainerWindow* ContainerWindow() const; 59 bool ActiveOnDevice(dev_t) const; 60 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 66 67 protected: 68 virtual void RestoreState(AttributeStreamNode*); 69 virtual void RestoreState(const BMessage&); 70 virtual void SavePoseLocations(BRect* = NULL); 71 virtual void SetupDefaultColumnsIfNeeded(); 72 virtual void SetViewMode(uint32); 73 virtual void OpenParent(); 74 virtual void EditQueries(); 75 virtual EntryListBase* InitDirentIterator(const entry_ref*); 76 virtual uint32 WatchNewNodeMask(); 77 virtual void AddPosesCompleted(); 78 79 private: 80 // list of all the queries this PoseView represents 81 // typically there will be one query per volume specified 82 // QueryEntryListCollection provides the abstraction layer 83 // defining the iterators for _add_poses_ 84 mutable BString fSearchForMimeType; 85 86 BRefFilter* fRefFilter; 87 BObjectList<BQuery>* fQueryList; 88 QueryEntryListCollection* fQueryListContainer; 89 90 bool fCreateOldPoseList; 91 92 typedef BPoseView _inherited; 93 }; 94 95 96 class QueryRefFilter : public BRefFilter { 97 public: 98 QueryRefFilter(bool showResultsFromTrash); 99 virtual ~QueryRefFilter(); 100 virtual bool Filter(const entry_ref* ref, BNode* node, stat_beos* st, 101 const char* filetype); 102 103 status_t LoadDirectoryFiltersFromFile(const BNode*); 104 status_t AddDirectoryFilter(const entry_ref*); 105 bool PassThroughDirectoryFilters(const entry_ref*) const; 106 107 private: 108 bool fShowResultsFromTrash; 109 BObjectList<entry_ref> fDirectoryFilters; 110 }; 111 112 113 class QueryEntryListCollection : public EntryListBase { 114 // This will become a replacement for BDirectory and QueryList in a 115 // PoseView, allowing PoseView to have an arbitrary collection of 116 // elements that behave as an EntryList 117 // For now just manage a list of BQueries 118 119 class QueryListRep { 120 public: 121 QueryListRep(BObjectList<BQuery>* queryList) 122 : 123 fQueryList(queryList), 124 fRefCount(0), 125 fShowResultsFromTrash(false), 126 fQueryListIndex(-1), 127 fDynamicDateQuery(false), 128 fRefreshEveryHour(false), 129 fRefreshEveryMinute(false), 130 fOldPoseList(NULL) 131 { 132 } 133 134 ~QueryListRep() 135 { 136 ASSERT(fRefCount <= 0); 137 delete fQueryList; 138 delete fOldPoseList; 139 } 140 141 BObjectList<BQuery>* OpenQueryList() 142 { 143 fRefCount++; 144 return fQueryList; 145 } 146 147 bool CloseQueryList() 148 { 149 return atomic_add(&fRefCount, -1) == 0; 150 } 151 152 BObjectList<BQuery>* fQueryList; 153 int32 fRefCount; 154 bool fShowResultsFromTrash; 155 int32 fQueryListIndex; 156 bool fDynamicDateQuery; 157 bool fRefreshEveryHour; 158 bool fRefreshEveryMinute; 159 160 PoseList* fOldPoseList; 161 // when doing a Refresh, this list is used to detect poses that 162 // are no longer a part of a fDynamicDateQuery and need to be 163 // removed 164 }; 165 166 public: 167 QueryEntryListCollection(Model*, BHandler* = NULL, 168 PoseList* oldPoseList = NULL); 169 virtual ~QueryEntryListCollection(); 170 171 QueryEntryListCollection* Clone(); 172 173 BObjectList<BQuery>* QueryList() const 174 { 175 return fQueryListRep->fQueryList; 176 } 177 178 PoseList* OldPoseList() const 179 { 180 return fQueryListRep->fOldPoseList; 181 } 182 void ClearOldPoseList(); 183 184 virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); 185 virtual status_t GetNextRef(entry_ref* ref); 186 virtual int32 GetNextDirents(struct dirent* buffer, size_t length, 187 int32 count = INT_MAX); 188 189 virtual status_t Rewind(); 190 virtual int32 CountEntries(); 191 192 bool ShowResultsFromTrash() const; 193 bool DynamicDateQuery() const; 194 bool DynamicDateRefreshEveryHour() const; 195 bool DynamicDateRefreshEveryMinute() const; 196 197 private: 198 QueryEntryListCollection(const QueryEntryListCollection&); 199 // only to be used by the Clone routine 200 status_t FetchOneQuery(const BQuery*, BHandler* target, 201 BObjectList<BQuery>*, BVolume*); 202 203 QueryListRep* fQueryListRep; 204 }; 205 206 } // namespace BPrivate 207 208 using namespace BPrivate; 209 210 211 #endif // _QUERY_POSE_VIEW_H 212