本文整理汇总了C++中Model::CloseNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Model::CloseNode方法的具体用法?C++ Model::CloseNode怎么用?C++ Model::CloseNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::CloseNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dir
void
NodePreloader::PreloadOne(const char* dirPath)
{
//PRINT(("preloading directory %s\n", dirPath));
BDirectory dir(dirPath);
if (!dir.InitCheck() == B_OK)
return;
node_ref nodeRef;
dir.GetNodeRef(&nodeRef);
// have to node monitor the whole directory
TTracker::WatchNode(&nodeRef, B_WATCH_DIRECTORY, this);
dir.Rewind();
for (;;) {
entry_ref ref;
if (dir.GetNextRef(&ref) != B_OK)
break;
BEntry entry(&ref);
if (!entry.IsFile())
// only interrested in files
continue;
Model* model = new Model(&ref, true);
if (model->InitCheck() == B_OK && model->IconFrom() == kUnknownSource) {
TTracker::WatchNode(model->NodeRef(),
B_WATCH_STAT | B_WATCH_ATTR, this);
IconCache::sIconCache->Preload(model, kNormalIcon, B_MINI_ICON,
true);
fModelList.AddItem(model);
model->CloseNode();
} else
delete model;
}
}
示例2: opener
ModelMenuItem *
BSlowContextMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
const BMessenger &target, bool suppressFolderHierarchy,
BContainerWindow *parentWindow, const BObjectList<BString> *typeslist,
TrackingHookData *hook)
{
if (model->InitCheck() != B_OK)
return NULL;
entry_ref ref;
bool container = false;
if (model->IsSymLink()) {
Model *newResolvedModel = NULL;
Model *result = model->LinkTo();
if (!result) {
newResolvedModel = new Model(model->EntryRef(), true, true);
if (newResolvedModel->InitCheck() != B_OK) {
// broken link, still can show though, bail
delete newResolvedModel;
newResolvedModel = NULL;
}
result = newResolvedModel;
}
if (result) {
BModelOpener opener(result);
// open the model, if it ain't open already
PoseInfo poseInfo;
ssize_t size = -1;
if (result->Node())
size = result->Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
&poseInfo, sizeof(poseInfo));
result->CloseNode();
ref = *result->EntryRef();
container = result->IsContainer();
}
model->SetLinkTo(result);
} else {
ref = *model->EntryRef();
container = model->IsContainer();
}
BMessage *message = new BMessage(*invokeMessage);
message->AddRef("refs", model->EntryRef());
// Truncate the name if necessary
BString truncatedString(model->Name());
be_plain_font->TruncateString(&truncatedString, B_TRUNCATE_END,
BNavMenu::GetMaxMenuWidth());
ModelMenuItem *item = NULL;
if (!container || suppressFolderHierarchy) {
item = new ModelMenuItem(model, truncatedString.String(), message);
if (invokeMessage->what != B_REFS_RECEIVED)
item->SetEnabled(false);
} else {
BNavMenu *menu = new BNavMenu(truncatedString.String(),
invokeMessage->what, target, parentWindow, typeslist);
menu->SetNavDir(&ref);
if (hook)
menu->InitTrackingHook(hook->fTrackingHook, &(hook->fTarget),
hook->fDragMessage);
item = new ModelMenuItem(model, menu);
item->SetMessage(message);
}
return item;
}
示例3: entry
status_t
TTracker::OpenRef(const entry_ref *ref, const node_ref *nodeToClose,
const node_ref *nodeToSelect, OpenSelector selector,
const BMessage *messageToBundle)
{
Model *model = NULL;
BEntry entry(ref, true);
status_t result = entry.InitCheck();
bool brokenLinkWithSpecificHandler = false;
BString brokenLinkPreferredApp;
if (result != B_OK) {
model = new Model(ref, false);
if (model->IsSymLink() && !model->LinkTo()) {
model->GetPreferredAppForBrokenSymLink(brokenLinkPreferredApp);
if (brokenLinkPreferredApp.Length() && brokenLinkPreferredApp != kTrackerSignature)
brokenLinkWithSpecificHandler = true;
}
if (!brokenLinkWithSpecificHandler) {
delete model;
(new BAlert("", "There was an error resolving the link.",
"Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
return result;
}
} else
model = new Model(&entry);
result = model->InitCheck();
if (result != B_OK) {
delete model;
return result;
}
bool openAsContainer = model->IsContainer();
if (openAsContainer && selector != kOpenWith) {
// if folder or query has a preferred handler and it's not the
// Tracker, open it by sending refs to the handling app
// if we are responding to the final open of OpenWith, just
// skip this and proceed to opening the container with Tracker
model->OpenNode();
BNodeInfo nodeInfo(model->Node());
char preferredApp[B_MIME_TYPE_LENGTH];
if (nodeInfo.GetPreferredApp(preferredApp) == B_OK
&& strcasecmp(preferredApp, kTrackerSignature) != 0)
openAsContainer = false;
model->CloseNode();
}
if (openAsContainer || selector == kRunOpenWithWindow) {
// special case opening plain folders, queries or using open with
OpenContainerWindow(model, 0, selector); // window adopts model
if (nodeToClose)
CloseParentWaitingForChildSoon(ref, nodeToClose);
} else if (model->IsQueryTemplate()) {
// query template - open new find window
(new FindWindow(model->EntryRef()))->Show();
if (nodeToClose)
CloseParentWaitingForChildSoon(ref, nodeToClose);
} else {
delete model;
// run Launch in a separate thread
// and close parent if successfull
if (nodeToClose)
Thread::Launch(new EntryAndNodeDoSoonWithMessageFunctor<TTracker,
bool (TTracker::*)(const entry_ref *, const node_ref *,
const BMessage *)>(&TTracker::LaunchAndCloseParentIfOK, this,
ref, nodeToClose, messageToBundle));
else {
BMessage refsReceived(B_REFS_RECEIVED);
if (messageToBundle) {
refsReceived = *messageToBundle;
refsReceived.what = B_REFS_RECEIVED;
}
refsReceived.AddRef("refs", ref);
if (brokenLinkWithSpecificHandler)
// This cruft is to support a hacky workaround for double-clicking
// broken refs for cifs; should get fixed in R5
LaunchBrokenLink(brokenLinkPreferredApp.String(), &refsReceived);
else
TrackerLaunch(&refsReceived, true);
}
}
if (nodeToSelect)
SelectChildInParentSoon(ref, nodeToSelect);
return B_OK;
}
示例4: model
BMenuItem*
BRecentItemsList::GetNextMenuItem(const BMessage* fileOpenInvokeMessage,
const BMessage* containerOpenInvokeMessage, BHandler* target,
entry_ref* currentItemRef)
{
entry_ref ref;
if (GetNextRef(&ref) != B_OK)
return NULL;
Model model(&ref, true);
if (model.InitCheck() != B_OK)
return NULL;
bool container = false;
if (model.IsSymLink()) {
Model* newResolvedModel = NULL;
Model* result = model.LinkTo();
if (result == NULL) {
newResolvedModel = new Model(model.EntryRef(), true, true);
if (newResolvedModel->InitCheck() != B_OK) {
// broken link, still can show though, bail
delete newResolvedModel;
result = NULL;
} else
result = newResolvedModel;
} else {
BModelOpener opener(result);
// open the model, if it ain't open already
PoseInfo poseInfo;
BNode* resultNode = result->Node();
if (resultNode != NULL) {
resultNode->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
&poseInfo, sizeof(poseInfo));
}
result->CloseNode();
ref = *result->EntryRef();
container = result->IsContainer();
}
model.SetLinkTo(result);
} else {
ref = *model.EntryRef();
container = model.IsContainer();
}
// if user asked for it, return the current item ref
if (currentItemRef != NULL)
*currentItemRef = ref;
BMessage* message;
if (container && containerOpenInvokeMessage)
message = new BMessage(*containerOpenInvokeMessage);
else if (!container && fileOpenInvokeMessage)
message = new BMessage(*fileOpenInvokeMessage);
else
message = new BMessage(B_REFS_RECEIVED);
message->AddRef("refs", model.EntryRef());
// Truncate the name if necessary
BString truncatedString(model.Name());
be_plain_font->TruncateString(&truncatedString, B_TRUNCATE_END,
BNavMenu::GetMaxMenuWidth());
ModelMenuItem* item = NULL;
if (!container || !fNavMenuFolders)
item = new ModelMenuItem(&model, truncatedString.String(), message);
else {
// add another nav menu item if it's a directory
BNavMenu* menu = new BNavMenu(truncatedString.String(), message->what,
target, 0);
menu->SetNavDir(&ref);
item = new ModelMenuItem(&model, menu);
item->SetMessage(message);
}
if (item != NULL && target != NULL)
item->SetTarget(target);
return item;
}
示例5: opener
ModelMenuItem *
BNavMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
const BMessenger &target, bool suppressFolderHierarchy,
BContainerWindow *parentWindow, const BObjectList<BString> *typeslist,
TrackingHookData *hook)
{
if (model->InitCheck() != B_OK)
return 0;
entry_ref ref;
bool container = false;
if (model->IsSymLink()) {
Model *newResolvedModel = 0;
Model *result = model->LinkTo();
if (!result) {
newResolvedModel = new Model(model->EntryRef(), true, true);
if (newResolvedModel->InitCheck() != B_OK) {
// broken link, still can show though, bail
delete newResolvedModel;
result = 0;
} else
result = newResolvedModel;
}
if (result) {
BModelOpener opener(result);
// open the model, if it ain't open already
PoseInfo poseInfo;
ssize_t size = -1;
if (result->Node())
size = result->Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
&poseInfo, sizeof(poseInfo));
result->CloseNode();
if (size == sizeof(poseInfo) && !BPoseView::PoseVisible(result,
&poseInfo, false)) {
// link target sez it doesn't want to be visible,
// don't show the link
PRINT(("not showing hidden item %s\n", model->Name()));
delete newResolvedModel;
return 0;
}
ref = *result->EntryRef();
container = result->IsContainer();
}
model->SetLinkTo(result);
} else {
ref = *model->EntryRef();
container = model->IsContainer();
}
BMessage *message = new BMessage(*invokeMessage);
message->AddRef("refs", model->EntryRef());
// Truncate the name if necessary
BString truncatedString;
TruncString(be_plain_font, model->Name(), truncatedString, GetMaxMenuWidth());
ModelMenuItem *item = NULL;
if (!container || suppressFolderHierarchy) {
item = new ModelMenuItem(model, truncatedString.String(), message);
if (invokeMessage->what != B_REFS_RECEIVED)
item->SetEnabled(false);
// the above is broken for FavoritesMenu::AddNextItem, which uses a
// workaround - should fix this
} else {
BNavMenu *menu = new BNavMenu(truncatedString.String(),
invokeMessage->what, target, parentWindow, typeslist);
menu->SetNavDir(&ref);
if (hook)
menu->InitTrackingHook(hook->fTrackingHook, &(hook->fTarget),
hook->fDragMessage);
item = new ModelMenuItem(model, menu);
item->SetMessage(message);
}
return item;
}