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 bool Filter(const entry_ref* ref, BNode* node, stat_beos* st, 100 const char* filetype); 101 102 private: 103 bool fShowResultsFromTrash; 104 }; 105 106 107 class QueryEntryListCollection : public EntryListBase { 108 // This will become a replacement for BDirectory and QueryList in a 109 // PoseView, allowing PoseView to have an arbitrary collection of 110 // elements that behave as an EntryList 111 // For now just manage a list of BQueries 112 113 class QueryListRep { 114 public: 115 QueryListRep(BObjectList<BQuery>* queryList) 116 : 117 fQueryList(queryList), 118 fRefCount(0), 119 fShowResultsFromTrash(false), 120 fQueryListIndex(-1), 121 fDynamicDateQuery(false), 122 fRefreshEveryHour(false), 123 fRefreshEveryMinute(false), 124 fOldPoseList(NULL) 125 { 126 } 127 128 ~QueryListRep() 129 { 130 ASSERT(fRefCount <= 0); 131 delete fQueryList; 132 delete fOldPoseList; 133 } 134 135 BObjectList<BQuery>* OpenQueryList() 136 { 137 fRefCount++; 138 return fQueryList; 139 } 140 141 bool CloseQueryList() 142 { 143 return atomic_add(&fRefCount, -1) == 0; 144 } 145 146 BObjectList<BQuery>* fQueryList; 147 int32 fRefCount; 148 bool fShowResultsFromTrash; 149 int32 fQueryListIndex; 150 bool fDynamicDateQuery; 151 bool fRefreshEveryHour; 152 bool fRefreshEveryMinute; 153 154 PoseList* fOldPoseList; 155 // when doing a Refresh, this list is used to detect poses that 156 // are no longer a part of a fDynamicDateQuery and need to be 157 // removed 158 }; 159 160 public: 161 QueryEntryListCollection(Model*, BHandler* = NULL, 162 PoseList* oldPoseList = NULL); 163 virtual ~QueryEntryListCollection(); 164 165 QueryEntryListCollection* Clone(); 166 167 BObjectList<BQuery>* QueryList() const 168 { 169 return fQueryListRep->fQueryList; 170 } 171 172 PoseList* OldPoseList() const 173 { 174 return fQueryListRep->fOldPoseList; 175 } 176 void ClearOldPoseList(); 177 178 virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); 179 virtual status_t GetNextRef(entry_ref* ref); 180 virtual int32 GetNextDirents(struct dirent* buffer, size_t length, 181 int32 count = INT_MAX); 182 183 virtual status_t Rewind(); 184 virtual int32 CountEntries(); 185 186 bool ShowResultsFromTrash() const; 187 bool DynamicDateQuery() const; 188 bool DynamicDateRefreshEveryHour() const; 189 bool DynamicDateRefreshEveryMinute() const; 190 191 private: 192 QueryEntryListCollection(const QueryEntryListCollection&); 193 // only to be used by the Clone routine 194 status_t FetchOneQuery(const BQuery*, BHandler* target, 195 BObjectList<BQuery>*, BVolume*); 196 197 QueryListRep* fQueryListRep; 198 }; 199 200 } // namespace BPrivate 201 202 using namespace BPrivate; 203 204 205 #endif // _QUERY_POSE_VIEW_H 206