コード例 #1
0
        public SmartPlaylistSource(string name, QueryNode condition, QueryOrder order, QueryLimit limit, IntegerQueryValue limit_value, bool hiddenWhenEmpty, PrimarySource parent)
            : this(name, parent)
        {
            ConditionTree     = condition;
            QueryOrder        = order;
            Limit             = limit;
            LimitValue        = limit_value;
            IsHiddenWhenEmpty = hiddenWhenEmpty;

            UpdateDependencies();
        }
コード例 #2
0
 public SmartPlaylistDefinition(string name, string description, string condition,
                                int limit_number, QueryLimit limit, QueryOrder order)
 {
     Name        = name;
     Description = description;
     Condition   = condition;
     LimitNumber = new IntegerQueryValue();
     LimitNumber.SetValue(limit_number);
     Limit = limit;
     Order = order;
 }
コード例 #3
0
        public SmartPlaylistSource(string name, QueryNode condition, QueryOrder order, QueryLimit limit, IntegerQueryValue limit_value, PrimarySource parent)
            : this(name, parent)
        {
            ConditionTree = condition;
            QueryOrder    = order;
            Limit         = limit;
            LimitValue    = limit_value;

            SetProperties();
            UpdateDependencies();
        }
コード例 #4
0
        // For existing smart playlists that we're loading from the database
        protected SmartPlaylistSource(int dbid, string name, string condition_xml, string order_by, string limit_number, string limit_criterion, PrimarySource parent, int count, bool is_temp) :
            base(generic_name, name, dbid, -1, 0, parent, is_temp)
        {
            ConditionXml = condition_xml;
            QueryOrder   = BansheeQuery.FindOrder(order_by);
            Limit        = BansheeQuery.FindLimit(limit_criterion);
            LimitValue   = new IntegerQueryValue();
            LimitValue.ParseUserQuery(limit_number);
            SavedCount = count;

            SetProperties();
            UpdateDependencies();
        }
コード例 #5
0
        public void QueryValueSql()
        {
            QueryValue qv;

            qv = new DateQueryValue(); qv.ParseUserQuery("2007-03-9");
            Assert.AreEqual(new DateTime(2007, 3, 9), qv.Value);
            Assert.AreEqual("2007-03-09", qv.ToUserQuery());
            Assert.AreEqual("1173420000", qv.ToSql());

            qv = new StringQueryValue(); qv.ParseUserQuery("foo 'bar'");
            Assert.AreEqual("foo 'bar'", qv.Value);
            Assert.AreEqual("foo 'bar'", qv.ToUserQuery());
            Assert.AreEqual("foo bar", qv.ToSql());

            qv = new StringQueryValue(); qv.ParseUserQuery("Foo Baño");
            Assert.AreEqual("Foo Baño", qv.Value);
            Assert.AreEqual("Foo Baño", qv.ToUserQuery());
            Assert.AreEqual("foo bano", qv.ToSql());

            qv = new ExactStringQueryValue(); qv.ParseUserQuery("foo 'bar'");
            Assert.AreEqual("foo 'bar'", qv.Value);
            Assert.AreEqual("foo 'bar'", qv.ToUserQuery());
            Assert.AreEqual("foo ''bar''", qv.ToSql());

            qv = new IntegerQueryValue(); qv.ParseUserQuery("22");
            Assert.AreEqual(22, qv.Value);
            Assert.AreEqual("22", qv.ToUserQuery());
            Assert.AreEqual("22", qv.ToSql());

            qv = new FileSizeQueryValue(); qv.ParseUserQuery("2048 KB");
            Assert.AreEqual(2097152, qv.Value);
            Assert.AreEqual("2.048 KB", qv.ToUserQuery());
            Assert.AreEqual("2097152", qv.ToSql());

            // TODO this will break once an it_IT translation for "days ago" etc is committed
            qv = new RelativeTimeSpanQueryValue(); qv.ParseUserQuery("2 days ago");
            Assert.AreEqual(-172800, qv.Value);
            Assert.AreEqual("2 days ago", qv.ToUserQuery());

            // TODO this will break once an it_IT translation for "minutes" etc is committed
            qv = new TimeSpanQueryValue(); qv.ParseUserQuery("4 minutes");
            Assert.AreEqual(240, qv.Value);
            Assert.AreEqual("4 minutes", qv.ToUserQuery());
            Assert.AreEqual("240000", qv.ToSql());
        }
コード例 #6
0
 public string ToSql(IntegerQueryValue limit_value)
 {
     return(RowBased ? string.Format("LIMIT {0}", limit_value.ToSql()) : null);
 }
コード例 #7
0
        protected override void OnResponse(ResponseType response)
        {
            //int w = -1, h = -1;
            //dialog.GetSize (out w, out h);
            //Console.WriteLine ("w = {0}, h = {1}", w, h);

            QueryNode node = builder.QueryNode;

            if (node == null)
            {
                //Console.WriteLine ("Editor query is null");
            }
            else
            {
                //Console.WriteLine ("Editor query is: {0}", node.ToXml (BansheeQuery.FieldSet, true));
            }

            if (response == ResponseType.Ok)
            {
                string            name           = PlaylistName;
                QueryNode         condition_tree = Condition;
                QueryLimit        limit          = Limit;
                QueryOrder        order          = Order;
                IntegerQueryValue limit_value    = LimitValue;

                ThreadAssist.Spawn(delegate {
                    //Console.WriteLine ("Name = {0}, Cond = {1}, OrderAndLimit = {2}", name, condition, order_by, limit_number);
                    if (playlist == null)
                    {
                        playlist = new SmartPlaylistSource(name, primary_source);

                        playlist.ConditionTree = condition_tree;
                        playlist.QueryOrder    = order;
                        playlist.Limit         = limit;
                        playlist.LimitValue    = limit_value;

                        playlist.Save();
                        primary_source.AddChildSource(playlist);
                        playlist.RefreshAndReload();
                        //SmartPlaylistCore.Instance.StartTimer (playlist);
                    }
                    else
                    {
                        playlist.ConditionTree = condition_tree;
                        playlist.QueryOrder    = order;
                        playlist.LimitValue    = limit_value;
                        playlist.Limit         = limit;

                        playlist.Name = name;
                        playlist.Save();
                        playlist.RefreshAndReload();

                        /*if (playlist.TimeDependent)
                         *  SmartPlaylistCore.Instance.StartTimer (playlist);
                         * else
                         *  SmartPlaylistCore.Instance.StopTimer ();*/

                        //playlist.ListenToPlaylists ();
                        //SmartPlaylistCore.Instance.SortPlaylists ();
                    }
                });
            }

            currently_editing = null;
        }
コード例 #8
0
 public SmartPlaylistSource(string name, QueryNode condition, QueryOrder order, QueryLimit limit, IntegerQueryValue limit_value, PrimarySource parent)
     : this(name, condition, order, limit, limit_value, false, parent)
 {
 }