Tracker: Style fixes

This commit is contained in:
John Scipione 2015-02-25 16:33:50 -05:00
parent 5940aaf69c
commit 8c2813c187
4 changed files with 47 additions and 38 deletions

View File

@ -133,6 +133,7 @@ BPose::CreateWidgets(BPoseView* poseView)
BColumn* column = poseView->ColumnAt(index);
if (column == NULL)
break;
fWidgetList.AddItem(new BTextWidget(fModel, column, poseView));
}
}
@ -147,6 +148,7 @@ BPose::AddWidget(BPoseView* poseView, BColumn* column)
BTextWidget* widget = new BTextWidget(fModel, column, poseView);
fWidgetList.AddItem(widget);
return widget;
}
@ -171,7 +173,7 @@ BPose::RemoveWidget(BPoseView*, BColumn* column)
{
int32 index;
BTextWidget* widget = WidgetFor(column->AttrHash(), &index);
if (widget)
if (widget != NULL)
delete fWidgetList.RemoveItemAt(index);
}
@ -183,7 +185,7 @@ BPose::Commit(bool saveChanges, BPoint loc, BPoseView* poseView,
int32 count = fWidgetList.CountItems();
for (int32 index = 0; index < count; index++) {
BTextWidget* widget = fWidgetList.ItemAt(index);
if (widget->IsActive()) {
if (widget != NULL && widget->IsActive()) {
widget->StopEdit(saveChanges, loc, poseView, this, poseIndex);
break;
}
@ -199,7 +201,7 @@ OneMouseUp(BTextWidget* widget, BPose* pose, BPoseView* poseView,
if (poseView->ViewMode() == kListMode)
rect = widget->CalcClickRect(poseLoc, column, poseView);
else
rect = widget->CalcClickRect(pose->Location(poseView), 0, poseView);
rect = widget->CalcClickRect(pose->Location(poseView), NULL, poseView);
if (rect.Contains(where)) {
widget->MouseUp(rect, poseView, pose, where);
@ -254,9 +256,9 @@ BPose::UpdateWidgetAndModel(Model* resolvedModel, const char* attrName,
// may overlap and we get aliasing
uint32 attrHash = AttrHashString(attrName, attrType);
BTextWidget* widget = WidgetFor(attrHash);
if (widget) {
if (widget != NULL) {
BColumn* column = poseView->ColumnFor(attrHash);
if (column)
if (column != NULL)
widget->CheckAndUpdate(poseLoc, column, poseView, visible);
} else if (attrType == 0) {
// attribute got likely removed, so let's search the
@ -265,9 +267,9 @@ BPose::UpdateWidgetAndModel(Model* resolvedModel, const char* attrName,
for (int32 i = 0; i < count; i++) {
BTextWidget* widget = fWidgetList.ItemAt(i);
BColumn* column = poseView->ColumnFor(widget->AttrHash());
if (column != NULL && !strcmp(column->AttrName(), attrName)) {
widget->CheckAndUpdate(poseLoc, column, poseView,
visible);
if (column != NULL
&& strcmp(column->AttrName(), attrName) == 0) {
widget->CheckAndUpdate(poseLoc, column, poseView, visible);
break;
}
}
@ -292,10 +294,8 @@ BPose::UpdateWidgetAndModel(Model* resolvedModel, const char* attrName,
if (column->StatField()) {
BTextWidget* widget = WidgetFor(column->AttrHash());
if (widget) {
widget->CheckAndUpdate(poseLoc, column, poseView,
visible);
}
if (widget != NULL)
widget->CheckAndUpdate(poseLoc, column, poseView, visible);
}
}
}
@ -364,9 +364,8 @@ void
BPose::UpdateBrokenSymLink(BPoint poseLoc, BPoseView* poseView)
{
ASSERT(TargetModel()->IsSymLink());
ASSERT(!TargetModel()->LinkTo());
if (!TargetModel()->IsSymLink() || TargetModel()->LinkTo())
ASSERT(TargetModel()->LinkTo() == NULL);
if (!TargetModel()->IsSymLink() || TargetModel()->LinkTo() != NULL)
return;
UpdateIcon(poseLoc, poseView);
@ -379,7 +378,7 @@ BPose::UpdateWasBrokenSymlink(BPoint poseLoc, BPoseView* poseView)
if (!fModel->IsSymLink())
return;
if (fModel->LinkTo()) {
if (fModel->LinkTo() != NULL) {
BEntry entry(fModel->EntryRef(), true);
if (entry.InitCheck() != B_OK) {
watch_node(fModel->LinkTo()->NodeRef(), B_STOP_WATCHING, poseView);
@ -391,7 +390,7 @@ BPose::UpdateWasBrokenSymlink(BPoint poseLoc, BPoseView* poseView)
poseView->CreateSymlinkPoseTarget(fModel);
UpdateIcon(poseLoc, poseView);
if (fModel->LinkTo())
if (fModel->LinkTo() != NULL)
fModel->LinkTo()->CloseNode();
}
@ -404,7 +403,7 @@ BPose::EditFirstWidget(BPoint poseLoc, BPoseView* poseView)
for (int32 i = 0; (column = poseView->ColumnAt(i)) != NULL; i++) {
BTextWidget* widget = WidgetFor(column->AttrHash());
if (widget && widget->IsEditable()) {
if (widget != NULL && widget->IsEditable()) {
BRect bounds;
// ToDo:
// fold the three StartEdit code sequences into a cover call
@ -412,6 +411,7 @@ BPose::EditFirstWidget(BPoint poseLoc, BPoseView* poseView)
bounds = widget->CalcRect(poseLoc, column, poseView);
else
bounds = widget->CalcRect(Location(poseView), NULL, poseView);
widget->StartEdit(bounds, poseView, this);
break;
}
@ -451,7 +451,7 @@ BPose::EditPreviousNextWidgetCommon(BPoseView* poseView, bool next)
BPoint poseLoc(0, poseIndex* poseView->ListElemHeight());
bounds = widget->CalcRect(poseLoc, column, poseView);
} else
bounds = widget->CalcRect(Location(poseView), 0, poseView);
bounds = widget->CalcRect(Location(poseView), NULL, poseView);
widget->StartEdit(bounds, poseView, this);
break;
@ -537,11 +537,13 @@ BPose::PointInPose(BPoint loc, const BPoseView* poseView, BPoint where,
BColumn* column = poseView->ColumnAt(index);
if (column == NULL)
break;
BTextWidget* widget = WidgetFor(column->AttrHash());
if (widget
if (widget != NULL
&& widget->CalcClickRect(loc, column, poseView).Contains(where)) {
if (hitWidget)
if (hitWidget != NULL)
*hitWidget = widget;
return true;
}
}
@ -595,7 +597,7 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView,
// if widget doesn't exist, create it
BTextWidget* widget = WidgetFor(column, poseView, modelOpener);
if (widget && widget->IsVisible()) {
if (widget != NULL && widget->IsVisible()) {
BRect widgetRect(widget->ColumnRect(rect.LeftTop(), column,
poseView));
@ -658,7 +660,7 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView,
if (widget == NULL || !widget->IsVisible())
return;
rect = widget->CalcRect(location, 0, poseView);
rect = widget->CalcRect(location, NULL, poseView);
bool selectDuringDraw = directDraw && selected
&& (poseView->IsDesktopWindow() || windowActive);
@ -713,7 +715,7 @@ BPose::DeselectWithoutErasingBackground(BRect, BPoseView* poseView)
return;
// just invalidate the background, don't draw anything
poseView->Invalidate(widget->CalcRect(location, 0, poseView));
poseView->Invalidate(widget->CalcRect(location, NULL, poseView));
}
@ -787,7 +789,7 @@ BPose::WidgetFor(uint32 attr, int32* index) const
}
}
return 0;
return NULL;
}

View File

@ -322,6 +322,7 @@ BPoseView::InitCommon()
fTitleView = new BTitleView(this);
if (fHScrollBar != NULL)
fHScrollBar->SetTitleView(fTitleView);
fCountView = new BCountView(this);
BPoint origin;
@ -2660,6 +2661,7 @@ BPoseView::RemoveColumn(BColumn* columnToRemove, bool runAlert)
int32 count = fPoseList->CountItems();
for (int32 index = 0; index < count; index++)
fPoseList->ItemAt(index)->RemoveWidget(this, columnToRemove);
fColumnList->RemoveItem(columnToRemove, false);
fTitleView->RemoveTitle(columnToRemove);
@ -2743,7 +2745,7 @@ BPoseView::AddColumn(BColumn* newColumn, const BColumn* after)
for (int32 index = startIndex; index < count; index++) {
BPose* pose = poseList->ItemAt(index);
if (!pose->WidgetFor(newColumn->AttrHash()))
if (pose->WidgetFor(newColumn->AttrHash()) == NULL)
pose->AddWidget(this, newColumn);
loc.y += fListElemHeight;
@ -6370,6 +6372,7 @@ BPoseView::InvertSelection()
} else {
if (index == startIndex)
fSelectionPivotPose = pose;
fSelectionList->AddItem(pose);
pose->Select(true);
}
@ -9005,6 +9008,7 @@ BPoseView::DrawViewCommon(const BRect &updateRect)
int32 count = poseList->CountItems();
int32 startIndex
= (int32)((updateRect.top - fListElemHeight) / fListElemHeight);
if (startIndex < 0)
startIndex = 0;

View File

@ -1245,7 +1245,7 @@ EachTextWidget(BPose* pose, BPoseView* poseView,
break;
BTextWidget* widget = pose->WidgetFor(column->AttrHash());
if (widget)
if (widget != NULL)
(func)(widget, pose, poseView, column, p1);
}
}
@ -1263,7 +1263,7 @@ EachTextWidget(BPose* pose, BPoseView* poseView,
break;
BTextWidget* widget = pose->WidgetFor(column->AttrHash());
if (widget)
if (widget != NULL)
(func)(widget, pose, poseView, column, p1, p2);
}
}
@ -1281,12 +1281,13 @@ WhileEachTextWidget(BPose* pose, BPoseView* poseView,
break;
BTextWidget* widget = pose->WidgetFor(column->AttrHash());
if (widget) {
if (widget != NULL) {
Result result = (func)(widget, pose, poseView, column, p1, p2);
if (result)
if (result != 0)
return result;
}
}
return 0;
}

View File

@ -159,6 +159,7 @@ BTextWidget::CalcRectCommon(BPoint poseLoc, const BColumn* column,
- (textWidth / 2);
if (result.left < 0)
result.left = 0;
result.right = result.left + textWidth + 1;
break;
@ -168,6 +169,7 @@ BTextWidget::CalcRectCommon(BPoint poseLoc, const BColumn* column,
if (result.left < 0)
result.left = 0;
break;
default:
TRESPASS();
break;
@ -217,7 +219,7 @@ BTextWidget::CalcClickRect(BPoint poseLoc, const BColumn* column,
if (result.Width() < kWidthMargin) {
// if resulting rect too narrow, make it a bit wider
// for comfortable clicking
if (column && column->Width() < kWidthMargin)
if (column != NULL && column->Width() < kWidthMargin)
result.right = result.left + column->Width();
else
result.right = result.left + kWidthMargin;
@ -436,7 +438,7 @@ BTextWidget::StartEdit(BRect bounds, BPoseView* view, BPose* pose)
// make this text widget invisible while we edit it
SetVisible(false);
ASSERT(view->Window());
ASSERT(view->Window() != NULL);
// how can I not have a Window here???
if (view->Window()) {
@ -452,7 +454,7 @@ BTextWidget::StopEdit(bool saveChanges, BPoint poseLoc, BPoseView* view,
{
// find the text editing view
BView* scrollView = view->FindView("BorderView");
ASSERT(scrollView);
ASSERT(scrollView != NULL);
if (scrollView == NULL)
return;
@ -480,7 +482,7 @@ BTextWidget::StopEdit(bool saveChanges, BPoint poseLoc, BPoseView* view,
scrollView->RemoveSelf();
delete scrollView;
ASSERT(view->Window());
ASSERT(view->Window() != NULL);
view->Window()->UpdateIfNeeded();
view->MakeFocus();