Esempio n. 1
0
        public override Term Invert(bool recurse)
        {
            AndTerm newme = new AndTerm(Parent, null);

            newme.CopyAndInvertSubTermsFrom(this, recurse);
            if (Parent != null)
            {
                Parent.Remove(this);
            }
            return(newme);
        }
Esempio n. 2
0
        public List<Literal> InsertTerm(Tag [] tags, Term parent, Literal after)
        {
            int position;
            if (after != null)
                position = WidgetPosition (after.Widget) + 1;
            else
                position = Children.Length - 1;

            var added = new List<Literal>();

            foreach (Tag tag in tags) {
                //Console.WriteLine ("Adding tag {0}", tag.Name);

                // Don't put a tag into a Term twice
                if (parent != Root && (parent.FindByTag (tag, true)).Count > 0)
                    continue;

                if (parent.Count > 0) {
                    Widget sep = parent.SeparatorWidget ();

                    InsertWidget (position, sep);
                    position++;
                }

                // Encapsulate new OR terms within a new AND term of which they are the
                // only member, so later other terms can be AND'd with them
                //
                // TODO should really see what type of term the parent is, and
                // encapsulate this term in a term of the opposite type. This will
                // allow the query system to be expanded to work for multiple levels much easier.
                if (parent == rootTerm) {
                    parent = new AndTerm (rootTerm, after);
                    after = null;
                }

                Literal term  = new Literal (parent, tag, after);
                term.TagsAdded  += HandleTagsAdded;
                term.LiteralsMoved += HandleLiteralsMoved;
                term.AttachTag  += HandleAttachTag;
                term.NegatedToggled += HandleNegated;
                term.Removing  += HandleRemoving;
                term.Removed  += HandleRemoved;
                term.RequireTag  += Require;
                term.UnRequireTag += UnRequire;

                added.Add (term);

                // Insert this widget into the appropriate place in the hbox
                InsertWidget (position, term.Widget);
            }

            UpdateQuery ();

            return added;
        }
Esempio n. 3
0
        private void Update()
        {
            // Clear the last root term
            root_term = null;

            if (ParensValid () && ConstructQuery (null, 0, entry.Text)) {
                if (RootTerm != null) {
                    //Log.DebugFormat("rootTerm = {0}", RootTerm);
                    if (!(RootTerm is AndTerm)) {
                        // A little hacky, here to make sure the root term is a AndTerm which will
                        // ensure we handle the Hidden tag properly
                        AndTerm root_parent = new AndTerm(null, null);
                        RootTerm.Parent = root_parent;
                        root_term = root_parent;
                    }

                    //Log.DebugFormat("rootTerm = {0}", RootTerm);
                    if (!(RootTerm is AndTerm)) {
                        // A little hacky, here to make sure the root term is a AndTerm which will
                        // ensure we handle the Hidden tag properly
                        AndTerm root_parent = new AndTerm(null, null);
                        RootTerm.Parent = root_parent;
                        root_term = root_parent;
                    }
                    //Log.DebugFormat ("condition = {0}", RootTerm.SqlCondition ());
                    query.TagTerm = new ConditionWrapper (RootTerm.SqlCondition ());
                } else {
                    query.TagTerm = null;
                    //Log.Debug ("root term is null");
                }
            }
        }
Esempio n. 4
0
 public override Term Invert(bool recurse)
 {
     var newme = new AndTerm (Parent, null);
     newme.CopyAndInvertSubTermsFrom (this, recurse);
     if (Parent != null)
         Parent.Remove (this);
     return newme;
 }
Esempio n. 5
0
        public List <Literal> InsertTerm(Tag [] tags, Term parent, Literal after)
        {
            int position;

            if (after != null)
            {
                position = WidgetPosition(after.Widget) + 1;
            }
            else
            {
                position = Children.Length - 1;
            }

            var added = new List <Literal>();

            foreach (var tag in tags)
            {
                //Console.WriteLine ("Adding tag {0}", tag.Name);

                // Don't put a tag into a Term twice
                if (parent != Root && (parent.FindByTag(tag, true)).Count > 0)
                {
                    continue;
                }

                if (parent.Count > 0)
                {
                    Widget sep = parent.SeparatorWidget();

                    InsertWidget(position, sep);
                    position++;
                }

                // Encapsulate new OR terms within a new AND term of which they are the
                // only member, so later other terms can be AND'd with them
                //
                // TODO should really see what type of term the parent is, and
                // encapsulate this term in a term of the opposite type. This will
                // allow the query system to be expanded to work for multiple levels much easier.
                if (parent == Root)
                {
                    parent = new AndTerm(Root, after);
                    after  = null;
                }

                var term = new Literal(parent, tag, after);
                term.TagsAdded      += HandleTagsAdded;
                term.LiteralsMoved  += HandleLiteralsMoved;
                term.AttachTag      += HandleAttachTag;
                term.NegatedToggled += HandleNegated;
                term.Removing       += HandleRemoving;
                term.Removed        += HandleRemoved;
                term.RequireTag     += Require;
                term.UnRequireTag   += UnRequire;

                added.Add(term);

                // Insert this widget into the appropriate place in the hbox
                InsertWidget(position, term.Widget);
            }

            UpdateQuery();

            return(added);
        }