haiku/src/kits/tracker/QueryPoseView.h

207 lines
5.6 KiB
C
Raw Normal View History

/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _QUERY_POSE_VIEW_H
#define _QUERY_POSE_VIEW_H
#include "EntryIterator.h"
#include "PoseView.h"
class BQuery;
namespace BPrivate {
class BQueryContainerWindow;
class QueryEntryListCollection;
2014-07-23 08:34:52 +04:00
class BQueryPoseView : public BPoseView {
public:
Tracker: use the Layout API wherever possible. Sorry this commit is so big, but I couldn't figure out how to do this incrementally without breaking things. I wasn't able to just merge Aldeck's branch, as it was a partial refactor of Tracker and didn't just rewrite the UI creation code to use layouts, and the changes for PM (e.g. addon loading, virtual directories) made it very hard to merge (it doesn't even compile after an automerge) so rather than spending time on that, I decided it'd be better to recreate his work. Miscellaneous notes: - This partially cleans up BPoseView & subclasses and BContainerWindow & subclasses -- none of the subclasses and child views abuse the parent's state, child views, or layout now. - BFilePanel and BDeskWindow are not on layouts, because: * BFilePanel docs in the Be Book instructed developers that wanted to modify BFilePanel's layout to just use FindView() and then move the views around. Obviously making it use layouts will break all BeOS apps that do this, and there are a lot of them (Pe, WonderBrush are just two examples.) I've added a note to the TODO list for R2 to create a layout-compatible API for this. * Some replicants (Workspaces, for example) rely on manipulating BDeskWindow's drawing state. This is incompatible with layouts, as at least in the case of Workspaces, it breaks a layouted version of BDeskWindow entirely. - I noticed a lot of #ifdef BEOS_VERSION ... gunk in the code. Tracker probably didn't build on BeOS just before this commit, and now it won't for sure, so I intend to go through and clean that out in the near future. This commit also fixes: - enhancement #4996 (make Tracker's navigator use vector icons) - bug #3039 (resizing OpenWithWindow flashes the blue border) - bug #3889 (OpenWithWindow redraw errors) - a regression that was a side effect of "dynamic_cast<BDeskWindow*>(this)" always returning NULL when run in the constructor. I just added a "bool isDeskWindow" to BContainerWindow's constructor that is only set to true by BDeskWindow. - a copy&paste error in VirtualDirectoryPoseView that was passing "uint32 resizeMode" as "uint32 viewMode". Thanks to Alexandre for his original branch (it was a very useful reference), Axel (for some miscellaneous advice & encouragement), Adrien & Humdinger (for user interface review), and Diver (for user interface review & testing).
2015-01-27 09:41:22 +03:00
BQueryPoseView(Model*);
virtual ~BQueryPoseView();
virtual void MessageReceived(BMessage* message);
const char* SearchForType() const;
BQueryContainerWindow* ContainerWindow() const;
bool ActiveOnDevice(dev_t) const;
void Refresh();
// makes queries that are static but need to appear dynamic
// live - for instance for a query that contains a
// date == today - RestartQuery gets called on midnight to update
// the contents
protected:
virtual void AttachedToWindow();
virtual void RestoreState(AttributeStreamNode*);
virtual void RestoreState(const BMessage&);
virtual void SavePoseLocations(BRect* = NULL);
virtual void SetUpDefaultColumnsIfNeeded();
virtual void SetViewMode(uint32);
virtual void OpenParent();
virtual void EditQueries();
virtual EntryListBase* InitDirentIterator(const entry_ref*);
virtual uint32 WatchNewNodeMask();
virtual void AddPosesCompleted();
private:
// list of all the queries this PoseView represents
// typically there will be one query per volume specified
// QueryEntryListCollection provides the abstraction layer
// defining the iterators for _add_poses_
mutable BString fSearchForMimeType;
BRefFilter* fRefFilter;
BObjectList<BQuery>* fQueryList;
QueryEntryListCollection* fQueryListContainer;
bool fCreateOldPoseList;
typedef BPoseView _inherited;
};
class QueryRefFilter : public BRefFilter {
public:
QueryRefFilter(bool showResultsFromTrash);
bool Filter(const entry_ref* ref, BNode* node, stat_beos* st,
const char* filetype);
private:
bool fShowResultsFromTrash;
};
class QueryEntryListCollection : public EntryListBase {
// This will become a replacement for BDirectory and QueryList in a
// PoseView, allowing PoseView to have an arbitrary collection of
// elements that behave as an EntryList
// For now just manage a list of BQueries
class QueryListRep {
public:
QueryListRep(BObjectList<BQuery>* queryList)
2014-07-23 08:34:52 +04:00
:
fQueryList(queryList),
fRefCount(0),
fShowResultsFromTrash(false),
fQueryListIndex(-1),
fDynamicDateQuery(false),
fRefreshEveryHour(false),
fRefreshEveryMinute(false),
fOldPoseList(NULL)
{
}
~QueryListRep()
2014-07-23 08:34:52 +04:00
{
ASSERT(fRefCount <= 0);
delete fQueryList;
delete fOldPoseList;
}
BObjectList<BQuery>* OpenQueryList()
2014-07-23 08:34:52 +04:00
{
fRefCount++;
return fQueryList;
}
bool CloseQueryList()
{
return atomic_add(&fRefCount, -1) == 0;
}
BObjectList<BQuery>* fQueryList;
int32 fRefCount;
bool fShowResultsFromTrash;
int32 fQueryListIndex;
bool fDynamicDateQuery;
bool fRefreshEveryHour;
bool fRefreshEveryMinute;
PoseList* fOldPoseList;
// when doing a Refresh, this list is used to detect poses that
// are no longer a part of a fDynamicDateQuery and need to be
// removed
};
public:
QueryEntryListCollection(Model*, BHandler* = NULL,
PoseList* oldPoseList = NULL);
virtual ~QueryEntryListCollection();
QueryEntryListCollection* Clone();
BObjectList<BQuery>* QueryList() const
2014-07-23 08:34:52 +04:00
{
return fQueryListRep->fQueryList;
}
PoseList* OldPoseList() const
2014-07-23 08:34:52 +04:00
{
return fQueryListRep->fOldPoseList;
}
void ClearOldPoseList();
virtual status_t GetNextEntry(BEntry* entry, bool traverse = false);
virtual status_t GetNextRef(entry_ref* ref);
virtual int32 GetNextDirents(struct dirent* buffer, size_t length,
int32 count = INT_MAX);
virtual status_t Rewind();
virtual int32 CountEntries();
bool ShowResultsFromTrash() const;
bool DynamicDateQuery() const;
bool DynamicDateRefreshEveryHour() const;
bool DynamicDateRefreshEveryMinute() const;
private:
QueryEntryListCollection(const QueryEntryListCollection&);
// only to be used by the Clone routine
status_t FetchOneQuery(const BQuery*, BHandler* target,
BObjectList<BQuery>*, BVolume*);
QueryListRep* fQueryListRep;
};
} // namespace BPrivate
using namespace BPrivate;
2014-06-21 03:10:08 +04:00
#endif // _QUERY_POSE_VIEW_H