hrev56165 adds 1 changeset to branch 'master'
old head: 44d08ffc4a3da5664127c1155d830dd9d8686f02
new head: c90d79f03a9aae5c5fa679b54839453095864539
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=c90d79f03a9a+%5E44d08ffc4a3d
----------------------------------------------------------------------------
c90d79f03a9a: tracker/FindPanel: style cleanup
* No functional change.
Change-Id: I8e5e941fe626a77134036e3828f23ab245d2f5c7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5358
Tested-by: Commit checker robot <no-reply+buildbot@xxxxxxxxxxxx>
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
[ Jim906 <jim_l@xxxxxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev56165
Commit: c90d79f03a9aae5c5fa679b54839453095864539
URL: https://git.haiku-os.org/haiku/commit/?id=c90d79f03a9a
Author: Jim906 <jim_l@xxxxxxxxxxxx>
Date: Tue Jun 7 21:57:37 2022 UTC
Committer: waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Wed Jun 8 21:30:34 2022 UTC
----------------------------------------------------------------------------
2 files changed, 241 insertions(+), 243 deletions(-)
src/kits/tracker/FindPanel.cpp | 53 ++---
src/kits/tracker/FindPanel.h | 431 ++++++++++++++++++-------------------
----------------------------------------------------------------------------
diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp
index a82003ff03..7a224234c0 100644
--- a/src/kits/tracker/FindPanel.cpp
+++ b/src/kits/tracker/FindPanel.cpp
@@ -135,21 +135,21 @@ static const char* operatorLabels[] = {
namespace BPrivate {
class MostUsedNames {
- public:
- MostUsedNames(const char* fileName, const char* directory,
- int32 maxCount = 5);
- ~MostUsedNames();
+public:
+
MostUsedNames(const char* fileName, const char* directory,
+ int32
maxCount = 5);
+
~MostUsedNames();
- bool ObtainList(BList* list);
- void ReleaseList();
+ bool ObtainList(BList* list);
+ void ReleaseList();
- void AddName(const char*);
+ void AddName(const char*);
- protected:
- struct list_entry {
- char* name;
- int32 count;
- };
+protected:
+ struct list_entry {
+ char* name;
+ int32 count;
+ };
static int CompareNames(const void* a, const void* b);
void LoadList();
@@ -995,6 +995,7 @@ FindPanel::ResizeMenuField(BMenuField* menuField)
menuField->SetExplicitSize(size);
}
+
static void
PopUpMenuSetTitle(BMenu* menu, const char* title)
{
@@ -1339,8 +1340,9 @@ FindPanel::FindAttrView(const char* name, int row) const
return NULL;
}
+
void
-FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const
+FindPanel::BuildAttrQuery(BQuery* query, bool& dynamicDate) const
{
dynamicDate = false;
@@ -1508,7 +1510,7 @@ FindPanel::PushMimeType(BQuery* query) const
void
-FindPanel::GetByAttrPredicate(BQuery* query, bool &dynamicDate) const
+FindPanel::GetByAttrPredicate(BQuery* query, bool& dynamicDate) const
{
ASSERT(Mode() == (int32)kByAttributeItem);
BuildAttrQuery(query, dynamicDate);
@@ -1957,12 +1959,14 @@ SortByDatePredicate(const EntryWithDate* entry1, const
EntryWithDate* entry2)
-1 : (entry1->second == entry2->second ? 0 : 1);
}
+
struct AddOneRecentParams {
BMenu* menu;
const BMessenger* target;
uint32 what;
};
+
static const entry_ref*
AddOneRecentItem(const entry_ref* ref, void* castToParams)
{
@@ -2692,7 +2696,7 @@ FindPanel::AddAttributeControls(int32 gridRow)
void
-FindPanel::RestoreAttrState(const BMessage &message, int32 index)
+FindPanel::RestoreAttrState(const BMessage& message, int32 index)
{
BMenuField* menuField
= dynamic_cast<BMenuField*>(FindAttrView("MenuField", index));
@@ -2840,7 +2844,7 @@ FindPanel::RemoveLogicMenu(int32 index)
void
-FindPanel::AddAttributes(BMenu* menu, const BMimeType &mimeType)
+FindPanel::AddAttributes(BMenu* menu, const BMimeType& mimeType)
{
// only add things to menu which have "user-visible" data
BMessage attributeMessage;
@@ -3137,20 +3141,17 @@ DeleteTransientQueriesTask::ProcessOneRef(Model* model)
class DeleteTransientQueriesFunctor : public FunctionObjectWithResult<bool> {
public:
- DeleteTransientQueriesFunctor(DeleteTransientQueriesTask* task)
- : task(task)
- {}
+
DeleteTransientQueriesFunctor(DeleteTransientQueriesTask* task)
+ :
+
task(task)
+ {}
- virtual ~DeleteTransientQueriesFunctor()
- {
- delete task;
- }
+ virtual
~DeleteTransientQueriesFunctor() { delete task; }
- virtual void operator()()
- { result = task->DoSomeWork(); }
+ virtual void operator()() { result =
task->DoSomeWork(); }
private:
- DeleteTransientQueriesTask* task;
+ DeleteTransientQueriesTask* task;
};
diff --git a/src/kits/tracker/FindPanel.h b/src/kits/tracker/FindPanel.h
index d7da0d54f0..76cc018b9b 100644
--- a/src/kits/tracker/FindPanel.h
+++ b/src/kits/tracker/FindPanel.h
@@ -77,100 +77,98 @@ _IMPEXP_TRACKER
BMenu* TrackerBuildRecentFindItemsMenu(const char* title);
struct MoreOptionsStruct {
- bool showMoreOptions;
- // Some options used to be in a collapsable part of the window,
but
- // this was removed. Now the options are always visible.
- bool searchTrash;
- int32 reserved1;
- bool temporary;
- bool reserved9;
- bool reserved10;
- bool reserved11;
- int32 reserved3;
- int32 reserved4;
- int32 reserved5;
- int32 reserved6;
- int32 reserved7;
- int32 reserved8;
- // reserve a bunch of fields so that we can add stuff later but not
- // make old queries incompatible. Reserved fields are set to 0 when
- // saved
-
- MoreOptionsStruct()
- :
- showMoreOptions(true),
- searchTrash(false),
- reserved1(0),
- temporary(true),
- reserved9(false),
- reserved10(false),
- reserved11(false),
- reserved3(0),
- reserved4(0),
- reserved5(0),
- reserved6(0),
- reserved7(0),
- reserved8(0)
- {
- }
-
- static void EndianSwap(void* castToThis);
-
- static void SetQueryTemporary(BNode*, bool on);
- static bool QueryTemporary(const BNode*);
+ // Some options used to be in a collapsable part of the
window, but
+ // this was removed. Now the options are always visible.
+ bool showMoreOptions;
+ bool searchTrash;
+ // reserve a bunch of fields so that we can add stuff
later but not
+ // make old queries incompatible. Reserved fields are
set to 0 when
+ // saved
+ int32 reserved1;
+ bool temporary;
+ bool reserved9;
+ bool reserved10;
+ bool reserved11;
+ int32 reserved3;
+ int32 reserved4;
+ int32 reserved5;
+ int32 reserved6;
+ int32 reserved7;
+ int32 reserved8;
+
+
MoreOptionsStruct()
+ :
+
showMoreOptions(true),
+
searchTrash(false),
+
reserved1(0),
+
temporary(true),
+
reserved9(false),
+
reserved10(false),
+
reserved11(false),
+
reserved3(0),
+
reserved4(0),
+
reserved5(0),
+
reserved6(0),
+
reserved7(0),
+
reserved8(0)
+ {}
+
+ static void EndianSwap(void* castToThis);
+
+ static void SetQueryTemporary(BNode*, bool
on);
+ static bool QueryTemporary(const BNode*);
};
class FindWindow : public BWindow {
public:
- FindWindow(const entry_ref* ref = NULL,
- bool editIfTemplateOnly = false);
- virtual ~FindWindow();
+
FindWindow(const entry_ref* ref = NULL,
+ bool
editIfTemplateOnly = false);
+ virtual ~FindWindow();
- FindPanel* BackgroundView() const
- { return fBackground; }
+ FindPanel* BackgroundView() const
{ return fBackground; }
- BNode* QueryNode() const
- { return fFile; }
+ BNode* QueryNode() const {
return fFile; }
- const char* QueryName() const;
- // reads in the query name from either a saved name in a
template
- // or form a saved query name
+ // reads in the query name from either a saved name in a template
+ // or form a saved query name
+ const char* QueryName() const;
- static bool IsQueryTemplate(BNode* file);
+ static bool IsQueryTemplate(BNode* file);
protected:
- virtual void MessageReceived(BMessage* message);
+ virtual void MessageReceived(BMessage*
message);
private:
- static BFile* TryOpening(const entry_ref* ref);
- static void GetDefaultQuery(BEntry &entry);
- // when opening an empty panel, use the default query to set the
- // panel up
- void SaveQueryAttributes(BNode* file, bool templateQuery);
-
- void Find();
- // retrieve the results
- void Save();
- // save the contents of the find window into the query file
-
- void SwitchToTemplate(const entry_ref*);
- bool FindSaveCommon(bool find);
-
- status_t SaveQueryAsAttributes(BNode*, BEntry*, bool queryTemplate,
- const BMessage* oldAttributes = 0, const BPoint* oldLocation =
0);
-
- void GetDefaultName(BString &);
- void GetPredicateString(BString &, bool &dynamicDate);
- // dynamic date is a date such as 'today'
-
- BFile* fFile;
- entry_ref fRef;
- bool fFromTemplate;
- bool fEditTemplateOnly;
- FindPanel* fBackground;
- mutable BString fQueryNameFromTemplate;
- BFilePanel* fSaveAsTemplatePanel;
+ static BFile* TryOpening(const entry_ref*
ref);
+ // when opening an empty panel, use the default query to set the panel
up
+ static void GetDefaultQuery(BEntry& entry);
+ void
SaveQueryAttributes(BNode* file, bool templateQuery);
+
+ // retrieve the results
+ void Find();
+ // save the contents of the find window into the query
file
+ void Save();
+
+ void SwitchToTemplate(const
entry_ref*);
+ bool FindSaveCommon(bool
find);
+
+ status_t
SaveQueryAsAttributes(BNode*, BEntry*, bool queryTemplate,
+ const
BMessage* oldAttributes = 0,
+ const
BPoint* oldLocation = 0);
+
+ void
GetDefaultName(BString&);
+ // dynamic date is a date such as 'today'
+ void
GetPredicateString(BString&, bool& dynamicDate);
+
+private:
+ BFile* fFile;
+ entry_ref fRef;
+ bool fFromTemplate;
+ bool fEditTemplateOnly;
+ FindPanel* fBackground;
+ mutable BString fQueryNameFromTemplate;
+ BFilePanel* fSaveAsTemplatePanel;
typedef BWindow _inherited;
};
@@ -178,114 +176,111 @@ private:
class FindPanel : public BView {
public:
- FindPanel(BFile*, FindWindow* parent, bool fromTemplate,
- bool editTemplateOnly);
- virtual ~FindPanel();
-
- virtual void AttachedToWindow();
- virtual void Draw(BRect updateRect);
- virtual void MessageReceived(BMessage*);
-
- void BuildAttrQuery(BQuery*, bool& dynamicDate) const;
- BPopUpMenu* MimeTypeMenu() const
- { return fMimeTypeMenu; }
- BMenuItem* CurrentMimeType(const char** type = NULL) const;
- status_t SetCurrentMimeType(BMenuItem* item);
- status_t SetCurrentMimeType(const char* label);
-
- BPopUpMenu* VolMenu() const
- { return fVolMenu; }
- uint32 Mode() const
- { return fMode; }
-
- static uint32 InitialMode(const BNode* entry);
- void SaveWindowState(BNode*, bool editTemplate);
-
- void SwitchToTemplate(const BNode*);
-
- void GetByAttrPredicate(BQuery*, bool &dynamicDate) const;
- // build up a query from by-attribute items
- void GetByNamePredicate(BQuery*) const;
- // build up a simple query from the name we are searching for
-
- void GetDefaultName(BString&) const;
- void GetDefaultAttrName(BString&, int32) const;
- const char* UserSpecifiedName() const;
- // name filled out in the query name text field
-
- static void AddRecentQueries(BMenu*, bool addSaveAsItem,
- const BMessenger* target, uint32 what);
- // populate the recent query menu with query templates and
recent
- // queries
+
FindPanel(BFile*, FindWindow* parent, bool fromTemplate,
+ bool
editTemplateOnly);
+ virtual ~FindPanel();
+
+ virtual void AttachedToWindow();
+ virtual void Draw(BRect updateRect);
+ virtual void MessageReceived(BMessage*);
+
+ void BuildAttrQuery(BQuery*,
bool& dynamicDate) const;
+ BPopUpMenu* MimeTypeMenu() const { return
fMimeTypeMenu; }
+ BMenuItem* CurrentMimeType(const
char** type = NULL) const;
+ status_t
SetCurrentMimeType(BMenuItem* item);
+ status_t
SetCurrentMimeType(const char* label);
+
+ BPopUpMenu* VolMenu() const { return
fVolMenu; }
+ uint32 Mode() const { return
fMode; }
+
+ static uint32 InitialMode(const BNode* entry);
+ void SaveWindowState(BNode*,
bool editTemplate);
+
+ void SwitchToTemplate(const
BNode*);
+
+ // build up a query from by-attribute items
+ void
GetByAttrPredicate(BQuery*, bool& dynamicDate) const;
+ // build up a simple query from the name we are
searching for
+ void
GetByNamePredicate(BQuery*) const;
+
+ void
GetDefaultName(BString&) const;
+ void
GetDefaultAttrName(BString&, int32) const;
+ // name filled out in the query name text field
+ const char* UserSpecifiedName() const;
+
+ // populate the recent query menu with query templates and recent
queries
+ static void AddRecentQueries(BMenu*, bool
addSaveAsItem,
+ const
BMessenger* target, uint32 what);
+
+private:
+ // populates the type menu
+ void AddMimeTypesToMenu();
+ static bool AddOneMimeTypeToMenu(const
ShortMimeInfo*, void* castToMenu);
+
+ // populates the volume menu
+ void AddVolumes(BMenu*);
+
+ void ShowVolumeMenuLabel();
+
+ // add one more attribute item to the attr view
+ void AddAttrRow();
+ // remove the last attribute item
+ void RemoveAttrRow();
+ void AddFirstAttr();
+
+ // panel building/restoring calls
+ void
RestoreWindowState(const BNode*);
+ void
RestoreMimeTypeMenuSelection(const BNode*);
+ void
AddByAttributeItems(const BNode*);
+ void
RemoveByAttributeItems();
+ void
RemoveAttrViewItems(bool removeGrid = true);
+ // MimeTypeWindow is only shown in kByNameItem and
kByAttributeItem modes
+ void
ShowOrHideMimeTypeMenu();
+
+ void
AddAttributeControls(int32);
+
+ // fMode gets set by this and the call relies on it
being up-to-date
+ void
ShowOrHideMoreOptions(bool show);
+ static int32 InitialAttrCount(const BNode*);
+ void
FillCurrentQueryName(BTextControl*, FindWindow*);
+ void
AddByNameOrFormulaItems();
+ void SetUpAddRemoveButtons();
+
+ // go from search by name to search by attribute, etc.
+ void SwitchMode(uint32);
+
+ void PushMimeType(BQuery*
query) const;
+
+ void
SaveAsQueryOrTemplate(const entry_ref*,
+ const
char*, bool queryTemplate);
+
+ BView* FindAttrView(const
char*, int row) const;
+
+ void AddAttributes(BMenu*
menu, const BMimeType& type);
+ void AddMimeTypeAttrs(BMenu*
menu);
+ void RestoreAttrState(const
BMessage&, int32);
+ void
SaveAttrState(BMessage*, int32);
+ void AddLogicMenu(int32,
bool selectAnd = true);
+ void RemoveLogicMenu(int32);
+
+ void
ResizeMenuField(BMenuField*);
private:
- void AddMimeTypesToMenu();
- // populates the type menu
- static bool AddOneMimeTypeToMenu(const ShortMimeInfo*, void*
castToMenu);
-
- void AddVolumes(BMenu*);
- // populates the volume menu
- void ShowVolumeMenuLabel();
-
- void AddAttrRow();
- // add one more attribute item to the attr view
- void RemoveAttrRow();
- // remove the last attribute item
- void AddFirstAttr();
-
- // panel building/restoring calls
- void RestoreWindowState(const BNode*);
- void RestoreMimeTypeMenuSelection(const BNode*);
- void AddByAttributeItems(const BNode*);
- void RemoveByAttributeItems();
- void RemoveAttrViewItems(bool removeGrid = true);
- void ShowOrHideMimeTypeMenu();
- // MimeTypeWindow is only shown in kByNameItem and
- // kByAttributeItem modes
-
- void AddAttributeControls(int32);
-
- void ShowOrHideMoreOptions(bool show);
- // fMode gets set by this and the call relies on it being
- // up-to-date
- static int32 InitialAttrCount(const BNode*);
- void FillCurrentQueryName(BTextControl*, FindWindow*);
- void AddByNameOrFormulaItems();
- void SetUpAddRemoveButtons();
-
- void SwitchMode(uint32);
- // go from search by name to search by attribute, etc.
-
- void PushMimeType(BQuery* query) const;
-
- void SaveAsQueryOrTemplate(const entry_ref*, const char*, bool
queryTemplate);
-
- BView* FindAttrView(const char*, int row) const;
-
- void AddAttributes(BMenu* menu, const BMimeType &type);
- void AddMimeTypeAttrs(BMenu* menu);
- void RestoreAttrState(const BMessage &, int32);
- void SaveAttrState(BMessage*, int32);
- void AddLogicMenu(int32, bool selectAnd = true);
- void RemoveLogicMenu(int32);
-
- void ResizeMenuField(BMenuField*);
-
- uint32 fMode;
- BGridLayout* fAttrGrid;
- BPopUpMenu* fMimeTypeMenu;
- BMenuField* fMimeTypeField;
- BPopUpMenu* fVolMenu;
- BPopUpMenu* fSearchModeMenu;
- BPopUpMenu* fRecentQueries;
- BBox* fMoreOptions;
- BTextControl* fQueryName;
- BString fInitialQueryName;
-
- BCheckBox* fTemporaryCheck;
- BCheckBox* fSearchTrashCheck;
-
- DraggableIcon* fDraggableIcon;
+ uint32 fMode;
+ BGridLayout* fAttrGrid;
+ BPopUpMenu* fMimeTypeMenu;
+ BMenuField* fMimeTypeField;
+ BPopUpMenu* fVolMenu;
+ BPopUpMenu* fSearchModeMenu;
+ BPopUpMenu* fRecentQueries;
+ BBox* fMoreOptions;
+ BTextControl* fQueryName;
+ BString fInitialQueryName;
+
+ BCheckBox* fTemporaryCheck;
+ BCheckBox* fSearchTrashCheck;
+
+ DraggableIcon* fDraggableIcon;
typedef BView _inherited;
@@ -293,67 +288,69 @@ private:
};
+// transient queries get deleted if they didn't get used in a while;
+// this is the task that takes care of it
class DeleteTransientQueriesTask {
- // transient queries get deleted if they didn't get used in a while;
- // this is the task that takes care of it
public:
- static void StartUpTransientQueryCleaner();
+ virtual
~DeleteTransientQueriesTask();
- bool DoSomeWork();
- virtual ~DeleteTransientQueriesTask();
+ static void StartUpTransientQueryCleaner();
+
+ // returns true when done
+ bool DoSomeWork();
protected:
- DeleteTransientQueriesTask();
- // returns true when done
+
DeleteTransientQueriesTask();
- enum State {
- kInitial,
- kAllocatedWalker,
- kTraversing,
- kError
- };
+ void Initialize();
+ bool GetSome();
- State state;
+ bool ProcessOneRef(Model*);
- void Initialize();
- bool GetSome();
+protected:
+ enum State {
+ kInitial,
+ kAllocatedWalker,
+ kTraversing,
+ kError
+ };
- bool ProcessOneRef(Model*);
+protected:
+ State state;
private:
- BTrackerPrivate::TNodeWalker* fWalker;
+ BTrackerPrivate::TNodeWalker* fWalker;
};
class RecentFindItemsMenu : public BMenu {
public:
- RecentFindItemsMenu(const char* title, const BMessenger* target,
- uint32 what);
+
RecentFindItemsMenu(const char* title,
+ const
BMessenger* target, uint32 what);
protected:
- virtual void AttachedToWindow();
+ virtual void AttachedToWindow();
private:
- BMessenger fTarget;
- uint32 fWhat;
+ BMessenger fTarget;
+ uint32 fWhat;
};
+// query/query template drag&drop helper
class DraggableQueryIcon : public DraggableIcon {
- // query/query template drag&drop helper
public:
- DraggableQueryIcon(BRect frame, const char* name,
- const BMessage* message, BMessenger target,
- uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
- uint32 flags = B_WILL_DRAW);
+
DraggableQueryIcon(BRect frame, const char* name,
+ const
BMessage* message, BMessenger target,
+ uint32
resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
+ uint32
flags = B_WILL_DRAW);
protected:
- virtual bool DragStarted(BMessage*);
+ virtual bool DragStarted(BMessage*);
};
} // namespace BPrivate
using namespace BPrivate;
-
#endif // _FIND_PANEL_H