Esempio n. 1
0
        public bool ItemChildSearch()
        {
            Item item = context.Selection;
            IEnumerable <Item> children = item.GetChildren();

            children = children.Concat(PluginManager.ItemSources
                                       .SelectMany(source => source.Safe.ChildrenOfItem(item))
                                       .Where(i => AcceptChildItem(i)));
            children = children.Concat(PluginManager.DynamicItemSources
                                       .SelectMany(source => source.ChildrenOfItem(item))
                                       .Where(i => AcceptChildItem(i)));

            if (!children.Any())
            {
                return(false);
            }

            SimpleSearchContext newContext = new SimpleSearchContext();

            newContext.ParentContext = context;
            context = newContext;

            context.Results =
                Do.UniverseManager.Search(Query, defaultFilter, children)
                .ToList();

            OnSearchFinished(true, context.ParentContext.Query != context.Query, Selection, Query);
            return(true);
        }
Esempio n. 2
0
        private void OnUpstreamSelectionChanged()
        {
            if (!SearchNeeded)
            {
                if (context.LastContext != null || context.ParentContext != null ||
                    !string.IsNullOrEmpty(context.Query) || context.Results.Any() || context.FullSelection.Any())
                {
                    context.Destroy();
                    context = new SimpleSearchContext();
                    base.OnSearchFinished(true, true, Selection, Query);
                }
                return;
            }

            textMode = false;
            if (timer > 0)
            {
                GLib.Source.Remove(timer);
            }
            base.OnSearchStarted(true);             //trigger our search start now
            timer = GLib.Timeout.Add(200, delegate {
                context.Destroy();
                context = new SimpleSearchContext();
                UpdateResults(true);
                return(false);
            });
        }
Esempio n. 3
0
 public virtual void Reset()
 {
     searchFilter = defaultFilter;
     context.Destroy();
     context          = new SimpleSearchContext();
     textModeFinalize = false;
     textMode         = false;
 }
Esempio n. 4
0
        public virtual void DeleteChar()
        {
            if (context.LastContext == null)
            {
                return;
            }

            Item tmp = context.Selection;

            context = context.LastContext;
            OnSearchFinished(tmp != context.Selection, true, Selection, Query);
        }
Esempio n. 5
0
        public object Clone()
        {
            SimpleSearchContext clone;

            clone                  = new SimpleSearchContext();
            clone.Query            = query;
            clone.LastContext      = LastContext;
            clone.ParentContext    = ParentContext;
            clone.Cursor           = Cursor;
            clone.SecondaryCursors = SecondaryCursors;             //Cloning these makes no sense
//			clone.Results = results.Clone () as Item[];
            clone.Results = new List <Item> (results);
            return(clone);
        }
Esempio n. 6
0
        private void BuildNewContextFromQuery()
        {
            string query = Query;

            context.Destroy();
            context = new SimpleSearchContext();

            foreach (char c in query.ToCharArray())
            {
                context.LastContext = context.Clone() as SimpleSearchContext;
                context.Query      += c;
                context.Results     = InitialResults();
            }
            base.OnSearchFinished(true, true, Selection, Query);
        }
Esempio n. 7
0
        public bool ItemParentSearch()
        {
            if (context.ParentContext == null)
            {
                return(false);
            }

            string old_query           = Query;
            SimpleSearchContext parent = context.ParentContext;

            context.Destroy(true);
            context = parent;
            OnSearchFinished(true, old_query != Query, Selection, Query);
            return(true);
        }
Esempio n. 8
0
        public override void Reset()
        {
            if (context.LastContext == null)
            {
                context.Destroy();
                context = new SimpleSearchContext();
                return;
            }

            while (context.LastContext != null)
            {
                context = context.LastContext;
            }
            textMode = false;

            base.OnSearchFinished(true, true, Selection, Query);
        }
Esempio n. 9
0
        private void OnUpstreamSelectionChanged()
        {
            textMode = false;
            if (timer > 0)
            {
                GLib.Source.Remove(timer);
            }
            if (wait_timer > 0)
            {
                GLib.Source.Remove(wait_timer);
            }

            base.OnSearchStarted(true);             // trigger our search start now
            timer = GLib.Timeout.Add(type_wait, delegate {
                context.Destroy();
                context = new SimpleSearchContext();
                UpdateResults(true);
                timer = 0;
                return(false);
            });
        }
Esempio n. 10
0
 protected SimpleSearchController()
 {
     context      = new SimpleSearchContext();
     searchFilter = defaultFilter;
 }