* Applied patch by Idefix that fixes bug #4730 by removing the iterate over

directory functionality without Tracker.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34103 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-11-17 22:07:03 +00:00
parent 744a460c12
commit bce3b09aed
2 changed files with 6 additions and 68 deletions
+6 -66
View File
@@ -2217,72 +2217,12 @@ ShowImageView::_SetTrackerSelectionToCurrent()
bool bool
ShowImageView::_FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind) ShowImageView::_FindNextImage(entry_ref *in_current, entry_ref *ref, bool next,
bool rewind)
{ {
ASSERT(next || !rewind); // Based on GetTrackerWindowFile function from BeMail
BEntry curImage(in_current);
entry_ref entry, *ref;
BDirectory parent;
BList entries;
bool found = false;
int32 cur;
if (curImage.GetParent(&parent) != B_OK) {
return false;
}
// insert current ref, so we can find it easily after sorting
entries.AddItem(in_current);
while (parent.GetNextRef(&entry) == B_OK) {
if (entry != *in_current) {
entries.AddItem(new entry_ref(entry));
}
}
entries.SortItems(_CompareEntries);
cur = entries.IndexOf(in_current);
ASSERT(cur >= 0);
// remove it so _FreeEntries() does not delete it
entries.RemoveItem(in_current);
if (next) {
// find the next image in the list
if (rewind) cur = 0; // start with first
for (; (ref = (entry_ref*)entries.ItemAt(cur)) != NULL; cur ++) {
if (_IsImage(ref)) {
found = true;
*out_image = (const entry_ref)*ref;
break;
}
}
} else {
// find the previous image in the list
cur --;
for (; cur >= 0; cur --) {
ref = (entry_ref*)entries.ItemAt(cur);
if (_IsImage(ref)) {
found = true;
*out_image = (const entry_ref)*ref;
break;
}
}
}
_FreeEntries(&entries);
return found;
}
bool
ShowImageView::_FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, bool rewind)
{
// Based on similar function from BeMail!
if (!fTrackerMessenger.IsValid()) if (!fTrackerMessenger.IsValid())
// If tracker scripting is not available, return false;
// fall back on directory searching code
return _FindNextImageByDir(in_current, ref, next, rewind);
// //
// Ask the Tracker what the next/prev file in the window is. // Ask the Tracker what the next/prev file in the window is.
@@ -2312,9 +2252,9 @@ ShowImageView::_FindNextImage(entry_ref *in_current, entry_ref *ref, bool next,
BMessage reply; BMessage reply;
if (fTrackerMessenger.SendMessage(&request, &reply) != B_OK) if (fTrackerMessenger.SendMessage(&request, &reply) != B_OK)
return _FindNextImageByDir(in_current, ref, next, rewind);; return false;
if (reply.FindRef("result", &nextRef) != B_OK) if (reply.FindRef("result", &nextRef) != B_OK)
return _FindNextImageByDir(in_current, ref, next, rewind);; return false;
if (_IsImage(&nextRef)) if (_IsImage(&nextRef))
foundRef = true; foundRef = true;
-2
View File
@@ -167,8 +167,6 @@ class ShowImageView : public BView {
static int _CompareEntries(const void* a, const void* b); static int _CompareEntries(const void* a, const void* b);
void _FreeEntries(BList* entries); void _FreeEntries(BList* entries);
void _SetTrackerSelectionToCurrent(); void _SetTrackerSelectionToCurrent();
bool _FindNextImageByDir(entry_ref *in_current, entry_ref *out_image,
bool next, bool rewind);
bool _FindNextImage(entry_ref *in_current, entry_ref *out_image, bool _FindNextImage(entry_ref *in_current, entry_ref *out_image,
bool next, bool rewind); bool next, bool rewind);
bool _ShowNextImage(bool next, bool rewind); bool _ShowNextImage(bool next, bool rewind);