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 class BQueryPoseView : public BPoseView { 50 public: 51 BQueryPoseView(Model*, BRect, uint32 resizeMask = B_FOLLOW_ALL); 52 virtual ~BQueryPoseView(); 53 54 virtual void MessageReceived(BMessage* message); 55 56 const char* SearchForType() const; 57 BQueryContainerWindow* ContainerWindow() const; 58 bool ActiveOnDevice(dev_t) const; 59 60 void Refresh(); 61 // makes queries that are static but need to appear dynamic 62 // live - for instance for a query that contains a 63 // date == today - RestartQuery gets called on midnight to update 64 // the contents 65 66 protected: 67 virtual void AttachedToWindow(); 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 bool ShouldShowPose(const Model*, const PoseInfo*); 78 virtual void AddPosesCompleted(); 79 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 bool fShowResultsFromTrash; 86 mutable BString fSearchForMimeType; 87 88 BObjectList<BQuery>* fQueryList; 89 QueryEntryListCollection* fQueryListContainer; 90 91 bool fCreateOldPoseList; 92 93 typedef BPoseView _inherited; 94 }; 95 96 97 class QueryEntryListCollection : public EntryListBase { 98 // This will become a replacement for BDirectory and QueryList in a 99 // PoseView, allowing PoseView to have an arbitrary collection of 100 // elements that behave as an EntryList 101 // For now just manage a list of BQueries 102 103 class QueryListRep { 104 public: 105 QueryListRep(BObjectList<BQuery>* queryList) 106 : fQueryList(queryList), 107 fRefCount(0), 108 fShowResultsFromTrash(0), 109 fOldPoseList(NULL) 110 {} 111 112 ~QueryListRep() 113 { 114 ASSERT(fRefCount <= 0); 115 delete fQueryList; 116 delete fOldPoseList; 117 } 118 119 BObjectList<BQuery>* OpenQueryList() 120 { 121 fRefCount++; 122 return fQueryList; 123 } 124 125 bool CloseQueryList() 126 { 127 return atomic_add(&fRefCount, -1) == 0; 128 } 129 130 BObjectList<BQuery>* fQueryList; 131 int32 fRefCount; 132 bool fShowResultsFromTrash; 133 int32 fQueryListIndex; 134 bool fDynamicDateQuery; 135 bool fRefreshEveryHour; 136 bool fRefreshEveryMinute; 137 138 PoseList* fOldPoseList; 139 // when doing a Refresh, this list is used to detect poses that 140 // are no longer a part of a fDynamicDateQuery and need to be 141 // removed 142 }; 143 144 public: 145 QueryEntryListCollection(Model*, BHandler* = NULL, 146 PoseList* oldPoseList = NULL); 147 virtual ~QueryEntryListCollection(); 148 149 QueryEntryListCollection* Clone(); 150 151 BObjectList<BQuery>* QueryList() const 152 { return fQueryListRep->fQueryList; } 153 154 PoseList* OldPoseList() const 155 { return fQueryListRep->fOldPoseList; } 156 void ClearOldPoseList(); 157 158 virtual status_t GetNextEntry(BEntry* entry, bool traverse = false); 159 virtual status_t GetNextRef(entry_ref* ref); 160 virtual int32 GetNextDirents(struct dirent* buffer, size_t length, 161 int32 count = INT_MAX); 162 163 virtual status_t Rewind(); 164 virtual int32 CountEntries(); 165 166 bool ShowResultsFromTrash() const; 167 bool DynamicDateQuery() const; 168 bool DynamicDateRefreshEveryHour() const; 169 bool DynamicDateRefreshEveryMinute() const; 170 171 private: 172 QueryEntryListCollection(const QueryEntryListCollection&); 173 // only to be used by the Clone routine 174 status_t FetchOneQuery(const BQuery*, BHandler* target, 175 BObjectList<BQuery>*, BVolume*); 176 177 QueryListRep* fQueryListRep; 178 }; 179 180 } // namespace BPrivate 181 182 using namespace BPrivate; 183 184 #endif // _QUERY_POSE_VIEW_H 185