コード例 #1
0
ファイル: PoseList.cpp プロジェクト: AmirAbrams/haiku
PoseList*
PoseList::FindAllPoses(const node_ref* node) const
{
	int32 count = CountItems();
	PoseList *result = new PoseList(5, false);
	for (int32 index = 0; index < count; index++) {
		BPose *pose = ItemAt(index);
		Model *model = pose->TargetModel();
		if (*model->NodeRef() == *node) {
			result->AddItem(pose, 0);
			continue;
		}

		if (!model->IsSymLink())
			continue;

		model = model->LinkTo();
		if (model != NULL && *model->NodeRef() == *node) {
			result->AddItem(pose);
			continue;
		}

		if (model == NULL) {
			Model model(pose->TargetModel()->EntryRef(), true);
			if (*model.NodeRef() == *node)
				result->AddItem(pose);
		}
	}

	return result;
}
コード例 #2
0
ファイル: QueryPoseView.cpp プロジェクト: bhanug/haiku
bool
BQueryPoseView::ShouldShowPose(const Model* model, const PoseInfo* poseInfo)
{
	// add_poses, etc. filter
	ASSERT(TargetModel());

	TTracker* tracker = dynamic_cast<TTracker*>(be_app);
	if (!fShowResultsFromTrash && tracker != NULL
		&& tracker->InTrashNode(model->EntryRef())) {
		return false;
	}

	bool result = _inherited::ShouldShowPose(model, poseInfo);

	PoseList* oldPoseList = fQueryListContainer->OldPoseList();
	if (result && oldPoseList != NULL) {
		// pose will get added - remove it from the old pose list
		// because it is supposed to be showing
		BPose* pose = oldPoseList->FindPose(model);
		if (pose != NULL)
			oldPoseList->RemoveItem(pose);
	}

	return result;
}
コード例 #3
0
ファイル: IMGDock.C プロジェクト: HeyJJ/ball
	void IMGDock::optimizeRotation(vector < int > & conf, PoseList& best_conformations, Size bond, bool ignore_original_angle)
	{
		// just in order to produce exactly the same result as before (since the order of tested conformation does play a role)
		if (!decrease_stepwidth_)
		{
			int no_steps = no_steps_;
			if (ignore_original_angle) no_steps--;

			for (int i = 0; i < no_steps; i++)
			{
				conf[bond] = (conf[bond]+step_width_)%360;
				applyConformation(conf);

				update();
				double score = getScore();
				if (best_conformations.size() < no_solutions_ || score < best_conformations.rbegin()->first)
				{
					best_conformations.insert(make_pair(score, conf));
					if (best_conformations.size() > no_solutions_)
					{
						PoseList::iterator it = best_conformations_.end();
						it--;
						best_conformations.erase(it);
					}
				}
			}
		}

		else
		{
			int original_value = conf[bond];
			conf[bond] = (conf[bond]-(no_steps_/2)*step_width_)%360;
			if (conf[bond] < 0) conf[bond] = 360+conf[bond];
			//Log<<"conf[bond] ="<<conf[bond]<<"  ";

			for (int i = 0; i < no_steps_; i++)
			{
				conf[bond] = (conf[bond]+step_width_)%360;
				if (ignore_original_angle && conf[bond] == original_value) continue; // this conformation has been evaluated previously

				applyConformation(conf);

				update();
				double score = getScore();
				if (best_conformations.size() < no_solutions_ || score < best_conformations.rbegin()->first)
				{
					best_conformations.insert(make_pair(score, conf));
					if (best_conformations.size() > no_solutions_)
					{
						PoseList::iterator it = best_conformations_.end();
						it--;
						best_conformations.erase(it);
					}
				}
			}//Log<<endl;
		}
	}
