Encapsulate proxy expansion code

How a proxy items are expanded is not something user code should concern itself with.
This commit is contained in:
Allan Odgaard
2012-09-07 10:31:39 +02:00
parent e33c680269
commit 2678358ff9
3 changed files with 10 additions and 3 deletions

View File

@@ -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;

View File

@@ -241,6 +241,14 @@ namespace bundles
return res;
}
std::vector<item_ptr> 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>();
}
item_ptr lookup (oak::uuid_t const& uuid)
{
iterate(item, AllItems)

View File

@@ -9,6 +9,7 @@ namespace bundles
inline bool set_index (std::vector<item_ptr> const& items) { return set_index(items, std::map< oak::uuid_t, std::vector<oak::uuid_t> >()); }
PUBLIC std::vector<item_ptr> 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<item_ptr> 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);