Tracker: Style fixes

* Style fixes to QueryContainerWindow.h
* Style fixes to ContainerWindow
* Style fixes to Model
* Style fixes to Tracker
* Style fixes to PoseView
  - Most of the changes come from unindenting the code
This commit is contained in:
John Scipione 2015-02-27 20:08:15 -05:00
parent f19ef17518
commit 7ef62fb6c2
6 changed files with 99 additions and 98 deletions

View File

@ -203,7 +203,7 @@ AddOneAddon(const Model* model, const char* name, uint32 shortcut,
static int32 static int32
AddOnThread(BMessage* refsMessage, entry_ref addonRef, entry_ref dirRef) AddOnThread(BMessage* refsMessage, entry_ref addonRef, entry_ref directoryRef)
{ {
std::auto_ptr<BMessage> refsMessagePtr(refsMessage); std::auto_ptr<BMessage> refsMessagePtr(refsMessage);
@ -222,7 +222,7 @@ AddOnThread(BMessage* refsMessage, entry_ref addonRef, entry_ref dirRef)
if (result >= 0) { if (result >= 0) {
// call add-on code // call add-on code
(*processRefs)(dirRef, refsMessagePtr.get(), 0); (*processRefs)(directoryRef, refsMessagePtr.get(), NULL);
unload_add_on(addonImage); unload_add_on(addonImage);
return B_OK; return B_OK;
@ -1664,7 +1664,7 @@ BContainerWindow::MessageReceived(BMessage* message)
// there is fMenuBar // there is fMenuBar
if (fMenuBar && fFileMenu) { if (fMenuBar && fFileMenu) {
item = fFileMenu->FindItem(kMoveToTrash); item = fFileMenu->FindItem(kMoveToTrash);
if (item) { if (item != NULL) {
item->SetLabel(dontMoveToTrash item->SetLabel(dontMoveToTrash
? B_TRANSLATE("Delete") ? B_TRANSLATE("Delete")
: B_TRANSLATE("Move to Trash")); : B_TRANSLATE("Move to Trash"));
@ -3213,12 +3213,11 @@ BContainerWindow::LoadAddOn(BMessage* message)
// add selected refs to message // add selected refs to message
BMessage* refs = new BMessage(B_REFS_RECEIVED); BMessage* refs = new BMessage(B_REFS_RECEIVED);
BObjectList<BPose>* selectionList = PoseView()->SelectionList();
BObjectList<BPose>* list = PoseView()->SelectionList();
int32 index = 0; int32 index = 0;
BPose* pose; BPose* pose;
while ((pose = list->ItemAt(index++)) != NULL) while ((pose = selectionList->ItemAt(index++)) != NULL)
refs->AddRef("refs", pose->TargetModel()->EntryRef()); refs->AddRef("refs", pose->TargetModel()->EntryRef());
refs->AddMessenger("TrackerViewToken", BMessenger(PoseView())); refs->AddMessenger("TrackerViewToken", BMessenger(PoseView()));

View File

@ -118,33 +118,33 @@ Model::Model()
} }
Model::Model(const Model &cloneThis) Model::Model(const Model& other)
: :
fEntryRef(cloneThis.fEntryRef), fEntryRef(other.fEntryRef),
fMimeType(cloneThis.fMimeType), fMimeType(other.fMimeType),
fPreferredAppName(NULL), fPreferredAppName(NULL),
fBaseType(cloneThis.fBaseType), fBaseType(other.fBaseType),
fIconFrom(cloneThis.fIconFrom), fIconFrom(other.fIconFrom),
fWritable(false), fWritable(false),
fNode(NULL), fNode(NULL),
fLocalizedName(cloneThis.fLocalizedName), fLocalizedName(other.fLocalizedName),
fHasLocalizedName(cloneThis.fHasLocalizedName), fHasLocalizedName(other.fHasLocalizedName),
fLocalizedNameIsCached(cloneThis.fLocalizedNameIsCached) fLocalizedNameIsCached(other.fLocalizedNameIsCached)
{ {
fStatBuf.st_dev = cloneThis.NodeRef()->device; fStatBuf.st_dev = other.NodeRef()->device;
fStatBuf.st_ino = cloneThis.NodeRef()->node; fStatBuf.st_ino = other.NodeRef()->node;
if (cloneThis.IsSymLink() && cloneThis.LinkTo()) if (other.IsSymLink() && other.LinkTo())
fLinkTo = new Model(*cloneThis.LinkTo()); fLinkTo = new Model(*other.LinkTo());
fStatus = OpenNode(cloneThis.IsNodeOpenForWriting()); fStatus = OpenNode(other.IsNodeOpenForWriting());
if (fStatus == B_OK) { if (fStatus == B_OK) {
ASSERT(fNode); ASSERT(fNode);
fNode->GetStat(&fStatBuf); fNode->GetStat(&fStatBuf);
ASSERT(fStatBuf.st_dev == cloneThis.NodeRef()->device); ASSERT(fStatBuf.st_dev == other.NodeRef()->device);
ASSERT(fStatBuf.st_ino == cloneThis.NodeRef()->node); ASSERT(fStatBuf.st_ino == other.NodeRef()->node);
} }
if (!cloneThis.IsNodeOpen()) if (!other.IsNodeOpen())
CloseNode(); CloseNode();
} }
@ -866,7 +866,7 @@ void
Model::UpdateEntryRef(const node_ref* dirNode, const char* name) Model::UpdateEntryRef(const node_ref* dirNode, const char* name)
{ {
if (IsVolume()) { if (IsVolume()) {
if (fVolumeName) if (fVolumeName != NULL)
DeletePreferredAppVolumeNameLinkTo(); DeletePreferredAppVolumeNameLinkTo();
fVolumeName = strdup(name); fVolumeName = strdup(name);
@ -875,7 +875,7 @@ Model::UpdateEntryRef(const node_ref* dirNode, const char* name)
fEntryRef.device = dirNode->device; fEntryRef.device = dirNode->device;
fEntryRef.directory = dirNode->node; fEntryRef.directory = dirNode->node;
if (fEntryRef.name && strcmp(fEntryRef.name, name) == 0) if (fEntryRef.name != NULL && strcmp(fEntryRef.name, name) == 0)
return; return;
fEntryRef.set_name(name); fEntryRef.set_name(name);
@ -887,7 +887,7 @@ Model::WatchVolumeAndMountPoint(uint32 , BHandler* target)
{ {
ASSERT(IsVolume()); ASSERT(IsVolume());
if (fEntryRef.name && fVolumeName if (fEntryRef.name != NULL && fVolumeName != NULL
&& strcmp(fEntryRef.name, "boot") == 0) { && strcmp(fEntryRef.name, "boot") == 0) {
// watch mount point for boot volume // watch mount point for boot volume
BString bootMountPoint("/"); BString bootMountPoint("/");

View File

@ -78,7 +78,7 @@ enum {
class Model { class Model {
public: public:
Model(); Model();
Model(const Model &); Model(const Model& other);
Model(const BEntry* entry, bool open = false, bool writable = false); Model(const BEntry* entry, bool open = false, bool writable = false);
Model(const entry_ref*, bool traverse = false, bool open = false, Model(const entry_ref*, bool traverse = false, bool open = false,
bool writable = false); bool writable = false);

View File

@ -8566,8 +8566,7 @@ BPoseView::ClearSelection()
fSelectionPivotPose = NULL; fSelectionPivotPose = NULL;
fRealPivotPose = NULL; fRealPivotPose = NULL;
if (fSelectionList->CountItems()) { if (fSelectionList->CountItems() > 0) {
// scan all visible poses first // scan all visible poses first
BRect bounds(Bounds()); BRect bounds(Bounds());
@ -8613,6 +8612,7 @@ BPoseView::ClearSelection()
fSelectionList->MakeEmpty(); fSelectionList->MakeEmpty();
} }
fMimeTypesInSelectionCache.MakeEmpty(); fMimeTypesInSelectionCache.MakeEmpty();
} }
@ -8625,7 +8625,8 @@ BPoseView::ShowSelection(bool show)
fSelectionVisible = show; fSelectionVisible = show;
if (fSelectionList->CountItems()) { if (fSelectionList->CountItems() <= 0)
return;
// scan all visible poses first // scan all visible poses first
BRect bounds(Bounds()); BRect bounds(Bounds());
@ -8689,10 +8690,10 @@ BPoseView::ShowSelection(bool show)
} else { } else {
if (fRealPivotPose) if (fRealPivotPose)
fSelectionPivotPose = fRealPivotPose; fSelectionPivotPose = fRealPivotPose;
fRealPivotPose = NULL; fRealPivotPose = NULL;
} }
} }
}
void void

View File

@ -50,7 +50,8 @@ class BQueryPoseView;
class BQueryContainerWindow : public BContainerWindow { class BQueryContainerWindow : public BContainerWindow {
public: public:
BQueryContainerWindow(LockingList<BWindow>* windowList, BQueryContainerWindow(
LockingList<BWindow>* windowList,
uint32 containerWindowFlags); uint32 containerWindowFlags);
BQueryPoseView* PoseView() const; BQueryPoseView* PoseView() const;

View File

@ -67,6 +67,7 @@ All rights reserved.
#include "ContainerWindow.h" #include "ContainerWindow.h"
#include "DeskWindow.h" #include "DeskWindow.h"
#include "FindPanel.h" #include "FindPanel.h"
#include "FunctionObject.h"
#include "FSClipboard.h" #include "FSClipboard.h"
#include "FSUtils.h" #include "FSUtils.h"
#include "InfoWindow.h" #include "InfoWindow.h"
@ -77,12 +78,11 @@ All rights reserved.
#include "PoseView.h" #include "PoseView.h"
#include "QueryContainerWindow.h" #include "QueryContainerWindow.h"
#include "StatusWindow.h" #include "StatusWindow.h"
#include "TrashWatcher.h"
#include "FunctionObject.h"
#include "TrackerSettings.h"
#include "TrackerSettingsWindow.h"
#include "TaskLoop.h" #include "TaskLoop.h"
#include "Thread.h" #include "Thread.h"
#include "TrackerSettings.h"
#include "TrackerSettingsWindow.h"
#include "TrashWatcher.h"
#include "VirtualDirectoryWindow.h" #include "VirtualDirectoryWindow.h"
@ -677,7 +677,6 @@ TTracker::MoveRefsToTrash(const BMessage* message)
BObjectList<entry_ref>* srcList = new BObjectList<entry_ref>(count, true); BObjectList<entry_ref>* srcList = new BObjectList<entry_ref>(count, true);
for (int32 index = 0; index < count; index++) { for (int32 index = 0; index < count; index++) {
entry_ref ref; entry_ref ref;
ASSERT(message->FindRef("refs", index, &ref) == B_OK); ASSERT(message->FindRef("refs", index, &ref) == B_OK);
if (message->FindRef("refs", index, &ref) != B_OK) if (message->FindRef("refs", index, &ref) != B_OK)
@ -685,14 +684,15 @@ TTracker::MoveRefsToTrash(const BMessage* message)
AutoLock<WindowList> lock(&fWindowList); AutoLock<WindowList> lock(&fWindowList);
BContainerWindow* window = FindParentContainerWindow(&ref); BContainerWindow* window = FindParentContainerWindow(&ref);
if (window) if (window != NULL) {
// if we have a window open for this entry, ask the pose to // if we have a window open for this entry, ask the pose to
// delete it, this will select the next entry // delete it, this will select the next entry
window->PoseView()->MoveEntryToTrash(&ref); window->PoseView()->MoveEntryToTrash(&ref);
else } else {
// add all others to a list that gets deleted separately // add all others to a list that gets deleted separately
srcList->AddItem(new entry_ref(ref)); srcList->AddItem(new entry_ref(ref));
} }
}
// async move to trash // async move to trash
FSMoveToTrash(srcList); FSMoveToTrash(srcList);
@ -817,7 +817,7 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose,
if (openAsContainer || selector == kRunOpenWithWindow) { if (openAsContainer || selector == kRunOpenWithWindow) {
// special case opening plain folders, queries or using open with // special case opening plain folders, queries or using open with
OpenContainerWindow(model, 0, selector, kRestoreDecor); OpenContainerWindow(model, NULL, selector, kRestoreDecor);
// window adopts model // window adopts model
if (nodeToClose) if (nodeToClose)
CloseParentWaitingForChildSoon(ref, nodeToClose); CloseParentWaitingForChildSoon(ref, nodeToClose);
@ -878,7 +878,7 @@ TTracker::RefsReceived(BMessage* message)
switch (selector) { switch (selector) {
case kRunOpenWithWindow: case kRunOpenWithWindow:
OpenContainerWindow(0, message, selector); OpenContainerWindow(NULL, message, selector);
// window adopts model // window adopts model
break; break;