コード例 #4
0
ファイル: QueryPoseView.cpp プロジェクト: RTOSkit/haiku
void
BQueryPoseView::AddPosesCompleted()
{
	ASSERT(Window()->IsLocked());

	PoseList* oldPoseList = fQueryListContainer->OldPoseList();
	if (oldPoseList) {
		int32 count = oldPoseList->CountItems();
		for (int32 index = count - 1; index >= 0; index--) {
			BPose* pose = oldPoseList->ItemAt(index);
			DeletePose(pose->TargetModel()->NodeRef());
		}
		fQueryListContainer->ClearOldPoseList();
	}

	_inherited::AddPosesCompleted();
}
コード例 #5
0
bool
VirtualDirectoryPoseView::_EntryRemoved(const BMessage* message)
{
	NotOwningEntryRef entryRef;
	node_ref nodeRef;

	if (message->FindInt32("device", &nodeRef.device) != B_OK
		|| message->FindInt64("node", &nodeRef.node) != B_OK
		|| message->FindInt64("directory", &entryRef.directory)
			!= B_OK
		|| message->FindString("name", (const char**)&entryRef.name) != B_OK) {
		return true;
	}
	entryRef.device = nodeRef.device;

	// It might be our definition file.
	if (nodeRef == *TargetModel()->NodeRef())
		return _inherited::FSNotification(message);

	// It might be one of our directories.
	BString path;
	if (message->FindString("path", &path) == B_OK
		&& fDirectoryPaths.HasString(path)) {
		// Find all poses that stem from that directory and generate an
		// entry-removed message for each.
		PoseList poses;
		for (int32 i = 0; BPose* pose = fPoseList->ItemAt(i); i++) {
			NotOwningEntryRef poseEntryRef = *pose->TargetModel()->EntryRef();
			if (poseEntryRef.DirectoryNodeRef() == nodeRef)
				poses.AddItem(pose);
		}

		for (int32 i = 0; BPose* pose = poses.ItemAt(i); i++) {
			_DispatchEntryCreatedOrRemovedMessage(B_ENTRY_REMOVED,
				*pose->TargetModel()->NodeRef(),
				*pose->TargetModel()->EntryRef(), NULL, false);
		}

		return true;
	}

	// If it is a directory, translate it.
	entry_ref* actualEntryRef = &entryRef;
	node_ref* actualNodeRef = &nodeRef;
	entry_ref definitionEntryRef;
	node_ref definitionNodeRef;

	VirtualDirectoryManager* manager = VirtualDirectoryManager::Instance();
	AutoLocker<VirtualDirectoryManager> managerLocker(manager);

	if (manager != NULL
		&& manager->GetSubDirectoryDefinitionFile(*TargetModel()->NodeRef(),
			entryRef.name, definitionEntryRef, definitionNodeRef)) {
		actualEntryRef = &definitionEntryRef;
		actualNodeRef = &definitionNodeRef;
	}

	// Check the pose. It might have been an entry that wasn't visible anyway.
	// In that case we can just ignore the notification.
	BPose* pose = fPoseList->FindPoseByFileName(actualEntryRef->name);
	if (pose == NULL || *actualNodeRef != *pose->TargetModel()->NodeRef())
		return true;

	// See, if another entry becomes visible, now.
	struct stat st;
	entry_ref visibleEntryRef;
	node_ref visibleNodeRef;
	if (_GetEntry(actualEntryRef->name, visibleEntryRef, &st)) {
		// If the new entry is a directory, translate it.
		visibleNodeRef = node_ref(st.st_dev, st.st_ino);
		if (S_ISDIR(st.st_mode)) {
			if (manager == NULL || manager->TranslateDirectoryEntry(
					*TargetModel()->NodeRef(), visibleEntryRef, visibleNodeRef)
					!= B_OK) {
				return true;
			}

			// Effectively nothing changes, when the removed entry was a
			// directory as well.
			if (visibleNodeRef == *actualNodeRef)
				return true;
		}
	}

	if (actualEntryRef == &entryRef) {
		managerLocker.Unlock();
		if (_inherited::FSNotification(message))
			pendingNodeMonitorCache.Add(message);
	} else {
		// tell the manager that the directory has been removed
		manager->DirectoryRemoved(*actualNodeRef);
		managerLocker.Unlock();

		_DispatchEntryCreatedOrRemovedMessage(B_ENTRY_REMOVED, *actualNodeRef,
			*actualEntryRef);
	}

	_DispatchEntryCreatedOrRemovedMessage(B_ENTRY_CREATED, visibleNodeRef,
		visibleEntryRef);

	return true;
}
コード例 #6
0
ファイル: QueryPoseView.cpp プロジェクト: RTOSkit/haiku
EntryListBase*
BQueryPoseView::InitDirentIterator(const entry_ref* ref)
{
	BEntry entry(ref);
	if (entry.InitCheck() != B_OK)
		return NULL;

	Model sourceModel(&entry, true);
	if (sourceModel.InitCheck() != B_OK)
		return NULL;

	ASSERT(sourceModel.IsQuery());

	// old pose list is used for finding poses that no longer match a
	// dynamic date query during a Refresh call
	PoseList* oldPoseList = NULL;
	if (fCreateOldPoseList) {
		oldPoseList = new PoseList(10, false);
		oldPoseList->AddList(fPoseList);
	}

	fQueryListContainer = new QueryEntryListCollection(&sourceModel, this,
		oldPoseList);
	fCreateOldPoseList = false;
	
	if (fQueryListContainer->InitCheck() != B_OK) {
		delete fQueryListContainer;
		fQueryListContainer = NULL;
		return NULL;
	}
	
	fShowResultsFromTrash = fQueryListContainer->ShowResultsFromTrash();

	TTracker::WatchNode(sourceModel.NodeRef(), B_WATCH_NAME | B_WATCH_STAT
		| B_WATCH_ATTR, this);

	fQueryList = fQueryListContainer->QueryList();
	
	if (fQueryListContainer->DynamicDateQuery()) {

		// calculate the time to trigger the query refresh - next midnight
		time_t now = time(0);

		time_t nextMidnight = now + 60 * 60 * 24;
			// move ahead by a day
		tm timeData;
		localtime_r(&nextMidnight, &timeData);
		timeData.tm_sec = 0;
		timeData.tm_min = 0;
		timeData.tm_hour = 0;
		nextMidnight = mktime(&timeData);

		time_t nextHour = now + 60 * 60;
			// move ahead by a hour
		localtime_r(&nextHour, &timeData);
		timeData.tm_sec = 0;
		timeData.tm_min = 0;
		nextHour = mktime(&timeData);

		PRINT(("%ld minutes, %ld seconds till next hour\n",
			(nextHour - now) / 60, (nextHour - now) % 60));

		time_t nextMinute = now + 60;
			// move ahead by a minute
		localtime_r(&nextMinute, &timeData);
		timeData.tm_sec = 0;
		nextMinute = mktime(&timeData);

		PRINT(("%ld seconds till next minute\n", nextMinute - now));

		bigtime_t delta;
		if (fQueryListContainer->DynamicDateRefreshEveryMinute())
			delta = nextMinute - now;
		else if (fQueryListContainer->DynamicDateRefreshEveryHour())
			delta = nextHour - now;
		else
			delta = nextMidnight - now;

#if DEBUG
		int32 secondsTillMidnight = (nextMidnight - now);
		int32 minutesTillMidnight = secondsTillMidnight/60;
		secondsTillMidnight %= 60;
		int32 hoursTillMidnight = minutesTillMidnight/60;
		minutesTillMidnight %= 60;

		PRINT(("%ld hours, %ld minutes, %ld seconds till midnight\n",
			hoursTillMidnight, minutesTillMidnight, secondsTillMidnight));
		
		int32 refreshInSeconds = delta % 60;
		int32 refreshInMinutes = delta / 60;
		int32 refreshInHours = refreshInMinutes / 60;
		refreshInMinutes %= 60;

		PRINT(("next refresh in %ld hours, %ld minutes, %ld seconds\n",
			refreshInHours, refreshInMinutes, refreshInSeconds));
#endif

		// bump up to microseconds
		delta *=  1000000;

		TTracker* tracker = dynamic_cast<TTracker*>(be_app);
		ASSERT(tracker);
		tracker->MainTaskLoop()->RunLater(
			NewLockingMemberFunctionObject(&BQueryPoseView::Refresh, this),
			delta);
	}
	
	return fQueryListContainer->Clone();
}