public QueryOrder (string name, string label, string order_sql, QueryField field) { this.name = name; this.label = label; this.order_sql = order_sql; this.field = field; }
public QueryOrder (string name, string label, string order_sql, QueryField field, bool asc) { Name = name; Label = label; OrderSql = order_sql; Field = field; Ascending = asc; }
protected virtual bool NeedsReloadWhenFieldChanged(Hyena.Query.QueryField field) { if (field == null) { return(true); } // If it's the artist or album name, then we care, since it affects the browser // FIXME this should be based on what filters (aka browsers) are active. InternetRadio, // for example, has only a Genre filter. if (field == Banshee.Query.BansheeQuery.ArtistField || field == Banshee.Query.BansheeQuery.AlbumField) { return(true); } if (DatabaseTrackModel == null) { Log.Error("DatabaseTrackModel should not be null in DatabaseSource.NeedsReloadWhenFieldChanged"); return(false); } // If it's the field we're sorting by, then yes, we care var sort_column = DatabaseTrackModel.SortColumn; if (sort_column != null && sort_column.Field == field) { return(true); } // Make sure the query isn't dependent on this field QueryNode query = DatabaseTrackModel.Query; if (query != null) { if (query != last_query) { query_fields = new List <QueryField> (query.GetFields()); last_query = query; } if (query_fields.Contains(field)) { return(true); } } return(false); }
public static QueryValue CreateFromStringValue(string input, QueryField field) { if (field == null) { QueryValue val = new StringQueryValue (); val.LoadString (input); return val; } else { foreach (QueryValue val in field.CreateQueryValues ()) { val.LoadString (input); if (!val.IsEmpty) { return val; } } } return null; }
protected override bool NeedsReloadWhenFieldChanged(Hyena.Query.QueryField field) { if (base.NeedsReloadWhenFieldChanged(field)) { return(true); } if (QueryOrder != null && QueryOrder.Field == field) { return(true); } if (relevant_fields.Contains(field)) { return(true); } return(false); }
public static QueryValue CreateFromXml (XmlElement parent, QueryField field) { if (field != null) { foreach (QueryValue val in field.CreateQueryValues ()) { if (CreateFromXml (val, parent)) { return val; } } return null; } else { foreach (Type subtype in subtypes) { QueryValue val = Activator.CreateInstance (subtype) as QueryValue; if (CreateFromXml (val, parent)) { return val; } } } return null; }
protected virtual bool NeedsReloadWhenFieldChanged(Hyena.Query.QueryField field) { if (field == null) { return(true); } // If it's the artist or album name, then we care, since it affects the browser if (field == Banshee.Query.BansheeQuery.ArtistField || field == Banshee.Query.BansheeQuery.AlbumField) { return(true); } ISortableColumn sort_column = (TrackModel is DatabaseTrackListModel) ? (TrackModel as DatabaseTrackListModel).SortColumn : null; // If it's the field we're sorting by, then yes, we care if (sort_column != null && sort_column.Field == field) { return(true); } // Make sure the query isn't dependent on this field QueryNode query = (TrackModel is DatabaseTrackListModel) ? (TrackModel as DatabaseTrackListModel).Query : null; if (query != null) { if (query != last_query) { query_fields = new List <QueryField> (query.GetFields()); last_query = query; } if (query_fields.Contains(field)) { return(true); } } return(false); }
private bool EmitTermMatch (StringBuilder sb, QueryField field, bool emit_or) { if (Value.IsEmpty) { return false; } if (emit_or) { sb.Append (" OR "); } sb.Append (field.ToSql (Operator, Value)); return true; }
private SortableColumn CreateText(QueryField field, double width, bool visible) { return Create (field, width, visible, new ColumnCellText (field.PropertyName, true)); }
private SortableColumn CreateText(QueryField field, double width) { return CreateText (field, width, false); }
private static QueryOrder CreateQueryOrder (string name, bool asc, string label, QueryField field) { return new QueryOrder (CreateOrderName (name, asc), label, GetSort (name, asc), field); }
public static string GetSort(QueryField field, bool asc) { if (field == null) { throw new ArgumentNullException ("field"); } bool sort_by_year = Banshee.Configuration.Schema.LibrarySchema.SortByAlbumYear.Get (); string sort_by_year_part = sort_by_year ? YearField.Column + " ASC," : ""; string sort = sort_by_year ? default_sort_by_year : default_sort; string ascDesc = asc ? "ASC" : "DESC"; string sort_query = null; if (field.Equals (GroupingField) || field.Equals (TrackNumberField)) { sort_query = String.Format (@" CoreAlbums.ArtistNameSortKey ASC, {0} CoreAlbums.TitleSortKey ASC, {1} ASC, {2} {3}", sort_by_year_part, DiscNumberField.Column, TrackNumberField.Column, ascDesc); } else if (field.Equals (AlbumArtistField)) { sort_query = String.Format (@" CoreAlbums.ArtistNameSortKey {0}, {1} CoreAlbums.TitleSortKey ASC, {2} ASC, {3} ASC", ascDesc, sort_by_year_part, DiscNumberField.Column, TrackNumberField.Column); } else if (field.Equals (ArtistField)) { sort_query = String.Format (@" CoreArtists.NameSortKey {0}, {1} CoreAlbums.TitleSortKey ASC, {2} ASC, {3} ASC", ascDesc, sort_by_year_part, DiscNumberField.Column, TrackNumberField.Column); } else if (field.Equals (AlbumField)) { sort_query = String.Format (@" CoreAlbums.TitleSortKey {0}, {1} {2} ASC, {3} ASC", ascDesc, sort_by_year_part, DiscNumberField.Column, TrackNumberField.Column); } else if (field.Equals (TitleField)) { sort_query = String.Format (@" CoreTracks.TitleSortKey {0}, CoreAlbums.ArtistNameSortKey ASC, {1} CoreAlbums.TitleSortKey ASC", ascDesc, sort_by_year_part); } else if (field.Equals (DiscNumberField)) { sort_query = String.Format (@" CoreAlbums.ArtistNameSortKey ASC, {0} CoreAlbums.TitleSortKey ASC, {1} {2}, {3} ASC", sort_by_year_part, DiscNumberField.Column, ascDesc, TrackNumberField.Column); } else if (field.Equals (ScoreField)) { sort_query = String.Format (@" {0} {1}, {2} {1}, {3}", field.Column, ascDesc, PlayCountField.Column, sort); } else if (field.Equals (ComposerField) || field.Equals (GenreField) || field.Equals (ComposerField) || field.Equals (ConductorField) || field.Equals (CommentField)) { sort_query = String.Format ( "HYENA_COLLATION_KEY({0}) {1}, {2}", field.Column, ascDesc, sort ); } else if (field.Equals (LastPlayedField) || field.Equals (LastSkippedField) || field.Equals (DateAddedField) || field.Equals (YearField) || field.Equals (BitRateField) || field.Equals (SampleRateField) || field.Equals (BitsPerSampleField) || field.Equals (BpmField) || field.Equals (TrackCountField) || field.Equals (DiscCountField) || field.Equals (DurationField) || field.Equals (RatingField) || field.Equals (PlayCountField) || field.Equals (SkipCountField) || field.Equals (FileSizeField) || field.Equals (UriField) || field.Equals (MimeTypeField) || field.Equals (LicenseUriField)) { sort_query = String.Format ( "{0} {1}, {2}", field.Column, ascDesc, sort ); } else { Hyena.Log.ErrorFormat ("Unknown query field passed in! {0} not recognized", field.Name); } return sort_query; }
public static string GetSort(QueryField key) { return GetSort (key, false); }
public static QueryOrder FindOrder(QueryField field, bool asc) { return Orders.FirstOrDefault (o => o != null && o.Field == field && o.Ascending == asc); }
private void ParseRelativeDateCondition (QueryTermNode term, string val, QueryField field, string op) { string new_op = op.Replace ('>', '^'); new_op = new_op.Replace ('<', '>'); new_op = new_op.Replace ('^', '<'); RelativeTimeSpanQueryValue date_value = new RelativeTimeSpanQueryValue (); // Have to flip the operator b/c of how we used to construct the SQL query term.Operator = date_value.OperatorSet [new_op]; // Have to negate the value b/c of how we used to constuct the SQL query date_value.SetRelativeValue (Convert.ToInt64 (val), TimeFactor.Second); term.Value = date_value; }
private void HandleFieldChanged (object o, EventArgs args) { if (field_chooser.Active < 0 || field_chooser.Active >= sorted_fields.Length) return; QueryField field = sorted_fields [field_chooser.Active]; // Leave everything as is unless the new field is a different type if (this.field != null && (field.ValueTypes.Length == 1 && this.field.ValueTypes.Length == 1 && field.ValueTypes[0] == this.field.ValueTypes[0])) { this.field = field; return; } op_chooser.Changed -= HandleOperatorChanged; this.field = field; // Remove old type's operators op_chooser.RemoveAll (); // Add new field's operators int val_count = 0; value_entries.Clear (); operators.Clear (); operator_entries.Clear (); foreach (QueryValue val in this.field.CreateQueryValues ()) { QueryValueEntry entry = QueryValueEntry.Create (val); value_entries.Add (entry); if (val_count++ > 0) { op_chooser.AppendText (String.Empty); operators.Add (null); } foreach (Operator op in val.OperatorSet) { op_chooser.AppendText (op.Label); operators.Add (op); operator_entries [op] = entry; } } SetValueEntry (value_entries[0]); // TODO: If we have the same operator that was previously selected, select it op_chooser.Changed += HandleOperatorChanged; op_chooser.Active = 0; }
public QueryTermBox (QueryField [] sorted_fields) : base () { this.sorted_fields = sorted_fields; BuildInterface (); }
public static SortableColumn Create(QueryField field, double width, bool visible, ColumnCell cell) { cell.Property = field.PropertyName; SortableColumn col = new SortableColumn ( field.ShortLabel, cell, width, field.Name, visible ); col.LongTitle = field.Label; col.Field = field; return col; }