Tracker: style fixes to FavoritesMenu

This commit is contained in:
John Scipione
2014-06-20 21:01:42 -04:00
parent e4d63b6d50
commit 345d92c402
2 changed files with 34 additions and 23 deletions
+21 -12
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved. All rights reserved.
*/ */
#include "FavoritesMenu.h" #include "FavoritesMenu.h"
#include <compat/sys/stat.h> #include <compat/sys/stat.h>
@@ -61,10 +62,15 @@ All rights reserved.
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "FavoritesMenu" #define B_TRANSLATION_CONTEXT "FavoritesMenu"
// #pragma mark - FavoritesMenu
FavoritesMenu::FavoritesMenu(const char* title, BMessage* openFolderMessage, FavoritesMenu::FavoritesMenu(const char* title, BMessage* openFolderMessage,
BMessage* openFileMessage, const BMessenger &target, BMessage* openFileMessage, const BMessenger &target,
bool isSavePanel, BRefFilter* filter) bool isSavePanel, BRefFilter* filter)
: BSlowMenu(title), :
BSlowMenu(title),
fOpenFolderMessage(openFolderMessage), fOpenFolderMessage(openFolderMessage),
fOpenFileMessage(openFileMessage), fOpenFileMessage(openFileMessage),
fTarget(target), fTarget(target),
@@ -96,7 +102,7 @@ FavoritesMenu::StartBuildingItemList()
{ {
// initialize the menu building state // initialize the menu building state
if (!fInitialItemCount) if (fInitialItemCount == 0)
fInitialItemCount = CountItems(); fInitialItemCount = CountItems();
else { else {
// strip the old items so we can add new fresh ones // strip the old items so we can add new fresh ones
@@ -141,24 +147,22 @@ FavoritesMenu::AddNextItem()
fContainer = new QueryEntryListCollection(&startModel); fContainer = new QueryEntryListCollection(&startModel);
else if (startModel.IsVirtualDirectory()) else if (startModel.IsVirtualDirectory())
fContainer = new VirtualDirectoryEntryList(&startModel); fContainer = new VirtualDirectoryEntryList(&startModel);
else else {
fContainer = new DirectoryEntryList(*dynamic_cast<BDirectory*> fContainer = new DirectoryEntryList(*dynamic_cast<BDirectory*>
(startModel.Node())); (startModel.Node()));
}
ThrowOnInitCheckError(fContainer); ThrowOnInitCheckError(fContainer);
ThrowOnError( fContainer->Rewind() ); ThrowOnError( fContainer->Rewind() );
} catch (...) { } catch (...) {
delete fContainer; delete fContainer;
fContainer = NULL; fContainer = NULL;
} }
} }
if (fState == kAddingFavorites) { if (fState == kAddingFavorites) {
entry_ref ref; entry_ref ref;
if (fContainer if (fContainer != NULL && fContainer->GetNextRef(&ref) == B_OK) {
&& fContainer->GetNextRef(&ref) == B_OK) {
Model model(&ref, true); Model model(&ref, true);
if (model.InitCheck() != B_OK) if (model.InitCheck() != B_OK)
return true; return true;
@@ -183,6 +187,7 @@ FavoritesMenu::AddNextItem()
fUniqueRefCheck.push_back(*model.EntryRef()); fUniqueRefCheck.push_back(*model.EntryRef());
AddItem(item); AddItem(item);
fSectionItemCount++; fSectionItemCount++;
return true; return true;
} }
@@ -272,7 +277,7 @@ FavoritesMenu::AddNextItem()
BMenuItem* item = BNavMenu::NewModelItem(&model, BMenuItem* item = BNavMenu::NewModelItem(&model,
fOpenFolderMessage, fTarget, true); fOpenFolderMessage, fTarget, true);
if (item) { if (item != NULL) {
if (!fAddedSeparatorForSection) { if (!fAddedSeparatorForSection) {
fAddedSeparatorForSection = true; fAddedSeparatorForSection = true;
AddItem(new TitledSeparatorItem( AddItem(new TitledSeparatorItem(
@@ -282,10 +287,12 @@ FavoritesMenu::AddNextItem()
item->SetEnabled(true); item->SetEnabled(true);
// BNavMenu::NewModelItem returns a disabled item here - // BNavMenu::NewModelItem returns a disabled item here -
// need to fix this in BNavMenu::NewModelItem // need to fix this in BNavMenu::NewModelItem
return true; return true;
} }
} }
} }
return false; return false;
} }
@@ -326,12 +333,13 @@ FavoritesMenu::ShouldShowModel(const Model* model)
} }
// #pragma mark - // #pragma mark - RecentsMenu
RecentsMenu::RecentsMenu(const char* name, int32 which, uint32 what, RecentsMenu::RecentsMenu(const char* name, int32 which, uint32 what,
BHandler* target) BHandler* target)
: BNavMenu(name, what, target), :
BNavMenu(name, what, target),
fWhich(which), fWhich(which),
fRecentsCount(0), fRecentsCount(0),
fItemIndex(0) fItemIndex(0)
@@ -420,18 +428,19 @@ RecentsMenu::AddRecents(int32 count)
if (fRecentList.FindRef("refs", fItemIndex++, &ref) != B_OK) if (fRecentList.FindRef("refs", fItemIndex++, &ref) != B_OK)
break; break;
if (ref.name && strlen(ref.name) > 0) { if (ref.name != NULL && strlen(ref.name) > 0) {
Model model(&ref, true); Model model(&ref, true);
ModelMenuItem* item = BNavMenu::NewModelItem(&model, ModelMenuItem* item = BNavMenu::NewModelItem(&model,
new BMessage(fMessage.what), new BMessage(fMessage.what),
Target(), false, NULL, TypesList()); Target(), false, NULL, TypesList());
if (item) { if (item != NULL) {
AddItem(item); AddItem(item);
// return true so that we know to reenter this list // return true so that we know to reenter this list
return true; return true;
} }
return true; return true;
} }
} }
+6 -4
View File
@@ -31,14 +31,15 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders. names are registered trademarks or trademarks of their respective holders.
All rights reserved. All rights reserved.
*/ */
#ifndef __FAVORITES_MENU__ #ifndef _FAVORITES_MENU_H
#define __FAVORITES_MENU__ #define _FAVORITES_MENU_H
#include <vector> #include <vector>
#include <ObjectList.h>
#include "NavMenu.h" #include "NavMenu.h"
#include "ObjectList.h"
class BRefFilter; class BRefFilter;
@@ -137,4 +138,5 @@ class RecentsMenu : public BNavMenu {
using namespace BPrivate; using namespace BPrivate;
#endif
#endif // _FAVORITES_MENU_H