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*, BRect, uint32 resizeMask = B_FOLLOW_ALL); 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 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 bool ShouldShowPose(const Model*, const PoseInfo*); 79 virtual void AddPosesCompleted(); 80 81 private: 82 // list of all the queries this PoseView represents 83 // typically there will be one query per volume specified 84 // QueryEntryListCollection provides the abstraction layer 85 // defining the iterators for _add_poses_ 86 bool fShowResultsFromTrash; 87 mutable BString fSearchForMimeType; 88 89 BObjectList<BQuery>* fQueryList; 90 QueryEntryListCollection* fQueryListContainer; 91 92 bool fCreateOldPoseList; 93 94 typedef BPoseView _inherited; 95 }; 96 97 98 class QueryEntryListCollection : public EntryListBase { 99 // This will become a replacement for BDirectory and QueryList in a 100 // PoseView, allowing PoseView to have an arbitrary collection of 101 // elements that behave as an EntryList 102 // For now just manage a list of BQueries 103 104 class QueryListRep { 105 public: 106 QueryListRep(BObjectList<BQuery>* queryList) 107 : 108 fQueryList(queryList), 109 fRefCount(0), 110 fShowResultsFromTrash(false), 111 fQueryListIndex(-1), 112 fDynamicDateQuery(false), 113 fRefreshEveryHour(false), 114 fRefreshEveryMinute(false), 115 fOldPoseList(NULL) 116 { 117 } 118 119 ~QueryListRep() 120 { 121 ASSERT(fRefCount <= 0); 122 delete fQueryList; 123 delete fOldPoseList; 124 } 125 126 BObjectList<BQuery>* OpenQueryList() 127 { 128 fRefCount++; 129 return fQueryList; 130 } 131 132 bool CloseQueryList() 133 { 134 return atomic_add(&fRefCount, -1) == 0; 135 } 136 137 BObjectList<BQuery>* fQueryList; 138 int32 fRefCount; 139 bool fShowResultsFromTrash; 140 int32 fQueryListIndex; 141 bool fDynamicDateQuery; 142 bool fRefreshEveryHour; 143 bool fRefreshEveryMinute; 144 145 PoseList* fOldPoseList; 146 // when doing a Refresh, this list is used to detect poses that 147 // are no longer a part of a fDynamicDateQuery and need to be 148 // removed 149 }; 150 151 public: 152 QueryEntryListCollection(Model*, BHandler* = NULL, 153 PoseList* oldPoseList = NULL); 154 virtual ~QueryEntryListCollection(); 155 156 QueryEntryListCollection* Clone(); 157 158 BObjectList<BQuery>* QueryList() const 159 { 160 return fQueryListRep->fQueryList; 161 } 162 163 PoseList* OldPoseList() const 164 { 165 return fQueryListRep->fOldPoseList; 166 } 167 void ClearOldPoseList(); 168 169 virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); 170 virtual status_t GetNextRef(entry_ref* ref); 171 virtual int32 GetNextDirents(struct dirent* buffer, size_t length, 172 int32 count = INT_MAX); 173 174 virtual status_t Rewind(); 175 virtual int32 CountEntries(); 176 177 bool ShowResultsFromTrash() const; 178 bool DynamicDateQuery() const; 179 bool DynamicDateRefreshEveryHour() const; 180 bool DynamicDateRefreshEveryMinute() const; 181 182 private: 183 QueryEntryListCollection(const QueryEntryListCollection&); 184 // only to be used by the Clone routine 185 status_t FetchOneQuery(const BQuery*, BHandler* target, 186 BObjectList<BQuery>*, BVolume*); 187 188 QueryListRep* fQueryListRep; 189 }; 190 191 } // namespace BPrivate 192 193 using namespace BPrivate; 194 195 196 #endif // _QUERY_POSE_VIEW_H 197