コード例 #1
0
        protected override TreeViewItem BuildRoot()
        {
            var id   = 1;
            var root = new TreeViewItem {
                id = id++, depth = -1, displayName = "Root", children = new List <TreeViewItem>()
            };

            m_UserQueries = new SearchQueryCategoryTreeViewItem(this, () => searchView.SaveUserSearchQuery(), new GUIContent(userQuery, null, userTooltip));
            foreach (var searchQuery in SearchQuery.userQueries)
            {
                var userQueryNode = new SearchQueryUserTreeViewItem(this, searchQuery);
                m_UserQueries.AddChild(userQueryNode);
            }
            root.AddChild(m_UserQueries);

            m_ProjectQueries = new SearchQueryCategoryTreeViewItem(this, () => searchView.SaveProjectSearchQuery(), new GUIContent(projectQuery, null, projectTooltip));
            foreach (var searchQueryAsset in SearchQueryAsset.savedQueries)
            {
                var projectQueryNode = new SearchQueryAssetTreeViewItem(this, searchQueryAsset);
                m_ProjectQueries.AddChild(projectQueryNode);
            }
            root.AddChild(m_ProjectQueries);

            return(root);
        }
コード例 #2
0
        public void Add(ISearchQuery query, bool select = true)
        {
            SearchQueryTreeViewItem item = null;

            if (query is SearchQueryAsset sqa)
            {
                item = new SearchQueryAssetTreeViewItem(this, sqa);
                m_ProjectQueries.AddChild(item);
                SetExpanded(m_ProjectQueries.id, true);
                SortBy(m_ProjectQueries, m_SortOrder);

                var evt = searchView.CreateEvent(SearchAnalytics.GenericEventType.QuickSearchCreateSearchQuery, query.searchText, query.filePath, "project");
                #if USE_SEARCH_MODULE
                evt.intPayload1 = query.GetResultViewState().tableConfig != null ? 1 : 0;
                #endif
                SearchAnalytics.SendEvent(evt);
            }
            else if (query is SearchQuery sq && SearchQuery.IsUserQuery(sq))
            {
                item = new SearchQueryUserTreeViewItem(this, sq);
                m_UserQueries.AddChild(item);
                SetExpanded(m_UserQueries.id, true);
                SortBy(m_UserQueries, m_SortOrder);

                var evt = searchView.CreateEvent(SearchAnalytics.GenericEventType.QuickSearchCreateSearchQuery, query.searchText, "", "user");
                #if USE_SEARCH_MODULE
                evt.intPayload1 = query.GetResultViewState().tableConfig != null ? 1 : 0;
                #endif
                SearchAnalytics.SendEvent(evt);
            }

            if (item != null)
            {
                BuildRows(rootItem);
                if (select)
                {
                    SetSelection(new int[] { item.id });
                }
            }
        }