From 2678358ff9bc3edebac496aebc9c35e975a17967 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Fri, 7 Sep 2012 10:31:39 +0200 Subject: [PATCH] Encapsulate proxy expansion code How a proxy items are expanded is not something user code should concern itself with. --- Frameworks/BundleMenu/src/BundleMenuDelegate.mm | 4 +--- Frameworks/bundles/src/query.cc | 8 ++++++++ Frameworks/bundles/src/query.h | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Frameworks/BundleMenu/src/BundleMenuDelegate.mm b/Frameworks/BundleMenu/src/BundleMenuDelegate.mm index 9133c10e..a22f0d86 100644 --- a/Frameworks/BundleMenu/src/BundleMenuDelegate.mm +++ b/Frameworks/BundleMenu/src/BundleMenuDelegate.mm @@ -68,9 +68,7 @@ OAK_DEBUG_VAR(BundleMenu); case bundles::kItemTypeProxy: { - std::string actionClass; - if(plist::get_key_path((*item)->plist(), "content", actionClass)) - OakAddBundlesToMenu(bundles::query(bundles::kFieldSemanticClass, actionClass, scope), hasSelection, true, aMenu, @selector(doBundleItem:)); + OakAddBundlesToMenu(bundles::items_for_proxy(*item, scope), hasSelection, true, aMenu, @selector(doBundleItem:)); } break; diff --git a/Frameworks/bundles/src/query.cc b/Frameworks/bundles/src/query.cc index 741369a1..5c0bc32a 100644 --- a/Frameworks/bundles/src/query.cc +++ b/Frameworks/bundles/src/query.cc @@ -241,6 +241,14 @@ namespace bundles return res; } + std::vector items_for_proxy (item_ptr proxyItem, scope::context_t const& scope, int kind, oak::uuid_t const& bundle, bool filter, bool includeDisabledItems) + { + std::string actionClass; + if(plist::get_key_path(proxyItem->plist(), "content", actionClass)) + return query(kFieldSemanticClass, actionClass, scope, kind, bundle, filter, includeDisabledItems); + return std::vector(); + } + item_ptr lookup (oak::uuid_t const& uuid) { iterate(item, AllItems) diff --git a/Frameworks/bundles/src/query.h b/Frameworks/bundles/src/query.h index df539107..4a086871 100644 --- a/Frameworks/bundles/src/query.h +++ b/Frameworks/bundles/src/query.h @@ -9,6 +9,7 @@ namespace bundles inline bool set_index (std::vector const& items) { return set_index(items, std::map< oak::uuid_t, std::vector >()); } PUBLIC std::vector query (std::string const& field, std::string const& value, scope::context_t const& scope = scope::wildcard, int kind = kItemTypeCommand|kItemTypeDragCommand|kItemTypeGrammar|kItemTypeMacro|kItemTypeSnippet|kItemTypeProxy|kItemTypeTheme, oak::uuid_t const& bundle = oak::uuid_t(), bool filter = true, bool includeDisabledItems = false); + PUBLIC std::vector items_for_proxy (item_ptr proxyItem, scope::context_t const& scope = scope::wildcard, int kind = kItemTypeCommand|kItemTypeDragCommand|kItemTypeGrammar|kItemTypeMacro|kItemTypeSnippet|kItemTypeProxy|kItemTypeTheme, oak::uuid_t const& bundle = oak::uuid_t(), bool filter = true, bool includeDisabledItems = false); PUBLIC item_ptr lookup (oak::uuid_t const& uuid); PUBLIC std::string name_with_selection (item_ptr const& item, bool hasSelection); PUBLIC std::string full_name_with_selection (item_ptr const& item, bool hasSelection);