Author: mmlr Date: 2010-02-02 18:56:52 +0100 (Tue, 02 Feb 2010) New Revision: 35389 Changeset: http://dev.haiku-os.org/changeset/35389/haiku Modified: haiku/trunk/src/kits/tracker/PoseView.cpp haiku/trunk/src/kits/tracker/PoseView.h Log: * Add an inline CurrentPoseList() that returns either the filtered or normal pose list and replaced the rather ugly "fFiltering ? ..." everywhere with it. * Automatic whitespace cleanup. Modified: haiku/trunk/src/kits/tracker/PoseView.cpp =================================================================== --- haiku/trunk/src/kits/tracker/PoseView.cpp 2010-02-02 17:37:53 UTC (rev 35388) +++ haiku/trunk/src/kits/tracker/PoseView.cpp 2010-02-02 17:56:52 UTC (rev 35389) @@ -1548,8 +1548,7 @@ if (ViewMode() == kListMode) { BRect bounds(Bounds()); float lastItemTop - = ((fFiltering ? fFilteredPoseList : fPoseList)->CountItems() - 1) - * fListElemHeight; + = (CurrentPoseList()->CountItems() - 1) * fListElemHeight; if (bounds.top > lastItemTop) BView::ScrollTo(bounds.left, max_c(lastItemTop, 0)); } @@ -2320,8 +2319,7 @@ BPose *pose = fSelectionList->FirstItem(); if (pose) { - pose->EditFirstWidget(BPoint(0, - (fFiltering ? fFilteredPoseList : fPoseList)->IndexOf(pose) + pose->EditFirstWidget(BPoint(0, CurrentPoseList()->IndexOf(pose) * fListElemHeight), this); } break; @@ -2607,7 +2605,7 @@ BRect rect(Bounds()); // add widget for all visible poses - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); int32 startIndex = (int32)(rect.top / fListElemHeight); BPoint loc(0, startIndex * fListElemHeight); @@ -3028,7 +3026,7 @@ BPoseView::SetPosesClipboardMode(uint32 clipboardMode) { if (ViewMode() == kListMode) { - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); BPoint loc(0,0); @@ -3713,7 +3711,7 @@ BPoint loc(0, start * fListElemHeight); BRect bounds(Bounds()); - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = start; index < end && index < count; index++) { BPose *pose = poseList->ItemAt(index); @@ -3809,7 +3807,7 @@ if (ViewMode() == kListMode) { // TODO: need a simple call to CalcRect that works both in listView and // icon view modes without the need for an index/pos - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); BPoint loc(0, 0); for (int32 index = 0; index < count; index++) { @@ -5414,7 +5412,7 @@ if (ViewMode() == kListMode) { // need to find the index of the pose in the pose list bool found = false; - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = 0; index < count; index++) { if (poseList->ItemAt(index) == pose) { @@ -5841,7 +5839,7 @@ bool iconMode = ViewMode() != kListMode; - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = startIndex; index < count; index++) { BPose *pose = poseList->ItemAt(index); @@ -5890,7 +5888,7 @@ bool iconMode = ViewMode() != kListMode; - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = startIndex; index < count; index++) { BPose *pose = poseList->ItemAt(index); @@ -5943,7 +5941,7 @@ expression = expressionPointer; - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); TrackerString name; @@ -6035,7 +6033,7 @@ // select the first entry (if in listview mode), and // scroll to the top of the view if (ViewMode() == kListMode) { - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); BPose *pose = fSelectionList->LastItem(); if (pose != NULL && fMultipleSelection && (modifiers() & B_SHIFT_KEY) != 0) { @@ -6061,7 +6059,7 @@ // select the last entry (if in listview mode), and // scroll to the bottom of the view if (ViewMode() == kListMode) { - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); BPose *pose = fSelectionList->FirstItem(); if (pose != NULL && fMultipleSelection && (modifiers() & B_SHIFT_KEY) != 0) { @@ -6350,7 +6348,7 @@ BPose *selectedPose = fSelectionList->LastItem(); if (ViewMode() == kListMode) { - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); switch (arrowKey) { case B_UP_ARROW: @@ -6785,8 +6783,7 @@ BPoint tempLoc; GetMouse(&tempLoc, &button); if (button) { - int32 index - = (fFiltering ? fFilteredPoseList : fPoseList)->IndexOf(pose); + int32 index = CurrentPoseList()->IndexOf(pose); message.AddInt32("buttons", (int32)button); BRect dragRect(GetDragRect(index)); BBitmap *dragBitmap = NULL; @@ -6875,7 +6872,7 @@ BRect bounds(Bounds()); - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); BPose *pose = poseList->ItemAt(clickedPoseIndex); if (ViewMode() == kListMode) { int32 count = poseList->CountItems(); @@ -6946,7 +6943,7 @@ BRect result; BRect bounds(Bounds()); - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); BPose *pose = poseList->ItemAt(clickedPoseIndex); if (ViewMode() == kListMode) { // get starting rect of clicked pose @@ -7150,7 +7147,7 @@ BPoint loc(0, startIndex * fListElemHeight); - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = startIndex; index < count; index++) { BPose *pose = poseList->ItemAt(index); @@ -7285,7 +7282,7 @@ } if (ViewMode() == kListMode) { - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 currSelIndex = poseList->IndexOf(pose); int32 lastSelIndex = poseList->IndexOf(fSelectionPivotPose); @@ -7338,8 +7335,7 @@ } } } else { - int32 index - = (fFiltering ? fFilteredPoseList : fPoseList)->IndexOf(pose); + int32 index = CurrentPoseList()->IndexOf(pose); if (!extendSelection) { if (!pose->IsSelected()) { // create new selection @@ -7485,8 +7481,7 @@ if (ViewMode() == kListMode) { BRect bounds(Bounds()); int32 index = (int32)(bounds.bottom / fListElemHeight); - BPose *pose - = (fFiltering ? fFilteredPoseList : fPoseList)->ItemAt(index); + BPose *pose = CurrentPoseList()->ItemAt(index); if (!pose && bounds.top > 0) // scroll up a little BView::ScrollTo(bounds.left, @@ -7538,8 +7533,7 @@ *poseIndex = index; BPoint loc(0, index * fListElemHeight); - BPose *pose - = (fFiltering ? fFilteredPoseList : fPoseList)->ItemAt(index); + BPose *pose = CurrentPoseList()->ItemAt(index); if (pose && pose->PointInPose(loc, this, point)) return pose; } else { @@ -8033,7 +8027,7 @@ int32 startIndex = (int32)(bounds.top / fListElemHeight); BPoint loc(0, startIndex * fListElemHeight); - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = startIndex; index < count; index++) { BPose *pose = poseList->ItemAt(index); @@ -8091,7 +8085,7 @@ int32 startIndex = (int32)(bounds.top / fListElemHeight); BPoint loc(0, startIndex * fListElemHeight); - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 index = startIndex; index < count; index++) { BPose *pose = poseList->ItemAt(index); @@ -8208,8 +8202,7 @@ if (column) { rect.left = rect.top = 0; rect.right = column->Offset() + column->Width(); - rect.bottom = fListElemHeight - * (fFiltering ? fFilteredPoseList : fPoseList)->CountItems(); + rect.bottom = fListElemHeight * CurrentPoseList()->CountItems(); } else rect.Set(LeftTop().x, LeftTop().y, LeftTop().x, LeftTop().y); @@ -8451,7 +8444,7 @@ BPoseView::DrawViewCommon(const BRect &updateRect) { if (ViewMode() == kListMode) { - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); int32 startIndex = (int32)((updateRect.top - fListElemHeight) / fListElemHeight); if (startIndex < 0) @@ -8496,7 +8489,7 @@ if (startIndex < 0) startIndex = 0; - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); if (!count) return; @@ -8563,8 +8556,7 @@ void BPoseView::CheckPoseSortOrder(BPose *pose, int32 oldIndex) { - _CheckPoseSortOrder(fFiltering ? fFilteredPoseList : fPoseList, pose, - oldIndex); + _CheckPoseSortOrder(CurrentPoseList(), pose, oldIndex); } @@ -8817,7 +8809,7 @@ float maxWidth = kMinColumnWidth; - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); for (int32 i = 0; i < count; ++i) { BTextWidget *widget = poseList->ItemAt(i)->WidgetFor(column->AttrHash()); @@ -9096,7 +9088,7 @@ BRect bounds(Bounds()); if (ViewMode() == kListMode) { - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); int32 startIndex = (int32)(bounds.top / fListElemHeight); @@ -9241,7 +9233,7 @@ BRect bounds(Bounds()); if (ViewMode() == kListMode) { - PoseList *poseList = fFiltering ? fFilteredPoseList : fPoseList; + PoseList *poseList = CurrentPoseList(); int32 count = poseList->CountItems(); int32 startIndex = (int32)(bounds.top / fListElemHeight); Modified: haiku/trunk/src/kits/tracker/PoseView.h =================================================================== --- haiku/trunk/src/kits/tracker/PoseView.h 2010-02-02 17:37:53 UTC (rev 35388) +++ haiku/trunk/src/kits/tracker/PoseView.h 2010-02-02 17:56:52 UTC (rev 35389) @@ -73,7 +73,7 @@ struct std::hash<node_ref> #endif { - size_t operator()(node_ref ref) const { + size_t operator()(node_ref ref) const { return ref.node; } }; @@ -327,7 +327,7 @@ bool FrameForPose(BPose *targetpose, bool convert, BRect *poseRect); bool CreateSymlinkPoseTarget(Model *symlink); // used to complete a symlink pose; returns true if - // target symlink should not be shown + // target symlink should not be shown void ResetPosePlacementHint(); void PlaceFolder(const entry_ref *, const BMessage *); @@ -423,7 +423,7 @@ // scripting handlers virtual bool HandleScriptingMessage(BMessage *message); - bool SetProperty(BMessage *message, BMessage *specifier, int32 form, + bool SetProperty(BMessage *message, BMessage *specifier, int32 form, const char *property, BMessage *reply); bool GetProperty(BMessage *, int32, const char *, BMessage *); bool CreateProperty(BMessage *message, BMessage *specifier, int32, @@ -468,7 +468,7 @@ virtual void AddPoses(Model *model = NULL); // if <model> is zero, PoseView has other means of iterating through all // the entries thaat it adds - + virtual void AddRootPoses(bool watchIndividually, bool mountShared); // watchIndividually is used when placing a volume pose onto the Desktop // where unlike in the Root window it will not be watched by the folder @@ -588,7 +588,7 @@ void HandleAutoScroll(); bool CheckAutoScroll(BPoint mouseLoc, bool shouldScroll, bool selectionScrolling = false); - // view extent handling + // view extent handling void RecalcExtent(); void AddToExtent(const BRect &); void ClearExtent(); @@ -615,7 +615,7 @@ virtual void AddPosesCompleted(); bool IsValidAddPosesThread(thread_id) const; - // filtering + // typeahead filtering void EnsurePoseUnselected(BPose *pose); void RemoveFilteredPose(BPose *pose, int32 index); void FilterChanged(); @@ -624,6 +624,7 @@ void StartFiltering(); void StopFiltering(); void ClearFilter(); + PoseList *CurrentPoseList() const; // misc BList *GetDropPointList(BPoint dropPoint, BPoint startPoint, const PoseList *, @@ -829,7 +830,7 @@ inline bool BPoseView::StateNeedsSaving() { - return fStateNeedsSaving || fViewState->StateNeedsSaving(); + return fStateNeedsSaving || fViewState->StateNeedsSaving(); } inline uint32 @@ -881,25 +882,25 @@ } inline uint32 -BPoseView::PrimarySort() const +BPoseView::PrimarySort() const { return fViewState->PrimarySort(); } inline uint32 -BPoseView::PrimarySortType() const +BPoseView::PrimarySortType() const { return fViewState->PrimarySortType(); } inline uint32 -BPoseView::SecondarySort() const +BPoseView::SecondarySort() const { return fViewState->SecondarySort(); } inline uint32 -BPoseView::SecondarySortType() const +BPoseView::SecondarySortType() const { return fViewState->SecondarySortType(); } @@ -949,13 +950,13 @@ inline int32 BPoseView::IndexOfPose(const BPose *pose) const { - return (fFiltering ? fFilteredPoseList : fPoseList)->IndexOf(pose); + return CurrentPoseList()->IndexOf(pose); } inline BPose * BPoseView::PoseAtIndex(int32 index) const { - return (fFiltering ? fFilteredPoseList : fPoseList)->ItemAt(index); + return CurrentPoseList()->ItemAt(index); } inline BColumn * @@ -979,7 +980,7 @@ inline int32 BPoseView::CountItems() const { - return (fFiltering ? fFilteredPoseList : fPoseList)->CountItems(); + return CurrentPoseList()->CountItems(); } @@ -1050,7 +1051,7 @@ } inline BRefFilter * -BPoseView::RefFilter() const +BPoseView::RefFilter() const { return fRefFilter; } @@ -1064,19 +1065,19 @@ inline BPose * BPoseView::FindPose(const Model *model, int32 *index) const { - return (fFiltering ? fFilteredPoseList : fPoseList)->FindPose(model, index); + return CurrentPoseList()->FindPose(model, index); } inline BPose * BPoseView::FindPose(const node_ref *node, int32 *index) const { - return (fFiltering ? fFilteredPoseList : fPoseList)->FindPose(node, index); + return CurrentPoseList()->FindPose(node, index); } inline BPose * BPoseView::FindPose(const entry_ref *entry, int32 *index) const { - return (fFiltering ? fFilteredPoseList : fPoseList)->FindPose(entry, index); + return CurrentPoseList()->FindPose(entry, index); } @@ -1094,8 +1095,15 @@ } +inline PoseList * +BPoseView::CurrentPoseList() const +{ + return fFiltering ? fFilteredPoseList : fPoseList; +} + + template<class Param1> -void +void EachTextWidget(BPose *pose, BPoseView *poseView, void (*func)(BTextWidget *, BPose *, BPoseView *, BColumn *, Param1), Param1 p1) { @@ -1112,7 +1120,7 @@ template<class Param1, class Param2> -void +void EachTextWidget(BPose *pose, BPoseView *poseView, void (*func)(BTextWidget *, BPose *, BPoseView *, BColumn *, Param1, Param2), Param1 p1, Param2 p2) @@ -1130,7 +1138,7 @@ template<class Result, class Param1, class Param2> -Result +Result WhileEachTextWidget(BPose *pose, BPoseView *poseView, Result (*func)(BTextWidget *, BPose *, BPoseView *, BColumn *, Param1, Param2), Param1 p1, Param2 p2)