Backgrounds: Rename CustomRefFilter to ImageFilter
... and simplify Filter() logic. Check that GuessMimeType() status is B_OK. Rename imageFiltering variable to filtering. No functional change intended unless GuessMimeType() errors. Change-Id: Ie29f8408a62ee65bf64db5c0bfcc8a13ef89aa15 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5496 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
264f77da03
commit
1a61e82bd4
@ -281,11 +281,11 @@ BackgroundsView::AllAttached()
|
||||
|
||||
BMessenger messenger(this);
|
||||
fPanel = new ImageFilePanel(B_OPEN_PANEL, &messenger, &ref,
|
||||
B_FILE_NODE, false, NULL, new CustomRefFilter(true));
|
||||
B_FILE_NODE, false, NULL, new ImageFilter(true));
|
||||
fPanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select"));
|
||||
|
||||
fFolderPanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL,
|
||||
B_DIRECTORY_NODE, false, NULL, new CustomRefFilter(false));
|
||||
B_DIRECTORY_NODE, false, NULL, new ImageFilter(false));
|
||||
fFolderPanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select"));
|
||||
|
||||
_LoadSettings();
|
||||
@ -1002,9 +1002,10 @@ BackgroundsView::RefsReceived(BMessage* message)
|
||||
|
||||
if (node.IsFile()) {
|
||||
BMimeType refType;
|
||||
BMimeType::GuessMimeType(&ref, &refType);
|
||||
if (!imageType.Contains(&refType))
|
||||
if (BMimeType::GuessMimeType(&ref, &refType) == B_OK
|
||||
&& !imageType.Contains(&refType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BGImageMenuItem* item;
|
||||
int32 index = AddImage(path);
|
||||
|
@ -171,30 +171,28 @@ ImageFilePanel::SelectionChanged()
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - CustomRefFilter
|
||||
// #pragma mark - ImageFilter
|
||||
|
||||
|
||||
CustomRefFilter::CustomRefFilter(bool imageFiltering)
|
||||
ImageFilter::ImageFilter(bool filtering)
|
||||
:
|
||||
fImageFiltering(imageFiltering)
|
||||
fImageFiltering(filtering)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CustomRefFilter::Filter(const entry_ref* ref, BNode* node,
|
||||
ImageFilter::Filter(const entry_ref* ref, BNode* node,
|
||||
struct stat_beos* stat, const char* filetype)
|
||||
{
|
||||
if (!fImageFiltering)
|
||||
return node->IsDirectory();
|
||||
bool isDirectory = node->IsDirectory();
|
||||
if (!fImageFiltering || isDirectory)
|
||||
return isDirectory;
|
||||
|
||||
if (node->IsDirectory())
|
||||
return true;
|
||||
|
||||
BMimeType imageType("image"), refType;
|
||||
BMimeType::GuessMimeType(ref, &refType);
|
||||
if (imageType.Contains(&refType))
|
||||
return true;
|
||||
BMimeType imageType("image");
|
||||
BMimeType refType;
|
||||
if (BMimeType::GuessMimeType(ref, &refType) == B_OK)
|
||||
return imageType.Contains(&refType);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ class BStringView;
|
||||
class BView;
|
||||
|
||||
|
||||
class CustomRefFilter : public BRefFilter {
|
||||
class ImageFilter: public BRefFilter {
|
||||
public:
|
||||
CustomRefFilter(bool imageFiltering);
|
||||
virtual ~CustomRefFilter() {};
|
||||
ImageFilter(bool filtering);
|
||||
virtual ~ImageFilter() {};
|
||||
|
||||
bool Filter(const entry_ref* ref, BNode* node,
|
||||
struct stat_beos* st, const char* filetype);
|
||||
@ -33,7 +33,7 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
class ImageFilePanel : public BFilePanel {
|
||||
class ImageFilePanel: public BFilePanel {
|
||||
public:
|
||||
ImageFilePanel(file_panel_mode mode = B_OPEN_PANEL,
|
||||
BMessenger* target = NULL,
|
||||
|
Loading…
Reference in New Issue
Block a user