Tracker: style fixes to FavoritesMenu
This commit is contained in:
@@ -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,17 +62,22 @@ 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),
|
:
|
||||||
fOpenFolderMessage(openFolderMessage),
|
BSlowMenu(title),
|
||||||
fOpenFileMessage(openFileMessage),
|
fOpenFolderMessage(openFolderMessage),
|
||||||
fTarget(target),
|
fOpenFileMessage(openFileMessage),
|
||||||
fContainer(NULL),
|
fTarget(target),
|
||||||
fInitialItemCount(0),
|
fContainer(NULL),
|
||||||
fIsSavePanel(isSavePanel),
|
fInitialItemCount(0),
|
||||||
fRefFilter(filter)
|
fIsSavePanel(isSavePanel),
|
||||||
|
fRefFilter(filter)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user