hrev44421 adds 2 changesets to branch 'master' old head: 0d47dc5dd23f53a6bbd999b44b010d68229a4f83 new head: ea001e585a588e40404945a1201821da893d2e09 ---------------------------------------------------------------------------- a51764c: WIP: Yet more style fixes, mostly 80 char violations. ea001e5: Round 2 of style changes to Tracker * focused on 80-char limit fixes. * also some whitespace and case statement indentation fixes [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 91 files changed, 3005 insertions(+), 2021 deletions(-) src/kits/tracker/AttributeStream.cpp | 47 +- src/kits/tracker/AttributeStream.h | 74 +-- src/kits/tracker/AutoMounterSettings.cpp | 4 +- src/kits/tracker/Background.h | 24 +- src/kits/tracker/BackgroundImage.cpp | 31 +- src/kits/tracker/BackgroundImage.h | 6 +- src/kits/tracker/Bitmaps.cpp | 25 +- src/kits/tracker/ContainerWindow.cpp | 375 ++++++++----- src/kits/tracker/ContainerWindow.h | 24 +- src/kits/tracker/CountView.cpp | 12 +- src/kits/tracker/DeskWindow.cpp | 17 +- src/kits/tracker/DeskWindow.h | 7 +- src/kits/tracker/DesktopPoseView.cpp | 30 +- src/kits/tracker/DirMenu.cpp | 25 +- src/kits/tracker/DirMenu.h | 5 +- src/kits/tracker/EntryIterator.cpp | 7 +- src/kits/tracker/EntryIterator.h | 4 +- src/kits/tracker/FSClipboard.cpp | 65 ++- src/kits/tracker/FSClipboard.h | 8 +- src/kits/tracker/FSUndoRedo.cpp | 39 +- src/kits/tracker/FSUtils.cpp | 140 +++-- src/kits/tracker/FSUtils.h | 81 +-- src/kits/tracker/FavoritesMenu.cpp | 17 +- src/kits/tracker/FavoritesMenu.h | 3 +- src/kits/tracker/FilePanelPriv.cpp | 142 +++-- src/kits/tracker/FilePanelPriv.h | 6 +- src/kits/tracker/FilePermissionsView.cpp | 111 ++-- src/kits/tracker/FindPanel.cpp | 706 +++++++++++++----------- src/kits/tracker/FindPanel.h | 21 +- src/kits/tracker/FunctionObject.h | 55 +- src/kits/tracker/GroupedMenu.cpp | 14 +- src/kits/tracker/GroupedMenu.h | 3 +- src/kits/tracker/IconCache.cpp | 194 ++++--- src/kits/tracker/IconCache.h | 84 +-- src/kits/tracker/IconMenuItem.h | 15 +- src/kits/tracker/InfoWindow.cpp | 264 +++++---- src/kits/tracker/InfoWindow.h | 6 +- src/kits/tracker/MimeTypeList.cpp | 5 +- src/kits/tracker/Model.cpp | 88 +-- src/kits/tracker/Model.h | 38 +- src/kits/tracker/Navigator.cpp | 60 +- src/kits/tracker/OpenWithWindow.cpp | 23 +- src/kits/tracker/OpenWithWindow.h | 59 +- src/kits/tracker/OverrideAlert.cpp | 11 +- src/kits/tracker/Pose.cpp | 91 +-- src/kits/tracker/Pose.h | 12 +- src/kits/tracker/PoseList.h | 37 +- src/kits/tracker/PoseView.cpp | 82 +-- src/kits/tracker/PoseView.h | 231 +++++--- src/kits/tracker/PoseViewScripting.cpp | 88 +-- src/kits/tracker/PublicCommands.h | 9 +- src/kits/tracker/QueryContainerWindow.cpp | 14 +- src/kits/tracker/QueryPoseView.cpp | 65 ++- src/kits/tracker/QueryPoseView.h | 6 +- src/kits/tracker/RecentItems.cpp | 11 +- src/kits/tracker/RecentItems.h | 15 +- src/kits/tracker/RegExp.cpp | 116 ++-- src/kits/tracker/SelectionWindow.cpp | 44 +- src/kits/tracker/Settings.cpp | 11 +- src/kits/tracker/Settings.h | 10 +- src/kits/tracker/SettingsHandler.cpp | 15 +- src/kits/tracker/SettingsHandler.h | 6 +- src/kits/tracker/SettingsViews.cpp | 70 ++- src/kits/tracker/SlowContextPopup.cpp | 47 +- src/kits/tracker/SlowContextPopup.h | 5 +- src/kits/tracker/SlowMenu.h | 3 +- src/kits/tracker/StatusWindow.cpp | 41 +- src/kits/tracker/TaskLoop.cpp | 33 +- src/kits/tracker/TaskLoop.h | 10 +- src/kits/tracker/TemplatesMenu.cpp | 3 +- src/kits/tracker/Tests.cpp | 18 +- src/kits/tracker/TextWidget.cpp | 37 +- src/kits/tracker/TextWidget.h | 6 +- src/kits/tracker/Thread.cpp | 6 +- src/kits/tracker/Thread.h | 27 +- src/kits/tracker/TitleView.cpp | 79 ++- src/kits/tracker/Tracker.cpp | 187 ++++--- src/kits/tracker/Tracker.h | 24 +- src/kits/tracker/TrackerInitialState.cpp | 221 ++++---- src/kits/tracker/TrackerScripting.cpp | 21 +- src/kits/tracker/TrackerSettings.cpp | 68 ++- src/kits/tracker/TrackerSettingsWindow.cpp | 21 +- src/kits/tracker/TrackerString.cpp | 138 +++-- src/kits/tracker/TrackerString.h | 3 +- src/kits/tracker/TrashWatcher.cpp | 18 +- src/kits/tracker/Utilities.cpp | 12 +- src/kits/tracker/Utilities.h | 32 +- src/kits/tracker/ViewState.h | 3 +- src/kits/tracker/VolumeWindow.cpp | 6 +- src/kits/tracker/WidgetAttributeText.cpp | 38 +- src/kits/tracker/WidgetAttributeText.h | 11 +- ############################################################################ Commit: a51764c53eecd8ca5f6312b92d8baccda89d5b1d URL: http://cgit.haiku-os.org/haiku/commit/?id=a51764c Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jul 28 03:12:08 2012 UTC WIP: Yet more style fixes, mostly 80 char violations. ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/AttributeStream.cpp b/src/kits/tracker/AttributeStream.cpp index 47a8ce0..e315b52 100644 --- a/src/kits/tracker/AttributeStream.cpp +++ b/src/kits/tracker/AttributeStream.cpp @@ -156,8 +156,8 @@ AttributeStreamNode::Contains(const char* name, uint32 type) off_t -AttributeStreamNode::Read(const char* name, const char* foreignName, uint32 type, - off_t size, void* buffer, void (*swapFunc)(void*)) +AttributeStreamNode::Read(const char* name, const char* foreignName, + uint32 type, off_t size, void* buffer, void (*swapFunc)(void*)) { if (!fReadFrom) return 0; @@ -288,8 +288,8 @@ AttributeStreamFileNode::Contains(const char* name, uint32 type) off_t -AttributeStreamFileNode::Read(const char* name, const char* foreignName, uint32 type, - off_t size, void* buffer, void (*swapFunc)(void*)) +AttributeStreamFileNode::Read(const char* name, const char* foreignName, + uint32 type, off_t size, void* buffer, void (*swapFunc)(void*)) { if (name && fNode->ReadAttr(name, type, 0, buffer, (size_t)size) == size) return size; @@ -306,8 +306,8 @@ AttributeStreamFileNode::Read(const char* name, const char* foreignName, uint32 off_t -AttributeStreamFileNode::Write(const char* name, const char* foreignName, uint32 type, - off_t size, const void* buffer) +AttributeStreamFileNode::Write(const char* name, const char* foreignName, + uint32 type, off_t size, const void* buffer) { ASSERT(fNode); ASSERT(dynamic_cast<BNode*>(fNode)); @@ -659,8 +659,8 @@ AttributeStreamFilterNode::Contains(const char* name, uint32 type) off_t -AttributeStreamFilterNode::Read(const char* name, const char* foreignName, uint32 type, - off_t size, void* buffer, void (*swapFunc)(void*)) +AttributeStreamFilterNode::Read(const char* name, const char* foreignName, + uint32 type, off_t size, void* buffer, void (*swapFunc)(void*)) { if (!fReadFrom) return 0; @@ -673,8 +673,8 @@ AttributeStreamFilterNode::Read(const char* name, const char* foreignName, uint3 off_t -AttributeStreamFilterNode::Write(const char* name, const char* foreignName, uint32 type, - off_t size, const void* buffer) +AttributeStreamFilterNode::Write(const char* name, const char* foreignName, + uint32 type, off_t size, const void* buffer) { if (!fWriteTo) return 0; @@ -693,7 +693,7 @@ NamesToAcceptAttrFilter::NamesToAcceptAttrFilter(const char** nameList) bool -NamesToAcceptAttrFilter::Reject(const char* name, uint32 , off_t ) +NamesToAcceptAttrFilter::Reject(const char* name, uint32, off_t) { for (int32 index = 0; ;index++) { if (!fNameList[index]) diff --git a/src/kits/tracker/AttributeStream.h b/src/kits/tracker/AttributeStream.h index 0102ba8..eb37452 100644 --- a/src/kits/tracker/AttributeStream.h +++ b/src/kits/tracker/AttributeStream.h @@ -114,11 +114,11 @@ public: virtual off_t Contains(const char*, uint32); // returns size of attribute if found - virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, - void* buffer, void (*swapFunc)(void*) = 0); + virtual off_t Read(const char* name, const char* foreignName, + uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0); // read from this node - virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, - const void* buffer); + virtual off_t Write(const char* name, const char* foreignName, + uint32 type, off_t size, const void* buffer); // write to this node // work calls @@ -307,22 +307,25 @@ private: class SelectiveAttributeTransformer : public AttributeStreamNode { // node applies a transformation on specified attributes public: - SelectiveAttributeTransformer(const char* attributeName, bool (*)(const char*, - uint32 , off_t , void*, void*), void* params); + SelectiveAttributeTransformer(const char* attributeName, + bool (*)(const char*, uint32 , off_t , void*, void*), void* params); virtual ~SelectiveAttributeTransformer(); - virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, - void* buffer, void (*swapFunc)(void*) = 0); + virtual off_t Read(const char* name, const char* foreignName, uint32 type, + off_t size, void* buffer, void (*swapFunc)(void*) = 0); virtual void Rewind(); protected: - virtual bool WillTransform(const char* name, uint32 type, off_t size, const char* data) const; + virtual bool WillTransform(const char* name, uint32 type, off_t size, + const char* data) const; // override to implement filtering; should only return true if transformation will // occur - virtual char* CopyAndApplyTransformer(const char* name, uint32 type, off_t size, const char* data); + virtual char* CopyAndApplyTransformer(const char* name, uint32 type, + off_t size, const char* data); // makes a copy of data - virtual bool ApplyTransformer(const char* name, uint32 type, off_t size, char* data); + virtual bool ApplyTransformer(const char* name, uint32 type, off_t size, + char* data); // transforms in place virtual const AttributeInfo* Next(); virtual const char* Get(); @@ -342,7 +345,8 @@ private: template <class Type> class AttributeStreamConstValue : public AttributeStreamNode { public: - AttributeStreamConstValue(const char* name, uint32 attributeType, Type value); + AttributeStreamConstValue(const char* name, uint32 attributeType, + Type value); protected: virtual bool CanFeed() const { return true; } diff --git a/src/kits/tracker/Background.h b/src/kits/tracker/Background.h index b850313..58e4b63 100644 --- a/src/kits/tracker/Background.h +++ b/src/kits/tracker/Background.h @@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - #ifndef _TRACKER_BACKGROUND_H #define _TRACKER_BACKGROUND_H + #include <SupportDefs.h> /*----------------------------------------------------------------*/ @@ -45,12 +45,18 @@ All rights reserved. /*----------------------------------------------------------------*/ /*----- Tracker background BMessage entries --------------------*/ -#define B_BACKGROUND_IMAGE "be:bgndimginfopath" // string path -#define B_BACKGROUND_MODE "be:bgndimginfomode" // int32, the enum below -#define B_BACKGROUND_ORIGIN "be:bgndimginfooffset" // BPoint -#define B_BACKGROUND_TEXT_OUTLINE "be:bgndimginfoerasetext" // bool - // NOTE: the actual attribute name is kept for backwards compatible settings -#define B_BACKGROUND_WORKSPACES "be:bgndimginfoworkspaces" // uint32 +#define B_BACKGROUND_IMAGE "be:bgndimginfopath" + // string path +#define B_BACKGROUND_MODE "be:bgndimginfomode" + // int32, the enum below +#define B_BACKGROUND_ORIGIN "be:bgndimginfooffset" + // BPoint +#define B_BACKGROUND_TEXT_OUTLINE "be:bgndimginfoerasetext" + // bool + // NOTE: the actual attribute name is kept for backwards + // compatible settings +#define B_BACKGROUND_WORKSPACES "be:bgndimginfoworkspaces" + // uint32 /*----------------------------------------------------------------*/ /*----- Background mode values ---------------------------------*/ @@ -65,7 +71,7 @@ enum { /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ -const int32 B_RESTORE_BACKGROUND_IMAGE = 'Tbgr'; // force a Tracker window to - // use a new background image +const int32 B_RESTORE_BACKGROUND_IMAGE = 'Tbgr'; + // force a Tracker window to use a new background image #endif // _TRACKER_BACKGROUND_H diff --git a/src/kits/tracker/BackgroundImage.cpp b/src/kits/tracker/BackgroundImage.cpp index f12d110..2007875 100644 --- a/src/kits/tracker/BackgroundImage.cpp +++ b/src/kits/tracker/BackgroundImage.cpp @@ -71,7 +71,7 @@ BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop) return NULL; BMessage container; - char* buffer = new char [info.size]; + char* buffer = new char[info.size]; status_t error = node->ReadAttr(kBackgroundImageInfo, info.type, 0, buffer, (size_t)info.size); if (error == info.size) @@ -104,14 +104,16 @@ BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop) be_control_look->SetBackgroundInfo(container); } - container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32*)&workspaces); + container.FindInt32(kBackgroundImageInfoWorkspaces, index, + (int32*)&workspaces); container.FindInt32(kBackgroundImageInfoMode, index, (int32*)&mode); - container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline); + container.FindBool(kBackgroundImageInfoTextOutline, index, + &textWidgetLabelOutline); container.FindPoint(kBackgroundImageInfoOffset, index, &offset); BackgroundImage::BackgroundImageInfo* imageInfo = new - BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode, offset, - textWidgetLabelOutline); + BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode, + offset, textWidgetLabelOutline); if (!result) result = new BackgroundImage(node, isDesktop); diff --git a/src/kits/tracker/Bitmaps.cpp b/src/kits/tracker/Bitmaps.cpp index 2f4f68c..a148342 100644 --- a/src/kits/tracker/Bitmaps.cpp +++ b/src/kits/tracker/Bitmaps.cpp @@ -104,7 +104,8 @@ BImageResources::FinishResources(BResources* res) const const void* -BImageResources::LoadResource(type_code type, int32 id, size_t* out_size) const +BImageResources::LoadResource(type_code type, int32 id, + size_t* out_size) const { // Serialize execution. // Looks like BResources is not really thread safe. We should @@ -116,12 +117,14 @@ BImageResources::LoadResource(type_code type, int32 id, size_t* out_size) const // Return the resource. Because we never change the BResources // object, the returned data will not change until TTracker is // destroyed. - return const_cast<BResources*>(&fResources)->LoadResource(type, id, out_size); + return const_cast<BResources*>(&fResources)->LoadResource(type, id, + out_size); } const void* -BImageResources::LoadResource(type_code type, const char* name, size_t* out_size) const +BImageResources::LoadResource(type_code type, const char* name, + size_t* out_size) const { // Serialize execution. BAutolock lock(fLock); @@ -131,12 +134,14 @@ BImageResources::LoadResource(type_code type, const char* name, size_t* out_size // Return the resource. Because we never change the BResources // object, the returned data will not change until TTracker is // destroyed. - return const_cast<BResources*>(&fResources)->LoadResource(type, name, out_size); + return const_cast<BResources*>(&fResources)->LoadResource(type, name, + out_size); } status_t -BImageResources::GetIconResource(int32 id, icon_size size, BBitmap* dest) const +BImageResources::GetIconResource(int32 id, icon_size size, + BBitmap* dest) const { size_t length = 0; const void* data; @@ -144,8 +149,10 @@ BImageResources::GetIconResource(int32 id, icon_size size, BBitmap* dest) const #ifdef __HAIKU__ // try to load vector icon data = LoadResource(B_VECTOR_ICON_TYPE, id, &length); - if (data != NULL && BIconUtils::GetVectorIcon((uint8*)data, length, dest) == B_OK) + if (data != NULL + && BIconUtils::GetVectorIcon((uint8*)data, length, dest) == B_OK) { return B_OK; + } #endif // fall back to R5 icon @@ -155,7 +162,8 @@ BImageResources::GetIconResource(int32 id, icon_size size, BBitmap* dest) const length = 0; data = LoadResource(size == B_LARGE_ICON ? 'ICON' : 'MICN', id, &length); - if (data == NULL || length != (size_t)(size == B_LARGE_ICON ? 1024 : 256)) { + if (data == NULL + || length != (size_t)(size == B_LARGE_ICON ? 1024 : 256)) { TRESPASS(); return B_ERROR; } @@ -212,7 +220,8 @@ BImageResources::find_image(void* memAddr) const status_t -BImageResources::GetBitmapResource(type_code type, int32 id, BBitmap** out) const +BImageResources::GetBitmapResource(type_code type, int32 id, + BBitmap** out) const { *out = NULL; diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index 34d9b28..4117d85 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -110,12 +110,14 @@ namespace BPrivate { class DraggableContainerIcon : public BView { public: - DraggableContainerIcon(BRect rect, const char* name, uint32 resizeMask); + DraggableContainerIcon(BRect rect, const char* name, + uint32 resizeMask); 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 MouseMoved(BPoint point, uint32 /*transit*/, + const BMessage* message); virtual void FrameMoved(BPoint newLocation); virtual void Draw(BRect updateRect); @@ -215,7 +217,8 @@ CompareLabels(const BMenuItem* item1, const BMenuItem* item2) static bool -AddOneAddon(const Model* model, const char* name, uint32 shortcut, bool primary, void* context) +AddOneAddon(const Model* model, const char* name, uint32 shortcut, + bool primary, void* context) { AddOneAddonParams* params = (AddOneAddonParams*)context; @@ -249,14 +252,16 @@ AddOnThread(BMessage* refsMessage, entry_ref addonRef, entry_ref dirRef) image_id addonImage = load_add_on(path.Path()); if (addonImage >= 0) { void (*processRefs)(entry_ref, BMessage*, void*); - result = get_image_symbol(addonImage, "process_refs", 2, (void**)&processRefs); + result = get_image_symbol(addonImage, "process_refs", 2, + (void**)&processRefs); #ifndef __INTEL__ if (result < 0) { PRINT(("trying old legacy ppc signature\n")); // try old-style addon signature result = get_image_symbol(addonImage, - "process_refs__F9entry_refP8BMessagePv", 2, (void**)&processRefs); + "process_refs__F9entry_refP8BMessagePv", 2, + (void**)&processRefs); } #endif @@ -279,8 +284,8 @@ AddOnThread(BMessage* refsMessage, entry_ref addonRef, entry_ref dirRef) buffer.ReplaceFirst("%error", strerror(result)); buffer.ReplaceFirst("%name", addonRef.name); - BAlert* alert = new BAlert("", buffer.String(), B_TRANSLATE("Cancel"), 0, 0, - B_WIDTH_AS_USUAL, B_WARNING_ALERT); + BAlert* alert = new BAlert("", buffer.String(), B_TRANSLATE("Cancel"), + 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); @@ -946,10 +951,12 @@ BContainerWindow::Init(const BMessage* message) float iconSize = fMenuBar->Bounds().Height() - 2; if (iconSize < 16) iconSize = 16; - float iconPosY = 1 + (fMenuBar->Bounds().Height() - 2 - iconSize) / 2; - BView* icon = new DraggableContainerIcon(BRect(Bounds().Width() - 4 - iconSize + 1, - iconPosY, Bounds().Width() - 4, iconPosY + iconSize - 1), - "ThisContainer", B_FOLLOW_RIGHT); + float iconPosY = 1 + (fMenuBar->Bounds().Height() - 2 + - iconSize) / 2; + BView* icon = new DraggableContainerIcon(BRect(Bounds().Width() + - 4 - iconSize + 1, iconPosY, Bounds().Width() - 4, + iconPosY + iconSize - 1), "ThisContainer", + B_FOLLOW_RIGHT); fMenuBar->AddChild(icon); } } else { @@ -958,11 +965,12 @@ BContainerWindow::Init(const BMessage* message) } AddContextMenus(); - AddShortcut('T', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kDelete), PoseView()); + AddShortcut('T', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kDelete), + PoseView()); AddShortcut('K', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kCleanupAll), PoseView()); - AddShortcut('Q', B_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY | B_CONTROL_KEY, - new BMessage(kQuitTracker)); + AddShortcut('Q', B_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY + | B_CONTROL_KEY, new BMessage(kQuitTracker)); AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, new BMessage(kOpenSelection), PoseView()); @@ -971,9 +979,12 @@ BContainerWindow::Init(const BMessage* message) #if DEBUG // add some debugging shortcuts - AddShortcut('D', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dbug'), PoseView()); - AddShortcut('C', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpcc'), PoseView()); - AddShortcut('F', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpfl'), PoseView()); + AddShortcut('D', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dbug'), + PoseView()); + AddShortcut('C', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpcc'), + PoseView()); + AddShortcut('F', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpfl'), + PoseView()); AddShortcut('F', B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY, new BMessage('dpfL'), PoseView()); #endif @@ -1007,7 +1018,8 @@ BContainerWindow::Init(const BMessage* message) void BContainerWindow::RestoreState() { - SetSizeLimits(kContainerWidthMinLimit, 10000, kContainerWindowHeightLimit, 10000); + SetSizeLimits(kContainerWidthMinLimit, 10000, + kContainerWindowHeightLimit, 10000); UpdateTitle(); @@ -1022,7 +1034,8 @@ BContainerWindow::RestoreState() void BContainerWindow::RestoreState(const BMessage &message) { - SetSizeLimits(kContainerWidthMinLimit, 10000, kContainerWindowHeightLimit, 10000); + SetSizeLimits(kContainerWidthMinLimit, 10000, + kContainerWindowHeightLimit, 10000); UpdateTitle(); @@ -1057,7 +1070,8 @@ BContainerWindow::RestoreStateCommon() if (!fBackgroundImage && !isDesktop && DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) // look for background image info in the source for defaults - fBackgroundImage = BackgroundImage::GetBackgroundImage(&defaultingNode, isDesktop); + fBackgroundImage + = BackgroundImage::GetBackgroundImage(&defaultingNode, isDesktop); } @@ -1075,7 +1089,8 @@ BContainerWindow::UpdateTitle() SetTitle(TargetModel()->Name()); if (Navigator()) - Navigator()->UpdateLocation(PoseView()->TargetModel(), kActionUpdatePath); + Navigator()->UpdateLocation(PoseView()->TargetModel(), + kActionUpdatePath); } @@ -1121,7 +1136,8 @@ BContainerWindow::FrameResized(float, float) if (offsetY < 0 && PoseView()->Bounds().bottom > extent.bottom && Bounds().Height() > fPreviousBounds.Height()) scroll.y - = max_c(fPreviousBounds.Height() - Bounds().Height(), offsetY); + = max_c(fPreviousBounds.Height() - Bounds().Height(), + offsetY); if (scroll != B_ORIGIN) PoseView()->ScrollBy(scroll.x, scroll.y); @@ -1154,7 +1170,8 @@ BContainerWindow::ViewModeChanged(uint32 oldMode, uint32 newMode) { BView* view = FindView("MenuBar"); if (view != NULL) { - // make sure the draggable icon hides if it doesn't have space left anymore + // make sure the draggable icon hides if it doesn't + // have space left anymore view = view->FindView("ThisContainer"); if (view != NULL) view->FrameMoved(view->Frame().LeftTop()); @@ -1248,8 +1265,10 @@ BContainerWindow::GetLayoutState(BNode* node, BMessage* message) continue; char* buffer = new char[info.size]; - if (node->ReadAttr(attrName, info.type, 0, buffer, (size_t)info.size) == info.size) + if (node->ReadAttr(attrName, info.type, 0, buffer, + (size_t)info.size) == info.size) { message->AddData(attrName, info.type, buffer, (ssize_t)info.size); + } delete [] buffer; } return B_OK; diff --git a/src/kits/tracker/DesktopPoseView.cpp b/src/kits/tracker/DesktopPoseView.cpp index ad9bedf..708be1e 100644 --- a/src/kits/tracker/DesktopPoseView.cpp +++ b/src/kits/tracker/DesktopPoseView.cpp @@ -241,7 +241,8 @@ DesktopPoseView::AdaptToVolumeChange(BMessage* message) entryMessage.AddInt32("opcode", B_ENTRY_REMOVED); entry_ref ref; if (entry.GetRef(&ref) == B_OK) { - BContainerWindow* disksWindow = tracker->FindContainerWindow(&ref); + BContainerWindow* disksWindow + = tracker->FindContainerWindow(&ref); if (disksWindow) { disksWindow->Lock(); disksWindow->Close(); @@ -252,7 +253,8 @@ DesktopPoseView::AdaptToVolumeChange(BMessage* message) entryMessage.AddInt64("node", model.NodeRef()->node); entryMessage.AddInt64("directory", model.EntryRef()->directory); entryMessage.AddString("name", model.EntryRef()->name); - BContainerWindow* deskWindow = dynamic_cast<BContainerWindow*>(Window()); + BContainerWindow* deskWindow + = dynamic_cast<BContainerWindow*>(Window()); if (deskWindow) deskWindow->PostMessage(&entryMessage, deskWindow->PoseView()); } diff --git a/src/kits/tracker/FSClipboard.cpp b/src/kits/tracker/FSClipboard.cpp index f20f7b1..8b8793c 100644 --- a/src/kits/tracker/FSClipboard.cpp +++ b/src/kits/tracker/FSClipboard.cpp @@ -195,8 +195,8 @@ FSClipboardClear() */ uint32 -FSClipboardAddPoses(const node_ref* directory, PoseList* list, uint32 moveMode, - bool clearClipboard) +FSClipboardAddPoses(const node_ref* directory, PoseList* list, + uint32 moveMode, bool clearClipboard) { uint32 refsAdded = 0; int32 listCount = list->CountItems(); @@ -409,13 +409,16 @@ FSClipboardPaste(Model* model, uint32 linksMode) // we need this data later on MakeModeNameFromRefName(modeName, refName); - if (!linksMode && clip->FindInt32(modeName, (int32*)&moveMode) != B_OK) + if (!linksMode && clip->FindInt32(modeName, (int32*)&moveMode) + != B_OK) { continue; + } BEntry entry(&ref); uint32 newMoveMode = 0; - bool sameDirectory = destNodeRef->device == ref.device && destNodeRef->node == ref.directory; + bool sameDirectory = destNodeRef->device == ref.device + && destNodeRef->node == ref.directory; if (!entry.Exists()) { // The entry doesn't exist anymore, so we'll remove @@ -435,9 +438,10 @@ FSClipboardPaste(Model* model, uint32 linksMode) copyList->AddItem(new entry_ref(ref)); } - // if the entry should have been removed from its directory, - // we want to copy that entry next time, no matter if the - // items don't have to be moved at all (source == target) + // if the entry should have been removed from its + // directory, we want to copy that entry next time, no + // matter if the items don't have to be moved at all + // (source == target) if (moveMode == kMoveSelectionTo) newMoveMode = kCopySelectionTo; } @@ -449,8 +453,8 @@ FSClipboardPaste(Model* model, uint32 linksMode) TClipboardNodeRef clipNode; MakeNodeFromName(&clipNode.node, modeName); clipNode.moveMode = kDelete; - updateMessage->AddData("tcnode", T_CLIPBOARD_NODE, &clipNode, - sizeof(TClipboardNodeRef), true); + updateMessage->AddData("tcnode", T_CLIPBOARD_NODE, + &clipNode, sizeof(TClipboardNodeRef), true); } } be_clipboard->Commit(); @@ -470,7 +474,7 @@ FSClipboardPaste(Model* model, uint32 linksMode) if (model->IsRoot()) { BAlert* alert = new BAlert("", B_TRANSLATE("You must drop items on one of the disk icons " - "in the \"Disks\" window."), B_TRANSLATE("Cancel"), NULL, NULL, + "in the \"Disks\" window."), B_TRANSLATE("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); @@ -499,9 +503,10 @@ FSClipboardPaste(Model* model, uint32 linksMode) } // asynchronous calls take over ownership of the objects passed to it - if (moveList->CountItems() > 0) - FSMoveToFolder(moveList, new BEntry(entry), linksMode ? linksMode : kMoveSelectionTo); - else + if (moveList->CountItems() > 0) { + FSMoveToFolder(moveList, new BEntry(entry), + linksMode ? linksMode : kMoveSelectionTo); + } else delete moveList; if (copyList->CountItems() > 0) @@ -761,7 +766,8 @@ BClipboardRefsWatcher::Clear() //void -//BClipboardRefsWatcher::UpdatePoseViews(bool clearClipboard, const node_ref* node) +//BClipboardRefsWatcher::UpdatePoseViews(bool clearClipboard, +// const node_ref* node) //{ // BMessage message(kFSClipboardChanges); // message.AddInt32("device", node->device); diff --git a/src/kits/tracker/FSClipboard.h b/src/kits/tracker/FSClipboard.h index acb4012..01a8893 100644 --- a/src/kits/tracker/FSClipboard.h +++ b/src/kits/tracker/FSClipboard.h @@ -67,7 +67,7 @@ class BClipboardRefsWatcher : public BLooper { void UpdatePoseViews(BMessage* reportMessage); protected: - virtual void MessageReceived(BMessage*); + virtual void MessageReceived(BMessage*); private: bool fRefsInClipboard; @@ -87,10 +87,12 @@ void FSClipboardStartWatch(BMessenger target); void FSClipboardStopWatch(BMessenger target); void FSClipboardClear(); -uint32 FSClipboardAddPoses(const node_ref* directory, PoseList* list, uint32 moveMode, bool clearClipboard); +uint32 FSClipboardAddPoses(const node_ref* directory, PoseList* list, + uint32 moveMode, bool clearClipboard); uint32 FSClipboardRemovePoses(const node_ref* directory, PoseList* list); bool FSClipboardPaste(Model* model, uint32 linksMode = 0); void FSClipboardRemove(Model* model); -uint32 FSClipboardFindNodeMode(Model* model, bool autoLock, bool updateRefIfNeeded); +uint32 FSClipboardFindNodeMode(Model* model, bool autoLock, + bool updateRefIfNeeded); #endif // FS_CLIPBOARD_H diff --git a/src/kits/tracker/FSUndoRedo.cpp b/src/kits/tracker/FSUndoRedo.cpp index cf6f895..b2b3c2c 100644 --- a/src/kits/tracker/FSUndoRedo.cpp +++ b/src/kits/tracker/FSUndoRedo.cpp @@ -50,7 +50,8 @@ class UndoItemMove : public UndoItem { /** source - list of file(s) that were moved. Assumes ownership. * origfolder - location it was moved from */ - UndoItemMove(BObjectList<entry_ref>* sourceList, BDirectory &target, BList* pointList); + UndoItemMove(BObjectList<entry_ref>* sourceList, BDirectory &target, + BList* pointList); virtual ~UndoItemMove(); virtual status_t Undo(); @@ -72,10 +73,12 @@ class UndoItemFolder : public UndoItem { virtual status_t Redo(); private: - /* this ref has two different meanings in the different states of this object: - - Undo() - fRef indicates the folder that was created via FSCreateNewFolderIn(...) - - Redo() - fRef indicates the folder in which FSCreateNewFolderIn() should be performed - */ + // this ref has two different meanings in the different states of + // this object: + // - Undo() - fRef indicates the folder that was created via + // FSCreateNewFolderIn(...) + // - Redo() - fRef indicates the folder in which + // FSCreateNewFolderIn() should be performed entry_ref fRef; }; @@ -169,8 +172,8 @@ Undo::Remove() } -MoveCopyUndo::MoveCopyUndo(BObjectList<entry_ref>* sourceList, BDirectory &dest, - BList* pointList, uint32 moveMode) +MoveCopyUndo::MoveCopyUndo(BObjectList<entry_ref>* sourceList, + BDirectory &dest, BList* pointList, uint32 moveMode) { if (moveMode == kMoveSelectionTo) fUndo = new UndoItemMove(sourceList, dest, pointList); @@ -200,8 +203,8 @@ RenameVolumeUndo::RenameVolumeUndo(BVolume &volume, const char* newName) // #pragma mark - -UndoItemCopy::UndoItemCopy(BObjectList<entry_ref>* sourceList, BDirectory &target, - BList* /*pointList*/, uint32 moveMode) +UndoItemCopy::UndoItemCopy(BObjectList<entry_ref>* sourceList, + BDirectory &target, BList* /*pointList*/, uint32 moveMode) : fSourceList(*sourceList), fTargetList(*sourceList), @@ -264,8 +267,8 @@ UndoItemCopy::UpdateEntry(BEntry* entry, const char* name) // #pragma mark - -UndoItemMove::UndoItemMove(BObjectList<entry_ref>* sourceList, BDirectory &target, - BList* /*pointList*/) +UndoItemMove::UndoItemMove(BObjectList<entry_ref>* sourceList, + BDirectory &target, BList* /*pointList*/) : fSourceList(*sourceList) { @@ -293,7 +296,8 @@ UndoItemMove::Undo() ChangeListSource(*list, entry); // FSMoveToFolder() owns its arguments - FSMoveToFolder(list, new BEntry(&fSourceRef), FSUndoMoveMode(kMoveSelectionTo), NULL); + FSMoveToFolder(list, new BEntry(&fSourceRef), + FSUndoMoveMode(kMoveSelectionTo), NULL); return B_OK; } @@ -303,8 +307,8 @@ status_t UndoItemMove::Redo() { // FSMoveToFolder() owns its arguments - FSMoveToFolder(new BObjectList<entry_ref>(fSourceList), new BEntry(&fTargetRef), - FSUndoMoveMode(kMoveSelectionTo), NULL); + FSMoveToFolder(new BObjectList<entry_ref>(fSourceList), + new BEntry(&fTargetRef), FSUndoMoveMode(kMoveSelectionTo), NULL); return B_OK; } diff --git a/src/kits/tracker/FSUtils.h b/src/kits/tracker/FSUtils.h index da95902..84e3889 100644 --- a/src/kits/tracker/FSUtils.h +++ b/src/kits/tracker/FSUtils.h @@ -46,8 +46,8 @@ All rights reserved. #include "ObjectList.h" -// Note - APIs/code in FSUtils.h and FSUtils.cpp is slated for a major cleanup -// -- in other words, you will find a lot of ugly cruft in here +// APIs/code in FSUtils.h and FSUtils.cpp is slated for a major cleanup +// -- in other words, you will find a lot of ugly cruft in here class BDirectory; class BEntry; @@ -165,36 +165,39 @@ private: #endif _IMPEXP_TRACKER status_t FSCopyAttributesAndStats(BNode*, BNode*); -_IMPEXP_TRACKER void FSDuplicate(BObjectList<entry_ref>* srcList, BList* pointList); -_IMPEXP_TRACKER void FSMoveToFolder(BObjectList<entry_ref>* srcList, BEntry*, uint32 moveMode, - BList* pointList = NULL); -_IMPEXP_TRACKER void FSMakeOriginalName(char* name, BDirectory* destDir, const char* suffix); +_IMPEXP_TRACKER void FSDuplicate(BObjectList<entry_ref>* srcList, + BList* pointList); +_IMPEXP_TRACKER void FSMoveToFolder(BObjectList<entry_ref>* srcList, BEntry*, + uint32 moveMode, BList* pointList = NULL); +_IMPEXP_TRACKER void FSMakeOriginalName(char* name, BDirectory* destDir, + const char* suffix); _IMPEXP_TRACKER bool FSIsTrashDir(const BEntry*); _IMPEXP_TRACKER bool FSIsPrintersDir(const BEntry*); _IMPEXP_TRACKER bool FSIsDeskDir(const BEntry*); _IMPEXP_TRACKER bool FSIsHomeDir(const BEntry*); _IMPEXP_TRACKER bool FSIsRootDir(const BEntry*); -_IMPEXP_TRACKER void FSMoveToTrash(BObjectList<entry_ref>* srcList, BList* pointList = NULL, - bool async = true); +_IMPEXP_TRACKER void FSMoveToTrash(BObjectList<entry_ref>* srcList, + BList* pointList = NULL, bool async = true); // Deprecated void FSDeleteRefList(BObjectList<entry_ref>*, bool, bool confirm = true); void FSDelete(entry_ref*, bool, bool confirm = true); void FSRestoreRefList(BObjectList<entry_ref>* list, bool async); -_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref* application, const BMessage* refsReceived, - bool async, bool openWithOK); - // Preferred way of launching; only pass an actual application in <application>, not - // a document; to open documents with the preferred app, pase 0 in <application> and - // stuff all the document refs into <refsReceived> - // Consider having silent mode that does not show alerts, just returns error code +_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref* application, + const BMessage* refsReceived, bool async, bool openWithOK); + // Preferred way of launching; only pass an actual application in + // <application>, not a document; to open documents with the preferred + // app, pase 0 in <application> and stuff all the document refs into + // <refsReceived> Consider having silent mode that does not show alerts, + // just returns error code _IMPEXP_TRACKER status_t FSOpenWith(BMessage* listOfRefs); // runs the Open With window; pas a list of refs _IMPEXP_TRACKER void FSEmptyTrash(); -_IMPEXP_TRACKER status_t FSCreateNewFolderIn(const node_ref* destDir, entry_ref* newRef, - node_ref* new_node); +_IMPEXP_TRACKER status_t FSCreateNewFolderIn(const node_ref* destDir, + entry_ref* newRef, node_ref* new_node); _IMPEXP_TRACKER void FSCreateTrashDirs(); _IMPEXP_TRACKER status_t FSGetTrashDir(BDirectory* trashDir, dev_t volume); _IMPEXP_TRACKER status_t FSGetDeskDir(BDirectory* deskDir); @@ -218,23 +221,26 @@ enum ReadAttrResult { kReadAttrForeignOK }; -ReadAttrResult ReadAttr(const BNode*, const char* hostAttrName, const char* foreignAttrName, - type_code , off_t , void*, size_t , void (*swapFunc)(void*) = 0, - bool isForeign = false); - // Endian swapping ReadAttr call; endianness is determined by trying first the - // native attribute name, then the foreign one; an endian swapping function can - // be passed, if null data won't be swapped; if <isForeign> set the foreign endianness - // will be read directly without first trying the native one +ReadAttrResult ReadAttr(const BNode*, const char* hostAttrName, + const char* foreignAttrName, type_code, off_t, void*, size_t, + void (*swapFunc)(void*) = 0, bool isForeign = false); + // Endian swapping ReadAttr call; endianness is determined by trying + // first the native attribute name, then the foreign one; an endian + // swapping function can be passed, if null data won't be swapped; + // if <isForeign> set the foreign endianness will be read directly + // without first trying the native one -ReadAttrResult GetAttrInfo(const BNode*, const char* hostAttrName, const char* foreignAttrName, - type_code* = NULL, size_t* = NULL); +ReadAttrResult GetAttrInfo(const BNode*, const char* hostAttrName, + const char* foreignAttrName, type_code* = NULL, size_t* = NULL); status_t FSCreateNewFolder(const entry_ref*); status_t FSRecursiveCreateFolder(const char* path); -void FSMakeOriginalName(BString &name, const BDirectory* destDir, const char* suffix = 0); +void FSMakeOriginalName(BString &name, const BDirectory* destDir, + const char* suffix = 0); status_t TrackerLaunch(const entry_ref* app, bool async); -status_t TrackerLaunch(const BMessage* refs, bool async, bool okToRunOpenWith = true); +status_t TrackerLaunch(const BMessage* refs, bool async, + bool okToRunOpenWith = true); status_t TrackerLaunch(const entry_ref* app, const BMessage* refs, bool async, bool okToRunOpenWith = true); status_t LaunchBrokenLink(const char*, const BMessage*); @@ -243,9 +249,9 @@ status_t FSFindTrackerSettingsDir(BPath*, bool autoCreate = true); bool FSIsDeskDir(const BEntry*); -// two separate ifYouDoAction and toDoAction versions are needed for localization -// purposes. The first one is used in "If you do action ..." sentence, -// the second one in the "To do action" sentence. +// two separate ifYouDoAction and toDoAction versions are needed for +// localization purposes. The first one is used in "If you do action..." +// sentence, the second one in the "To do action" sentence. bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry, const char* ifYouDoAction, const char* toDoAction, const char* toConfirmAction, bool dontAsk = false, @@ -254,12 +260,14 @@ bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry, bool CheckDevicesEqual(const entry_ref* entry, const Model* targetModel); // Deprecated calls use newer calls above instead -_IMPEXP_TRACKER void FSLaunchItem(const entry_ref*, BMessage* = NULL, int32 workspace = -1); +_IMPEXP_TRACKER void FSLaunchItem(const entry_ref*, BMessage* = NULL, + int32 workspace = -1); _IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref*, BMessage*, int32 workspace, bool asynch); _IMPEXP_TRACKER void FSOpenWithDocuments(const entry_ref* executableToLaunch, BMessage* documentEntryRefs); -_IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref* ref, BMessage* listOfRefs); +_IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref* ref, + BMessage* listOfRefs); // some extra directory_which values @@ -279,7 +287,8 @@ class WellKnowEntryList { // system hierarchy public: struct WellKnownEntry { - WellKnownEntry(const node_ref* node, directory_which which, const char* name) + WellKnownEntry(const node_ref* node, directory_which which, + const char* name) : node(*node), which(which), @@ -314,8 +323,8 @@ class WellKnowEntryList { WellKnowEntryList(); void AddOne(directory_which, const char* name); void AddOne(directory_which, const char* path, const char* name); - void AddOne(directory_which, directory_which base, const char* extension, - const char* name); + void AddOne(directory_which, directory_which base, + const char* extension, const char* name); std::vector<WellKnownEntry> entries; static WellKnowEntryList* self; diff --git a/src/kits/tracker/FavoritesMenu.cpp b/src/kits/tracker/FavoritesMenu.cpp index 44a0924..294448a 100644 --- a/src/kits/tracker/FavoritesMenu.cpp +++ b/src/kits/tracker/FavoritesMenu.cpp @@ -124,7 +124,8 @@ FavoritesMenu::AddNextItem() try { BPath path; - ThrowOnError( find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) ); + ThrowOnError(find_directory(B_USER_SETTINGS_DIRECTORY, + &path, true)); path.Append(kGoDirectory); mkdir(path.Path(), 0777); @@ -169,7 +170,8 @@ FavoritesMenu::AddNextItem() if (item == NULL) return true; - item->SetLabel(ref.name); // this is the name of the link in the Go dir + item->SetLabel(ref.name); + // this is the name of the link in the Go dir if (!fAddedSeparatorForSection) { fAddedSeparatorForSection = true; @@ -214,7 +216,8 @@ FavoritesMenu::AddNextItem() if (!ShouldShowModel(&model)) return true; - BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFileMessage, fTarget); + BMenuItem* item = BNavMenu::NewModelItem(&model, + fOpenFileMessage, fTarget); if (item) { if (!fAddedSeparatorForSection) { fAddedSeparatorForSection = true; @@ -252,8 +255,10 @@ FavoritesMenu::AddNextItem() // don't add folders that are already in the GoTo section if (find_if(fUniqueRefCheck.begin(), fUniqueRefCheck.end(), - bind2nd(std::equal_to<entry_ref>(), ref)) != fUniqueRefCheck.end()) + bind2nd(std::equal_to<entry_ref>(), ref)) + != fUniqueRefCheck.end()) { continue; + } Model model(&ref, true); if (model.InitCheck() != B_OK) @@ -262,8 +267,8 @@ FavoritesMenu::AddNextItem() if (!ShouldShowModel(&model)) return true; - BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFolderMessage, - fTarget, true); + BMenuItem* item = BNavMenu::NewModelItem(&model, + fOpenFolderMessage, fTarget, true); if (item) { if (!fAddedSeparatorForSection) { fAddedSeparatorForSection = true; diff --git a/src/kits/tracker/FilePanelPriv.cpp b/src/kits/tracker/FilePanelPriv.cpp index 5131a96..70d8cc3 100644 --- a/src/kits/tracker/FilePanelPriv.cpp +++ b/src/kits/tracker/FilePanelPriv.cpp @@ -507,7 +507,8 @@ TFilePanel::AdjustButton() if (!button) return; - BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("text view")); + BTextControl* textControl + = dynamic_cast<BTextControl*>(FindView("text view")); BObjectList<BPose>* selectionList = fPoseView->SelectionList(); BString buttonText = fButtonText; bool enabled = false; @@ -522,7 +523,8 @@ TFilePanel::AdjustButton() enabled = true; buttonText = B_TRANSLATE("Open"); } else { - // insert the name of the selected model into the text field + // insert the name of the selected model into + // the text field textControl->SetText(model->Name()); textControl->MakeFocus(true); } @@ -736,30 +738,39 @@ TFilePanel::Init(const BMessage*) AddShortcut('W', B_COMMAND_KEY, new BMessage(kCancelButton)); AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome)); - AddShortcut('A', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kShowSelectionWindow)); + AddShortcut('A', B_COMMAND_KEY | B_SHIFT_KEY, + new BMessage(kShowSelectionWindow)); AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), PoseView()); - AddShortcut('S', B_COMMAND_KEY, new BMessage(kInvertSelection), PoseView()); + AddShortcut('S', B_COMMAND_KEY, new BMessage(kInvertSelection), + PoseView()); AddShortcut('Y', B_COMMAND_KEY, new BMessage(kResizeToFit), PoseView()); AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, new BMessage(kOpenDir)); - AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY | B_OPTION_KEY, new BMessage(kOpenDir)); + AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY | B_OPTION_KEY, + new BMessage(kOpenDir)); AddShortcut(B_UP_ARROW, B_COMMAND_KEY, new BMessage(kOpenParentDir)); - AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY, new BMessage(kOpenParentDir)); + AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY, + new BMessage(kOpenParentDir)); // New code to make buttons font sensitive rect = windRect; rect.top = rect.bottom - 35; rect.bottom -= 10; rect.right -= 25; - float default_width = be_plain_font->StringWidth(fButtonText.String()) + 20; - rect.left = (default_width > 75) ? (rect.right - default_width) : (rect.right - 75); + float default_width + = be_plain_font->StringWidth(fButtonText.String()) + 20; + rect.left = default_width > 75 + ? rect.right - default_width : rect.right - 75; - BButton* default_button = new BButton(rect, "default button", fButtonText.String(), - new BMessage(kDefaultButton), B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM); + BButton* default_button = new BButton(rect, "default button", + fButtonText.String(), new BMessage(kDefaultButton), + B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM); fBackView->AddChild(default_button); rect.right = rect.left -= 10; - float cancel_width = be_plain_font->StringWidth(B_TRANSLATE("Cancel")) + 20; - rect.left = (cancel_width > 75) ? (rect.right - cancel_width) : (rect.right - 75); + float cancel_width + = be_plain_font->StringWidth(B_TRANSLATE("Cancel")) + 20; + rect.left = cancel_width > 75 + ? rect.right - cancel_width : rect.right - 75; BButton* cancel_button = new BButton(rect, "cancel button", B_TRANSLATE("Cancel"), new BMessage(kCancelButton), @@ -804,7 +815,8 @@ void TFilePanel::RestoreState() { BNode defaultingNode; - if (DefaultStateSourceNode(kDefaultFilePanelTemplate, &defaultingNode, false)) { + if (DefaultStateSourceNode(kDefaultFilePanelTemplate, &defaultingNode, + false)) { AttributeStreamFileNode streamNodeSource(&defaultingNode); RestoreWindowState(&streamNodeSource); PoseView()->Init(&streamNodeSource); @@ -882,7 +894,8 @@ TFilePanel::AddFileContextMenus(BMenu* menu) new BMessage(B_CUT), 'X')); menu->AddItem(new BMenuItem(B_TRANSLATE("Copy"), new BMessage(B_COPY), 'C')); -// menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); + //menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), + // 'V')); menu->SetTargetForItems(PoseView()); } @@ -898,10 +911,12 @@ TFilePanel::AddVolumeContextMenus(BMenu* menu) menu->AddItem(new BMenuItem(B_TRANSLATE("Edit name"), new BMessage(kEditItem), 'E')); menu->AddSeparatorItem(); - menu->AddItem(new BMenuItem(B_TRANSLATE("Cut"), new BMessage(B_CUT), 'X')); + menu->AddItem(new BMenuItem(B_TRANSLATE("Cut"), new BMessage(B_CUT), + 'X')); menu->AddItem(new BMenuItem(B_TRANSLATE("Copy"), new BMessage(B_COPY), 'C')); -// menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); + //menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), + // 'V')); menu->SetTargetForItems(PoseView()); } @@ -955,7 +970,8 @@ TFilePanel::MenusBeginning() int32 count = PoseView()->SelectionList()->CountItems(); EnableNamedMenuItem(fMenuBar, kNewFolder, !TargetModel()->IsRoot()); - EnableNamedMenuItem(fMenuBar, kMoveToTrash, !TargetModel()->IsRoot() && count); + EnableNamedMenuItem(fMenuBar, kMoveToTrash, !TargetModel()->IsRoot() + && count); EnableNamedMenuItem(fMenuBar, kGetInfo, count != 0); EnableNamedMenuItem(fMenuBar, kEditItem, count == 1); @@ -977,9 +993,12 @@ TFilePanel::MenusEnded() void TFilePanel::ShowContextMenu(BPoint point, const entry_ref* ref, BView* view) { - EnableNamedMenuItem(fWindowContextMenu, kNewFolder, !TargetModel()->IsRoot()); - EnableNamedMenuItem(fWindowContextMenu, kOpenParentDir, !TargetModel()->IsRoot()); - EnableNamedMenuItem(fWindowContextMenu, kMoveToTrash, !TargetModel()->IsRoot()); + EnableNamedMenuItem(fWindowContextMenu, kNewFolder, + !TargetModel()->IsRoot()); + EnableNamedMenuItem(fWindowContextMenu, kOpenParentDir, + !TargetModel()->IsRoot()); + EnableNamedMenuItem(fWindowContextMenu, kMoveToTrash, + !TargetModel()->IsRoot()); _inherited::ShowContextMenu(point, ref, view); } @@ -998,7 +1017,8 @@ TFilePanel::SetButtonLabel(file_panel_button selector, const char* text) switch (selector) { case B_CANCEL_BUTTON: { - BButton* button = dynamic_cast<BButton*>(FindView("cancel button")); + BButton* button + = dynamic_cast<BButton*>(FindView("cancel button")); if (!button) break; @@ -1016,7 +1036,8 @@ TFilePanel::SetButtonLabel(file_panel_button selector, const char* text) { fButtonText = text; float delta = 0; - BButton* button = dynamic_cast<BButton*>(FindView("default button")); + BButton* button + = dynamic_cast<BButton*>(FindView("default button")); if (button) { float old_width = button->StringWidth(button->Label()); button->SetLabel(text); @@ -1043,7 +1064,8 @@ TFilePanel::SetSaveText(const char* text) if (!text) return; - BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("text view")); + BTextControl* textControl + = dynamic_cast<BTextControl*>(FindView("text view")); textControl->SetText(text); textControl->TextView()->SelectAll(); } @@ -1060,9 +1082,9 @@ TFilePanel::MessageReceived(BMessage* message) if (message->FindRef("refs", &ref) == B_OK) { BEntry entry(&ref, true); if (entry.InitCheck() == B_OK) { - // Double-click on dir or link-to-dir ALWAYS opens the dir. - // If more than one dir is selected, the - // first is entered. + // Double-click on dir or link-to-dir ALWAYS opens the + // dir. If more than one dir is selected, the first is + // entered. if (entry.IsDirectory()) { entry.GetRef(&ref); bool isDesktop = SwitchDirToDesktopIfNeeded(ref); @@ -1075,7 +1097,8 @@ TFilePanel::MessageReceived(BMessage* message) // Otherwise, we have a file or a link to a file. // AdjustButton has already tested the flavor; // all we have to do is see if the button is enabled. - BButton* button = dynamic_cast<BButton*>(FindView("default button")); + BButton* button = dynamic_cast<BButton*>( + FindView("default button")); if (!button) break; @@ -1087,15 +1110,19 @@ TFilePanel::MessageReceived(BMessage* message) // Don't allow saves of multiple files if (count > 1) { ShowCenteredAlert( - B_TRANSLATE("Sorry, saving more than one item is not allowed."), + B_TRANSLATE( + "Sorry, saving more than one " + "item is not allowed."), B_TRANSLATE("Cancel")); } else { - // if we are a savepanel, set up the filepanel correctly - // then pass control so we follow the same path as if the user + // if we are a savepanel, set up the + // filepanel correctly then pass control + // so we follow the same path as if the user // clicked the save button - // set the 'name' fld to the current ref's name - // notify the panel that the default button should be enabled + // set the 'name' fld to the current ref's + // name notify the panel that the default + // button should be enabled SetSaveText(ref.name); SelectionChanged(); @@ -1144,8 +1171,10 @@ TFilePanel::MessageReceived(BMessage* message) case kAddCurrentDir: { BPath path; - if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) + != B_OK) { break; + } path.Append(kGoDirectory); BDirectory goDirectory(path.Path()); @@ -1155,7 +1184,8 @@ TFilePanel::MessageReceived(BMessage* message) entry.GetPath(&path); BSymLink link; - goDirectory.CreateSymLink(TargetModel()->Name(), path.Path(), &link); + goDirectory.CreateSymLink(TargetModel()->Name(), path.Path(), + &link); } break; } @@ -1163,8 +1193,10 @@ TFilePanel::MessageReceived(BMessage* message) case kEditFavorites: { BPath path; - if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) + if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) + != B_OK) { break; + } path.Append(kGoDirectory); BMessenger msgr(kTrackerSignature); @@ -1199,7 +1231,8 @@ TFilePanel::MessageReceived(BMessage* message) if (fIsSavePanel) { if (PoseView()->IsFocus() && PoseView()->SelectionList()->CountItems() == 1) { - Model* model = (PoseView()->SelectionList()->FirstItem())->TargetModel(); + Model* model = (PoseView()->SelectionList()-> + FirstItem())->TargetModel(); if (model->ResolveIfLink()->IsDirectory()) { PoseView()->CommitActivePose(); PoseView()->OpenSelection(); @@ -1215,13 +1248,17 @@ TFilePanel::MessageReceived(BMessage* message) case B_OBSERVER_NOTICE_CHANGE: { int32 observerWhat; - if (message->FindInt32("be:observe_change_what", &observerWhat) == B_OK) { + if (message->FindInt32("be:observe_change_what", &observerWhat) + == B_OK) { switch (observerWhat) { case kDesktopFilePanelRootChanged: { bool desktopIsRoot = true; - if (message->FindBool("DesktopFilePanelRoot", &desktopIsRoot) == B_OK) - TrackerSettings().SetDesktopFilePanelRoot(desktopIsRoot); + if (message->FindBool("DesktopFilePanelRoot", + &desktopIsRoot) == B_OK) { + TrackerSettings(). + SetDesktopFilePanelRoot(desktopIsRoot); + } SetTo(TargetModel()->EntryRef()); break; } @@ -1416,9 +1453,10 @@ TFilePanel::HandleSaveButton() fTextControl->TextView()->SelectAll(); return; } else { - // if this was invoked by a dbl click, it is an explicit replacement - // of the file. - BString str(B_TRANSLATE("The file \"%name\" already exists in the specified folder. Do you want to replace it?")); + // if this was invoked by a dbl click, it is an explicit + // replacement of the file. + BString str(B_TRANSLATE("The file \"%name\" already exists in " + "the specified folder. Do you want to replace it?")); str.ReplaceFirst("%name", fTextControl->Text()); if (ShowCenteredAlert(str.String(), B_TRANSLATE("Cancel"), @@ -1512,8 +1550,10 @@ TFilePanel::HandleOpenButton() if (((fNodeFlavors & B_DIRECTORY_NODE) != 0 && model->ResolveIfLink()->IsDirectory()) || ((fNodeFlavors & B_SYMLINK_NODE) != 0 && model->IsSymLink()) - || ((fNodeFlavors & B_FILE_NODE) != 0 && model->ResolveIfLink()->IsFile())) + || ((fNodeFlavors & B_FILE_NODE) != 0 + && model->ResolveIfLink()->IsFile())) { message.AddRef("refs", model->EntryRef()); + } } OpenSelectionCommon(&message); @@ -1550,7 +1590,8 @@ TFilePanel::WindowActivated(bool active) // #pragma mark - -BFilePanelPoseView::BFilePanelPoseView(Model* model, BRect frame, uint32 resizeMask) +BFilePanelPoseView::BFilePanelPoseView(Model* model, BRect frame, + uint32 resizeMask) : BPoseView(model, frame, kListMode, resizeMask), fIsDesktop(model->IsDesktop()) { @@ -1583,8 +1624,8 @@ bool BFilePanelPoseView::FSNotification(const BMessage* message) { if (IsDesktopView()) { - // Pretty much copied straight from DesktopPoseView. Would be better - // if the code could be shared somehow. + // Pretty much copied straight from DesktopPoseView. + // Would be better if the code could be shared somehow. switch (message->FindInt32("opcode")) { case B_DEVICE_MOUNTED: { @@ -1600,7 +1641,8 @@ BFilePanelPoseView::FSNotification(const BMessage* message) break; if (settings.MountVolumesOntoDesktop() - && (!volume.IsShared() || settings.MountSharedVolumesOntoDesktop())) { + && (!volume.IsShared() + || settings.MountSharedVolumesOntoDesktop())) { // place an icon for the volume onto the desktop CreateVolumePose(&volume, true); } @@ -1692,7 +1734,8 @@ BFilePanelPoseView::AdaptToVolumeChange(BMessage* message) message->FindBool("ShowDisksIcon", &showDisksIcon); message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop); - message->FindBool("MountSharedVolumesOntoDesktop", &mountSharedVolumesOntoDesktop); + message->FindBool("MountSharedVolumesOntoDesktop", + &mountSharedVolumesOntoDesktop); BEntry entry("/"); Model model(&entry); @@ -1725,7 +1768,8 @@ BFilePanelPoseView::AdaptToDesktopIntegrationChange(BMessage* message) bool mountSharedVolumesOntoDesktop = true; message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop); - message->FindBool("MountSharedVolumesOntoDesktop", &mountSharedVolumesOntoDesktop); + message->FindBool("MountSharedVolumesOntoDesktop", + &mountSharedVolumesOntoDesktop); ShowVolumes(false, mountSharedVolumesOntoDesktop); ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop); diff --git a/src/kits/tracker/FilePanelPriv.h b/src/kits/tracker/FilePanelPriv.h index b9de5c9..7f4b242 100644 --- a/src/kits/tracker/FilePanelPriv.h +++ b/src/kits/tracker/FilePanelPriv.h @@ -122,7 +122,8 @@ protected: virtual void WindowActivated(bool state); static filter_result FSFilter(BMessage*, BHandler**, BMessageFilter*); - static filter_result MessageDropFilter(BMessage*, BHandler**, BMessageFilter*); + static filter_result MessageDropFilter(BMessage*, BHandler**, + BMessageFilter*); int32 ShowCenteredAlert(const char* text, const char* button1, const char* button2 = NULL, const char* button3 = NULL); diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index 55643e2..bc530d9 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -106,7 +106,8 @@ namespace BPrivate { class MostUsedNames { public: - MostUsedNames(const char* fileName, const char* directory, int32 maxCount = 5); + MostUsedNames(const char* fileName, const char* directory, + int32 maxCount = 5); ~MostUsedNames(); bool ObtainList(BList* list); @@ -175,8 +176,8 @@ MoreOptionsStruct::QueryTemporary(const BNode* node) FindWindow::FindWindow(const entry_ref* newRef, bool editIfTemplateOnly) : - BWindow(kInitialRect, B_TRANSLATE("Find"), B_TITLED_WINDOW, B_NOT_RESIZABLE - | B_NOT_ZOOMABLE), + BWindow(kInitialRect, B_TRANSLATE("Find"), B_TITLED_WINDOW, + B_NOT_RESIZABLE | B_NOT_ZOOMABLE), fFile(TryOpening(newRef)), fFromTemplate(false), fEditTemplateOnly(false), @@ -218,7 +219,8 @@ FindWindow::FindWindow(const entry_ref* newRef, bool editIfTemplateOnly) fFromTemplate = IsQueryTemplate(fFile); - fBackground = new FindPanel(Bounds(), fFile, this, fFromTemplate, fEditTemplateOnly); + fBackground = new FindPanel(Bounds(), fFile, this, fFromTemplate, + fEditTemplateOnly); AddChild(fBackground); } @@ -292,8 +294,10 @@ const char* FindWindow::QueryName() const { if (fFromTemplate) { - if (!fQueryNameFromTemplate.Length()) - fFile->ReadAttrString(kAttrQueryTemplateName, &fQueryNameFromTemplate); + if (!fQueryNameFromTemplate.Length()) { + fFile->ReadAttrString(kAttrQueryTemplateName, + &fQueryNameFromTemplate); + } return fQueryNameFromTemplate.String(); } @@ -375,7 +379,8 @@ FindWindow::SaveQueryAttributes(BNode* file, bool queryTemplate) // save date/time info for recent query support and transient query killer int32 currentTime = (int32)time(0); - file->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, ¤tTime, sizeof(int32)); + file->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, ¤tTime, + sizeof(int32)); int32 tmp = 1; file->WriteAttr("_trk/recentQuery", B_INT32_TYPE, 0, &tmp, sizeof(int32)); } @@ -393,7 +398,8 @@ FindWindow::SaveQueryAsAttributes(BNode* file, BEntry* entry, bool queryTemplate // and the file's location FSSetPoseLocation(entry, *oldLocation); - BNodeInfo(file).SetType(queryTemplate ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE); + BNodeInfo(file).SetType(queryTemplate + ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE); BString predicate; bool dynamicDate; @@ -509,7 +515,8 @@ FindWindow::Find() } int32 currentTime = (int32)time(0); - fFile->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, ¤tTime, sizeof(int32)); + fFile->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, ¤tTime, + sizeof(int32)); // tell the tracker about it BMessage message(B_REFS_RECEIVED); @@ -683,7 +690,8 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* parent, BMessenger self(this); fRecentQueries = new BPopUpMenu("RecentQueries"); - FindPanel::AddRecentQueries(fRecentQueries, true, &self, kSwitchToQueryTemplate); + FindPanel::AddRecentQueries(fRecentQueries, true, &self, + kSwitchToQueryTemplate); AddChild(new MiniMenuField(rect, "RecentQueries", fRecentQueries)); @@ -741,8 +749,8 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* parent, B_TRANSLATE_NOCOLLECT(kDragNDropActionSpecifiers[1])); BMessenger self(this); - fDraggableIcon = new DraggableQueryIcon(DraggableIcon::PreferredRect(draggableIconOrigin, - B_LARGE_ICON), "saveHere", &dragNDropMessage, + fDraggableIcon = new DraggableQueryIcon(DraggableIcon::PreferredRect( + draggableIconOrigin, B_LARGE_ICON), "saveHere", &dragNDropMessage, self, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); AddChild(fDraggableIcon); } @@ -769,8 +777,8 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* parent, rect = expandedBounds; rect.right = rect.left + 200; rect.bottom = rect.top + 20;; - fQueryName = new BTextControl(rect, "queryName", B_TRANSLATE("Query name:"), - "", 0); + fQueryName = new BTextControl(rect, "queryName", + B_TRANSLATE("Query name:"), "", 0); fQueryName->SetDivider(fQueryName->StringWidth(fQueryName->Label()) + 5); fMoreOptionsPane->AddItem(fQueryName, 1); FillCurrentQueryName(fQueryName, parent); @@ -838,9 +846,9 @@ FindPanel::AttachedToWindow() fQueryName->SetTarget(this); fLatch->SetTarget(fMoreOptionsPane); RestoreMimeTypeMenuSelection(node); - // preselect the mime we used the last time - // have to do it here because AddByAttributeItems will build different - // menus based on which mime type is preselected + // preselect the mime we used the last time have to do it here + // because AddByAttributeItems will build different menus based + // on which mime type is preselected RestoreWindowState(node); if (!Window()->CurrentFocus()) { @@ -971,9 +979,10 @@ FindPanel::ShowVolumeMenuLabel() tmpItem = item; } } + if (countSelected == 0) { // no disk selected, for now revert to search all disks - // ToDo: + // TODO: // show no disks here and add a check that will not let the // query go if the user doesn't pick at least one fVolMenu->ItemAt(0)->SetMarked(true); @@ -997,51 +1006,49 @@ FindPanel::MessageReceived(BMessage* message) switch (message->what) { case kVolumeItem: - { - // volume changed - BMenuItem* invokedItem; - dev_t dev; - if (message->FindPointer("source", (void**)&invokedItem) != B_OK) - return; - - if (message->FindInt32("device", &dev) != B_OK) - break; - - BMenu* menu = invokedItem->Menu(); - ASSERT(menu); - - if (dev == -1) { - - // all disks selected, uncheck everything else - int32 count = menu->CountItems(); - for (int32 index = 2; index < count; index++) - menu->ItemAt(index)->SetMarked(false); - - // make all disks the title and check it - PopUpMenuSetTitle(menu, menu->ItemAt(0)->Label()); - menu->ItemAt(0)->SetMarked(true); - - } else { - // a specific volume selected, unmark "all disks" - menu->ItemAt(0)->SetMarked(false); + { + // volume changed + BMenuItem* invokedItem; + dev_t dev; + if (message->FindPointer("source", (void**)&invokedItem) != B_OK) + return; - // toggle mark on invoked item - int32 count = menu->CountItems(); - for (int32 index = 2; index < count; index++) { - BMenuItem* item = menu->ItemAt(index); + if (message->FindInt32("device", &dev) != B_OK) + break; - if (invokedItem == item) { - // we just selected this - bool wasMarked = item->IsMarked(); - item->SetMarked(!wasMarked); - } + BMenu* menu = invokedItem->Menu(); + ASSERT(menu); + + if (dev == -1) { + // all disks selected, uncheck everything else + int32 count = menu->CountItems(); + for (int32 index = 2; index < count; index++) + menu->ItemAt(index)->SetMarked(false); + + // make all disks the title and check it + PopUpMenuSetTitle(menu, menu->ItemAt(0)->Label()); + menu->ItemAt(0)->SetMarked(true); + } else { + // a specific volume selected, unmark "all disks" + menu->ItemAt(0)->SetMarked(false); + + // toggle mark on invoked item + int32 count = menu->CountItems(); + for (int32 index = 2; index < count; index++) { + BMenuItem* item = menu->ItemAt(index); + + if (invokedItem == item) { + // we just selected this + bool wasMarked = item->IsMarked(); + item->SetMarked(!wasMarked); } } - // make sure the right label is showing - ShowVolumeMenuLabel(); - - break; } + // make sure the right label is showing + ShowVolumeMenuLabel(); + + break; + } case kByAttributeItem: case kByNameItem: @@ -1058,34 +1065,35 @@ FindPanel::MessageReceived(BMessage* message) break; case kMIMETypeItem: - { - BMenuItem* item; - if (message->FindPointer("source", (void**)&item) == B_OK) { - // don't add the "All files and folders" to the list - if (fMimeTypeMenu->IndexOf(item) != 0) - gMostUsedMimeTypes.AddName(item->Label()); + { + BMenuItem* item; + if (message->FindPointer("source", (void**)&item) == B_OK) { + // don't add the "All files and folders" to the list + if (fMimeTypeMenu->IndexOf(item) != 0) + gMostUsedMimeTypes.AddName(item->Label()); - SetCurrentMimeType(item); - } + SetCurrentMimeType(item); + } - // mime type switched - if (fMode != kByAttributeItem) - break; + // mime type switched + if (fMode != kByAttributeItem) + break; - // the attributes for this type may be different, rip out the existing ones - RemoveAttrViewItems(); + // the attributes for this type may be different, + // rip out the existing ones + RemoveAttrViewItems(); - Window()->ResizeTo(Window()->Frame().Width(), - ViewHeightForMode(kByAttributeItem, fLatch->Value() != 0)); + Window()->ResizeTo(Window()->Frame().Width(), + ViewHeightForMode(kByAttributeItem, fLatch->Value() != 0)); - BBox* box = dynamic_cast<BBox*>(FindView("Box")); - ASSERT(box); - box->ResizeTo(box->Bounds().Width(), - BoxHeightForMode(kByAttributeItem, fLatch->Value() != 0)); + BBox* box = dynamic_cast<BBox*>(FindView("Box")); + ASSERT(box); + box->ResizeTo(box->Bounds().Width(), + BoxHeightForMode(kByAttributeItem, fLatch->Value() != 0)); - AddAttrView(); - break; - } + AddAttrView(); + break; + } case kNameModifiedMessage: // the query name was edited, make the query permanent @@ -1093,67 +1101,74 @@ FindPanel::MessageReceived(BMessage* message) break; case B_SAVE_REQUESTED: - { - // finish saving query template from a SaveAs panel - entry_ref ref; - status_t error = message->FindRef("refs", &ref); + { + // finish saving query template from a SaveAs panel + entry_ref ref; + status_t error = message->FindRef("refs", &ref); + if (error == B_OK) { + // direct entry selected, convert to parent dir and name + BEntry entry(&ref); + error = entry.GetParent(&entry); if (error == B_OK) { - // direct entry selected, convert to parent dir and name - BEntry entry(&ref); - error = entry.GetParent(&entry); - if (error == B_OK) { - entry.GetRef(&dir); - name = ref.name; - } - } else { - // parent dir and name selected - error = message->FindRef("directory", &dir); - if (error == B_OK) - error = message->FindString("name", &name); + entry.GetRef(&dir); + name = ref.name; } + } else { + // parent dir and name selected + error = message->FindRef("directory", &dir); if (error == B_OK) - SaveAsQueryOrTemplate(&dir, name, true); + error = message->FindString("name", &name); } + + if (error == B_OK) + SaveAsQueryOrTemplate(&dir, name, true); + break; + } case B_COPY_TARGET: - { - // finish drag&drop - const char* str; - const char* mimeType = NULL; - const char* actionSpecifier = NULL; - if (message->FindString("be:types", &str) == B_OK - && strcasecmp(str, B_FILE_MIME_TYPE) == 0 - && (message->FindString("be:actionspecifier", &actionSpecifier) == B_OK - || message->FindString("be:filetypes", &mimeType) == B_OK) - && message->FindString("name", &name) == B_OK - && message->FindRef("directory", &dir) == B_OK) { - - bool query = false; - bool queryTemplate = false; - - if (actionSpecifier - && strcasecmp(actionSpecifier, - B_TRANSLATE_NOCOLLECT( - kDragNDropActionSpecifiers[0])) == 0) { - query = true; - } else if (actionSpecifier - && strcasecmp(actionSpecifier, - B_TRANSLATE_NOCOLLECT( - kDragNDropActionSpecifiers[1])) == 0) { - queryTemplate = true; - } else if (mimeType && strcasecmp(mimeType, - kDragNDropTypes[0]) == 0) { - query = true; - } else if (mimeType && strcasecmp(mimeType, kDragNDropTypes[1]) == 0) - queryTemplate = true; - - if (query || queryTemplate) - SaveAsQueryOrTemplate(&dir, name, queryTemplate); + { + // finish drag&drop + const char* str; + const char* mimeType = NULL; + const char* actionSpecifier = NULL; + + if (message->FindString("be:types", &str) == B_OK + && strcasecmp(str, B_FILE_MIME_TYPE) == 0 + && (message->FindString("be:actionspecifier", + &actionSpecifier) == B_OK + || message->FindString("be:filetypes", &mimeType) == B_OK) + && message->FindString("name", &name) == B_OK + && message->FindRef("directory", &dir) == B_OK) { + + bool query = false; + bool queryTemplate = false; + + if (actionSpecifier + && strcasecmp(actionSpecifier, + B_TRANSLATE_NOCOLLECT( + kDragNDropActionSpecifiers[0])) == 0) { + query = true; + } else if (actionSpecifier + && strcasecmp(actionSpecifier, + B_TRANSLATE_NOCOLLECT( + kDragNDropActionSpecifiers[1])) == 0) { + queryTemplate = true; + } else if (mimeType && strcasecmp(mimeType, + kDragNDropTypes[0]) == 0) { + query = true; + } else if (mimeType && strcasecmp(mimeType, + kDragNDropTypes[1]) == 0) { + queryTemplate = true; } + + if (query || queryTemplate) + SaveAsQueryOrTemplate(&dir, name, queryTemplate); } + break; + } default: _inherited::MessageReceived(message); @@ -1163,11 +1178,13 @@ FindPanel::MessageReceived(BMessage* message) void -FindPanel::SaveAsQueryOrTemplate(const entry_ref* dir, const char* name, bool queryTemplate) +FindPanel::SaveAsQueryOrTemplate(const entry_ref* dir, const char* name, + bool queryTemplate) { BDirectory directory(dir); BFile file(&directory, name, O_RDWR | O_CREAT | O_TRUNC); - BNodeInfo(&file).SetType(queryTemplate ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE); + BNodeInfo(&file).SetType(queryTemplate + ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE); BMessage attach(kAttachFile); attach.AddRef("directory", dir); @@ -1194,7 +1211,8 @@ FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const if (!textControl) return; - BMenuField* menuField = dynamic_cast<BMenuField*>(view->FindView("MenuField")); + BMenuField* menuField + = dynamic_cast<BMenuField*>(view->FindView("MenuField")); if (!menuField) return; @@ -1218,78 +1236,85 @@ FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const break; case B_TIME_TYPE: - { - int flags = 0; - DEBUG_ONLY(time_t result =) - parsedate_etc(textControl->TextView()->Text(), -1, &flags); - dynamicDate = (flags & PARSEDATE_RELATIVE_TIME) != 0; - PRINT(("parsedate_etc - date is %srelative, %" - B_PRIdTIME "\n", - dynamicDate ? "" : "not ", result)); - - query->PushDate(textControl->TextView()->Text()); - } + { + int flags = 0; + DEBUG_ONLY(time_t result =) + parsedate_etc(textControl->TextView()->Text(), -1, + &flags); + dynamicDate = (flags & PARSEDATE_RELATIVE_TIME) != 0; + PRINT(("parsedate_etc - date is %srelative, %" + B_PRIdTIME "\n", + dynamicDate ? "" : "not ", result)); + + query->PushDate(textControl->TextView()->Text()); break; + } case B_BOOL_TYPE: - { - uint32 value; - if (strcasecmp(textControl->TextView()->Text(), "true") == 0) - value = 1; - else if (strcasecmp(textControl->TextView()->Text(), "true") == 0) - value = 1; - else - value = (uint32)atoi(textControl->TextView()->Text()); - - value %= 2; - query->PushUInt32(value); - } + { + uint32 value; + if (strcasecmp(textControl->TextView()->Text(), + "true") == 0) { + value = 1; + } else if (strcasecmp(textControl->TextView()->Text(), + "true") == 0) { + value = 1; + } else + value = (uint32)atoi(textControl->TextView()->Text()); + + value %= 2; + query->PushUInt32(value); break; + } case B_UINT8_TYPE: case B_UINT16_TYPE: case B_UINT32_TYPE: - query->PushUInt32((uint32)StringToScalar(textControl->TextView()->Text())); + query->PushUInt32((uint32)StringToScalar( + textControl->TextView()->Text())); break; case B_INT8_TYPE: case B_INT16_TYPE: case B_INT32_TYPE: - query->PushInt32((int32)StringToScalar(textControl->TextView()->Text())); + query->PushInt32((int32)StringToScalar( + textControl->TextView()->Text())); break; case B_UINT64_TYPE: - query->PushUInt64((uint64)StringToScalar(textControl->TextView()->Text())); + query->PushUInt64((uint64)StringToScalar( + textControl->TextView()->Text())); break; case B_OFF_T_TYPE: case B_INT64_TYPE: - query->PushInt64(StringToScalar(textControl->TextView()->Text())); + query->PushInt64(StringToScalar( + textControl->TextView()->Text())); break; case B_FLOAT_TYPE: - { - float floatVal; - sscanf(textControl->TextView()->Text(), "%f", &floatVal); - query->PushFloat(floatVal); - } + { + float floatVal; + sscanf(textControl->TextView()->Text(), "%f", &floatVal); + query->PushFloat(floatVal); break; + } case B_DOUBLE_TYPE: - { - double doubleVal; - sscanf(textControl->TextView()->Text(), "%lf", &doubleVal); - query->PushDouble(doubleVal); - } + { + double doubleVal; + sscanf(textControl->TextView()->Text(), "%lf", &doubleVal); + query->PushDouble(doubleVal); break; - + } } } query_op theOperator; BMenuItem* operatorItem = item->Submenu()->FindMarked(); if (operatorItem && operatorItem->Message() != NULL) { - operatorItem->Message()->FindInt32("operator", (int32*)&theOperator); + operatorItem->Message()->FindInt32("operator", + (int32*)&theOperator); query->PushOp(theOperator); } else query->PushOp(B_EQ); @@ -1297,7 +1322,8 @@ FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const // add logic based on selection in Logic menufield if (index > 0) { TAttrView* prevView = fAttrViewList.ItemAt(index - 1); - menuField = dynamic_cast<BMenuField*>(prevView->FindView("Logic")); + menuField + = dynamic_cast<BMenuField*>(prevView->FindView("Logic")); if (menuField) { item = menuField->Menu()->FindMarked(); if (item) { @@ -1348,7 +1374,8 @@ FindPanel::GetByAttrPredicate(BQuery* query, bool &dynamicDate) const void FindPanel::GetDefaultName(BString &result) const { - BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("TextControl")); + BTextControl* textControl + = dynamic_cast<BTextControl*>(FindView("TextControl")); switch (Mode()) { case kByNameItem: result.SetTo(B_TRANSLATE_COMMENT("Name = %name", @@ -1393,16 +1420,17 @@ void FindPanel::GetByNamePredicate(BQuery* query) const { ASSERT(Mode() == (int32)kByNameItem); - BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("TextControl")); + BTextControl* textControl + = dynamic_cast<BTextControl*>(FindView("TextControl")); ASSERT(textControl); query->PushAttr("name"); query->PushString(textControl->TextView()->Text(), true); - if (strstr(textControl->TextView()->Text(), "*")) + if (strstr(textControl->TextView()->Text(), "*")) { // assume pattern is a regular expression and try doing an exact match query->PushOp(B_EQ); - else + } else query->PushOp(B_CONTAINS); PushMimeType(query); @@ -1446,14 +1474,16 @@ FindPanel::SwitchMode(uint32 mode) bounds.bottom -= 10; if (fLatch->Value()) bounds.bottom -= kMoreOptionsDelta; - box->ResizeTo(bounds.Width(), BoxHeightForMode(mode, fLatch->Value() != 0)); + box->ResizeTo(bounds.Width(), BoxHeightForMode(mode, + fLatch->Value() != 0)); RemoveByAttributeItems(); ShowOrHideMimeTypeMenu(); AddByNameOrFormulaItems(); if (buffer.Length()) { - ASSERT(mode == kByFormulaItem || oldMode == kByAttributeItem); + ASSERT(mode == kByFormulaItem + || oldMode == kByAttributeItem); BTextControl* textControl = dynamic_cast<BTextControl*> (FindView("TextControl")); textControl->SetText(buffer.String()); @@ -1492,9 +1522,11 @@ FindPanel::CurrentMimeType(const char** type) const // search for marked item in the list BMenuItem* item = MimeTypeMenu()->FindMarked(); - // if it's one of the most used items, ignore it - if (item != NULL && MimeTypeMenu()->IndexOf(item) != 0 && item->Submenu() == NULL) + if (item != NULL && MimeTypeMenu()->IndexOf(item) != 0 + && item->Submenu() == NULL) { + // if it's one of the most used items, ignore it item = NULL; + } if (item == NULL) { for (int32 index = MimeTypeMenu()->CountItems(); index-- > 0;) { @@ -1536,7 +1568,7 @@ FindPanel::SetCurrentMimeType(BMenuItem* item) fMimeTypeField->MenuItem()->SetLabel(item->Label()); BMenuItem* search; - for (int32 i = 2;(search = MimeTypeMenu()->ItemAt(i)) != NULL;i++) { + for (int32 i = 2; (search = MimeTypeMenu()->ItemAt(i)) != NULL; i++) { if (item == search || !search->Label()) continue; if (!strcmp(item->Label(),search->Label())) { @@ -1583,12 +1615,14 @@ FindPanel::SetCurrentMimeType(const char* label) if (submenu != NULL && !found) { for (int32 subIndex = submenu->CountItems(); subIndex-- > 0;) { BMenuItem* subItem = submenu->ItemAt(subIndex); - if (subItem->Label() != NULL && !strcmp(label, subItem->Label())) { + if (subItem->Label() != NULL + && !strcmp(label, subItem->Label())) { subItem->SetMarked(true); found = true; } } } + if (item->Label() != NULL && !strcmp(label, item->Label())) { item->SetMarked(true); return B_OK; @@ -1615,8 +1649,9 @@ FindPanel::AddOneMimeTypeToMenu(const ShortMimeInfo* info, void* castToMenu) BMessage* msg = new BMessage(kMIMETypeItem); msg->AddString("mimetype", info->InternalName()); - superItem->Submenu()->AddItem(new IconMenuItem(info->ShortDescription(), - msg, info->InternalName(), B_MINI_ICON)); + superItem->Submenu()->AddItem(new IconMenuItem( + info->ShortDescription(), msg, info->InternalName(), + B_MINI_ICON)); } return false; @@ -1628,8 +1663,8 @@ FindPanel::AddMimeTypesToMenu() { BMessage* itemMessage = new BMessage(kMIMETypeItem); itemMessage->AddString("mimetype", kAllMimeTypes); - MimeTypeMenu()->AddItem(new BMenuItem(B_TRANSLATE("All files and folders"), - itemMessage)); + MimeTypeMenu()->AddItem( + new BMenuItem(B_TRANSLATE("All files and folders"), itemMessage)); MimeTypeMenu()->AddSeparatorItem(); MimeTypeMenu()->ItemAt(0)->SetMarked(true); @@ -1777,8 +1812,8 @@ AddOneRecentItem(const entry_ref* ref, void* castToParams) void -FindPanel::AddRecentQueries(BMenu* menu, bool addSaveAsItem, const BMessenger* target, - uint32 what) +FindPanel::AddRecentQueries(BMenu* menu, bool addSaveAsItem, + const BMessenger* target, uint32 what) { BObjectList<entry_ref> templates(10, true); BObjectList<EntryWithDate> recentQueries(10, true); @@ -1788,7 +1823,8 @@ FindPanel::AddRecentQueries(BMenu* menu, bool addSaveAsItem, const BMessenger* t BVolume volume; roster.Rewind(); while (roster.GetNextVolume(&volume) == B_OK) { - if (volume.IsPersistent() && volume.KnowsQuery() && volume.KnowsAttr()) { + if (volume.IsPersistent() && volume.KnowsQuery() + && volume.KnowsAttr()) { BQuery query; query.SetVolume(&volume); @@ -2046,9 +2082,11 @@ FindPanel::SaveWindowState(BNode* node, bool editTemplate) saveMoreOptions.searchTrash = fSearchTrashCheck->Value() != 0; saveMoreOptions.temporary = fTemporaryCheck->Value() != 0; - if (node->WriteAttr(kAttrQueryMoreOptions, B_RAW_TYPE, 0, &saveMoreOptions, - sizeof(saveMoreOptions)) == sizeof(saveMoreOptions)) + if (node->WriteAttr(kAttrQueryMoreOptions, B_RAW_TYPE, 0, + &saveMoreOptions, + sizeof(saveMoreOptions)) == sizeof(saveMoreOptions)) { node->RemoveAttr(kAttrQueryMoreOptionsForeign); + } if (editTemplate) { if (UserSpecifiedName()) { @@ -2059,36 +2097,37 @@ FindPanel::SaveWindowState(BNode* node, bool editTemplate) switch (Mode()) { case kByAttributeItem: - { - BMessage message; - int32 count = fAttrViewList.CountItems(); - node->WriteAttr(kAttrQueryInitialNumAttrs, B_INT32_TYPE, 0, - &count, sizeof(int32)); - - for (int32 index = 0; index < count; index++) - fAttrViewList.ItemAt(index)->SaveState(&message, index); - - ssize_t size = message.FlattenedSize(); - char* buffer = new char[size]; - status_t result = message.Flatten(buffer, size); - if (result == B_OK) { - node->WriteAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0, - buffer, (size_t)size); - } - delete [] buffer; + { + BMessage message; + int32 count = fAttrViewList.CountItems(); + node->WriteAttr(kAttrQueryInitialNumAttrs, B_INT32_TYPE, 0, + &count, sizeof(int32)); + + for (int32 index = 0; index < count; index++) + fAttrViewList.ItemAt(index)->SaveState(&message, index); + + ssize_t size = message.FlattenedSize(); + char* buffer = new char[size]; + status_t result = message.Flatten(buffer, size); + if (result == B_OK) { + node->WriteAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0, + buffer, (size_t)size); } + + delete[] buffer; break; + } case kByNameItem: case kByFormulaItem: - { - BTextControl* textControl = dynamic_cast<BTextControl*> - (FindView("TextControl")); - ASSERT(textControl); - BString formula(textControl->TextView()->Text()); - node->WriteAttrString(kAttrQueryInitialString, &formula); - break; - } + { + BTextControl* textControl = dynamic_cast<BTextControl*> + (FindView("TextControl")); + ASSERT(textControl); + BString formula(textControl->TextView()->Text()); + node->WriteAttrString(kAttrQueryInitialString, &formula); + break; + } } } @@ -2169,7 +2208,8 @@ FindPanel::RestoreWindowState(const BNode* node) // set modification message after checking the temporary check box, // and filling out the text control so that we do not // always trigger clearing of the temporary check box. - fQueryName->SetModificationMessage(new BMessage(kNameModifiedMessage)); + fQueryName->SetModificationMessage( + new BMessage(kNameModifiedMessage)); } // get volumes to perform query on @@ -2178,23 +2218,25 @@ FindPanel::RestoreWindowState(const BNode* node) attr_info info; if (node->GetAttrInfo(kAttrQueryVolume, &info) == B_OK) { char* buffer = new char[info.size]; - if (node->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0, buffer, (size_t)info.size) - == info.size) { + if (node->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0, buffer, + (size_t)info.size) == info.size) { BMessage message; if (message.Unflatten(buffer) == B_OK) { for (int32 index = 0; ;index++) { ASSERT(index < 100); BVolume volume; - // match a volume with the info embedded in the message - status_t result = MatchArchivedVolume(&volume, &message, index); + // match a volume with the info embedded in + // the message + status_t result = MatchArchivedVolume(&volume, &message, + index); if (result == B_OK) { char name[256]; volume.GetName(name); SelectItemWithLabel(fVolMenu, name); searchAllVolumes = false; } else if (result != B_DEV_BAD_DRIVE_NUM) - // if B_DEV_BAD_DRIVE_NUM, the volume just isn't mounted this - // time around, keep looking for more + // if B_DEV_BAD_DRIVE_NUM, the volume just isn't + // mounted this time around, keep looking for more // if other error, bail break; } @@ -2208,37 +2250,40 @@ FindPanel::RestoreWindowState(const BNode* node) switch (Mode()) { case kByAttributeItem: - { - int32 count = InitialAttrCount(node); + { + int32 count = InitialAttrCount(node); - attr_info info; - if (node->GetAttrInfo(kAttrQueryInitialAttrs, &info) != B_OK) - break; - char* buffer = new char[info.size]; - if (node->ReadAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0, buffer, (size_t)info.size) - == info.size) { - BMessage message; - if (message.Unflatten(buffer) == B_OK) - for (int32 index = 0; index < count; index++) - fAttrViewList.ItemAt(index)->RestoreState(message, index); - } - delete [] buffer; + attr_info info; + if (node->GetAttrInfo(kAttrQueryInitialAttrs, &info) != B_OK) break; + char* buffer = new char[info.size]; + if (node->ReadAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0, + buffer, (size_t)info.size) == info.size) { + BMessage message; + if (message.Unflatten(buffer) == B_OK) + for (int32 index = 0; index < count; index++) { + fAttrViewList.ItemAt(index)->RestoreState(message, + index); + } } + delete[] buffer; + break; + } case kByNameItem: case kByFormulaItem: - { - BString buffer; - if (node->ReadAttrString(kAttrQueryInitialString, &buffer) == B_OK) { - BTextControl* textControl = dynamic_cast<BTextControl*> - (FindView("TextControl")); - ASSERT(textControl); + { + BString buffer; + if (node->ReadAttrString(kAttrQueryInitialString, &buffer) + == B_OK) { + BTextControl* textControl = dynamic_cast<BTextControl*> + (FindView("TextControl")); + ASSERT(textControl); - textControl->TextView()->SetText(buffer.String()); - } + textControl->TextView()->SetText(buffer.String()); } break; + } } // try to restore focus and possibly text selection @@ -2304,7 +2349,8 @@ FindPanel::AddByNameOrFormulaItems() BRect bounds(box->Bounds()); bounds.InsetBy(10, 10); - BTextControl* textControl = new BTextControl(bounds, "TextControl", "", "", NULL); + BTextControl* textControl = new BTextControl(bounds, "TextControl", + "", "", NULL); textControl->SetDivider(0.0f); box->AddChild(textControl); textControl->MakeFocus(); @@ -2353,7 +2399,8 @@ FindPanel::RemoveByAttributeItems() void FindPanel::ShowOrHideMimeTypeMenu() { - BMenuField* menuField = dynamic_cast<BMenuField*>(FindView("MimeTypeMenu")); + BMenuField* menuField + = dynamic_cast<BMenuField*>(FindView("MimeTypeMenu")); if (Mode() == (int32)kByFormulaItem && !menuField->IsHidden()) menuField->Hide(); else if (menuField->IsHidden()) @@ -2398,8 +2445,8 @@ TAttrView::TAttrView(BRect frame, int32 index) for (int32 i = 0; i < 5; i++) { message = new BMessage(kAttributeItem); message->AddInt32("operator", operators[i]); - submenu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(operatorLabels[i]), - message)); + submenu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT( + operatorLabels[i]), message)); } // mark first item @@ -2464,7 +2511,7 @@ TAttrView::TAttrView(BRect frame, int32 index) AddChild(fTextControl); AddChild(fMenuField); - // add attributes from currently selected mimetype + // add attributes from currently selected mimetype } @@ -2558,7 +2605,8 @@ TAttrView::SaveState(BMessage* message, int32) if (field) { BMenuItem* item = field->Menu()->FindMarked(); ASSERT(item); - message->AddInt32("logicalRelation", item ? field->Menu()->IndexOf(item) : 0); + message->AddInt32("logicalRelation", + item ? field->Menu()->IndexOf(item) : 0); } } @@ -2618,7 +2666,8 @@ TAttrView::Draw(BRect) // draws the is/contains, etc. string bounds.left -= (width + 10); bounds.bottom -= 6; - DrawString(item->Submenu()->FindMarked()->Label(), bounds.LeftBottom()); + DrawString(item->Submenu()->FindMarked()->Label(), + bounds.LeftBottom()); } } @@ -2677,15 +2726,19 @@ TAttrView::AddAttributes(BMenu* menu, const BMimeType &mimeType) // go through each field in meta mime and add it to a menu for (int32 index = 0; ; index++) { const char* publicName; - if (attributeMessage.FindString("attr:public_name", index, &publicName) != B_OK) + if (attributeMessage.FindString("attr:public_name", index, + &publicName) != B_OK) { break; + } if (!attributeMessage.FindBool("attr:viewable")) continue; const char* attributeName; - if (attributeMessage.FindString("attr:name", index, &attributeName) != B_OK) + if (attributeMessage.FindString("attr:name", index, &attributeName) + != B_OK) { continue; + } int32 type; if (attributeMessage.FindInt32("attr:type", index, &type) != B_OK) @@ -2714,7 +2767,8 @@ TAttrView::AddAttributes(BMenu* menu, const BMimeType &mimeType) message = new BMessage(kAttributeItem); message->AddInt32("operator", B_NE); - submenu->AddItem(new BMenuItem(B_TRANSLATE("is not"), message)); + submenu->AddItem(new BMenuItem(B_TRANSLATE("is not"), + message)); submenu->SetTargetForItems(this); message = new BMessage(kAttributeItem); @@ -2942,12 +2996,14 @@ DeleteTransientQueriesTask::ProcessOneRef(Model* model) ASSERT(dynamic_cast<TTracker*>(be_app)); // check that it is not showing - if (dynamic_cast<TTracker*>(be_app)->EntryHasWindowOpen(model->EntryRef())) { + if (dynamic_cast<TTracker*>(be_app)->EntryHasWindowOpen( + model->EntryRef())) { PRINT(("query %s, showing, can't delete\n", model->Name())); return false; } - PRINT(("query %s, old, temporary, not shownig - deleting\n", model->Name())); + PRINT(("query %s, old, temporary, not shownig - deleting\n", + model->Name())); BEntry entry(model->EntryRef()); entry.Remove(); @@ -2993,8 +3049,8 @@ DeleteTransientQueriesTask::StartUpTransientQueryCleaner() // #pragma mark - -RecentFindItemsMenu::RecentFindItemsMenu(const char* title, const BMessenger* target, - uint32 what) +RecentFindItemsMenu::RecentFindItemsMenu(const char* title, + const BMessenger* target, uint32 what) : BMenu(title, B_ITEMS_IN_COLUMN), fTarget(*target), fWhat(what) @@ -3029,7 +3085,8 @@ TrackerBuildRecentFindItemsMenu(const char* title) DraggableQueryIcon::DraggableQueryIcon(BRect frame, const char* name, - const BMessage* message, BMessenger messenger, uint32 resizeFlags, uint32 flags) + const BMessage* message, BMessenger messenger, uint32 resizeFlags, + uint32 flags) : DraggableIcon(frame, name, B_QUERY_MIMETYPE, B_LARGE_ICON, message, messenger, resizeFlags, flags) { @@ -3056,7 +3113,8 @@ DraggableQueryIcon::DragStarted(BMessage* dragMessage) // #pragma mark - -MostUsedNames::MostUsedNames(const char* fileName, const char* directory, int32 maxCount) +MostUsedNames::MostUsedNames(const char* fileName, const char* directory, + int32 maxCount) : fFileName(fileName), fDirectory(directory), @@ -3157,7 +3215,8 @@ MostUsedNames::AddName(const char* name) list_entry* entry = NULL; if (fList.CountItems() > fCount * 2) { - entry = static_cast<list_entry*>(fList.RemoveItem(fList.CountItems() - 1)); + entry = static_cast<list_entry*>( + fList.RemoveItem(fList.CountItems() - 1)); // is this the name we want to add here? if (strcmp(name, entry->name)) { @@ -3169,9 +3228,12 @@ MostUsedNames::AddName(const char* name) } if (entry == NULL) { - for (int32 i = 0; (entry = static_cast<list_entry*>(fList.ItemAt(i))) != NULL; i++) + for (int32 i = 0; + (entry = static_cast<list_entry*>(fList.ItemAt(i))) != NULL; + i++) { if (!strcmp(entry->name, name)) break; + } } if (entry == NULL) { diff --git a/src/kits/tracker/GroupedMenu.cpp b/src/kits/tracker/GroupedMenu.cpp index 8eb4dfb..d781ee7 100644 --- a/src/kits/tracker/GroupedMenu.cpp +++ b/src/kits/tracker/GroupedMenu.cpp @@ -176,8 +176,10 @@ TGroupedMenu::TGroupedMenu(const char* name) TGroupedMenu::~TGroupedMenu() { TMenuItemGroup* group; - while ((group = static_cast<TMenuItemGroup*>(fGroups.RemoveItem(0L))) != NULL) + while ((group = static_cast<TMenuItemGroup*>(fGroups.RemoveItem(0L))) + != NULL) { delete group; + } } @@ -247,7 +249,8 @@ TGroupedMenu::CountGroups() void -TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex) +TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item, + int32 atIndex) { int32 groupIndex = fGroups.IndexOf(group); bool addSeparator = false; @@ -257,7 +260,8 @@ TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex if (groupIndex > 0) { // add this group after an existing one TMenuItemGroup* previous = GroupAt(groupIndex - 1); - group->fFirstItemIndex = previous->fFirstItemIndex + previous->fItemsTotal; + group->fFirstItemIndex = previous->fFirstItemIndex + + previous->fItemsTotal; addSeparator = true; } else { // this is the first group @@ -283,7 +287,8 @@ TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex // insert item for real - AddItem(item, atIndex + group->fFirstItemIndex + (group->HasSeparator() ? 1 : 0)); + AddItem(item, + atIndex + group->fFirstItemIndex + (group->HasSeparator() ? 1 : 0)); // move the groups after this one @@ -320,4 +325,3 @@ TGroupedMenu::RemoveGroupItem(TMenuItemGroup* group, BMenuItem* item) group->fFirstItemIndex -= removedSeparator ? 2 : 1; } } - diff --git a/src/kits/tracker/IconCache.cpp b/src/kits/tracker/IconCache.cpp index bfdc610..8cf9d8e 100644 --- a/src/kits/tracker/IconCache.cpp +++ b/src/kits/tracker/IconCache.cpp @@ -242,13 +242,17 @@ IconCacheEntry::IconHitTest(BPoint where, IconDrawMode mode, icon_size size) con BBitmap* -IconCacheEntry::ConstructBitmap(BBitmap* constructFrom, IconDrawMode requestedMode, - IconDrawMode constructFromMode, icon_size size, LazyBitmapAllocator* lazyBitmap) +IconCacheEntry::ConstructBitmap(BBitmap* constructFrom, + IconDrawMode requestedMode, IconDrawMode constructFromMode, + icon_size size, LazyBitmapAllocator* lazyBitmap) { ASSERT(requestedMode == kSelected && constructFromMode == kNormalIcon); // for now - if (requestedMode == kSelected && constructFromMode == kNormalIcon) - return IconCache::sIconCache->MakeSelectedIcon(constructFrom, size, lazyBitmap); + + if (requestedMode == kSelected && constructFromMode == kNormalIcon) { + return IconCache::sIconCache->MakeSelectedIcon(constructFrom, size, + lazyBitmap); + } return NULL; } @@ -260,7 +264,8 @@ IconCacheEntry::ConstructBitmap(IconDrawMode requestedMode, icon_size size, { BBitmap* source = (size == B_MINI_ICON) ? fMiniIcon : fLargeIcon; ASSERT(source); - return ConstructBitmap(source, requestedMode, kNormalIcon, size, lazyBitmap); + return ConstructBitmap(source, requestedMode, kNormalIcon, size, + lazyBitmap); } @@ -303,14 +308,13 @@ IconCache::IconCache() } -// The following calls use the icon lookup sequence node-prefered app for node- -// metamime-preferred app for metamime to find an icon; +// The following calls use the icon lookup sequence node-prefered app for +// node-metamime-preferred app for metamime to find an icon; // if we are trying to get a specialized icon, we will first look for a normal -// icon in each of the locations, if we get a hit, we look for the specialized, -// if we don't find one, we try to auto-construct one, if we can't we assume the -// icon is not available -// for now the code only looks for normal icons, selected icons are auto-generated - +// icon in each of the locations, if we get a hit, we look for the +// specialized, if we don't find one, we try to auto-construct one, if we +// can't we assume the icon is not available for now the code only looks for +// normal icons, selected icons are auto-generated IconCacheEntry* IconCache::GetIconForPreferredApp(const char* fileTypeSignature, const char* preferredApp, IconDrawMode mode, icon_size size, @@ -336,20 +340,24 @@ IconCache::GetIconForPreferredApp(const char* fileTypeSignature, if (!entry || !entry->HaveIconBitmap(NORMAL_ICON_ONLY, size)) { - PRINT_DISK_HITS(("File %s; Line %d # hitting disk for preferredApp %s, type %s\n", + PRINT_DISK_HITS( + ("File %s; Line %d # hitting disk for preferredApp %s, type %s\n", __FILE__, __LINE__, preferredApp, fileTypeSignature)); BMimeType preferredAppType(preferredApp); BString signature(fileTypeSignature); signature.ToLower(); - if (preferredAppType.GetIconForType(signature.String(), lazyBitmap->Get(), - size) != B_OK) + if (preferredAppType.GetIconForType(signature.String(), + lazyBitmap->Get(), size) != B_OK) { return NULL; + } BBitmap* bitmap = lazyBitmap->Adopt(); if (!entry) { - PRINT_ADD_ITEM(("File %s; Line %d # adding entry for preferredApp %s, type %s\n", - __FILE__, __LINE__, preferredApp, fileTypeSignature)); + PRINT_ADD_ITEM( + ("File %s; Line %d # adding entry for preferredApp %s, " + "type %s\n", __FILE__, __LINE__, preferredApp, + fileTypeSignature)); entry = fSharedCache.AddItem(fileTypeSignature, preferredApp); } entry->SetIcon(bitmap, kNormalIcon, size); @@ -394,8 +402,10 @@ IconCache::GetIconFromMetaMime(const char* fileType, IconDrawMode mode, return NULL; SharedCacheEntry* aliasTo = NULL; - if (entry) - aliasTo = (SharedCacheEntry*)entry->ResolveIfAlias(&fSharedCache); + if (entry) { + aliasTo + = (SharedCacheEntry*)entry->ResolveIfAlias(&fSharedCache); + } // look for icon defined by preferred app from metamime aliasTo = (SharedCacheEntry*)GetIconForPreferredApp(fileType, @@ -407,7 +417,8 @@ IconCache::GetIconFromMetaMime(const char* fileType, IconDrawMode mode, // make an aliased entry so that the next time we get a // hit on the first FindItem in here if (!entry) { - PRINT_ADD_ITEM(("File %s; Line %d # adding entry as alias for type %s\n", + PRINT_ADD_ITEM( + ("File %s; Line %d # adding entry as alias for type %s\n", __FILE__, __LINE__, fileType)); entry = fSharedCache.AddItem(&aliasTo, fileType); entry->SetAliasFor(&fSharedCache, aliasTo); [ *** diff truncated: 2474 lines dropped *** ] ############################################################################ Revision: hrev44421 Commit: ea001e585a588e40404945a1201821da893d2e09 URL: http://cgit.haiku-os.org/haiku/commit/?id=ea001e5 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jul 28 18:00:24 2012 UTC Round 2 of style changes to Tracker * focused on 80-char limit fixes. * also some whitespace and case statement indentation fixes ----------------------------------------------------------------------------