Tracker: miscellaneous style fixes

This commit is contained in:
John Scipione 2014-07-04 19:25:11 -04:00
parent 6ab2085f7b
commit d7e6821137
7 changed files with 70 additions and 70 deletions

View File

@ -121,10 +121,9 @@ class DraggableContainerIcon : public BView {
virtual void AttachedToWindow();
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where);
virtual void MouseMoved(BPoint point, uint32 /*transit*/,
const BMessage* message);
virtual void FrameMoved(BPoint newLocation);
virtual void MouseUp(BPoint);
virtual void MouseMoved(BPoint point, uint32, const BMessage*);
virtual void FrameMoved(BPoint);
virtual void Draw(BRect updateRect);
private:
@ -333,7 +332,7 @@ DraggableContainerIcon::AttachedToWindow()
void
DraggableContainerIcon::MouseDown(BPoint point)
DraggableContainerIcon::MouseDown(BPoint where)
{
// we only like container windows
BContainerWindow* window = dynamic_cast<BContainerWindow*>(Window());
@ -347,13 +346,13 @@ DraggableContainerIcon::MouseDown(BPoint point)
uint32 buttons;
window->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
if (IconCache::sIconCache->IconHitTest(point, window->TargetModel(),
if (IconCache::sIconCache->IconHitTest(where, window->TargetModel(),
kNormalIcon, B_MINI_ICON)) {
// The click hit the icon, initiate a drag
fDragButton = buttons
& (B_PRIMARY_MOUSE_BUTTON | B_SECONDARY_MOUSE_BUTTON);
fDragStarted = false;
fClickPoint = point;
fClickPoint = where;
} else
fDragButton = 0;
@ -363,7 +362,7 @@ DraggableContainerIcon::MouseDown(BPoint point)
void
DraggableContainerIcon::MouseUp(BPoint /*point*/)
DraggableContainerIcon::MouseUp(BPoint)
{
if (!fDragStarted)
Window()->Activate(true);
@ -374,12 +373,11 @@ DraggableContainerIcon::MouseUp(BPoint /*point*/)
void
DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/,
const BMessage* /*message*/)
DraggableContainerIcon::MouseMoved(BPoint where, uint32, const BMessage*)
{
if (fDragButton == 0 || fDragStarted
|| (abs((int32)(point.x - fClickPoint.x)) <= kDragSlop
&& abs((int32)(point.y - fClickPoint.y)) <= kDragSlop))
|| (abs((int32)(where.x - fClickPoint.x)) <= kDragSlop
&& abs((int32)(where.y - fClickPoint.y)) <= kDragSlop))
return;
BContainerWindow* window = static_cast<BContainerWindow*>(Window());
@ -461,7 +459,7 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/,
void
DraggableContainerIcon::FrameMoved(BPoint /*newLocation*/)
DraggableContainerIcon::FrameMoved(BPoint)
{
BMenuBar* bar = dynamic_cast<BMenuBar*>(Parent());
if (bar == NULL)
@ -667,27 +665,27 @@ BContainerWindow::Quit()
fNavigationItem = NULL;
}
if (fOpenWithItem && !fOpenWithItem->Menu()) {
if (fOpenWithItem != NULL && fOpenWithItem->Menu() == NULL) {
delete fOpenWithItem;
fOpenWithItem = NULL;
}
if (fMoveToItem && !fMoveToItem->Menu()) {
if (fMoveToItem != NULL && fMoveToItem->Menu() == NULL) {
delete fMoveToItem;
fMoveToItem = NULL;
}
if (fCopyToItem && !fCopyToItem->Menu()) {
if (fCopyToItem != NULL && fCopyToItem->Menu() == NULL) {
delete fCopyToItem;
fCopyToItem = NULL;
}
if (fCreateLinkItem && !fCreateLinkItem->Menu()) {
if (fCreateLinkItem != NULL && fCreateLinkItem->Menu() == NULL) {
delete fCreateLinkItem;
fCreateLinkItem = NULL;
}
if (fAttrMenu && !fAttrMenu->Supermenu()) {
if (fAttrMenu != NULL && fAttrMenu->Supermenu() == NULL) {
delete fAttrMenu;
fAttrMenu = NULL;
}
@ -1563,14 +1561,14 @@ BContainerWindow::MessageReceived(BMessage* message)
|| isRoot != PoseView()->TargetModel()->IsRoot())
RepopulateMenus();
// Update Navigation bar
if (Navigator()) {
if (Navigator() != NULL) {
// update Navigation bar
int32 action = kActionSet;
if (message->FindInt32("action", &action) != B_OK)
if (message->FindInt32("action", &action) != B_OK) {
// Design problem? Why does FindInt32 touch
// 'action' at all if he can't find it??
action = kActionSet;
}
Navigator()->UpdateLocation(PoseView()->TargetModel(),
action);
}

View File

@ -80,18 +80,17 @@ DesktopPoseView::InitDesktopDirentIterator(BPoseView* nodeMonitoringTarget,
ASSERT(!sourceModel.IsQuery());
ASSERT(!sourceModel.IsVirtualDirectory());
ASSERT(sourceModel.Node());
BDirectory* sourceDirectory
= dynamic_cast<BDirectory*>(sourceModel.Node());
ASSERT(sourceModel.Node() != NULL);
ASSERT(sourceDirectory);
BDirectory* sourceDirectory = dynamic_cast<BDirectory*>(sourceModel.Node());
ASSERT(sourceDirectory != NULL);
// build an iterator list, start with boot
EntryListBase* perDesktopIterator
= new CachedDirectoryEntryList(*sourceDirectory);
result->AddItem(perDesktopIterator);
if (nodeMonitoringTarget) {
if (nodeMonitoringTarget != NULL) {
TTracker::WatchNode(sourceModel.NodeRef(),
B_WATCH_DIRECTORY | B_WATCH_NAME | B_WATCH_STAT | B_WATCH_ATTR,
nodeMonitoringTarget);
@ -99,7 +98,7 @@ DesktopPoseView::InitDesktopDirentIterator(BPoseView* nodeMonitoringTarget,
if (result->Rewind() != B_OK) {
delete result;
if (nodeMonitoringTarget)
if (nodeMonitoringTarget != NULL)
nodeMonitoringTarget->HideBarberPole();
return NULL;

View File

@ -304,7 +304,7 @@ BInfoWindow::BInfoWindow(Model* model, int32 group_index,
TTracker::WatchNode(model->NodeRef(), B_WATCH_ALL | B_WATCH_MOUNT, this);
// window list is Locked by Tracker around this constructor
if (list)
if (list != NULL)
list->AddItem(this);
AddShortcut('E', 0, new BMessage(kEditItem));
@ -597,15 +597,15 @@ BInfoWindow::MessageReceived(BMessage* message)
case B_NODE_MONITOR:
switch (message->FindInt32("opcode")) {
case B_ENTRY_REMOVED:
{
node_ref itemNode;
message->FindInt32("device", &itemNode.device);
message->FindInt64("node", &itemNode.node);
// our window itself may be deleted
if (*TargetModel()->NodeRef() == itemNode)
Close();
break;
}
{
node_ref itemNode;
message->FindInt32("device", &itemNode.device);
message->FindInt64("node", &itemNode.node);
// our window itself may be deleted
if (*TargetModel()->NodeRef() == itemNode)
Close();
break;
}
case B_ENTRY_MOVED:
case B_STAT_CHANGED:
@ -640,11 +640,12 @@ BInfoWindow::MessageReceived(BMessage* message)
case kPermissionsSelected:
if (fPermissionsView == NULL) {
// Only true on first call.
fPermissionsView
= new FilePermissionsView(BRect(kBorderWidth + 1,
fAttributeView->Bounds().bottom,
fAttributeView->Bounds().right,
fAttributeView->Bounds().bottom+80), fModel);
fPermissionsView = new FilePermissionsView(
BRect(kBorderWidth + 1,
fAttributeView->Bounds().bottom,
fAttributeView->Bounds().right,
fAttributeView->Bounds().bottom + 80),
fModel);
ResizeBy(0, fPermissionsView->Bounds().Height());
fAttributeView->AddChild(fPermissionsView);
@ -1168,11 +1169,9 @@ AttributeView::ModelChanged(Model* model, BMessage* message)
if (message->FindString("attr", &attrName) == B_OK) {
if (strcmp(attrName, kAttrLargeIcon) == 0
|| strcmp(attrName, kAttrIcon) == 0) {
IconCache::sIconCache->IconChanged(model->ResolveIfLink());
Invalidate();
} else if (strcmp(attrName, kAttrMIMEType) == 0) {
if (model->OpenNode() == B_OK) {
model->AttrChanged(attrName);
InitStrings(model);

View File

@ -890,12 +890,12 @@ Model::WatchVolumeAndMountPoint(uint32 , BHandler* target)
BEntry mountPointEntry(bootMountPoint.String());
Model mountPointModel(&mountPointEntry);
TTracker::WatchNode(mountPointModel.NodeRef(), B_WATCH_NAME
| B_WATCH_STAT | B_WATCH_ATTR, target);
TTracker::WatchNode(mountPointModel.NodeRef(),
B_WATCH_NAME | B_WATCH_STAT | B_WATCH_ATTR, target);
}
return TTracker::WatchNode(NodeRef(), B_WATCH_NAME | B_WATCH_STAT
| B_WATCH_ATTR, target);
return TTracker::WatchNode(NodeRef(),
B_WATCH_NAME | B_WATCH_STAT | B_WATCH_ATTR, target);
}
@ -907,13 +907,13 @@ Model::AttrChanged(const char* attrName)
// return true if icon needs updating
ASSERT(IsNodeOpen());
if (attrName
if (attrName != NULL
&& (strcmp(attrName, kAttrIcon) == 0
|| strcmp(attrName, kAttrMiniIcon) == 0
|| strcmp(attrName, kAttrLargeIcon) == 0))
return true;
if (!attrName
if (attrName == NULL
|| strcmp(attrName, kAttrMIMEType) == 0
|| strcmp(attrName, kAttrPreferredApp) == 0) {
char mimeString[B_MIME_TYPE_LENGTH];
@ -923,24 +923,24 @@ Model::AttrChanged(const char* attrName)
else {
// node has a specific mime type
fMimeType = mimeString;
if (!IsVolume()
&& !IsSymLink()
&& info.GetPreferredApp(mimeString) == B_OK)
if (!IsVolume() && !IsSymLink()
&& info.GetPreferredApp(mimeString) == B_OK) {
SetPreferredAppSignature(mimeString);
}
}
#if xDEBUG
if (fIconFrom != kNode)
if (fIconFrom != kNode) {
PRINT(("%s, %s:updating icon because file type changed\n",
Name(), attrName ? attrName : ""));
else
PRINT(("not updating icon even thoug type changed "
"because icon from node\n"));
Name(), attrName != NULL ? attrName : ""));
} else {
PRINT(("Not updating icon even though type changed "
"because icon is from node.\n"));
}
#endif
return fIconFrom != kNode;
// update icon unless it is comming from a node
// update icon unless it is coming from a node
}
return attrName == NULL;

View File

@ -74,6 +74,7 @@ enum {
kModelSupportsFile
};
class Model {
public:
Model();
@ -482,9 +483,10 @@ Model::HasLocalizedName() const
inline
ModelNodeLazyOpener::ModelNodeLazyOpener(Model* model, bool writable,
bool openLater)
: fModel(model),
fWasOpen(model->IsNodeOpen()),
fWasOpenForWriting(model->IsNodeOpenForWriting())
:
fModel(model),
fWasOpen(model->IsNodeOpen()),
fWasOpenForWriting(model->IsNodeOpenForWriting())
{
if (!openLater)
OpenNode(writable);

View File

@ -77,7 +77,7 @@ public:
void DrawBar(BPoint where, BView* view, icon_size kind);
void DrawIcon(BPoint, BView*, icon_size, bool direct,
void DrawIcon(BPoint where, BView* view, icon_size kind, bool direct,
bool drawUnselected = false);
void DrawToggleSwitch(BRect, BPoseView*);
void MouseUp(BPoint poseLoc, BPoseView*, BPoint where, int32 index);
@ -166,13 +166,15 @@ BPose::TargetModel() const
inline Model*
BPose::ResolvedModel() const
{
return fModel->IsSymLink() ?
(fModel->LinkTo() ? fModel->LinkTo() : fModel) : fModel;
if (fModel->IsSymLink())
return fModel->LinkTo() != NULL ? fModel->LinkTo() : fModel;
else
return fModel;
}
inline bool
BPose::IsSelected() const
BPose::IsSelected() const
{
return fIsSelected;
}

View File

@ -5748,7 +5748,7 @@ BPoseView::AttributeChanged(const BMessage* message)
&& targetModel->IsNodeOpen()
&& targetModel->AttrChanged(attrName)) {
// the icon of our target has changed, update drag icon
// TODO: make this simpler (ie. store the icon with the window)
// TODO: make this simpler (i.e. store the icon with the window)
BView* view = Window()->FindView("MenuBar");
if (view != NULL) {
view = view->FindView("ThisContainer");
@ -5766,7 +5766,7 @@ BPoseView::AttributeChanged(const BMessage* message)
for (int i = 0; i < posesCount; i++) {
BPose* pose = posesFound->ItemAt(i);
Model* poseModel = pose->TargetModel();
if (poseModel->IsSymLink() && *poseModel->NodeRef() != itemNode) {
if (poseModel->IsSymLink() && *(poseModel->NodeRef()) != itemNode) {
// change happened on symlink's target
poseModel = poseModel->ResolveIfLink();
}