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,72 +8625,73 @@ 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());
if (ViewMode() == kListMode) { if (ViewMode() == kListMode) {
int32 startIndex = (int32)(bounds.top / fListElemHeight); int32 startIndex = (int32)(bounds.top / fListElemHeight);
BPoint loc(0, startIndex * fListElemHeight); BPoint loc(0, startIndex * fListElemHeight);
PoseList* poseList = CurrentPoseList(); PoseList* poseList = CurrentPoseList();
int32 count = poseList->CountItems(); int32 count = poseList->CountItems();
for (int32 index = startIndex; index < count; index++) { for (int32 index = startIndex; index < count; index++) {
BPose* pose = poseList->ItemAt(index); BPose* pose = poseList->ItemAt(index);
if (fSelectionList->HasItem(pose))
if (pose->IsSelected() != show
|| fShowSelectionWhenInactive) {
if (!fShowSelectionWhenInactive)
pose->Select(show);
pose->Draw(BRect(pose->CalcRect(loc, this, false)),
bounds, this, false);
}
loc.y += fListElemHeight;
if (loc.y > bounds.bottom)
break;
}
} else {
int32 startIndex = FirstIndexAtOrBelow(
(int32)(bounds.top - IconPoseHeight()), true);
int32 count = fVSPoseList->CountItems();
for (int32 index = startIndex; index < count; index++) {
BPose* pose = fVSPoseList->ItemAt(index);
if (pose != NULL) {
if (fSelectionList->HasItem(pose)) if (fSelectionList->HasItem(pose))
if (pose->IsSelected() != show if (pose->IsSelected() != show
|| fShowSelectionWhenInactive) { || fShowSelectionWhenInactive) {
if (!fShowSelectionWhenInactive) if (!fShowSelectionWhenInactive)
pose->Select(show); pose->Select(show);
pose->Draw(BRect(pose->CalcRect(loc, this, false)), Invalidate(pose->CalcRect(this));
bounds, this, false);
} }
loc.y += fListElemHeight; if (pose->Location(this).y > bounds.bottom)
if (loc.y > bounds.bottom)
break; break;
} }
} else {
int32 startIndex = FirstIndexAtOrBelow(
(int32)(bounds.top - IconPoseHeight()), true);
int32 count = fVSPoseList->CountItems();
for (int32 index = startIndex; index < count; index++) {
BPose* pose = fVSPoseList->ItemAt(index);
if (pose != NULL) {
if (fSelectionList->HasItem(pose))
if (pose->IsSelected() != show
|| fShowSelectionWhenInactive) {
if (!fShowSelectionWhenInactive)
pose->Select(show);
Invalidate(pose->CalcRect(this));
}
if (pose->Location(this).y > bounds.bottom)
break;
}
}
} }
}
// now set all other poses // now set all other poses
int32 count = fSelectionList->CountItems(); int32 count = fSelectionList->CountItems();
for (int32 index = 0; index < count; index++) { for (int32 index = 0; index < count; index++) {
BPose* pose = fSelectionList->ItemAt(index); BPose* pose = fSelectionList->ItemAt(index);
if (pose->IsSelected() != show && !fShowSelectionWhenInactive) if (pose->IsSelected() != show && !fShowSelectionWhenInactive)
pose->Select(show); pose->Select(show);
} }
// finally update fRealPivotPose/fSelectionPivotPose // finally update fRealPivotPose/fSelectionPivotPose
if (!show) { if (!show) {
fRealPivotPose = fSelectionPivotPose; fRealPivotPose = fSelectionPivotPose;
fSelectionPivotPose = NULL; fSelectionPivotPose = NULL;
} else { } else {
if (fRealPivotPose) if (fRealPivotPose)
fSelectionPivotPose = fRealPivotPose; fSelectionPivotPose = fRealPivotPose;
fRealPivotPose = NULL;
} fRealPivotPose = NULL;
} }
} }

View File

@ -50,22 +50,23 @@ class BQueryPoseView;
class BQueryContainerWindow : public BContainerWindow { class BQueryContainerWindow : public BContainerWindow {
public: public:
BQueryContainerWindow(LockingList<BWindow>* windowList, BQueryContainerWindow(
uint32 containerWindowFlags); LockingList<BWindow>* windowList,
uint32 containerWindowFlags);
BQueryPoseView* PoseView() const; BQueryPoseView* PoseView() const;
bool ActiveOnDevice(dev_t) const; bool ActiveOnDevice(dev_t) const;
protected: protected:
virtual void CreatePoseView(Model*); virtual void CreatePoseView(Model*);
virtual BPoseView* NewPoseView(Model* model, uint32 viewMode); virtual BPoseView* NewPoseView(Model* model, uint32 viewMode);
virtual void AddWindowMenu(BMenu* menu); virtual void AddWindowMenu(BMenu* menu);
virtual void AddWindowContextMenus(BMenu* menu); virtual void AddWindowContextMenus(BMenu* menu);
virtual void SetUpDefaultState(); virtual void SetUpDefaultState();
private: private:
typedef BContainerWindow _inherited; typedef BContainerWindow _inherited;
}; };
} // namespace BPrivate } // namespace BPrivate

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"
@ -631,7 +631,7 @@ TTracker::Pulse()
void void
TTracker::SetDefaultPrinter(const BMessage* message) TTracker::SetDefaultPrinter(const BMessage* message)
{ {
// get the first item selected // get the first item selected
int32 count = 0; int32 count = 0;
uint32 type = 0; uint32 type = 0;
message->GetInfo("refs", &type, &count); message->GetInfo("refs", &type, &count);
@ -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,13 +684,14 @@ 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
@ -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;